Prepare for your Next Interview
This is a discussion on How to Import the data from MS-Excel in QTP? within the QTP forums, part of the Software Testing category; Pls Anyone tell me How to import a single data from the Excel in QTP. Give me exact coding for the sample flight application.........
| Sponsored Links |
|
|||
|
Re: How to Import the data from MS-Excel in QTP?
Hi ramyamca1984
For import the data from excel in QTP you have to write one line on the top of your qtp script and that is: DataTable.Importsheet"C:\Path name(Ex:Mar_Qtp)\Excelsheet name(Ex:abc.xls)",1,Global Now run the script.While run time you can see the import data on you data table in QTP. Hope It will help you Newhere |
| The Following User Says Thank You to newhere For This Useful Post: | ||
|
|||
|
Re: How to Import the data from MS-Excel in QTP?
Hi,
As Ramya suggested Importing data from excel sheet into your datatable can be achieved. But incase you wish to read Excel values into your script, try this.... dim sExcelObj dim sWorkBook dim sWorkSheets dim sValue set sExcelObj = CreateObject("Excel.Application") sExcelObj.Visible = true set sWorkBook = sExcelObj.Workbooks.Open ("path of file") set sWorkSheets = sWorkBook.ActiveWorkbook.worksheets ("sheetname") sValue = sWorkSheets.cells(row,col).value You can also create an array to continously loop through your excel sheet and read all required values. Cheers...
__________________
Regards, V.Umesh Krishnan QA Consultant |
| The Following User Says Thank You to bizzzzzare For This Useful Post: | ||
|
|||
|
Re: How to Import the data from MS-Excel in QTP?
Hi,
I am new to QTP. I did like you explained. But it is not working.What happening here is, always script is running from first line means, Next iteration also running from first line.Every time it is taking value from from first row of excel sheet. It is not going to second line. Please explain me, how to reach next row. Thanks in advance Quote:
|
|
|||
|
Re: How to Import the data from MS-Excel in QTP?
Quote:
QTP records your actions on the application in the form of vbscript now once the recording has been done ...usually we enhance the code accoring to our requirements and need by modifying using control constructs in the script we add few lines of code too ..to make QTP behave as desired In general if you want QTP to iterate over all rows in datatable then go to file> settins > Run and check on the radiobutton "run on all rows" probably you willl be able to solve the problem hope the iteration doesn't become indefinite Last edited by admin : 12-14-2007 at 06:28 AM. |
|
|||
|
Re: How to Import the data from MS-Excel in QTP?
Quote:
To add a sheet datatable.addsheet("sheetname") To import sheet datatable.importsheet "c:\excelfile.xls", "sheet1" To get a value form excel file.. Empno = datatable.value("empno", "sheet1") To run the script for all the iterations.. For i = 1 to datatable.getsheet("sheet1").getrowcount msgbox datatable.value("empno", "sheet1") Next OR For i = 1 to datatable.getrowcount datatable.setcurrentrow(i) datatable.getcurrentrow msgbox datatable.value("empno", "sheet1") datatable.setnextrow Next |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Import excel sheet into PowerCenter | nsakhi | Data Warehousing | 0 | 09-16-2007 05:51 AM |
| reading data from excel sheet in QTP | JobHelper | QTP | 4 | 09-11-2007 06:33 AM |
| Unable to import data into local sheet | Geek_Guest | QTP | 1 | 07-31-2007 11:39 AM |
| Load data from oracle to Excel | bunty4u | Data Warehousing | 3 | 04-15-2007 01:50 PM |
| Microsoft CRM : 5 ways to import data | Jim.Anderson | Microsoft CRM | 0 | 09-27-2006 06:39 AM |