Spread for ASP.NET 10 Product Documentation > Developer's Guide > Managing File Operations > Opening Existing Files > Opening an Excel-Formatted File |
You can open an existing Excel-formatted (BIFF8 format or XLSX) file or stream. With the SheetView object, you can open a specific Excel sheet to a specific sheet, the currently active sheet, in Spread. You can specify which sheet in Excel to open, either by the sheet index or by the sheet name. There are multiple OpenExcel methods each with several options.
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. The content can be lossless only if the opening file format is similar to the saving file format. If the advanced document content uses files besides the xls(x) file, then the additional files need to be in the same folder with the xls(x) file. Advanced content could be macros, ActiveX controls, data connections, etc. In order to keep any document caching settings (changes would be lost during a postback), open the original file with the document caching only setting and then save the file using the document caching setting.
You can also open a file from inside Spread Designer.
For more information about how the data is imported from the Excel format, see the Import and Export Reference.
Use the FpSpread object’s OpenExcel method, providing the path and file name for the file to open, or providing additional information using one of the overloaded methods.
This example code opens an Excel-formatted file, loads the data from the specified Excel sheet into this sheet, and sets the number of rows displayed on a single page to match the number of rows in the Excel file.
C# |
Copy Code
|
---|---|
FpSpread1.OpenExcel("c:\\excelfile.xls", 2);
FpSpread1.ActiveSheetView.PageSize = FpSpread1.Rows.Count;
|
VB |
Copy Code
|
---|---|
FpSpread1.OpenExcel("c:\excelfile.xls", 2)
FpSpread1.ActiveSheetView.PageSize = FpSpread1.Rows.Count
|