Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write in Excel
#41
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#42
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,

Hope my previous mail explains my query............

Regards,
Anu
Reply
#43
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#44
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#45
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#46
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#47
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#48
Solved: 11 Years, 3 Months, 3 Weeks ago
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


Attached Files Image(s)
   
Reply
#49
Solved: 11 Years, 3 Months, 3 Weeks ago
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.

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Write in Excel Continued Anu 3 3,313 08-27-2010, 08:53 AM
Last Post: basanth27
  Write Heading in excel Anu 27 19,880 08-05-2010, 03:02 PM
Last Post: Anu

Forum Jump:


Users browsing this thread: 2 Guest(s)