XLL+ Class Library (7.0)

AvgOpt Sample

An option value calculator add-in, which demonstrates the use of a results cache to speed up performance


This add-in contains a calculator for calculating the value of a complex option. It uses a results cache to speed up performance.

The calculation of the option value is very slow (since it uses a Monte-Carlo algorithm) and it is therefore worthwhile storing the results of calculations in a cache, and retrieving them if they are ever needed again. Since Excel often recalculates cells whose inputs have not changed, this technique offers a significant performance enhancement. The programming cost is zero, since the XLL+ AppWizard and Function Wizard generate and maintain all the code for using the cache.


The sample displays the following features:


The following steps were significant in creating and completing the AvgOpt application.

Classes and functions used

CXlOperCache | CXlOperCache::Save | CXlOperCache::Restore | CXlOperCache::Clear | CXlOper::Format | CXlOper::Ret | CXlMenu | CXlMenu::SetTexts | CXlMenu::AddItem | CXlMenu::Create | CXlMenu::Destroy | CXllApp::WinMessageBox | ::XllGetTypedApp

Sample project

Each sample project is located in a sub-directory of the Samples directory of the XLL+ installation. To use the sample project, open the solution file AvgOpt.sln or the project file AvgOpt.vcproj.

You can enable debugging under Excel by using the Setup Debugging command in the XLL+ ToolWindow.

When delivered, the help files are excluded from the build. You can enable the help build by selecting the files AvgOpt.help.xml and AvgOpt.chm in the Solution Explorer, and using the right-click menu to view Properties. Select the page "Configuration Properties/General" and set the "Excluded from build" property to "No". See Generating help in the User Guide for more information.

See Also

List of Sample Projects