SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    Nov 2007
    Location
    Bangalore, Karnataka
    Posts
    245
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Creating excell file and write result to it.

    Hi,

    As am new to QTP can anybody get me the code to create a excell file and write result to it, so i can analyse the code and understand the concept.


    Thanks in advance,
    CHheeerrsss
    Cheerrss

  2. #2
    Moderator
    Join Date
    Jan 2007
    Location
    Pittsburgh, PA
    Posts
    2,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Creating excell file and write result to it.

    Please search this forum.

  3. #3
    Member
    Join Date
    Nov 2007
    Location
    Bangalore, Karnataka
    Posts
    245
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Creating excell file and write result to it.

    hi TReddy already i have gone through the forum and i got some posts regarding this, but i am unable to understnd that code, so am looking for specific code to understand it.
    Anyways thanks for your reply.

    CheerSSsss
    Cheerrss

  4. #4
    Junior Member
    Join Date
    Dec 2007
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Creating excell file and write result to it.

    Dim ExcelSheet
    Set ExcelSheet = CreateObject("iexplorer.exe")
    ' Make Excel visible through the Application object.
    ExcelSheet.Application.Visible = True
    ' Place some text in the first cell of the sheet.
    ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1"
    ' Save the sheet.
    ExcelSheet.SaveAs "C:\DOCS\TEST.XLS"
    ' Close Excel with the Quit method on the Application object.
    ExcelSheet.Application.Quit
    ' Release the object variable.
    Set ExcelSheet = Nothing

  5. #5
    Junior Member
    Join Date
    Dec 2007
    Location
    China
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Creating excell file and write result to it.

    Function CreateExcel(sFilePath,sFileContent) 'As Excel.Application
    Dim ExcelApp,ExcelWorkbook,ExcelWorksheet
    Set ExcelApp = CreateObject("Excel.Application")
    'Create a new excel Object
    ExcelApp.Visible = True
    Set ExcelWorkbook = ExcelApp.Workbooks.Add
    ExcelWorkbook.SaveAs(sFilePath)
    ExcelWorkbook.WorkSheets("Sheet1").Activate
    ExcelWorkbook.WorkSheets("Sheet1").Cells(1,1)=sFil eContent
    ExcelWorkbook.Save()
    Set ExcelWorkbook = Nothing
    Set ExcelApp = Nothing
    End Function

  6. #6
    Junior Member
    Join Date
    Dec 2007
    Location
    China
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Creating excell file and write result to it.

    sFilePath is place you want to save the document
    sFileContent is the content of the document
    the function maybe can give you some help

  7. #7
    Senior Member
    Join Date
    Dec 2004
    Location
    Australia
    Posts
    163
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Creating excell file and write result to it.


  8. #8
    Junior Member
    Join Date
    Nov 2007
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Creating excell file and write result to it.

    Dim fso
    Set fso = CreateObject("scripting.filesystemobject")
    On Error Resume Next
    set xlApp = CreateObject("Excel.Application")

    If Err.number > 0 Then
    Alert "Did't save *.xls correctly,please check Excele Application!"
    else
    xlApp.Visible=true
    set myWorkbook = xlApp.Workbooks.Add
    set myWorksheet = myWorkbook.Worksheets(1)
    'create head of table
    myWorksheet.Range("A1").Value = "title"
    myWorksheet.Range("A2").Value = "what are you doing now?"
    myWorksheet.Range("B2").Value = "what are you doing now?"
    myWorksheet.Range("A3").value = "where are you from?"

    If fso.FileExists("d:\temp.xls") Then
    fso.DeleteFile("D:\temp.xls")
    End If

    myWorkbook.SaveAs("D:\temp.xls")
    xlApp.Quit
    End if

    Hi,
    you can refer to above vbscripts,Beacuse i lenrn a little about excel,you must lean on yourself.
    jack.feng

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 8.82%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:25 PM.

Copyright BetaSoft Inc.