XLL+ Class Library (7.0)

XLL+ Application Wizard - Generated Code

The code blocks generated by the various settings of the XLL+ Application Wizard are listed below.

In the code below, the add-in is assumed to be called MyAddin; your file names and your code should replace MyAddin with the name of your add-in.

XLL friendly name

This is the name that will be displayed in the Excel Add-ins dialog.

It is defined in MyAddin.cpp:

CopyC++
/* static */ LPCTSTR CMyAddinApp::m_pszDefName = _T("MyAddin");

Create 64-bit version

To create a 64-bit version at a later time:

  1. In Visual Studio, click the menu item Build/Configuration Mnager....
  2. In the Active solution platform combo box, select <New...>.
  3. In the New Solution Platform dialog, select x64. Ensure that Create new project platforms is checked, and press OK.

Use Unicode libraries

This switch chooses the character set for your project, via the project settings, as follows:

Common Language Runtime Support (/clr)

This switch enables CLR support for your project.

You can change the project settings to or from CLR later yourself, if necessary, as follows:

Add XLL+ Include and Lib paths

If this box is checked, then the directories containing XLL+ will be added to the project's Include and Lib paths.

If you uncheck the box, you will need to make sure that the XLL+ header files and library files are available to the compiler and linker respectively.

  1. In the Project Properties dialog, set Configuration to All Configurations and Platform to All Platforms.
  2. Select the node C/C++ / General and add one of the following to the Additional Include Directories list:
    Visual Studio Path
    VS 2005 $(Xlp80InstallDir7)include
    VS 2008 $(Xlp90InstallDir7)include
    VS 2010 $(Xlp100InstallDir7)include
  3. Select the node Linker / General and add one of the following to the Additional Library Directories list:
    Visual Studio Path
    VS 2005 $(Xlp80InstallDir7)lib\$(PlatformName)
    VS 2008 $(Xlp90InstallDir7)lib\$(PlatformName)
    VS 2010 $(Xlp100InstallDir7)lib\$(PlatformName)

If you have moved the XLL+ header files and libraries since you installed them, then use the XLL+ Options page to change the values of Settings.IncludePath and Settings.LibPath. These are the values that are used by the AppWizard.

Include a cache for results

This box adds a results cache to your project.

In MyAddin.h, the following will appear before the class definition:

CopyC++
#include <xlserialize.h>

In MyAddin.h, the following will appear within the public section of the class definition:

CopyC++
// Data
    CXlOperCache m_cache;

Save the cache to file

Check this box to save the results cache to file.

In MyAddin.h, the following will appear within the public section of the class definition, after CXlOperCache m_cache;:

CopyC++
CString m_strCacheFile;

In MyAddin.cpp, the following will appear within the method CMyAddinApp::OnXllOpenEx():

CopyC++
// Restore the cache (if it exists), ignoring failure 
if (CXlOperCache::GetUserCacheFilePath(m_strCacheFile))
    m_cache.Restore(m_strCacheFile);

In MyAddin.cpp, the following will appear within the method CMyAddinApp::OnXllClose():

CopyC++
// Save cache
m_cache.Save(m_strCacheFile);

Add to the ribbon

If this box is checked, then skeleton code and resources to create a group on the Office ribbon will be added to your project. See Adding Ribbon support to a project for instructions.

Add a menu

If this box is checked, then skeleton code to create a menu will be added to your project.

In MyAddin.h, the following will appear before the class definition:

CopyC++
#include <xlmenu.h>

In MyAddin.h, the following will appear within the public section of the class definition:

CopyC++
// Menu
    CXlMenu m_menu;

In MyAddin.cpp, the following will appear within the method CMyAddinApp::OnXllOpenEx():

CopyC++
if (!SupportsRibbon())
{
    // Set up menu 
    // TODO: Change the menu captions 
    //       Write an add-in function to be called when the menu item is clicked 
    //       Add other menu items
    m_menu.SetTexts(_T("&My menu"));
    m_menu.AddItem(_T("&My menu task"), _T("MyAddinFunction"));
    m_menu.Create();
}

In MyAddin.cpp, the following will appear within the method CMyAddinApp::OnXllClose():

CopyC++
// Delete menu 
if (!SupportsRibbon())
    m_menu.Destroy();

Add a toolbar

If this box is checked, then a toolbar will be added to your project.

In MyAddin.h, the following will appear within the public section of the class definition:

CopyC++
// Toolbar 
    static LPCTSTR m_pszToolbarName;

In MyAddin.cpp, the following will appear before the class implementation:

CopyC++
#include <xltoolbar.h>

In MyAddin.cpp, the following will appear within the method CMyAddinApp::OnXllOpenEx():

CopyC++
if (!SupportsRibbon())
{
    // Create toolbar 
    // TODO: Change the toolbar name and captions 
    //       Write an add-in function to be called when the tool button is clicked 
    //       Add other buttons
    CXlToolbarState tstate;
    CXlToolbar::AddToolbar(m_pszToolbarName, tstate);
    CXlToolbar::AddTool(m_pszToolbarName, 1, _T("MyAddinFunction"), _T("My addin function"));
    CXlToolbar::SetToolBitmap(m_pszToolbarName, 1, IDB_BITMAP1);
    CXlToolbar::ShowToolbar(m_pszToolbarName, tstate, true, CXlToolbar::DockRight);
}

In MyAddin.cpp, the following will appear within the method CMyAddinApp::OnXllClose():

CopyC++
// Delete toolbar 
if (!SupportsRibbon())
    CXlToolbar::DeleteToolbar(m_pszToolbarName);

Generate a VersionInfo function

This option will add a standard VersionInfo add-in function to your XLL, which can be used in a spreadsheet to get details of the author, date, version build and copyright of the XLL.

You can add a VersionInfo function later by using the Add VersionInfo Function command.

Enable Logging

This option will add basic logging functionality to the project, using the framework in cpplog.h. The following changes are made:

The following will appear in MyAddin.cpp before the #ifdef _DEBUG line:

CopyC++
#include <cpplog.h> 
using namespace psl::log;
static LoggerPtr g_logger = Logger::getLogger(_T("Global"));

In MyAddin.cpp, the following will appear within the method CMyAddinApp::OnXllOpenEx():

CopyC++
// Start logging 
if (!XllConfigurator::configure())    
    return FALSE;

A new file MyAddin.xll.log.ini is added to the project. Its contents are as follows:

CopyC++
# To write to different appenders, add them to the rootLogger directive, 
# e.g.:
#    log.rootLogger=ERROR, T
#    log.rootLogger=ERROR, F, T

# To set the severity level for all loggers, change the level in the 
# rootLogger directive, e.g.:
#    log.rootLogger=INFO, T

# To set the severity level for a specific logger, use a logger directive, 
# e.g.:
#    log.logger.CMyLoggedClass=TRACE
#    log.logger.Global=DEBUG

log.rootLogger=ERROR, F

log.appender.F=FileAppender
log.appender.F.File=%TMP%\MyAddin.log
log.appender.F.layout=PatternLayout
log.appender.F.layout.ConversionPattern=%-20.20d %t %-5p %c %m%n

log.appender.T=TraceAppender
log.appender.T.layout=PatternLayout
log.appender.T.layout.ConversionPattern=%c %-5p %c %m%n

The following Custom Build Step settings are applied to the file:

Setting Value
Command line copy "$(InputFileName)" "$(TargetDir)"
Description Copy log configuration file to output
Outputs "$(TargetDir)$(InputFileName)"

See Also

XLL+ AppWizard - Overview | XLL+ AppWizard - Application Settings | Project Settings