Saturday, January 3, 2009

Excel4Net: deployment – part 1

In this post I am would like to compare deployment models of Managed Automation (COM) add-in and Excel4Net.

To do that – let’s implement a user defined function (UDF) - bond pricing function, using .NET:



With the Excel4Net all we need to do:
1. Copy the resulting assembly into the destination folder
2. Copy the spreadsheet to the destination folder

And after we invoke “Insert Function” dialog (just type =func() anywhere in the spreadsheet) we will see this function ready to be used:



if we spend extra 5 minutes amending the auto generated documentation, we could get something like this:



Press “OK” – that will insert bond price function call into the spreadsheet. This is it.

In case if we have decided to build Managed Automation (COM) add-in all we would have to:

1. Add ComVisible attribute to the class
2. Implement register and un-register functions to be able register and unregister add-in in the registry
3. Copy the resulting assembly to the destination folder
4. Register resulting assembly using regasm.exe
5. Update Excel.exe.config file to load specific version of .NET
6. Register the add-in in Excel (dozen of clicks in five different Excel windows)

After we invoke the “Insert Function” dialog, we will see our function:






Press “OK” – that will insert bond price function call into the spreadsheet.

Though both approaches yielded exactly the same result, what were different – the amount of time and effort spent.

If you want to try Excel4Net - please download a free fully functional beta here: www.excel4net.com/Download.aspx


p.s.

There are two good articles on how to create Managed Automaton Add-in and UDF using .NET:

Managed Automation Add-ins
Writing user defined functions for Excel in .NET

No comments:

Post a Comment