Re: Calling Excel from c++

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



All Office components export automation interfaces.

The Good News is that these are pretty well documented.

The Bad News is that the documentation is mindlessly hard to use, because it was designed
by people who were clueless about the design of useful documentation. So I can say that
the interfaces are well-documented only if you have the patience to track them down. This
means you bring up Excel, bring up the VBA macro editor, go to its Help, and start down a
tedious (but actually complete) path.

I found the people over in the microsoft.public.office.developer.automation to be
remarkably helpful in giving me the key insights into how documents are organized and what
automation methods you need to use. Once you have that information, you can "translate"
it to the COM methods of the interface.

You can also see some of the code I wrote (including error detection and response) in a
program I wrote called the PowerPoint Indexer, which you can download free from my MVP
Tips site. The core skeleton would be useful for interfacing to any office component, but
the details of the data structures I walk down are obviously PowerPoint rather than Excel
structures. So you'll have to figure out how to find a file, a sheet, a cell, etc., but
once you have figured out the VBA method, you will be able to figure out the MFC classes
you have to import without too much more effort, and what methods to call in them. There's
a bit of a learning curve, but within a couple days you should be able to do something
useful (the hardest part for me was detecting and recovering from errors, if for no other
reason to figure out what I'd coded wrong and fix it, so you'll probably be able to reuse
some of my code for doing that.
joe

On Sun, 7 Dec 2008 22:20:18 -0800 (PST), hamishd <Hamish.Dean@xxxxxxxxx> wrote:

Hi. I want to be able access Excel (read, write, and format data) from
within C++.

I have been doing it the other way around (calling c++ dlls from VBA)
and it's just not quite as powerful as i would like.

Any pointers to a good website or something on how to do this?
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Python for large projects
    ... >> The ability to do unit testing should not be an afterthought. ... > look into a queue, and if there is a new URL to fetch, fetches it with ... All of the interfaces to the job management object and the job object need to be ... interface documentation and one writing test scaffolding against the same ...
    (comp.lang.python)
  • Re: Statically AND Dynamically Typed Language ??
    ... right that such `interfaces' make a good way to structure documentation. ... In Lisp, for the purposes of writing manuals, one usually documents ... Python largely follows the language-supported division of code into ...
    (comp.lang.misc)
  • Re: c-client/imap4r1.h (C)
    ... These interfaces are documented to some degress in the internal.txt file which is included in the UW IMAP toolkit distribution. ... If you have a third party distribution of c-client, ask the third party where the documentation files and sample programs are located. ...
    (comp.mail.imap)
  • Re: DreamScripter question re: import module
    ... > For direct support from Developer Express, ... >> Their documentation doesn't specify any particular derivation dependencies ... >> that their interfaces should work fine even for basic types like integers ... >> properties, and variable declarations.) ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Perhaps Linux Desktop will happen someday.
    ... Desktops that do talk and listen will soon be old news. ... >> unable to grasp the concept of modularity and code separation. ... Mine didn't have a problem displaying the documentation, ...
    (alt.os.linux)