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 ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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.
__________________
Thanks & Regards Krishnamurthy Tatavarthy |
|
|||
|
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 |
|
|||
|
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.
__________________
Yours, Krishna |
|
|||
|
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. |
|
|||
|
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....... |
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| difference between Data Warehouse and Online Analytical Processing | techguru | Data Warehousing | 1 | 04-10-2006 12:25 PM |
| Use XML to Import Data | Matrix_2006 | XML | 0 | 02-18-2006 03:07 AM |
| Saving a data in excel sheet....Using QTP | oracleraju | Testing Tutorials | 3 | 09-02-2005 06:20 AM |
| hierarchail & network | kisshug | Oracle Tutorials | 2 | 05-01-2005 05:17 PM |
| can we write data back to data table? | mangalsachin2002 | Testing Tutorials | 1 | 03-21-2005 03:35 PM |