Spread for ASP.NET 9.0 Product Documentation
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.

Using Code

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.

Example

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

Using the Spread Designer

  1. Select the File menu.
  2. Choose the Open option.
  3. The Open dialog appears.
  4. Change the Files of type box to Excel files (*.XLS).
  5. Specify the path and file name of the file to open, and then click Open.
  6. Set the PageSize property to the total number of rows if you wish to see all the rows on one page. Use the Property Grid to set the PageSize property.
  7. Click OK to close the Spread Designer.
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options | Documentation Feedback