How to get data from a particular row and a particular column from Data Table in QTP?
Check this Post for Datatable Methods.
QTP Script to get particular cell value from datatable in the specified row.
Below script is for retrieving 2rd row,2rd column cell value from datatable.
In datatable we have values as shown below
A B C
1 QQ xx
2 TT yy
3 PP zz
Script to get value "TT" from datatable is
Method 1
Syntax:Datatable.getsheet("Sheet Name"/Sheet Id).getparameter("Column Name").valuebyrow(Row Number)
msgbox Datatable.getsheet("Global").getparameter("B").valuebyrow(2)
Method 2
Syntax:datatable.SetCurrentRow(rownumber)
Cell Vaue=datatable.Value("ColumnName"/Column Number,"SheetName"/Sheet Id)
datatable.SetCurrentRow(2)
msgbox datatable.Value(2,1)
QTP Script to get RowCount of DataTable for Specific Column
QTP Script to get columncount,rowcount,column names of datatable
Script to Get Cell Value of Particular Row and Column from Data Table in QTP
DataTable Methods(1)
1.AddSheet:-It is used for adding a new sheet to runtime datatable.
Syntax:-DataTable.AddSheet("Sheetname")
Example:-DataTable.AddSheet("laxmi")
2.DeleteSheet:-It is used for deleting a specified sheet from runtime datatable.
Syntax:-DataTable.DeleteSheet("Sheetname")
Example:-DataTable.DeleteSheet("laxmi")
3.Import:-It is used for importing all the sheets from Excel sheet to runtime datatable.
Syntax:-DataTable.Import"Path of Excel sheet"
Example:-DataTable.Import"d:\excel1.xls"
4.ImportSheet:-It is used for importing a specified sheet from Excel sheet to runtime datatable.
Syntax:-DataTable.ImportSheet"Path of Excel Sheet",Source sheetid,Destination sheetid
Example:-DataTable.ImportSheet"d:\excel2.xls",1,1
Here Source and Destination Sheet ids are 1(in this example)
1 is for Global Sheet.
5.Export:-It is used for exporting a complete runtime datatable(all sheets) to a specified location(path).
Syntax:-DataTable.Export"Path where excel sheet has to be created"
Example:-DataTable.Export"d:\excel3.xls"
6.ExportSheet:-It is used for exporting a specified sheet from a runtime datatable to specified location.
Syntax:-DataTable.ExportSheet"Path of Excel Sheet",Sheet id which has to be exported.
Example:-DataTable.ExportSheet"d:\excel4.xls",1
Datatable Methods(2)