Writing Excel User Defined Functions in VSTO 2007

I apologize in advance in case I'm barking up the wrong tree...
I would like to write an user defined function that can be called from an excel cell (i.e. "=foorbar(42)").

I've found several rather complex guides:
http://blogs.msdn.com/eric_carter/archive/2004/12/01/273127.aspx

I've also seen there's an commercial product that provides extended capabilities
for Excel / Office (Add-In-Express) but I'm really not into spending $250 for an an excel UDF...

Is there some easy way of defining a .NET / C# function inside the add-in created by orcas and have it callable from Excel?

[617 byte] By [damageboy] at [2008-2-4]
# 1
I am looking for exactly the same thing. Have you found any answers yet?

Cheers,
Martin.

Creamportion at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Visual Studio Tools for Office Orcas...
# 2
Well,
The closest I've come to something working is
the "WishExcelHad" sample developed by Danny Khen:
http://blogs.msdn.com/excel/archive/2006/05/03/589094.aspx

or directly:
http://officeblogs.net/excel/WishExcelHad-Managed.zip

Note that to re-compile this you actually need the unreleased XLL SDK - xlcall.h and xlcall32.lib...

To get these you will have to mail Danny as they are in pre-release ATM.

His sample contains working implementations for .NET c# managed UDFs.

It comes no-where near to the ease of the commercial product I've found (Add-in Express)
but it also works for $0...

damageboy at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Visual Studio Tools for Office Orcas...
# 3
http://exceldna.typepad.com/
tomasat at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Visual Studio Tools for Office Orcas...
# 4

Hi.

Let me elaborate on tomasat's answer a bit.

ExcelDna allows you to create user-defined functions and macros for Excel using any .Net language, including C#, VB, F#. The project is open-source with a liberal license that also allows unrestricted commercial use. The best place to start is at the google group: http://groups.google.com/group/exceldna. The introductory page is at http://groups.google.com/group/exceldna/web and has links to samples and instructions. User-defined code can be in text-based script files that are compiled on the fly, or in pre-compiled .dll libraries. There is no dependency or interaction with VSTO, and the only redistribution requirement is the .Net 2.0 runtime.

ExcelDna is implemented through the Excel SDK (.xll) interface, thus works with all Excel versions since Excel'97. In particular it also works with Excel 2007, although I have not yet implemented any of the Excel 2007 enhancements. Soon after the new SDK is released (hopefully in the next few months) I plan to make a version that supports the large grid, multithreaded recalculation and Unicode strings.

Regards,

Govert van Drimmelen

GovertvanDrimmelen at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Visual Studio Tools for Office Orcas...

Visual Studio Orcas

Site Classified