Micro Focus QTP (UFT) Forums
Write Heading in excel - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Write Heading in excel (/Thread-Write-Heading-in-excel)

Pages: 1 2 3


Write Heading in excel - Anu - 07-01-2010

hi,

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

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

Regards,
Anu


RE: Write Heading in excel - sreekanth chilam - 07-01-2010

Hi,

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


RE: Write Heading in excel - Anu - 07-12-2010

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


RE: Write Heading in excel - basanth27 - 07-13-2010

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

Createobject("Excel.application")


RE: Write Heading in excel - Anu - 07-13-2010

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


RE: Write Heading in excel - sasmitakumari - 07-13-2010

Refer following link
http://www.sqaforums.com/showflat.php?Cat=0&Board=UBB20&Number=214260&Searchpage=1&Main=214257&Words=+ham_hoc_hoi&topic=&Search=true
Look into the code section for "Insert header into the sheet"


RE: Write Heading in excel - Anu - 07-26-2010

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


RE: Write Heading in excel - sasmitakumari - 07-26-2010

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



RE: Write Heading in excel - Anu - 07-26-2010

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


RE: Write Heading in excel - sasmitakumari - 07-26-2010

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.