Geeks Talk

Prepare for your Next Interview




How to Import the data from MS-Excel in QTP?

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.........


Go Back   Geeks Talk > Software Testing > QTP

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-04-2007
ramyamca1984's Avatar
Contributing Member
 
Join Date: Oct 2007
Location: India
Posts: 36
Thanks: 4
Thanked 3 Times in 3 Posts
ramyamca1984 is on a distinguished road
How to Import the data from MS-Excel in QTP?

Pls

Anyone tell me How to import a single data from the Excel in QTP.

Give me exact coding for the sample flight application......

Last edited by ramyamca1984 : 12-04-2007 at 07:06 AM. Reason: Mistake in typing
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-04-2007
Contributing Member
 
Join Date: Sep 2007
Location: MD
Posts: 58
Thanks: 9
Thanked 4 Times in 4 Posts
newhere is on a distinguished road
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
Reply With Quote
The Following User Says Thank You to newhere For This Useful Post:
  #3 (permalink)  
Old 12-04-2007
Expert Member
 
Join Date: Oct 2007
Location: Mumbai
Posts: 347
Thanks: 4
Thanked 54 Times in 44 Posts
bizzzzzare is on a distinguished road
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
Reply With Quote
The Following User Says Thank You to bizzzzzare For This Useful Post:
  #4 (permalink)  
Old 12-04-2007
Junior Member
 
Join Date: Nov 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
thatiper is on a distinguished road
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:
Originally Posted by newhere View Post
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
Reply With Quote
  #5 (permalink)  
Old 12-05-2007
ramyamca1984's Avatar
Contributing Member
 
Join Date: Oct 2007
Location: India
Posts: 36
Thanks: 4
Thanked 3 Times in 3 Posts
ramyamca1984 is on a distinguished road
Re: How to Import the data from MS-Excel in QTP?

Pls tell How to Import the data from MS-Access in QTP?
Reply With Quote
  #6 (permalink)  
Old 12-14-2007
Contributing Member
 
Join Date: Jan 2007
Location: india
Posts: 41
Thanks: 7
Thanked 3 Times in 3 Posts
aardvax is on a distinguished road
Re: How to Import the data from MS-Excel in QTP?

Quote:
Originally Posted by thatiper View Post
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
hi thatiper
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.
Reply With Quote
  #7 (permalink)  
Old 05-20-2008
Junior Member
 
Join Date: Dec 2007
Location: Pittsburgh
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
rohinikatneni is on a distinguished road
Re: How to Import the data from MS-Excel in QTP?

Quote:
Originally Posted by thatiper View Post
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
its as simple as this....

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
Reply With Quote
  #8 (permalink)  
Old 05-22-2008
Junior Member
 
Join Date: Sep 2005
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
chandu is on a distinguished road
Re: How to Import the data from MS-Excel in QTP?

can any body show me the test script for functional testing in qtp on any topic
Reply With Quote
Reply

  Geeks Talk > Software Testing > QTP


Thread Tools
Display Modes


Similar Threads

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


All times are GMT -4. The time now is 05:04 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved