4 Excel Add-in Development in C/C++
1.2.3 C/C++ DLLs that can access the C API and XLL add-ins
If you want your DLL to be able to access the C API, then you need a C or C++ compiler,
as well as the C API library and header file. The C API functions and the definitions of the
data types that Excel uses are contained in the library and header files
xlcall32.lib
and xlcall.h. Both of these are contained in a sample project, downloadable from
Microsoft at the time of writing, free of charge, at download.microsoft.com/download/
platformsdk/sample27/1/NT4/EN-US/Frmwrk32.exe. It is also possible to link Excel’s
library in its DLL form,
xlcall32.dll, in your DLL project, removing the need to
obtain the static
.lib version. This file is created as part of a standard Excel installation.
Another approach is to create the
.lib file from the .dll file, as discussed in section 5.1.
This framework project is also included with Microsoft’s Excel 97 Developer’s Kit
(1997, Microsoft Press) on its accompanying CD ROM. The book contains a great
deal of useful reference data, and describes the framework project in detail, something
beyond the scope of this book. It is perhaps a little short on practical guidance, but
owning a copy is nevertheless recommended. At time of writing, this book is now out
of print, but still available on the Microsoft Developer Network (MSDN) website at
msdn.microsoft.com/library/default.asp?url =/library/officedev/office97/edkfrnt.htm
.
An XLL add-in is a DLL that exports a set of interface functions to help Excel load and
manage the add-in directly. These functions, in turn, need to be able to access Excel’s func-
tionality via the C API, if only to be able to register the exported functions and commands.
Only when registered can they be accessed directly from the worksheet (if functions) or via
menus and toolbars (if commands). The C API is based on the XLM (Excel 4 macro lan-
guage). This book provides guidance on the most relevant C API functions in Chapter 8.
However, for a full description of all the C API’s XLM equivalents you should ideally
have a copy of the XLM help file, which is typically named
Macrofun.hlp.This
is, at the time of writing, downloadable in the form of a self-extracting executable from
Microsoft at download.microsoft.com/download/excel97win/utility4/1/WIN98/EN-US/
Macrofun.exe.
1.2.4 C/C++/C# .NET add-ins
This book does not cover .NET and C#. These technologies are an important part of
Microsoft’s vision for the future. The resources required to apply these technologies are
Visual Studio .NET and a .NET-compatible version of Excel, i.e., Excel 2002 and later.
The principle purpose of this book is to bring the power of compiled C and C++ to Excel
users, rather than to be a manual for implementing these new technologies.
1.3 TO WHICH VERSIONS OF EXCEL DOES THIS
BOOK APPLY?
Table 1.2 shows the marketing names and the underlying version numbers to which this
book applies. Excel screenshots in this book (worksheets, dialogs, etc.) are all those of
Excel 2000. Most of the interface differences between versions 2000 and 2003 (the latest
at the time of writing) are quite superficial. The workbooks on the CD ROM are Excel
2000 format. (Contact ccppaddin@eigensys.com if you require 97 format files.)