Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write Heading in excel
07-01-2010, 06:13 PM
Post: #1
Write Heading in excel

hi,

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

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

Regards,
Anu
Find all posts by this user
Quote this message in a reply
07-01-2010, 11:10 PM
Post: #2
RE: Write Heading in excel
Hi,

Use Excel COM's for this and suggest you to google it in this forum , You can implement on your ownSmile

Never limit your challenges , Challenge your limits
Visit this user's website Find all posts by this user
Quote this message in a reply
07-12-2010, 01:37 PM
Post: #3
RE: Write Heading in excel
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
Find all posts by this user
Quote this message in a reply
07-13-2010, 09:56 AM
Post: #4
RE: Write Heading in excel
(07-12-2010 01:37 PM)Anu Wrote:  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

With the spoon closer to the mouth now, try googling for,

Createobject("Excel.application")

Basanth
QTP On Unix- Java Way - Without Putty or Terminal Emulation
You have no idea how high I can fly...
Find all posts by this user
Quote this message in a reply
07-13-2010, 02:34 PM
Post: #5
RE: Write Heading in excel
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 File(s) Image(s)
   
Find all posts by this user
Quote this message in a reply
07-13-2010, 02:58 PM
Post: #6
RE: Write Heading in excel
Refer following link
http://www.sqaforums.com/showflat.php?Ca...earch=true
Look into the code section for "Insert header into the sheet"
Find all posts by this user
Quote this message in a reply
07-22-2010, 04:45 PM
Post: #7
RE: Write Heading in excel
You can simulate this by disabeling the column&row headings,and typing
your own column headers in the first row and the split the window on
the first row and the do freeze panes. Throw in a few colors to make it
look good and presto, almost as good as real column headers.

DM Unseen
Find all posts by this user
Quote this message in a reply
07-26-2010, 11:40 AM
Post: #8
RE: Write Heading in excel
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




(07-13-2010 02:58 PM)sasmitakumari Wrote:  Refer following link
http://www.sqaforums.com/showflat.php?Ca...earch=true
Look into the code section for "Insert header into the sheet"
Find all posts by this user
Quote this message in a reply
07-26-2010, 05:24 PM (This post was last modified: 07-26-2010 05:26 PM by sasmitakumari.)
Post: #9
RE: Write Heading in excel
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
Find all posts by this user
Quote this message in a reply
07-26-2010, 05:35 PM
Post: #10
RE: Write Heading in excel
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


(07-26-2010 05:24 PM)sasmitakumari Wrote:  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
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Write in Excel Anu 48 5,106 12-20-2010 04:58 PM
Last Post: James
  Write in Excel Continued Anu 3 641 08-27-2010 08:53 AM
Last Post: basanth27

Forum Jump:


User(s) browsing this thread: 1 Guest(s)