Save figure table to Excel file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Save figure table to Excel file

  1. #1
    Mahendra Gunawan Guest

    Save figure table to Excel file

    Hi all,

    I have Table contait fields Firstname and LastName, I wanna Access to this
    table and save to Excel file,

    First row save to Sheet A1 for FirstName, A2 for LastName
    Second row save to B1 for Firstname, B2 for LastName
    and soon ..



    Does any one know how to do this, please give me a sample code

    Thank you for you help

    MGunawan
    -----------
    One more, Can I Save formula as say to Sheet A9 with A1+A1




  2. #2
    G. Allen Guest

    Re: Save figure table to Excel file


    First set a reference to the Microsoft Excel Object Library then add the following:

    Dim xl as Excel.Application
    Dim wkb as Excel.Workbook
    Dim wks as Excel.worksheet

    Set xl = new Excel.Application

    If xl.workbooks.count = 0 then xl.workbooks.add
    set wkb = xl.workbooks(1)

    if wkb.worksheets.count = 0 then xl.worksheets.add
    set wks = wkb.worksheets(1)

    ' Open your recordset here.

    wks.range("A1") = rs(0)
    wks.range("B1") = rs(1)
    wks.range("C1").NumberFormula = "=A1+B1"

    ' etc . . .

    The lines that check the count properties are sort of overkill. Almost everyone
    has Excel set to open with a workbook/worksheet already available but everyone
    once in a while you'll run into someone who doesn't.

    Keep in mind that I wrote that off the top of my head so there may be a syntax
    error or two. In particular I'm pretty sure that the workbooks and worksheets
    collections are 1-based but you might need to start at 0.



    "Mahendra Gunawan" <gunawan@romindo.com> wrote:
    >Hi all,
    >
    >I have Table contait fields Firstname and LastName, I wanna Access to this
    >table and save to Excel file,
    >
    >First row save to Sheet A1 for FirstName, A2 for LastName
    >Second row save to B1 for Firstname, B2 for LastName
    >and soon ..
    >
    >
    >
    >Does any one know how to do this, please give me a sample code
    >
    >Thank you for you help
    >
    >MGunawan
    >-----------
    >One more, Can I Save formula as say to Sheet A9 with A1+A1
    >
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center