Micro Focus QTP (UFT) Forums
Unable to import excel sheet to qtp - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Unable to import excel sheet to qtp (/Thread-Unable-to-import-excel-sheet-to-qtp)



Unable to import excel sheet to qtp - shyams - 04-24-2011

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


RE: Unable to import excel sheet to qtp - sreekanth chilam - 04-24-2011

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






RE: Unable to import excel sheet to qtp - shyams - 04-29-2011

Thanks dude


RE: Unable to import excel sheet to qtp - nilanjans - 04-12-2012

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


RE: Unable to import excel sheet to qtp - vinod123 - 04-13-2012

use DataTable.Import(path of the excel file)


RE: Unable to import excel sheet to qtp - abhis786hek - 04-22-2012

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.