Quality is delighting customers
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:
Pls.. give me the solution asap.
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.
I gave the path as
DataTable.ImportSheet "C:\Program Files\Tests\Framework\DDAFW2\Datatable.xls","Sheet1",Global
but it is not working.
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
datable.importsheet "C:\Program Files\Tests\Framework\DDAFW2\Datatable.xls","dtglobalsheet",1
It should work
I tried with "dtglobalsheet" also but it is not working.
Follow the steps:
First save the file as xls format like Test.xls
then execute the command :
Hi , do this it works
for i = 1 to 3 step 1
i hope it works,,,
lakshmi kanth reddy
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
By using this you can retrieve the data very easily.
If you dont want to use the Datatable you can simply write
and modify the sheetcount in the looping structure
Hope it works for you,