Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to import excel sheet to qtp
#1
Not Solved Cool 
Hi friends,

can you explain me what is 1,2 in import sheet and what is Action 1 and datatable.getsheet.

Code:
systemutil.Run"C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
datatable.ImportSheet "E:\Test1.xls",1,2
d=datatable.GetSheet("Action1").getrowcount
For i=1 to d
DataTable.GetSheet("Action1").SetCurrentRow(i)
username=datatable.Value("u","Action1")
password=datatable.Value("p","Action1")
d1=datatable.Value("d1","Action1")
dialog("Login").WinEdit("Agent Name:").Type username
dialog("Login").Winedit("Password:").Type password
dialog("Login").WinButton("OK").Click
window("text:=Flight Reservation").winobject("text:=__/__/__").Type d1

Next

Thanks,
Shyam
Reply
#2
Not Solved
Hi Shyam,

1,2 are the Sheet indexes.

Syntax
Code:
DataTable.ImportSheet(FileName, SheetSource, SheetDest)

1 --> Source Sheet which you want to import from
2 --> Destination Sheet to which you want to import

Example:
In external excel file:
sheet1 --> 1
sheet2 --> 2

In Datatable:
Global Datasheet --> 1
Action1 DataSheet --> 2


If we use Datatable.GetRowCount then it would return the no. of rows in Global Data sheet by-Default
So if we want to return the No. of rows in Action1 Datasheet then we have to use GetSheet method as given below.
Code:
datatable.GetSheet("Action1").getrowcount



Reply
#3
Not Solved
Thanks dude
Reply
#4
Not Solved
Hi,

Below is the basic code Importing a spcific sheet from xternal Excel file.
Code:
DataTable.ImportSheet (FilePath, SourceSheetNo., DestinationSheetNo.)


Suppose we have .xls file named "TestDemo.xls", and want to populate its 3rd sheet on datatables Action2 Localsheet.(Sheet Id 3)
So for that purpose,

DataTable.ImportSheet (FilePath, 3, 3) should work fine.

Regards,
Nilanjan
Reply
#5
Not Solved
use DataTable.Import(path of the excel file)
Reply
#6
Not Solved
I am getting error while I am executing following script:

DataTable.Importsheet
Code:
"D:\QTP_notes\class_notes\FlightProj\TestData\data.xls","login","Action1"
n= DataTable.GetSheet("Action1").GetParameterCount
msgbox n

'first line is importing my file to Action1 data tabel
but It is not able to execute second line.

I stored a file "data.xls" at given path but at the line I am getting general error.In data.xls there is one worksheet named as login and it contains 1 row.

I have attached the file too. I am not sure where I am doing wrong?

Please help.



Sorry 2nd line is:
Code:
n= DataTable.GetSheet("Action1").GetRowCount
I posted wrong in my previous post.

Thanks.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading data from excel sheet serenediva 1 9,622 03-03-2017, 10:07 AM
Last Post: vinod123
  How import final calculated values by cell formula from Excel not the formula itself. qtped 1 4,861 01-17-2017, 04:05 PM
Last Post: sagar.raythatha
Smile Importing Excel sheet - Reference Values are not recognized michiusa69 3 7,885 01-23-2015, 02:36 AM
Last Post: lkng2001
  How to pass a date from Excel sheet to web form revati.shendure 1 2,973 11-27-2014, 11:54 AM
Last Post: revati.shendure
  Datatable import error Prashanth 7 16,400 11-19-2014, 06:53 PM
Last Post: praveen.g3

Forum Jump:


Users browsing this thread: 1 Guest(s)