ImportExcelSheet Method
Applies To
fpSpread control
Description
Imports the specified sheet from an Excel-formatted file.
Syntax
BOOL CSpreadSheet::ImportExcelSheet (shortWorkbookHandle, const VARIANT& Sheet);
fpSpread.ImportExcelSheet(ByVal WorkbookHandle As Integer, ByVal Sheet As Variant) As Boolean
Parameters
The following parameters are available:
Parameter | Description |
---|---|
WorkbookHandle | Handle of the workbook containing the sheet you want to import, returned from the GetExcelSheetList method |
Sheet | Sheet number or name |
Remarks
Use this method to import a sheet from an Excel-formatted file. Spread can only import from Excel-formatted files in BIFF8 format, which is the format used by Excel 97, Excel 2000, and Excel 2002.
Call the GetExcelSheetList method before you call this method. This method is called for the current sheet setting unless you first set the Sheet property to specify the sheet with which you want to work.
To find the number or name of the sheet you want to import, call the GetExcelSheetList method to return the handle to the workbook and an array of the sheet numbers or names available in the workbook. Then, provide the workbook handle in the WorkbookHandle parameter and provide the number or name in the Sheet parameter. The numbers returned from the array are zero-based.
The workbook handle returned by the GetExcelSheetList method is an identifier that represents an Excel workbook that was opened by the Spread import process. The handle is global: if your project contains other fpSpread controls, or multiple projects are running that contain fpSpread controls, any of the fpSpread controls can use the workbook handle created by the import process. For more information about the workbook handle, see the GetExcelSheetList method.
When you call the GetExcelSheetList method, you can specify to create a log file using the LogFileName parameter. When the GetExcelSheetList method is called, the conversion process creates a log file with information about the conversion of the Excel-formatted file. When you subsequently call the ImportExcelSheet method, additional conversion information is appended to the log file about the sheet you are importing. If you call the ImportExcelSheet method again for another sheet in the file, the information about that sheet is appended to the log file.
Caution: Loading an Excel file into the control deletes the data currently in the control. The loaded file overwrites existing data. Also, if your sheet had more columns and rows than the loaded sheet, those columns and rows are removed. For example, if your sheet had 100 columns and rows of data, and the loaded sheet has 50 columns and rows of data, once the new sheet is loaded, the control only has 50 columns and rows. |
For instructions and more information about importing Excel-formatted files, see Loading an Excel-Formatted File and Excel-Formatted File Import/Export (online PDF manual). Excel-Formatted File Import/Export includes a list and description of the log message numbers.
Return Type
True if successful; otherwise, False.
See Also
Loading an Excel-Formatted File
Excel-Formatted File Import/Export (online PDF manual)
Sheet property
ExportToExcel, GetExcelSheetList, IsExcelFile methods
DLL Correspondence
SSImportExcelSheet function