Search notes:

XLL

Expected exported functions

Excel and the Add-in manager expect (or at least look for) the following exported functions in an XLL:
xlAddInManagerInfo12 Called when the Add-in Manager is invoked the first time in an Excel session in order to query information about the XLL. The pre-2007 version of this function is xlAddInManagerInfo,
xlAutoAdd Called when the XLL is activated using the Add-in Manager (but not when Excel loads pre-installed add-ins). Used, for example, to display a dialog box, read configuration data from the registry, checking licence etc.
xlAutoClose Called when the XLL is deactivated. Functions that were registered in xlAutoOpen don't have to be unregistered, Excel will do that when the xlAutoClose returns.
xlAutoFree12 Used to to free memory allocated on an XLOPER12 structure. The pre-2007 version of this function is xlAutoFree.
xlAutoOpen Used to register XLL functions and commands, initalized data strucuters etc. This function must be implemented.
xlAutoRegister12 Called whenever a call has been made to the XLM function REGISTER or the C-API equivalent xlfRegister (without specifying the type_text argument). The pre-2007 version of this function is xlAutoRegister.
xlAutoRemove Called when the XLL is deactivated using the Add-in Manager.

Excel12, Excel12v

Excel provides the two functions Excel12 and Excel12v to expose internal functionality to XLLs.
These functions can only be called when Excel has passed control to the XLL (but not, for example in DllMain).
Prior to Excel 2007, these functions were named Excel4 and Excel4v.
int Excel12(
      int        iFunction,
      LPXLOPER12 pxRes,
      int        iCount,
      LPXLOPER12 argument1,
                 ...
);

iFunction

The value of iFunction can be one of the following constants:
xlAbort
xlAsyncReturn
xlCoerce
xlDefineBinaryName
xlDisableXLMsgs Deprecated
xlEnableXLMsgs Deprecated
xlEventRegister Introduced in Excel 2010
xlFree
xlGetBinaryName
xlGetHwnd
xlGetInst
xlGetName
xlRunningOnCluster
xlSet
xlSheetId
xlSheetNm
xlStack
xlUDF
xlfCaller
xlfEvaluate
xlfGetDef
xlfGetName
xlfRegister Two forms
xlfRegisterId
xlfUnregister Two forms
xlfSetName
xlcSelect
xlc… Are there other xlc constants?

Framework library functions

The framework library functions makes writing XLLs easier.
debugPrintf
GetTempMemory
FreeAllTempMemory
InitFramework
QuitFramework
Excel12f
TempNum12
TempStr12
TempStr12Const
TempBool12
TempInt12
TempErr12
TempActiveRef12
TempActiveCell12
TempActiveRow12
TempActiveColumn12
TempMissing12
These functions are found in framewrk.c (framewrk.h) and framewrk.lib.

Cluster Connector Functions

CallUDF
CancelOutstandingRequests
CloseSession
OpenSession
PingSession
ShowOptions

xlcall.h

Some interesting typedefs in xlcall.h.
Excel (XLL) uses wide characters for strings:
typedef WCHAR XCHAR;
Rows, columns and sheet IDs:
typedef INT32 RW;
typedef INT32 COL;
typedef DWORD_PTR IDSHEET;

XLOPER12

XLOPER12 is a union that combines the following fields in val. How val is interpreted is defined in the member xltype (which is a DWORD).
.val Type .xltype
num double xltypeNum
str LPSTR xltypeStr
xbool BOOL xltypeBool
err int xltypeErr
w int xltypeInt
sref struct xltypeSRef
mref struct xltypeRef
array struct xltypeMulti
flow struct xltypeFlow
bigdata struct xltypeBigData
LPXLOPER12 is pointer to XLOPER12
XLOPER12 was introduced with Excel 2007 to accomodate larger grids and to support Unicode strings.

Misc

Multithreading

It seems that the XLL interface allows for multithreaded programming (to be confirmed).

See also

The function application.registerXLL of the Excel Object application.
XLCALL32.DLL.
Options -> Advanced -> Formulas -> Allow user-defined XLL functions to run on a computer cluster

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1758194376, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/Office/Excel/Add-ins/XLL/index(206): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78