Function to fetch data from excel works only for first row
I am relatively new to QTP and am in the learning stage.
Using a function to fetch data from excel (based on column name) to QTP data table for data driven testing.
How do i modify the function fnGetDataTableValue to fetch data if there is more than 1 row of data in the excel?Presently with the existing function QTP runs two iterations (2 rows of data in excel) but only with the first row of data.
sExcelPath = "D:\QTP_Hybrid\DataSheet\1.xls"
'initialize return the sheet to empty
fnGetDataFromExcelSheet = "Empty"
'add a blank sheet to datatable
'fetch data from excel to empty sheet
'return value to calling function
fnGetDataFromExcelSheet = Datatable.Value(strColumnName,"dtDataSheet")
'Delete reference to sheet
When importing your datatable you have to advance thru the sheet yourself using SetNetRow. From the QTP help:
Sets the row after the current (active) row as the new current row in the run-time Data Table.
Note: You can only set a row that contains at least one value. If the current row is the last row in the Data Table, applying this method sets the first row in the Data Table as the new current row.
The following example uses the SetNextRow method to change the active row to the next row in the run-time Data Table.
HTH, Mark Smith.