
- Forum
- Testing
- Software Testing
- Import EXCEL Data into QTP Global Data Table
Import EXCEL Data into QTP Global Data Table
This is a discussion on Import EXCEL Data into QTP Global Data Table within the Software Testing forums, part of the Testing category; Hi, Wanted a Help. Doubt No.1 ---------- Any one who knows about export and import of data from QTP Gloabl ...
-
09-21-2006, 08:02 AM #1
- Join Date
- Aug 2006
- Answers
- 3
Import EXCEL Data into QTP Global Data Table
Hi,
Wanted a Help.
Doubt No.1
----------
Any one who knows about export and import of data from QTP Gloabl Data Table to Office Excel and Office Excel to QTP Global Data Table.
at 1st I have placed the data in QTP Global Data Table.
Later I am exported the data to the Office Excel Sheet.
I am not able to retrive the data from the Office Excel Sheet.
Doubt No.2
-----------
Instead of placing the data in the QTP Global Data Table. I wanted to Store the data directly in office Excel Sheet and call the data back into QTP while I am Running the Script.
Can any one help me in this 2 issues.
-
try this..
You can use Action and Test parameters to parameterize the hard coded value of Excel sheet path, or even you can go for Environment variables.
Using Test and Action parameter:
Follow following procedure
Go to Test Settings-> Parameters-> define the input parameters (for ex: path)
As Test parameter can't be used directly in Test script, goto Correspoding Action an right click and go to Action properties and define Action parameter to use.(for ex: path1)
then goto Action Call Properties-> and set value for defined action parameter
as Test parameter(in value column for that parameter click on the '<>' to set value and set Test parameter as parameter type and set "path" variable to Action parameter(path1)
and use same action parameter in the datatable.import sheet statement
datatable.importsheet path1 When we run the Test we can give the path of Excel sheet in "Run dialog box->Paramters" .
Using of Environment variable define an environment varibale in Test->settings->Environment parameters
Select parameter type as "Userdefined" from list box and define the parameter and use directly in datatable.importsheet statement. Here we need to give value of path before executing the script.
Ref: QTP : I m setting the excel sheet path in QTP for importing as : datatable.importsheet "C:Qtpabc.xls" but
-
04-18-2007, 05:43 AM #3
- Join Date
- Apr 2007
- Answers
- 1
Import and Export Sheet
Use the following statements for importing
DataTable.ImportSheet "..\..\TestData\Input.xls",1,dtGlobalSheet
DataTable.ExportSheet "..\..\Results\Output.xls","Global"
-
Simple Answer
just follow the steps:-
1) Record script in QTP
2) Save the script
3) close QTP
4) open saved script location in your local drive.(You can see a folder with your actuall script name)
5) open the folder
6) you can find 'Default.xls'
7) enter the data what ever you want in this excel file.
Do remember QTP will treat that the first row as column names.
8) save the excel and close.
9) open QTP application. Press 'Ctrl+O'
and open the script you just saved.
10) you can see the data what ever you have saved in 'Default.xls' sheet in Data table.
The other simple way is just right click on datatable and select File>Import From File To import data from office excel.
Cheers.
-
thse things are ok
any other methods and procedures
-
11-30-2007, 07:16 AM #6
- Join Date
- Nov 2007
- Location
- Bangalore,India
- Answers
- 1
Ans for Doubt No.1
for importing a file:
DataTable.Import "filename.txt"
(you have to write the path name also for eg:
DataTable.Import "C:\Documents and
Settings\mercury\Desktop\fly.txt")
for Exporting a file:
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("fileName.txt",True)
(Eg:Set MyFile = fso.CreateTextFile("C:\Documents and Settings\mercury\Desktop\flight.txt",True)
MyFile.WriteLine("Fly_From"&" "&"Fly_To"&" "&"Order_No"&" "&" Flight" )
C1=DataTable.Value(1,1)&" "
C2=DataTable.Value(2,1)&" "
C3=DataTable.Value(3,1)&" "
c4=DataTable.Value(4,1)
B=C1&C2&C3&c4
MyFile.WriteLine(B)
This is just an example
Note: To get the contents in diff column in Exel sheet give tab.
-
11-30-2007, 07:45 AM #7
- Join Date
- Feb 2007
- Location
- Chennai
- Answers
- 84
help
is there any openings in ur company
-
12-09-2007, 10:59 PM #8
- Join Date
- Jun 2006
- Answers
- 1
the syntax to import sheets from excel to data table is...........
DataTable.ImportSheet "location of .xls file","sheet in .xls file","sheet in data table"
Ex: DataTable.ImportSheet "C:\gettingstarted.xls","sheet1","action1"
similarly u can import other required sheets into data table as well.......
-
Sponsored Ads
«
tutorials on vb scrpiting in qtp
|
Can mercury interative tools be installed inwindows vista home edition
»

Reply With Quote





