Codematic Excel developers logo
Codematic spreadsheet-excel development image

Rapid Application Development / Advanced Excel Development

Products for Excel
Commercial Products:
  - Classic Ribbon
  - Alt-FileSearch
  - Password Remover
Spreadsheet Quality Products
Free Products
Excel Development
Excel Development Index
Excel VBA
- VBA IDE (editor)
- VBA Training
- VBA Best Practice
- VBA Performance
- COM Performance
- VBA Security
Excel and Databases
Excel and Pivot Tables
Excel Add-ins
Worksheet Functions
Excel and xlls
Excel (in)security
Excel testing
Excel and .net
Excel External Links
Excel Developer Types
Professional Excel Development
Excel 2007
Excel 2010
Excel Development Archive
Spreadsheet Services
Spreadsheet Development
Spreadsheet Migration
Spreadsheet Maintenance
Spreadsheet Review
Spreadsheet Management
Excel User Confs
Consultant Profile
Book Reviews
Site Map

Visual Studio Excel Development

There is much more to working with Excel from Visual Studio than just VSTO. Here's a summary table of the main design patterns and the type of VS project to use.

Solution Type
Technology Type   Workbook With Code Behind Application Level Feature Custom Worksheet Function Automation Project
VSTO (VS 2003)   ü      
VSTO (VS 2008)   ü ü    
COM Add-in     ü    
Automation Add-in       ü  
Win32 XLL     ü ü  
VBA   ü ü ü  
Standalone exe         ü

Here is the powerpoint presentation from the DDD2 community event at Microsoft. The presentation introduces these design patterns and the types of Visual Studio project to use to create each one. It also covered what a COM Shim is and why you need them, and gave some potential reasons to use .net for Excel developments. The VSTO Demo was VS2005RC the COM add-in and the Automation Add-in were VS2003.

As of summer 2008, the Excel/.net story is still less than compelling, although it is improving all the time. At this time the Codematic view is the 2008 VSTO dependencies are very real barrier to adoption for our clients. Standalone exes created in .net can however work extremely well, even if automating Excel.

COM Add-ins

COM Add-ins are found here:

.net Worksheet Functions

Here is the C# source code for a worksheet function project. You need to create a class library project and swap the contents of that file for this file - cut and paste everything within the namespace is probably the easiest. You then need to set project properties to register for COM interop, and set Excel as the Debug application and run. You will also need to load the addin in Excel by picking it from the list of automation add-ins.

If you want the full gory details of creating your own custom Visual Studio project like this:

then get in touch. Warning - not for novices! If there is enough interest I may create an installation routine - but that's doubtful given the poor performance of .net worksheet functions. This class is based on the work of Eric Carter in Visual Studio Tools for Office, be sure to buy that book (and read it) if you are interested in this area.

.net Worksheet Function Performance

Here is a performance table for a moderately complex array formula I converted to various types of Visual Studio (2003) project:

Performance (Excel 2003)
57,000 formulas, calculated 10 times
Version Time Performance
  Seconds % of Excel
Excel 27 100%
VBA 29 107%
VB6 32 119%
C# 260 963%
C++ (XLL+) 13 48%

Here is the worksheet function that was converted (it returns the last non zero value from a list of 100 values):


If you would like the full set of projects to play with then let us know. The C++ one was written with the help of XLL+ from Planatech so you will need a demo copy of that. In fact you can download a Zip with an instruction doc, a test workbook, and the VB6 VBA and C# source code here (1.5Mb). You will need Visual Studio 6 for the VB version and 2003 for the C# one (it may work in other versions - let us know).

All the programmed solutions benefited from using a specific algorithm suited to the problem. The performance difference would be quite different for any other problem. The likely outcome being Excel and C++ much closer and VBA/VB6 further behind. C# unfortunately, would probably never make the grade.

The VBA one was compiled, and the IDE closed before running. The VB6 version had all speed optimisations set. I did not bother with a version as there seems no reason to believe it would be materially faster than C#.

The C# code is significantly different to the other code as it needs an Excel reference to be able to understand the range that is passed in. In VB6 and VBA that is treated as a variant, and looped through in the normal way. However, simply adding 2 doubles (ie no Excel objects) in the above manner takes 30 seconds in C#, so its not just the Excel reference, if at all (Excel comparison time? 0 seconds rounded to 0 decimal places!).

The only fair conclusion from this analysis is that it is very expensive to pass through the Primary Interop assemblies for Office 2003. If a worksheet function is only used a few times then the benefits of .net may outweigh the speed penalty, but for the type of use I see, .net is not currently appropriate. This issue has been raised with Microsoft and they are investigating it.

For now, and probably for a good while into the future, the only viable technology to implement most worksheet functions seems to be C++. And conveniently enough XLL's are also simple to deploy, requiring no registry access, no VB runtimes, and no .net framework. They also work with all versions of Excel from 97 onwards.

And guess what? Codematic can help you write your custom worksheet functions in C++.

We can work from scratch, a paper spec, a complex worksheet function, a VB/VBA function, even old XLM, whatever, we'll convert it to a C++ XLL.

If you require any more information please get in touch.



Upcoming Events:

25 January 2012 - UK Excel Developer Conference - London

Products for sale:


Office 2007 FileSearch replacement logo

New information about the missing FileSearch feature in Office 2007 and details of our pragmatic solution (Current price GBP 30.00)


worksheet password remover logo

Instant Excel worksheet protection remover and password recovery (Current price GBP 15.00)

Classic Ribbon Tab

classic ribbon for office 2007 logo

Add Excel 97/2000/2002/2003 compatible menu structure to Excel 2007
(Current Price GBP 10.00)


Products coming soon:

Link Manager

(Find and control external links in Excel Workbooks)

Due by Q1 2111.

XLAnalyst Pro

(Excel VBA based spreadsheet auditing tool)

Due before the end of 2111.

This page was last reviewed on December 21, 2011

©Codematic Ltd 1999-2011