Hi,
I want to write data in excel but not in DataTable of QTP.
Hope this explain my query and you can provide the work around for this.
Waiting dor early response.
Regards,
Anu
Hi,
If we can directly write the data in excel then why is there any need to write data in Data Table of QTP?
Regards,
Anu
Hi,
If we can write data directly in excel then why is there any need to write in DataTable of QTP and then to excel...............
Regards,
Anu
Hi,
Hope my previous mail explains my query............
Regards,
Anu
(08-24-2010 09:53 AM)venkatbatchu Wrote: [ -> ]Hi Anu,
First it will write the data to the data table onCe all data comes to data table i.e by executing script then we can export the data at last to external source i.e excefile which will be stroed in ur disk.
Please let me know for further clarification.
Regards,
Venkat.Batchu
Hi Anu,
I understood ur query.
Datatable is a Excel kind of thing which is similar like Excel.
If you want to write the data directly to excel then u need to use Excel objects.
It seems your way of thinking is completely writing data into excel.
See for this you have two ways.
First Way:
1. First fetch the data from web table to data table
2. Now export the data from the data table to excel using Datatable.Export "file path"
Second Way:
1. Using Excel objects
2. You need to create objects for excel application, workbook,worksheet
Ex: please get some idea by using excel objects
Code:
Set aa=CreateObject ("Excel.Application")
Set b=aa.Workbooks.Open("C:\.........\Test Results\TestResults.xls")
Set c=aa.Worksheets("Sheet1")
aa.DisplayAlerts=False
rc=c.UsedRange.Rows.count
rc=rc+1
c.Cells(rc,1).value=Testcase
c.Cells(rc,2).value=Functionality
c.Cells(rc,3).value=Description
c.Cells(rc,4).value=Result
b.Save
b.Close
Set aa=Nothing
If you still dont get idea, first try to go through Datatable concept from learnqtp tutorial.
Note: Did you execute the code which i posted early for fetching data from web table to datatable.
Please let me know for further clarification.
Regards,
Venkat.Batchu
Hi,
Yes, i tried the code given by you.
If i change the itrcount to 10 then it is not navigating to the next page and if i run the same code then nothing gets write in excel...........
Please help!!!!!!!!!!!!
Regards,
Anu
Hi Anu,
Have you maintained the object repository.
If yes means use the implemnetation logic which i have posted earlier.
No measn please start doing that.
Regards,
Venkat.Batchu
Hi,
Yes i had maintained my repository and i had already run the code but it is not running properly means it is not writing the data to excel.
Please look into my code give me the work around for that because the code give by you is not working at my side..............
Tried many times still not working.............
Waiting for response.
Regards,
Anu
Hi,
Please provide me sum work around for my problem so that i can proceed further as my deadline is nearby............
Waiting for early response..........
Regards,
Anu
Hi Anu,
Please follow the below approach
1. File-->Settings-->Run-->Run One Iteration only
2. Copy the entire code as I mentioned below
3. Add the objects to object repository as like in the attached screen shot (Here “Phone table” object and “Next link” are in object repository)
4. Execute the script
5. Observe that it will work as expected
Code:
'intpages=Total no of pages here it is 293
Datatable.GlobalSheet.AddParameter "PhoneNo",""
Datatable.GlobalSheet.AddParameter "Name",""
Datatable.GlobalSheet.AddParameter "Address",""
For p=1 to 293 step 1
rcount=Browser("BSNL GUJARAT TELECOM CIRCLE:Ma").Page("BSNL GUJARAT TELECOM CIRCLE:Ma").WebTable("innertext:=Phone no.*").GetROProperty("rows")
For temp=2 to rcount-1 Step 1
intpno=Browser("BSNL GUJARAT TELECOM CIRCLE:Ma").Page("BSNL GUJARAT TELECOM CIRCLE:Ma").WebTable("innertext:=Phone no.*").GetcellData(temp,1)
strname=Browser("BSNL GUJARAT TELECOM CIRCLE:Ma").Page("BSNL GUJARAT TELECOM CIRCLE:Ma").WebTable("innertext:=Phone no.*").GetcellData(temp,2)
straddress=Browser("BSNL GUJARAT TELECOM CIRCLE:Ma").Page("BSNL GUJARAT TELECOM CIRCLE:Ma").WebTable("innertext:=Phone no.*").GetcellData(temp,3)
Datatable.SetCurrentRow(Datatable.GetRowCount+1)
Datatable.Value("PhoneNo","Global")=intpno
Datatable.Value("Name","Global")=strname
Datatable.Value("Address","Global")=straddress
If temp=rcount-1 Then
Browser("BSNL GUJARAT TELECOM CIRCLE:Ma").Page("BSNL GUJARAT TELECOM CIRCLE:Ma").Link("Next").Click
Browser("BSNL GUJARAT TELECOM CIRCLE:Ma").Sync
Browser("BSNL GUJARAT TELECOM CIRCLE:Ma").Page("BSNL GUJARAT TELECOM CIRCLE:Ma").Sync
Wait 3
End If
rcount=Browser("BSNL GUJARAT TELECOM CIRCLE:Ma").Page("BSNL GUJARAT TELECOM CIRCLE:Ma").WebTable("innertext:=Phone no.*").GetROProperty("rows")
Next
Next
Wait 2
Datatable.Export "C:\Output.xls"
I hope now u will get some idea.
Regards,
Venkat.Batchu
(08-23-2010 11:21 AM)venkatbatchu Wrote: [ -> ]Hi,
Instead of using Excel obects you could go with data tables.
Lets assume that 1000 records are available on web page.
'if all the rows are displaying in sngle page (all the records) (Ex: 1000 records in single page)
Code:
'To add the column names "Name","Address" for the data table.
Datatable.AddParameter("Name","")
Datatable.AddParameter("Address","")
'To fetch the row count from the web table
intrcount=Browser("xxxxx").Page("xxx").WebTable("xxxxx").GetRoProperty("eows")
For temp=1 to intrcount-1 step 1
Datatable.setcurrentrow(temp)
strcustname=Browser("xxxxx").Page("xxx").WebTable("xxxxx").GetCellData(temp,"Name")
straddress=Browser("xxxxx").Page("xxx").WebTable("xxxxx").GetCellData(temp,"Address")
strcustname=Datatable.Value("Name")
straddress=Datatable.Value("Address")
Next
Wait 3
Datatable.Export "File path"
If 1000 records are displaying in 50 pages i.e 20 records in one page (20 *50)
Code:
'To add the column names "Name","Address" for the data table.
Datatable.AddParameter("Name","")
Datatable.AddParameter("Address","")
'To fetch the row count from the web table
intrcount=Browser("xxxxx").Page("xxx").WebTable("xxxxx").GetRoProperty("eows")
For temp=1 to intrcount-1 step 1
Datatable.setcurrentrow(temp)
strcustname=Browser("xxxxx").Page("xxx").WebTable("xxxxx").GetCellData(temp,"Name")
straddress=Browser("xxxxx").Page("xxx").WebTable("xxxxx").GetCellData(temp,"Address")
strcustname=Datatable.Value("Name")
straddress=Datatable.Value("Address")
'To click the Next page
If ((temp%20)=0) Then
Browser("xxxxxxxx").Page("xxxxxxxx").Weblink("Next").Click
Browser("xxxxxxxxxxx").Page("xxxxxxxxxxxx").Sync
Wait 2
End If
Next
Wait 3
Datatable.Export "File path"
With the above code we could export the data which is available in Web table simply we can say data export from web table to data table and finally exporting to required path.
Please let me know for further clarification.
Thanks and Reagrds,
Venkat.Batchu
Sorry for my ignorance guys, I am not able to go through all the posts in this thread,
Anu -actually I dint understand what problem you are facing exactly. please mention the error if you receive any and for which statement.
Is there any changes you made there in the code.
If i remember it correctly It was working fine earlier, I had also tried the same on your site. I will check if I still have the code with me.
also I would like to suggest to close this thread here and start this discussion in a fresh thread as it is going quite lengthy.
For example I want value in L8 to multiply by M6 and the result in N8 or if I put a value in N8 I want it to divide by M6 and the result in L8 without loosing the formula in both cells(L8,N8) each time I type my value.