Spread 8.0 Documentation
ActiveX
Support Options

Glossary Item Box

ActiveX


To load an existing spreadsheet from an Excel-formatted file

  1. Call the IsExcelFile method to determine if the file is an Excel 97, Excel 2000, or Excel 2002 file (in BIFF8 format). Call the IsExcel2007File method to determine if the file is an xlsx file.
    If the file is an Excel file in BIFF8 format, continue to step 2. If the file is an xlsx file, skip to step 5. If the file is not of the previous two types, Spread will not be able to load the file.
  2. Use the ImportExcelBook method or call the GetExcelSheetList method, and set the parameters as follows:
    1. Set the FileName parameter to the path and file name of the Excel-formatted spreadsheet.
    2. Declare the array to contain the list of sheet names. Set the size of the array as follows:
      1. If you want to return just the number of worksheets in the Excel-formatted file, specify Null or zero to be passed as the List parameter to retrieve the number of worksheets. For example, your code can be:
        Dim List() as String
        GetExcelSheetList("file.xls", Null, ListCount, "", True)
      2. If you know the number of worksheets in the Excel-formatted file, specify the size of the array as the number of worksheets. For example, your code can be:
        Dim List(12) as String
        GetExcelSheetList("file.xls", List, ListCount, "", True)
      3. Alternatively, if you do not know the number of worksheets in the Excel-formatted file, you can specify the size of the array, and then compare the size of your array to the returned value of the ListCount parameter. For example, your code can be:
        Dim List(10) as String
        GetExcelSheetList("file.xls", List, ListCount, "", True)
        If the ListCount parameter returns 10 or less than 10, you do not need to call the GetExcelSheetList method again. If the ListCount parameter returns a number greater than 10, you must ReDim your array and call the GetExcelSheetList method again, as described in Step 3.
    3. Set the LogFileName parameter to the path and file name of the log file that records the manner in which Spread handles the import of Excel features, including cell types and other settings. If you do not want to generate a log file, set the LogFileName parameter to 0.
    4. Set the Replace parameter to TRUE to read the entire Excel file.

      Note: Set the Replace parameter to TRUE in any case in which you want to force a Refresh of the information read from the Excel-formatted file. For example, you would want to force a Refresh any time you are importing a different Excel-formatted file to overwrite the earlier data read when importing the previous Excel-formatted file or if the Excel file has changed.

  3. If in Step 2 you did not know the number of worksheets in the Excel-formatted file, call the GetExcelSheetList method again, and set the parameters as follows:
    1. Set the FileName parameter to the path and file name of the Excel-formatted spreadsheet.
    2. Declare the array to contain the list of sheet names. Redimension the List parameter with the same number of elements as the total number of sheets in the workbook (step 2 returned the number of worksheets in the ListCount parameter), as the following code illustrates:
      ReDim List(listcount)
      where listcount is the total number of sheets in the workbook.
    3. Set the LogFileName parameter to the path and file name of the log file that records the manner in which Spread handles the import of Excel features, including cell types and other settings. If you do not want to generate a log file, set the LogFileName parameter to 0.
    4. Set the Replace parameter to FALSE.
  4. If you did not use the ImportExcelBook method, call the ImportExcelSheet method, setting the parameters as follows:
    1. Set the WorkbookHandle parameter to the value returned by the WorkbookHandle parameter from the GetExcelSheetList method.
      The workbook handle is a global and unique identifier that represents an Excel file that has been opened during the import conversion process. For more information about the workbook handle, see the GetExcelSheetList method topic.
    2. Set the Sheet parameter to one of the following values:
      • The Worksheet number
        The Worksheet number is zero-based and is an index in the array (List) returned by the GetExcelSheetList method in step 3.
      • The Worksheet name
        The Worksheet name is a string from the array (List) returned by the GetExcelSheetList method in step 3.
      • A variant that contains either the worksheet number or worksheet name. For example:
        Dim worksheet
        worksheet = "Sheet1"
        or
        worksheet = 0
  5. Call the OpenExcel2007File method.
Copyright © GrapeCity, inc. All rights reserved.