Skip to content
 

How can we extract data from Microsoft excel sheet to QTP

A simple example to demonstrate on Extracting data from Microsoft Excel sheet to QTP:

So just for testing purpose, please create test.xls in the C drive.
And also make sure you have some test data in the excel sheet.

excel_path = “c:\test.xls”
sheet-of-excel = “test_sheet”
excel_row = 1
excel_column = 1

Function extract_from_excel(excel_path, sheet1,row_no, col_no)
set excel_object = createObject(“excel.application”)
set my_sheet = excel_object.sheets.item(sheet1)
value = my_sheet.cells(row_no,col_no)
excel_object.application.quit
set excel_object = nothing
extract_from_excel = value
end function.

here you can display a message box with the results.

msgbox extract_from_excel(excel_path, sheet1, row_no, col_no)

Hope the above example is helpful to you all guys.

Save on DeliciousDigg This
Submit to StumbleUponTweet

Leave a Reply