1

Possible Duplicate:
Excel files and C++

I am using an API called UltimateGrid which allows me to easily create Excel-like grids using C++/MFC. I need a way to export all of the contents of these grids to an actual Excel document. I could not find anything about this in the documentation for this API. Then I got to thinking ... exporting contents to an Excel document is a common requirement in applications. I was thinking about creating a right-click menu option for exporting a grid to Excel. I feel like I am reinventing the wheel as I start to code this. I googled around and saw a lot of common ways of dealing with this when database tables are involved. But that is not the case here. My underlying "datasource" is not a database table, but rather just some business objects internal to the application. Am I going to have to just write my own custom handler that iterates through the business objects corresponding to the rows and output them to a CSV file to be used by Excel?

Community
  • 1
  • 1
user1040229
  • 491
  • 6
  • 18

2 Answers2

0

I'm not sure how automated you want this to be. I did this a while back (as in years ago), so forgive me if this info is out of date. Here's what I remember:

  1. CSV is fine, as long as you don't want to export formats, graphs, etc...

  2. You should be able to access the Excel object from your C++ code, and Microsoft should have documentation on how to do this.

  3. It may be easier to have your C++ generate a VBScript to access the component, since last I checked, there was much less red tape to doing it that way, but you could run into permissions/security issues with this method.

Also, have you checked to see if UltimateGrid supports other export formats that are compatible with Excel?

RonaldBarzell
  • 3,822
  • 1
  • 16
  • 23
0

If there are no other options, I think you might want to look into DDE (Dynamic Data Exchange). There could be a limitation on that OS should be Microsoft Windows, however you might be able to find some open source/runtime that supports other OSs as well.

One that I used long ago was NDde.

swcraft
  • 2,014
  • 3
  • 22
  • 43