Pls
Anyone tell me How to import a single data from the Excel in QTP.
Give me exact coding for the sample flight application......
Printable View
Pls
Anyone tell me How to import a single data from the Excel in QTP.
Give me exact coding for the sample flight application......
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:
[COLOR="DarkRed"]
DataTable.Importsheet"C:\Path name(Ex:Mar_Qtp)\Excelsheet name(Ex:abc.xls)",1,Global[/COLOR]
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
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...
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=newhere;21950]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:
[COLOR="DarkRed"]
DataTable.Importsheet"C:\Path name(Ex:Mar_Qtp)\Excelsheet name(Ex:abc.xls)",1,Global[/COLOR]
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[/QUOTE]
Pls tell How to Import the data from MS-Access in QTP?
[quote=thatiper;21967]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]
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
[quote=thatiper;21967]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]
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
can any body show me the test script for functional testing in qtp on any topic
[QUOTE=bizzzzzare;21954]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
[B][COLOR="Red"]You can also create an array to continously loop through your excel sheet and read all required values.[/COLOR][/B]
Cheers...[/QUOTE]
I've a question :confused: for bizzzzzare: Per your mention above(highlighted in red)Can you please guide me with creating an array of all the rows matching specified criteria by continously looping through the [B]used range[/B] in an external excel sheet instead of the datatable.
I'll really appreciate it.
Thanks.
Hi bizzzzzare! I've a question :confused: for you: Can you please tell me how can I create an array to continously loop through an excel sheet and read all required values. I'd really appreciate it. Thanks. I'm in the constant process of learning coding in QTP.
Hi boss
the mentioned code is a sample code. just modify it according ur requirements.
============================================================
testSheetPath = 'address off the sheet
testSheetName = 'name of the sheet
columnno = 1 'In excel sheet you are selecting A1 cell
For start =1 to end 'Starting from 1st cell to end point
start = start+1 'incrementation
for i = 1 to rowscount
[FONT=courier new] S[/FONT]et objWorkbook = objExcel.WorkBooks.Open("path of the file.xls")
Set objDriverSheet = objWorkbook.Worksheets("name of the sheet")
columncount = objDriverSheet.usedrange.columns.count
rowcount = objDriverSheet.usedrange.rows.count
for i = 1 to colunmcount
columnname = objDriversheet.cells(i,1)
if columnname = knowncolumnname then
for j = 1 to rowcount
fieldvalue = objdriversheet.cells(j,i)
next
next
next
end if
next
For each element in arrField 'for statement to retrieve the value
arrFieldNameAndValue = split(element,";",-1)
strFieldName = arrFieldNameAndValue(0)
strFieldValue = arrFieldNameAndValue(1)
strFieldName = removespace(lcase(strFieldName)) 'removing all the spaces
Select Case strFieldName
Case "Cellvalue"
strcellvalue = strFieldValue
Case " "
end select
next
Hello Bhaskar,
I can't thank you enough for your help. I'm a little confused with the array part. I saw your answer for another post which was more clear, but unfortunately it did not have the explanation of the array part.
[url]http://www.geekinterview.com/talk/1327-reading-data-from-excel-sheet-qtp.html[/url]
Can you please explain clearly the array part. I'll really really appreciate it. Thanks so much in advance.
datatable.AddSheet("AAAA")
datatable.ImportSheet "D:\shiva\other\Keyword.xls","AA","AAAA"
rc=datatable.GetSheet("AAAA").GetRowCount
msgbox rc
For i=1 to rc
datatable.GetSheet("AAAA").SetCurrentRow(i)
a=datatable.Value("shiva","AAAA")
msgbox a
Next
Hi any one tell me that how to make word gabling??? shiva--->vasih (or) ivahs like this???