Wrapper Classes

The command line tool CWGENCLS.EXE generates all the code for the wrapper library. For each XLL, two classes are generated: one is for use from Visual Basic for Applications (VBA), which has a limited implementation of the COM interface, and the other is for use from all other development environments. The add-in functions of the XLL are exposed as methods of each wrapper class.

Wrapper libraries are authored in C#; for more details see the XLL+ documentation, in particular the topic Tools Reference/XLL Wrapper/XLL Wrapper Generator/Getting Started/Wrapper classes.


Each of the wrapper methods delegates the actual work of calling the XLL method to an engine, which is represented by the IWrapperEngine interface. There are two implementations of IWrapperEngine available:

  1. ExcelWrapperEngine uses an instance of Excel to execute the XLL add-in function. The Excel instance is fully controlled by the engine: it is invisible to the user, and it is closed by the engine when it is no longer required.
  2. XllHostWrapperEngine uses an instance of XLL Host. This engine should be used when Excel cannot be available on a computer or when Excel is considered too unstable to be part of an application stack.

The code in the wrapper class is ignorant of which engine is being used; the same wrapper classes can be used with ExcelWrapperEngine and with XllHostWrapperEngine.