XLL+ Class Library

::IMPLEMENT_XLLFN_EX

Declare and describe an add-in function

[C++]
IMPLEMENT_XLLFN_EX(
   LABEL nmEntryPoint,
   const char* pszArgTemplate,
   const char* pszName,
   const char* pszCategory,
   const char* pszArgNames,
   const char* pszHelpText,
   const char* pszArgHelpText,
   int usAvailability
);

Parameters

nmEntryPoint

Name of the 'C' function. Note that the function name is not in quotes - it is a label, not a string. Most of the other arguments to the macro are strings, so they can be either string literals (such as "RB") or references to strings (e.g. CMyXllApp::m_pszDefCategory).

pszArgTemplate

The type text of the function, containing the data type of the return value and data types of the arguments. The first letter of the type text specifies the return value. Subsequent letters, starting with the second, specify the data types of the arguments, in order. For a list of data types and the letters used to represent them see Data types. Thus if, for example, if the string is "AB", it represents a function that returns a Boolean result and takes one double argument. See the table in Data types for a full list of the data types supported.

In addition, the string can be terminated by one or both of the characters '#' and '!'. The hash symbol ('#') indicates that resolution of the function's arguments is delayed. Experienced SDK programmers will appreciate the occasional utility of this option. See the Excel 97 Developer's Kit (Microsoft Press) for more information.

The '!' suffix makes the function volatile. Volatile functions are resolved every time any part of a worksheet is recalculated, or when the F9 function key is pressed or when Application.Calculate() is invoked. This option is useful when the results of functions are determined by outside factors (such as the current time, or data held in a database) in addition to the value of their arguments.

pszName

Name of function as exported to Excel. This is the function's name as you will use it in Excel - it does not need to be the same as the 'C' name of the function.

pszCategory

The category under which the function will appear in the Excel Function Wizard.

pszArgNames

The names of the function's arguments, separated by commas. For example, "Arg1,Arg2".

pszHelpText

The description of the function which will appear in the Excel Function Wizard.

pszArgHelpText

The descriptions of the function's arguments which will appear in the Excel Function Wizard. Each description should be separated from the next by a null character ("\0"). An extra null character should terminate the string. Thus a function that concatenates its two arguments might have argument help text as follows: "Left-hand string\0Right-hand string\0\0".

usAvailability

Flag indicating from where the function may be invoked. 1 indicates that the function is available only from Excel worksheets; 2 that it is available only from Excel macro sheets; 3 that it is available in both. No other values are acceptable.

Remarks

Note: The IMPLEMENT_XLLFN_EX macro is deprecated. The macro IMPLEMENT_XLLFN2 should be used instead. IMPLEMENT_XLLFN2 offers a more powerful set of arguments.

The IMPLEMENT_XLLFN_EX macro manages the registration of a 'C' function as an Excel add-in function. It is supported by the XLL Plus Function Wizard, which can be used to maintain the code for both the macro and the function definition.

The macro defines a static instance of a 'C' structure (XLLFN) which contains the details that define the add-in function. It also defines another 'C' structure (XLLFN_INIT) whose constructor function will add the address of the XLLFN to a global chain intitialised at DLL load time, before any other methods or call-back functions are invoked.

When the function AddStaticFns() is called during the DLL's InitInstance() method, the functions defined in the global chain are added to the CXllApp object's function list. During the XllLoad operation invoked by Excel when the XLL is opened, this list of functions is registered with Excel using the SDK xlfRegister entry-point.

Requirements

Header: xllplus.h

See Also

Global functions & macros