Problem in using Excel as Database using QTP
I know the methods of using an Excel sheet as Database using ADODB connection and Jet provider. Thanks to SQAForums.
I used to access the sheet, by giving some header in the first row of the sheet.
Now, I am trying to do the same without headers in the first row. But I am not able to perform the same function without using any headers!!
The following query code, when I use "Numbers" as the header in the first row of the sheet.
strHeader = "HDR=Yes;"
' Open the object for the Excel file
Set objExcel = CreateObject( "ADODB.Connection" )
objExcel.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:\Test1.xls" & ";Extended Properties=""Excel 8.0;" & strHeader & """"
' Open a recordset object for the sheet and range
Set objRS = CreateObject( "ADODB.Recordset" )
strRange = "Sheet1" & "$" & "A1" & ":" & "C8"
objRS.Open "Select * from [" & strRange & "] where Numbers>18", objExcel, 3
Now how to perform the same action, when I do not have the header - Numbers? I tried giving, the Column Name "A" in the place of the header. I tried changing 'HDR=NO'. None of these worked. I could not find anything solving my issue in google too.
Please let me know how to do the same
- Devaraj R