Spread for ASP.NET 9.0 Product Documentation > Developer's Guide > Managing File Operations > Saving Data to a File > Saving to an Excel File |
You can save data to an Excel-formatted (BIFF8 format or XLSX) file or stream. There are multiple SaveExcel methods each with several options. For instance, you can specify whether headers are saved with the data using the setting of the IncludeHeaders enumeration. Use the ExcelSaveFlags.UseOOXMLFormat with the ExcelSaveFlags enumeration to save to an XLSX format.
The document caching option in the ExcelOpenFlags or ExcelSaveFlags enumeration allows users to open, edit, and save without the loss of advanced document content and formatting. Advanced content includes items such as macros, ActiveX controls, data connections, and so on. Consider the following when using the document caching option:
You can also save a file from inside Spread Designer.
For instructions for opening Excel-compatible files, see Opening an Excel-Formatted File.
For more information about how the data and formatting is exported to the Excel file format, see the Import and Export Reference.
Use the FpSpread object’s SaveExcel method, providing the path and file name for the file to save, or providing additional information using one of the overloaded methods.
The first example saves the data in a FpSpread component to an Excel-formatted file and specifies that both row and column headers are included in the output. The second example saves to a stream.
C# |
Copy Code
|
---|---|
// Save data to Excel-formatted file, including headers. FpSpread1.SaveExcel("C:\\excelfile.xls", FarPoint.Web.Spread.Model.IncludeHeaders.BothCustomOnly); // Save data to memory stream and then load in second component. System.IO.MemoryStream s = new System.IO.MemoryStream(); FpSpread1.SaveExcel(s); s.Position = 0; FpSpread2.OpenExcel(s); s.Close(); |
VB |
Copy Code
|
---|---|
' Save data to an Excel-formatted file, including headers. FpSpread1.SaveExcel("C:\excelfile.xls", FarPoint.Web.Spread.Model.IncludeHeaders.BothCustomOnly) ' Save data to memory stream and then load in second component. Dim s As New System.IO.MemoryStream() FpSpread1.SaveExcel(s) s.Position = 0 FpSpread2.OpenExcel(s) s.Close() |
The Save As dialog appears.
Click OK to close the Spread Designer.