Creating Add-Ins in C++ for Excel

Creating Add-Ins in C++ for Excel

Postby Cuchulainn » Mon May 14, 2007 11:01 am

Chapter overview of MC book

///



In this important chapter we discuss how to integrate our code with other libraries and applications, in particular Excel. In particular, we create applications in which Excel is used as the front-end to the Monte Carlo applications, libraries and other code. We show how to create the software for user input, output, processing and communication between Excel and C++. We consider this chapter to be important because Excel is a hugely popular application in finance and it is used on a daily basis by quantitative analysis, quantitative and IT developers in many of the investment banks throughout the world.

There are two main techniques that allows us to write C++ applications that interoperate with Excel and we speak of Excel add-ins this context:



XLL adds-ins

This is the oldest form of add-in. These add-ins are written in C using the Microsoft XLL application-programming interface. The code is compiled to a dynamic link library (DLL) having the extension .xll. They are useful for the creation of Excel worksheet functions or functions that we call using menus.

The advantage in this case is that XLL is efficient and it works with all versions of Excel from Excel 95 upwards. The perceived disadvantage is that development work has ceased and it is likely that the product will not be updated.



COM add-ins

These were introduced in Excel 2000 and are based on a generic COM (Component Object Model) interface for add-ins. All Office products use this interface as well as the Visual Studio and VBA development environments.

Some remarks need to be made concerning this kind of add-in. First, having created a COM add-in you must register it in the registry for each host application (for example, Excel or Word) that it supports. This allows the host application to find the add-in. In general terms, the registry is a hierarchical data store that holds many different kinds of data, for example DLLs and their file locations. Second, COM add-ins cannot be used to create Excel worksheet functions, at least not directly. If you wish to do so, then you should call the COM add-in function through an XLA (the VBA way of creating add-ins) add-in worksheet function.



Automation add-ins

This option has been available since the introduction o Excel XP. It uses COM objects whose public functions are used as worksheet functions. Menus are not supported.

An automation add-in is always loaded on demand.



We examine of the above options in detail and we provide a step-by-step account for creating an add-in and we give several examples to show how to create an add-in. In particular, we discuss worksheet functions for library-related functionality as well as complete applications that are started from within Excel.

Finally, we discuss how to visual output in Excel and we have found this feature to be very useful when testing and debugging applications. We conclude with a discussion of Excel and XML (Extendible Markup Language). XML is a standard language for data representation (in Duffy 2004 we discuss XML and C++ integration and some applications in finance).
User avatar
Cuchulainn
 
Posts: 668
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Cuchulainn » Mon Sep 10, 2007 5:39 pm

Here is a summary for the steps when creating AddIns; it complements the chapter 29 in the book.
Attachments
Quick Guide to Creating COM AddIns for Excel in C.doc
(29.5 KiB) Downloaded 1751 times
User avatar
Cuchulainn
 
Posts: 668
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Cuchulainn » Tue Nov 20, 2007 11:58 am

Here is a link to a bug fix from Microsoft (problem with loading addins)



http://support.microsoft.com/kb/908002
User avatar
Cuchulainn
 
Posts: 668
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Cuchulainn » Fri Dec 04, 2009 10:51 pm

Here is the new code for Add Ins in COM. Visual Studio uses new strings due to the new compiler!!





Forget the old COMUTILS (they use strings that don't work on VS2008 :()
Attachments
ComAddinUtils.hpp
(882 Bytes) Downloaded 1185 times
ComAddinUtils.cpp
(4.06 KiB) Downloaded 1201 times
Last edited by Cuchulainn on Fri Dec 04, 2009 11:18 pm, edited 1 time in total.
User avatar
Cuchulainn
 
Posts: 668
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Cuchulainn » Fri Dec 04, 2009 11:06 pm

And here are the Excel app utilities with the new strings (VS2008!!)
Attachments
ExcelUtils.hpp
(2.44 KiB) Downloaded 1264 times
ExcelUtils.cpp
(8.84 KiB) Downloaded 1521 times
ExcelImports.h
(2.66 KiB) Downloaded 1184 times
User avatar
Cuchulainn
 
Posts: 668
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Re: Creating Add-Ins in C++ for Excel

Postby blackbee045 » Wed Oct 15, 2014 8:53 pm

We provide a step-by-step account for creating an add-in and we give several examples to show how to create an add-in. In particular, we discuss worksheet functions for library-related functionality as well as complete applications that are started from within Excel.
blackbee045
 
Posts: 1
Joined: Tue Oct 14, 2014 8:32 pm


Return to Financial Instrument Pricing using C++ (Duffy)

Who is online

Users browsing this forum: No registered users and 1 guest

cron