CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    78

    How to export contents of a recordset to an Excell Sheet?

    Hi everyone,

    I need to know how one goes about opening Excell, writing data to an Excell sheet, and saving it.

    Your help is much appreciated... Thank You!


  2. #2
    Join Date
    Apr 2001
    Posts
    7

    Re: How to export contents of a recordset to an Excell Sheet?

    If you dont need any special formatting just write the recordset to a comma delimited file and save it as file.csv. This will reduce the overhead of having to use the excel object model.

    Just make sure that if any of the data is character make sure you put [""] around it.

    The output file would look like:

    col1, col2, "col3"

    etc...

    Kev.-



  3. #3
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: How to export contents of a recordset to an Excell Sheet?

    Not sure what is the implementation of your program. Another way of retrieving data from DB into Excel is to use the QUERY tool in Excel.

    In Excel 2000: Data->Get External Data->New Query which will allow you to query your DB directly from Excel and display the contents.

    Otherwise, comma-delimited file is the easiest way to go.

    -Cool Bizs

    Good Luck,
    -Cool Bizs

  4. #4
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    78

    Thanks kconcept and coolbiz for your tips

    Thanks guys, your tips really helped.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured