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.
This is the name that will be displayed in the Excel Add-ins dialog.
It is defined in MyAddin.cpp
:
/* static */ LPCTSTR CMyAddinApp::m_pszDefName = _T("MyAddin");
To create a 64-bit version at a later time:
<New...>
.x64
.
Ensure that Create new project platforms is checked, and press OK.This switch chooses the character set for your project, via the project settings, as follows:
UNICODE
and _UNICODE
to the list of "Preprocessor Definitions"
under "C/C++/Preprocessor".
For non-unicode builds, remove them.This switch enables CLR support for your project.
You can change the project settings to or from CLR later yourself, if necessary, as follows:
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.
All Configurations
and Platform to All Platforms
.Visual Studio | Path |
---|---|
VS 2005 | $(Xlp80InstallDir7)include |
VS 2008 | $(Xlp90InstallDir7)include |
VS 2010 | $(Xlp100InstallDir7)include |
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.
This box adds a results cache to your project.
In MyAddin.h
, the following will appear before the class definition:
#include <xlserialize.h>
In MyAddin.h
, the following will appear within the public section of the class definition:
// Data
CXlOperCache m_cache;
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;
:
CString m_strCacheFile;
In MyAddin.cpp
, the following will appear within the method CMyAddinApp::OnXllOpenEx()
:
// 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()
:
// Save cache
m_cache.Save(m_strCacheFile);
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.
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:
#include <xlmenu.h>
In MyAddin.h
, the following will appear within the public section of the class definition:
// Menu
CXlMenu m_menu;
In MyAddin.cpp
, the following will appear within the method CMyAddinApp::OnXllOpenEx()
:
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()
:
// Delete menu if (!SupportsRibbon()) m_menu.Destroy();
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:
// Toolbar static LPCTSTR m_pszToolbarName;
In MyAddin.cpp
, the following will appear before the class implementation:
#include <xltoolbar.h>
In MyAddin.cpp
, the following will appear within the method CMyAddinApp::OnXllOpenEx()
:
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()
:
// Delete toolbar if (!SupportsRibbon()) CXlToolbar::DeleteToolbar(m_pszToolbarName);
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.
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:
#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()
:
// Start logging if (!XllConfigurator::configure()) return FALSE;
A new file MyAddin.xll.log.ini
is added to the project.
Its contents are as follows:
# 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)" |
XLL+ AppWizard - Overview | XLL+ AppWizard - Application Settings | Project Settings