XLKit  0.1.0
 All Classes Files Functions Typedefs Macros Groups
XLKit Documentation

Introduction

XLKit is a modern C++ wrapper for using the Excel XLL SDK. It is used to write native plug-ins (aka Add-Ins) for Microsoft Excel. This is an open-source project distributed under the Mozilla Public License v2.0.

The requirements for this library are:

It was developed using the Excel 2013 XLL SDK and Boost 1.55 although older versions should work as well. The requirement for Visual Studio 2013 is because it uses C++11 features.

Installation

To add the use of XLKit to your project, add the top level XLKit directory to your list of project include directories. Since this library also requires some Boost and Excel SDK headers, you also need those in your project include directories as well. To summarize, your include directories need to ensure that these includes work:

  1. <xlkit/xlkit.hpp> (from xlkit library)
  2. <boost/config.hpp> (from boost library)
  3. <xlcall.h> (from Excel XLL Software Development Kit)

XLKit consists of only one main module, xlkit.cpp. So the simplest way is to simply add include <xlkit/xlkit.cpp> into a .cpp file that is compiled in your project. This file pulls in <windows.h> and defines the require XLL entry points for your project to be recognized by Excel. Alternatively, you can also compile this file into its own library and then link it into your project.

Detailed project creation instructions is in the setup howto.

Usage

Once you have the necessary set up, to write your XLL is simple. Here's the simplest example. See more details in xlkitExample.cpp.

// Set the label that shows up in the Add-in Manager. Only do this once.
XLKIT_INIT_ADDIN_LABEL("XLKit Test Addin")
// Define a function that can be used from Excel.
// It needs to use the XLKIT_API calling convention
// Supported return/parameter types are: double, int, const char*, xlOperand*
double XLKIT_API
xlCirc(double diameter)
{
// Export this function to the DLL and start a try block around the code
// Code for the function
return diameter * 3.14159;
// End the try block with default catch clauses and give it the return type
// to have sensible return values when exceptions are caught.
}
// Register it with Excel
XLKIT_REGISTER(xlCirc, "Circumference of a circle.")