SSGetExcelSheetList Function
Applies To
fpSpread DLL control
Description
Returns a handle to the Excel workbook and a list of the sheet names in the specified Excel-formatted file.
Syntax
BOOL SSGetExcelSheetList(HWND hWnd, LPCTSTR lpszFileName, GLOBALHANDLE FAR *lpghList, LPSHORT lpnListCount, LPCTSTR lpszLogFileName, LPSHORT lpnWorkbookHandle, BOOL fReplace);
BOOL TSpread::GetExcelSheetList( LPCTSTR lpszFileName, GLOBALHANDLE FAR *lpghList, LPSHORT lpnListCount, LPCTSTR lpszLogFileName, LPSHORT lpnWorkbookHandle, BOOL fReplace);
Parameters
The following parameters are available:
Parameter | Description |
---|---|
hWnd | Window handle of the fpSpread control |
lpszFileName | Path and file name of the file for which you want to return the sheet list |
lpghList | List of sheet names; the list names are provided as NULL-terminated strings |
lpnListCount | Returns the total number of sheets in the specified Excel workbook |
lpszLogFileName | Specifies the path and file name of the log file created when Spread creates the sheet list If you do not provide a file name, the export will not create a log file. If you do not want to create a log file, set this parameter to NULL. |
lpnWorkbookHandle | Returns the handle to the workbook from the Excel-formatted file |
fReplace | Specifies whether to read all the information from the specified file, or just the sheet information |
Remarks
Excel-formatted files can contain multiple sheets; however, Spread can only import one sheet at a time from an Excel-formatted file. Use this function to return a handle to the workbook and a list of the sheets in an Excel workbook.
The workbook handle returned by the function 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. This is similar to how controls can share fonts and colors.
Workbook handles provide the benefit of opening the Excel file only once, as well as reducing storage requirements, providing faster sheet requests, and providing the ability to access multiple Excel workbook sheets simultaneously across controls and applications.
When the application opens an Excel file for importing, the import process loads the "global" portion of the Excel file and returns the list of sheet names and the workbook handle to the application. After the initial "global" load, the application (or any application that contains an fpSpread control) can load any of the sheets in the Excel file using the workbook handle.
If the application needs to query the sheet list again, you can call the SSGetExcelSheetList function with the same parameters as in the initial call, except the fReplace parameter. You can set the fReplace parameter to FALSE if you do not need to get the refreshed version of the Excel file, and can therefore use the global information from the initial load. Set the fReplace parameter to TRUE if you need to get the refreshed version of the Excel file, including the new global information.
The list returned by the function contains a list of the names of the sheets in the specified file. When you call the SSImportExcelSheet function, you can use one of the names in the list to specify the sheet to import, or you can refer to the sheet by its list index. If you use the sheet index, remember that the sheet index is zero-based.
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 Value
TRUE if the function completes successfully; FALSE otherwise.
See Also
Loading an Excel-Formatted File
Excel-Formatted File Import/Export (online PDF manual)
SSExportToExcel, SSImportExcelSheet, SSIsExcelFile functions
ActiveX Correspondence
GetExcelSheetList method