Excel xlls and the C API

My list of promised but not delivered items on this blog is getting longer and longer, but here is another…

I’ve had a request for some introductory training in writing xlls in C/C++. Doing that face to face may prove to be unrealistic, so I’m thinking of producing some stuff here for people to have a go with and discuss etc.

Is that something people would be interested in? Leave a comment if so, and I’ll raise it up my priority list (I’m thinking over the next month or so).

I’m thinking of tackling it from an Excel VBA dev perspective rather than C/C++, so I’d mainly be covering just how to get your code into worksheet functions – you’d have to sort out your own C/C++ code. I’ll use Visual Studio 6.0, not because I’m in some Northern time warp, but because it has no .net noise. At some point I should move to a newer IDE and revel in the productivity improvements, one day. If you don’t have an IDE then I think you should be able to download Visual Studio C++ Express for free, get the platform SDK too and you should be sorted. Another option is http://www.bloodshed.net/ (Dev C++)

To get you started there are some book reviews here.

Key xll book summaries:

Steve Dalton – Excel Add-in development in C/C++, thorough coverage, excellent content, most helpful if you are happy with C++, some fair barriers for pure VBA folks. Comes with useful framework code to wrap up the C API.

Microsoft Excel 97 Developers kit (hard to get hold of now) – covers use of their C based framework, makes sense from a VBA POV

Bullen, Bovey and Green Professional Excel Development – has an excellent chapter on xlls, should make sense to VBA developers.

Some open source/free-ish xll frameworks:

http://xlw.sourceforge.net/ (Started by Jérôme Lecomte, recent updates(C++))

 http://sourceforge.net/projects/xll/ (Keith Lewis xll framework (C++))

http://support.microsoft.com/kb/q152152/ (latest version of MS xll framework stuff, C rather than C++)

To get a sense of what bits of Excel you can play with via xlls you should get hold of MacroFun, this is the original Excel 4 XLM help file. These are the functions and features that are exposed via the C API. 

You will also need the C header files these should come with the MS framework above, but if not http://support.microsoft.com/kb/178474.

They’re the main ones I can think of off the top of my head. If there’s anything I have missed be sure and leave a comment. Other than that I’m sure google (or your favorite other searh engine (anyone recommend others?)) can help.

Xlls get a significant revamp in Excel 2007 and are the stated add-in technology of choice, so this isn’t going to go away anytime soon.

Cheers

Simon

Advertisements

5 Responses to “Excel xlls and the C API”

  1. Marcus Says:

    This is one of those areas that I’ve always been interested in investigating but as John Lennon said: ‘life is what happens when you’re busy making other plans’. I even bought a couple of C++ books and started reading.

    I currently use VB6 to create DLL’s (incl. COM Add-ins) as my work revolves around business processes and MIS. I was also looking at Delphi instead, primarily from the COM Add-In side, although I believe it can create XLL’s (2 birds, 1 stone).

  2. Simon Says:

    Marcus – I know what you mean.
    re VB and COM dlls, you might be interested in a performance post I have coming up within the week.
    Delphi has lots going for it, in particular a good/lively community, I havent really given it the time/effort it probably deserves.
    cheers
    Simon

  3. Ross Says:

    Hi Simon,

    Yeah it would be of interest to me. I would also like to take a look at c++ addin development -are they super quick? are they very difficult to build? – I’ll check out that book you mention when/if time permits.

    Simon, you talk about using vb6 as it avoids .net complexities, but I’m right in assuming it’s much quicker too – v’s C++. Net? no interop right.
    I know you have this on you site too, but have you looked at C# v’s C++ in .net – do you think c++ would be quicker in this case? My guess would be no?

  4. Simon Says:

    Ross
    I was just about to declare this closed due to lack on interest!
    xlls quick? yes, fast interface to Excel, fast execution speed.
    Hard to write? No with a tool, yes if limited C/C++ knowledge.
    VB6 is faster than .net at talking to Excel. In C++ .net you can drop into native code any time.
    Personally I think C# is the best .net language, I have never bothered with VB.net and can’t see the point of C++ .net (and I’ve heard a few -ve stories). You can use VS2005 (incl express) to write C++ native code applications (like xlls), but I tend to use VC6. Not totally clear what I’m missing by not updating, except a lot of .net noise, and a better code editor.
    I’m now thinking of waiting for Orcas and updating to that, as I think it has some new C++ stuff.
    pure .net performance compares, I have no idea I’m afraid, I don’t think anyone would willingly do C++ .net.

  5. Ross Says:

    Thanks Simon,

    “Personally I think C# is the best .net language, I have never bothered with VB.net and can’t see the point of C++ .net (and I’ve heard a few -ve stories). You can use VS2005 (incl express) to write C++ native code applications (like xlls),”

    Yeah I know you’re a big fan of C#, so far I’ve only played around with VB , starting to get the hang of it now. I didn’t know that you could drop into native C++ though.

    I can see your point about C++.net though if C# has all it’s strenghts what is the point of it?

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: