You are on page 1of 5

QTP Data Table

Data Table has two types of data sheets— Global and Action. You can access the different sheets by
clicking the appropriate tabs below the Data Table. You store data in the Global tab when you want it to
be available to all actions in your test and you want the data to control the number of test iterations. You
store data in the action’s tab when you want to use the data in Data Table parameters for that action only
and you want the data to control the number of action iterations.

The Data Table has the characteristics of a Microsoft Excel spreadsheet, meaning that you can store and
use data in its cells and you can also execute mathematical formulas within the cells. You can use the
DataTable, DTSheet and DTParameter utility objects to manipulate the data in any cell in the Data Table.
The use of complex and/or nested formulas in the Data Table is not supported.

You can insert Data Table parameters and output values into your test. Using Data Table parameters
and/or output values in a test enables you to create a data-driven test or action that runs several times
using the data you supply. In each repetition, or iteration, QuickTest uses a different value from the Data
Table.

During the run session, QuickTest creates a run-time Data Table—a live version of the Data Table
associated with your test. During the run session, QuickTest displays the run-time data in the Data Table
pane so that you can see any changes to the Data Table as they occur. When the run session ends, the
run-time Data Table closes, and the Data Table pane again displays the stored design-time Data Table.
Data entered in the run-time Data Table during the run session is not saved with the test. The final data
from the run-time Data Table is displayed in the Run-Time Data Table in the Test Results window.

QTP Data Table Methods

(1) Add Sheet:

We can use this method to “add” one new sheet to the run time data

table.

Syntax: DataTable.AddSheet "sheet name"

Ex: DataTable.AddSheet "gcreddy"

(2) Delete Sheet:

We can use this method to “delete” one specified sheet from the Run

Time Data table.


Syntax: datatable.DeleteSheet (Sheet_ID)

Ex: datatable.DeleteSheet (3)

(3) GetSheetCount

We can use this method to count number of sheets in the run time data

table.

Syntax:

datatable.GetSheetCount

msgbox datatable.GetSheetCount

(4) GetRowCount

We can use this method to count number of rows in the 1st sheet

(longest column) of the Run time data table.

Syntax: datatable.GetRowCount

Ex: msgbox datatable.GetRowCount

(5) GetSheet
We can use this method to return a specified sheet from the Run Time

data table.
Syntax: datatable.GetSheet(SheetID)

Ex: msgbox datatable. GetSheet(1).GetRowCount

(6) Value

We can use this method to set or get value of cell in the specified

parameter and the current row of the Rum time data table.

To set data

Syntax: datatable.Value(Parameter_Name, Sheet_Name) = Value /

variable Or

datatable(Parameter_Name, Sheet_Name) = Value / variable

To get data

Syntax: Variable = datatable.Value(Parameter_Name, Sheet_Name) Or

Variable = datatable(Parameter_Name, Sheet_Name)

Ex:

Option explicit Dim a, b, c

a=datatable.Value (1,1) b=datatable.Value (2,1) c=cint(a)+cint(b)

datatable.Value (3,1) = c

Note: Default property of Datatable is value

(7) SetCurrentRow

We can use this method to take a specified row as current row in the Run

Time Datatable (By default it is 1st Row of 1st Sheet)

Syntax: datatable.SetCurrentRow(Row_Number)
g="gcreddy"

datatable.SetCurrentRow (3) datatable.Value (1,1) = g

(8) SetNextRow

We can use this method to take the row after the current Row as New

Current Row in the Run time data table.

Syntax: datatable.SetNextRow

Ex: g="gcreddy"

datatable.SetCurrentRow (3) datatable.SetNextRow datatable.Value (1,1)

=g

(9) SetPrevRow

We can use this method to take the row before the current Row as New

Current Row in the Run time data table.

Syntax: datatable.SetPrevRow

Ex: g="gcreddy"

datatable.SetCurrentRow (3) datatable.SetPrevRow datatable.Value (1,1)

=s

(10) Import

We can use this method to import Microsoft Excel File to the Runtime

Data Table (Including all sheets)

Syntax: datatable.Import “Path of File”

Ex: datatable.Import “F:\Inputdata.xls”

11) ImportSheet
We can use this method to import a specified sheet of Microsoft Excel

Sheet to the Runtime Data table.

Syntax: datatable.ImportSheet “Path of File”, “Source Sheet”,

“Destination Sheet”

Ex: datatable.ImportSheet “E:\gcreddy.xls”,3,1

(12) Export

We can use this method to export a copy of Run Time Data table to

another location (Including all sheets)

Syntax: datatable.Export “Path of File”

Ex: datatable.Export “F:\gcreddy.xls”

13) ExportSheet

We can use this method to export a copy specified sheet of Run Time

Data table to the existing or new Excel File.

Syntax: datatable.ExportSheet “Path of File”, “Sheet Name / Source

Sheet”

Ex: datatable.ExportSheet “F:\gcreddy.xls”, 2

You might also like