Micro Focus QTP (UFT) Forums

Full Version: How many ways we can use external XL sheet data import in to runtime datatable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All

Please help me to get data from external XLsheet to datatable (runtime) and use that data in to my applications

Code:
Using Datatable.getsheet

Dim rcount,i, Fdate, Cname, etc...

Datatable.AddSheet("Dtsheet")
datatable.importsheet("C\...\data.xls","sheet1","Dtsheet"

rcount = datatable.getsheet("Dtsheet").getrowcount

for i = 1 to rcount step 1

datatable.setcurrentrow(i)

Fdate = datatable.value("flydate","Dtsheet")
.
.
.
Cnmae = datatable.value("cname","Dtsheet")
,
,

window("flightReservation").active
window("flightReservation").ActiveX("MaskEdBox").type "Fdate"
...
..
Some one please explain the complete flow please

How the data entering in to the (run time) datatable

When the data assigned to variables, how the data input to the application and all other ways to do this with different ways.

Some time working and some time don't work.

I would like to know which way and How many ways we can use external XL sheet data import in to runtime datatable and how we can use that data for Application test data.

Please give some brief description along with example code please.

It should be really appreciated your effort and thanks in advance

Cheers
Hi govQa,

You just forgot couple of points in your example.

1)Instead of datatable.setcurrentrow(i) ...... give Datatable.GetSheet("Dtsheet").SetCurrentRow(i) as shown below.
2) FYI..If you are running the script using the Getrowcount thru For Loop...then in File --> Settings -->Run Tab , Select "Run On One Iteration" RadioButton --> Apply -->OK.

Now Try to Execute the code given below & see.....

Example:
Code:
Dim rcount,i, Fdate, Cname, etc...

Datatable.AddSheet("Dtsheet")
datatable.importsheet("C\...\data.xls","sheet1","Dtsheet")

rcount = datatable.getsheet("Dtsheet").getrowcount

for i = 1 to rcount
datatable.Datatable.GetSheet("Dtsheet").SetCurrentRow(i)
Fdate = datatable.value("flydate","Dtsheet")
.
.
.
Cnmae = datatable.value("cname","Dtsheet")
,
,

window("flightReservation").active
window("flightReservation").ActiveX("MaskEdBox").type "Fdate"
...
..
Next