In QTP, we have a datatable that can be used to store the runtime data from application or test data.
In datatable we have multiple sheets as mentioned below.
By default globalsheet is refered.
To get reference to the any other sheet use below syntax
datatable.GetSheet("sheetname")
Examples of Datatable in QTP -
'to add new sheet to datatable, you can use below method
datatable.AddSheet("sagar")
'to add parameter to the sheet
datatable.GetSheet("sagar").addParameter "id",1
'in above statement, we have added parameter with name id to sheet called sagar. 1 is the value added into first row of that parameter
'to set the row pointer we can use setCurrentRow method
datatable.GetSheet("sagar").setCurrentRow(1)
'Above statement will set row pointer to first row in sheet name sagar.
'to access data from the sheet, use below statement.
datatable("id","sagar") = "ppp:"
'above code will store ppp: in the sagar-sheet and under id column/parameter
'to move to next row, use below method.
'datatable.GetSheet("sagar").SetNextRow
datatable.GetSheet("sagar").setCurrentRow(2)
datatable("id","sagar") = "1"
'datatable.GetSheet("sagar").SetNextRow
'Please remember that You can only set a next row that contains at least one value.
datatable.GetSheet("sagar").setCurrentRow(3)
datatable("id","sagar") = "112"
datatable.GetSheet("sagar").setCurrentRow(1)
for i=1 to 3
msgbox datatable("id","sagar")
datatable.GetSheet("sagar").SetNextRow
next
'to get the total number of rows in any sheet we can use.
datatable.GetSheet("sagar").getRowCount
You may find below links very useful if you want to know more about data tables in QTP.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.
In datatable we have multiple sheets as mentioned below.
- GlobalSheet - can be accessed from any action.
- LocalSheet per Action - can be accessed from specific sheet only.
- Any user defined sheet.
By default globalsheet is refered.
To get reference to the any other sheet use below syntax
datatable.GetSheet("sheetname")
Examples of Datatable in QTP -
'to add new sheet to datatable, you can use below method
datatable.AddSheet("sagar")
'to add parameter to the sheet
datatable.GetSheet("sagar").addParameter "id",1
'in above statement, we have added parameter with name id to sheet called sagar. 1 is the value added into first row of that parameter
'to set the row pointer we can use setCurrentRow method
datatable.GetSheet("sagar").setCurrentRow(1)
'Above statement will set row pointer to first row in sheet name sagar.
'to access data from the sheet, use below statement.
datatable("id","sagar") = "ppp:"
'above code will store ppp: in the sagar-sheet and under id column/parameter
'to move to next row, use below method.
'datatable.GetSheet("sagar").SetNextRow
datatable.GetSheet("sagar").setCurrentRow(2)
datatable("id","sagar") = "1"
'datatable.GetSheet("sagar").SetNextRow
'Please remember that You can only set a next row that contains at least one value.
datatable.GetSheet("sagar").setCurrentRow(3)
datatable("id","sagar") = "112"
datatable.GetSheet("sagar").setCurrentRow(1)
for i=1 to 3
msgbox datatable("id","sagar")
datatable.GetSheet("sagar").SetNextRow
next
'to get the total number of rows in any sheet we can use.
datatable.GetSheet("sagar").getRowCount
You may find below links very useful if you want to know more about data tables in QTP.
- How to export datatable sheets to excel
- How to import excel-sheet to datatable
- How to read value from cell in datatable in QTP
- Explain setcurrentrow method in qtp
- Datatable object in qtp
- How to export datatable to excel in qtp
- How to get current sheet from datatable
- How to check if parameter exists in sheet in datatable in qtp
- Explain dtsheet object in qtp
- What are the utility objects in qtp
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs