Quality Testing

Quality is delighting customers

Hi friends,

 

I am unable to import excel data in QTP.

 

1) I created one excel file in C drive ("C:\Program Files\Tests\Framework\DDAFW2\Datatable.xls")

2) In QTP, Open a new test script and write 

DataTable.ImportSheet "C:\Program Files\Tests\Framework\DDAFW\Datatable.xls","Sheet1",Global

3) Save the test script

4) Run the test script

 

when i am running the test script, i am getting the error message as

"A general error occurred while importing sheet  from file C:\Program Files\Tests\Framework\DDAFW2\Datatable.xls to sheet Sheet1".

 

In my data table Sheet1 contains data as follows:

CN CD CRD
CustomerA DescriptionA active_customers
CustomerB DescriptionB add_project
CustomerC DescriptionC add_more_customers_action

 

Pls.. give me the solution asap.

 

 

Views: 4395

Reply to This

Replies to This Discussion

Hi,

The problem is not with QTP, it is your carelessness..............You please check the path of your excel file. You have created a file inside "DDAFW2" folder but when importing you are trying to get it from "DDAFW" folder. Definitely QTP will throw error.

Best Regards,

Bibin

 

Hi,

I gave the path as

DataTable.ImportSheet "C:\Program Files\Tests\Framework\DDAFW2\Datatable.xls","Sheet1",Global

but it is not working.

 

Regards,

Mythreyi

 

 

hi

 

you write data in data table like as u mentioned in the above query. so that you can write path of the file as simple like in d: drive

like datable.importsheet "D:/input.xls","dtglobalsheet",1

CN CD CRD
CustomerA DescriptionA active_customers
CustomerB DescriptionB add_project
CustomerC DescriptionC add_more_customers_action

 

 

 

datable.importsheet "C:\Program Files\Tests\Framework\DDAFW2\Datatable.xls","dtglobalsheet",1

 

It should work

Hi,

 

I tried with "dtglobalsheet" also but it is not working.

 

Regards,

Mythreyi

Follow the steps:

First save the file as xls format like Test.xls

 

then execute the command :

DataTable.ImportSheet"D:\sasidhar\Test1.xls",1,1

Hi , do this it works

                  datatable.addsheet("reddy")

                  datatable.importsheet("c:\My documents\reddy.xls",1,3

                  n=datatable.getrowcount

                  for i = 1 to 3 step 1

                  x=datatable("CN",3)

                  y=datatable("CD",3)

                  z=datatable("CRD",3)

                   next

                    i hope it works,,,

                  Regard's

                  lakshmi kanth reddy

I am getting the same error , it works sometimes and it doesn't getting general error please help

Hi,

Please follow the following steps i hope it works:

 

1) Click the Data Table option from the toolbar

2) Now Right Click the Data Table and select Import a file

3) You can Select the Path of the file to be imported.

4) After the File is loaded in the Data Table you can write the code to retrieve the data.

In this we suppose that CN is the first column, CD is the second column, and CRD is the third column.

i have used variables like l,k,j. l variable is used for the sheetcount, k variable is used for the column count and j variable is used for the row count

Code can be like this:

colcount = datatable.GetSheet(k).GetParametercount
rowcount = datatable.GetSheet(K).GetParametercount
shtcount = datatable.Getsheetcount

for i = 1 to rowcount step 1
for j = 1 to colcount step 1
for k = 1 to shtcount step 1
datatable.setcurrentrow(i)
val =datatable.Getsheet(k).GetParameter(j).ValuebyRow(i)
next
next
next

 

By using this you can retrieve the data very easily.

 

If you dont want to use the Datatable you can simply write

daatatable.Import("C:\Program Files\Tests\Framework\DDAFW\Datatable.xls")

and modify the sheetcount in the looping structure

 

Hope it works for you,

Anjali Vaswani

 

 

 

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service