Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write Heading in excel
#1
Solved: 10 Years, 8 Months, 2 Weeks ago
hi,

I want to write Name, Address,ID as a heading in different coloumns of excel using QTP.

Thnks in advance...........

Regards,
Anu
Reply
#2
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi,

Use Excel COM's for this and suggest you to google it in this forum , You can implement on your ownSmile
Reply
#3
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi,

i google Excel COM's but did not find any related topic on it.
could u please elaborate on it or mail me any link so that i can work on it.

Thnks,
Anu
Reply
#4
Solved: 10 Years, 8 Months, 2 Weeks ago
With the spoon closer to the mouth now, try googling for,

Createobject("Excel.application")
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#5
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi,

Thnks for your reply................

My query is that suppose i googled anything like 'page' and on the basis of my query it shows the result.
The screen shot is attached below................

Now i want to write the heading to excel using QTP.Moreover, the heading changes as i changed my searching criteria.

Hope, this explains my problem.Sad

Regards,
Anu


Attached Files Image(s)
   
Reply
#6
Solved: 10 Years, 8 Months, 2 Weeks ago
Refer following link
http://www.sqaforums.com/showflat.php?Ca...earch=true
Look into the code section for "Insert header into the sheet"
Reply
#7
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi,
i used the link http://www.sqaforums.com/showflat.php?
but did not get the required result.
Could you please elaborate your solution so that i can use it properly.
Waiting for reply............

Regards,
Anu
Reply
#8
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi Anu,
You need to save the file to see the result after run.
Try this out.

Code:
Dim sHeader, sHeaderList
Dim ExcelSheet
Dim sPath,sDataFile
Dim FSO, bFileFlag,sMyFile
Dim objExcel,i

sHeader  = "Name,Address,ID"
sPath = "C:\"
sDataFile  = "DataFile.xls"

Set FSO = CreateObject("Scripting.FileSystemObject")
  
    bFileFlag = FSO.FileExists(sPath & sDataFile)
   If(Not bFileFlag) Then
        Set sMyFile = FSO.CreateTextFile (sPath & sDataFile, True, False)
        sMyFile.Close
        Set FSO = Nothing
    End If
    
    Set objExcel = CreateObject ("Excel.Application")
    objExcel.DisplayAlerts = False
Set ExcelSheet = CreateObject("Excel.Sheet")
' Make Excel visible through the Application object.
ExcelSheet.Application.Visible = True
'*** Writing Header***'
  sHeaderList = Split(sHeader, ",")
    i = 0
    For Each sHeader in sHeaderList
        i = i + 1
        ExcelSheet.ActiveSheet.Cells(1, i).Value = sHeader
    Next
' Save the sheet.
ExcelSheet.SaveAs "C:\DataFile.xls"
' Close Excel with the Quit method on the Application object.
ExcelSheet.Application.Quit
' Release the object variable.
Set ExcelSheet = Nothing
Set objExcel = Nothing
Reply
#9
Solved: 10 Years, 8 Months, 2 Weeks ago
Hi,

Thnks for your reply, but the reply seems that u could not understand my query.
My problem is that my header is dynamic and it is changing every time i change my search criteria.
Hope this explain my problem.................

Regards,
Anu
Reply
#10
Solved: 10 Years, 8 Months, 2 Weeks ago
Do you mean your header would contain the headings of search result?
If so, get the headers of the search result and store them in an array.
And then use that array in above logic for displaying the header in the excel sheet.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Write in Excel Continued Anu 3 3,150 08-27-2010, 08:53 AM
Last Post: basanth27
  Write in Excel Anu 48 28,515 08-25-2010, 06:08 PM
Last Post: Saket

Forum Jump:


Users browsing this thread: 1 Guest(s)