Exporting to excel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Exporting to excel

    Hi

    I have a winform db app with access backend db using strongly typed dataset.
    Is there a way to run a query on a table and export the output into an excel
    sheet with a specified name, overwriting the excel file if it already exists
    at the destination. Is there a way to do all this by press of a button so
    its easy for the end user?

    Many Thanks

    Regards


  • cfps.Christian

    #2
    Re: Exporting to excel

    Do some research in using ODBC against an Excel table. This will
    allow you to write SQL commands against the Excel table so you might
    be able to do a delete on the spreadsheet and a bulk insert and be
    done with it.

    Your last option should be to use the Excel interop as it can be a
    little unwieldy and a little too much precision.

    Comment

    • eBob.com

      #3
      Re: Exporting to excel


      "cfps.Christian " <ge0193387@otc. eduwrote in message
      news:1b2cf6a6-c36d-42ff-ac28-bb1ff61958d4@z2 8g2000prd.googl egroups.com...
      Do some research in using ODBC against an Excel table. This will
      allow you to write SQL commands against the Excel table so you might
      be able to do a delete on the spreadsheet and a bulk insert and be
      done with it.
      >
      Your last option should be to use the Excel interop as it can be a
      little unwieldy and a little too much precision.
      I'm not the OP, but ... it never ceases to amaze me what useful information
      I pick up here. I had not idea such a capability existed. THANKS!

      BTW, in my experience the interop interface is not only unwieldy but it is
      also difficult to find thorough documentation.

      Bob


      Comment

      • cfps.Christian

        #4
        Re: Exporting to excel

        There's documentation!

        The Excel interop isn't near as bad as the Word interop, its at least
        slightly logical. The only warning I ever give when working with any
        of the interops is to be certain that you manage your memory
        correctly. They have a nasty habit of living until you're extremely
        specific in shutting them down.

        Since others might be interested:
        www.connectionstrings.com to get the excel spreadsheet ODBC connection
        string.
        use $ before sheet name to query (took a co-worker the better part of
        a week to figure that out)

        Comment

        Working...