XLL+ Class Library (7.0)

Utility classes

XLL+ contains many utility classes for various purposes. Some of the more commonly used classes are discussed below.


The CXlDate class wraps calls to Excel's built-in date functions. Some are listed below.

Method Description
Today() Returns today's date as an Excel serial integer.
Now() Returns the time now as an Excel serial number.
SerialToDate() Converts an Excel serial number to year/month/day.
DateToSerial() Creates an Excel serial number from year/month/day.

Any call to the Excel API can fail. If CXlDate methods fail, they throw an exception of type CXlApiException. Since exceptions of this type are caught by the add-in's wrapper function, they can be ignored by the developer. This feature makes CXlDate's methods convenient to use, e.g.:

// Call to Now() may throw an exception, but we don't care 
double alarmCall = CXlDate::Now() + 0.25;


The CXllFinder class is a utility class to help you search and replace the contents and formulae of cells.

Use the finder class with the following pattern:

const char* pszMatch = "fred";
CXllFinder finder(pszMatch, ...);
CXlRef xlrFind;
while (finder.FindNext(xlrFind)) {
    // Inspect the current value
    CXlOper xloValue;
    // Use the current value... 
    // Change the value in the matched cell

Note that only one instance of CXllFinder can be used at a time, since the class manipulates the active selection. CXllFinder can only be used from macro functions. It will fail if used from worksheet functions.

See also the FindReplace sample project.

Serialization classes

The XLL+ class library contains a number of classes to help with serialization. They are used (among other purposes) to implement the results cache, where they assist with the transfer of data to and from disk, and for making unique keys from a function's argument values.

The main classes are listed below:

Class Description
CXlOStream A stream wrapper that allows the output of Excel native types to STL output streams.
CXlOStrStream A class that converts Excel native types to in-memory byte arrays.
CXlIStream A stream wrapper that allows the input of Excel native types from STL input streams.
CXlIStrStream A class that reads Excel native types from in-memory byte arrays.
CXlSerialData A byte array containing native and Excel data types.
CXlInputKey A specialised instance of serialized data, which contains all the inputs to an add-in function, as a byte array.

Next: Using the Microsoft Foundation Classes >>