Forum Discussion

ASV's avatar
ASV
Contributor
12 years ago

How to get the value using header of table in excel file.

Hi 

I want to get the value from excel file in which exists a table with headers. I can get the value writing this-



fID = objSheet.Cells(excelRowN, 1).Value



but writing this



fID = objSheet.Cells(excelRowN, "ID").Value



("ID" the header of first column. You can see it in attachment) I get error.

4 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi,



    When using Excel's Sheet.Cells API, you can't refer to the columns by headers. You can only use column indexes (1, 2 etc) or column letters (A, B etc).



    However, if you read the file using TestComplete's DDT.ExcelDriver instead, you'll be able to use the column headers:

    Call DDT.ExcelDriver("C:\OutputOrders.xlsx", "Sheet1", True)



    While Not DDT.CurrentDriver.EOF

      fID = DDT.CurrentDriver.Value("ID")

      ' Do something with fID

      ...



      DDT.CurrentDriver.Next

    WEnd
  • I am using DDT driver to get data from Excel sheet. I want to go to specified row( rowNo x ) in the sheet. How can I achieve this.

    ( I am using  Test Complete 8.6 )