Description
A sheet in the run-time Data Table. This object is not a built-in utility object, but can be accessed using one of the following methods or properties:
Notes:
All methods performed on this object apply to the run-time DataTable object only. Changes to the run-time DataTable object are reflected in the test results, but the design time Data Table is not affected.
When working with scripted components, the name of the (single) Data Sheet is identical to the name of scripted component. If you save the scripted component with a new name, the name of the data sheet changes accordingly.
Associated Methods
Associated Properties
DataTable.AddSheet(SheetName)
Return Value
DTSheet Object.
Example
The following example uses the AddSheet method to create the new sheet, "MySheet" in the run-time Data Table and then adds a parameter to the new sheet.
Variable=DataTable.AddSheet ("MySheet").AddParameter("Time", "8:00")
DataTable.GetSheet(SheetID)
Argument
|
Type
|
Description
|
---|---|---|
SheetID
|
Variant
|
Identifies the sheet to be returned. The Sheet ID can be the sheet name or index. Index values begin with 1.
|
Return Value
DTSheet Object
Examples
The following example uses the GetSheet method to return the "MySheet" sheet of the run-time Data Table and add a parameter to it.
MyParam=DataTable.GetSheet ("MySheet").AddParameter("Time", "8:00")
You can also use this to add a parameter to the "MySheet" local sheet (note that no value is returned).
DataTable.GetSheet ("MySheet").AddParameter "Time", "8:00"
The example below performs the equivalent of renaming a column (parameter) in the DataTable by copying the data from one column to a new column with a new name, and then deleting the old column.
'add a new column
DataTable.GetSheet("dtGlobalSheet").AddParameter "NewColumn","Row1Value"
'copy the cells from the old column into the new column
cnt=DataTable.GetRowCount
For i=1 to cnt
DataTable.SetCurrentRow(i)
OldVal=DataTable.Value("OldColumn","dtGlobalSheet")
DataTable.Value("NewColumn","dtGlobalSheet")=OldVal
Next
'delete the old column
DataTable.GetSheet("dtGlobalSheet").DeleteParameter("OldColumn")
DataTable.GetSheet("dtGlobalSheet").AddParameter "NewColumn","Row1Value"
'copy the cells from the old column into the new column
cnt=DataTable.GetRowCount
For i=1 to cnt
DataTable.SetCurrentRow(i)
OldVal=DataTable.Value("OldColumn","dtGlobalSheet")
DataTable.Value("NewColumn","dtGlobalSheet")=OldVal
Next
'delete the old column
DataTable.GetSheet("dtGlobalSheet").DeleteParameter("OldColumn")
DataTable.GlobalSheet
Example
The following example uses the GlobalSheet property to return the global sheet of the run-time Data Table in order to add a parameter (column) to it.
ParamValue=DataTable.GlobalSheet.AddParameter("Time", "5:45")
You can also use this method to add a parameter to the global sheet (note that no value is returned).
DataTable.GlobalSheet.AddParameter "Time", "5:45"
DataTable.LocalSheet
Example
The following example uses the LocalSheet property to return the local sheet of the run-time Data Table in order to add a parameter (column) to it.
MyParam=DataTable.LocalSheet.AddParameter("Time", "5:45")
For more on Automation Testing Using QTP :
Data-driven-approach-qtp-automation Testing
Object-repository-in-qtp
Vbscripting-in-qtp
What is Selenium-in-automation-testing
What is Qtp-recovery-objects-associated-methods
What is Qtp-recovery-objects-associated
What is Qtp-extern-objects
Scripts-classification-in-qtp
How to do datetime-formatting-in-vsts
Vbscript-in-qtp
For more on Automation Testing Using QTP :
Data-driven-approach-qtp-automation Testing
Object-repository-in-qtp
Vbscripting-in-qtp
What is Selenium-in-automation-testing
What is Qtp-recovery-objects-associated-methods
What is Qtp-recovery-objects-associated
What is Qtp-extern-objects
Scripts-classification-in-qtp
How to do datetime-formatting-in-vsts
Vbscript-in-qtp
Post a Comment