SQL Object
 
Syntax
 
SQL.ImportExcelFile(FileName, Array2D()[, Worksheet])
 
Description
Opens an .xls file and loads its contents into a two-dimensional array variable. All records are loaded into the array, with a maximum of 65536 rows.
 
When loading is successful, this function returns the value TRUE, or else FALSE.
 
The first dimension of the array contains the lines of the worksheet, the second dimension contains the individual columns. Array2D(0,0) contains the first column of the first row.
 
 
Note: Does not require an installed version of Micorosoft Excel.
        Supports worksheets that are Excel-97 compatible (BIFF9 format).
 
Parameter
Description
FileName
Path and file name reference to an MS Excel worksheet (.xls) or other compatible (convertible) file.
Array2D
A variable of type two-dimensional Array (variant) in which the worksheet is loaded (max 65536 rows).
Worksheet
Optional. If a file contains multiple worksheets, the index or worksheet name can be specified here. If not specified, the first worksheet is loaded.
 
See Also
Example
 
Sub Main
 
   Dim sFile As String
   Dim myCells() As Variant
   Dim x As Integer, y As Integer
 
   sFile = InputBox$("Excel file:")
 
   If SQL.ImportExcelFile(sFile, myCells()) = True Then
      For x = 0 To UBound(myCells)
         For y = 0 To UBound(myCells,2)
            Debug.Print x & vbTab & y & vbTab & myCells(x,y)
         Next y
      Next y
   End If
 
End Sub