Micro Focus QTP (UFT) Forums

Full Version: Adding rows to the DataTable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I cannot seem to add rows to my Datatable. I am capturing transaction times using the MercuryTimers function then I save the first value along with the column name using the Addparameter function. This all works fine, but I do many iterations and I want to populate the rows of the existing columns not keep adding more columns. Is there a way to do this?

Code:
DataTable.GetSheet("Action1")
DataTable.SetCurrentRow(intIteration)
' here i need something other than addparameter if iteration > 1
DataTable.LocalSheet.AddParameter "LoginPage", loginpageTime
Wend
DataTable.ExportSheet "C:\Automation Data\data\SingleUser.xls", 2
I found one answer here I will try, my search criteria was not so good Big Grin
https://www.learnqtp.com/forums/add-a-ro...-1461.html
Code:
p=datatable.AddSheet ("My").AddParameter("city","New York")

i=datatable.GetSheet ("My").getcurrentrow
msgbox i 'This will give 1 as the current row is 1.

q=datatable.GetSheet ("My").SetNextRow 'This one is getting null value.It should show 2
'but nothing
msgbox q

datatable.getsheet("My").Setcurrentrow(2) 'then i've used this cuz i know my current
'row index is 2
'******** Both code below worked for adding value in run time data sheet.
'datatable.Value("city",3)="Bombay"   '3 is for sheet index  for Sheet name My
Datatable.Getsheet("My").GetParameter("city").Value="Bombay"

Data=datatable("city",3)'getting  current row value from sheet My index 3
msgbox Data
the idea was to load columns that match the raw data from loadrunner that I am gathering so I could extrapolate the page rendering time rather than having to cut rows and paste them into columns manually. the following solution worked:
Code:
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Workbooks.Add
Set ExcelSheet = ExcelApp.ActiveSheet
...
While intIteration < 30
...  
MercuryTimers("Save").Start
Browser("WebBrowser").Page("WebPage").Link("Save").Click
Browser("WebBrowser").Page("WebPage").WebElement("Success").CheckProperty "visible", True, 30000
intSave= MercuryTimers("Save").Stop
...
Services.SetTransaction "Iteration",intIteration, Pass
labels = Array("Login", "Mainpage","Search", "Save", "Logout")
results = Array(intLogin, intMainpage, intSearch, intSave, intLogout)
For i=0 to 4
results(i) = results(i)/1000
ExcelSheet.Cells(intIteration,i+1).Value = results(i)
Services.SetTransaction labels(i), results(i), Pass
Next
...
Wend
...
ExcelSheet.SaveAs "C:\Automation Data\SingleUser.xls"
ExcelSheet.Application.Quit
Set ExcelSheet = Nothing