calling C# functions from excel

  • Thread starter Thread starter Mark Schaffer
  • Start date Start date
M

Mark Schaffer

Basically, I have two questions:

1. How do you create an .xll file using C# and Visual Studio .NET?

2. How do you make functions callable/visible from Excel (2000 or XP)?

I am very new to this type of programming, so I apologize if this is very
elementary or obvious. Most of my previous experience is mostly in Fortran,
various assembly codes, and some C.

Thanks.
 
Mark,

You can not create an .xll file using C#, as far as I know.

If you want to make calls to .NET objects from within Excel, then you
will want to look into COM interop, which will allow you create COM objects
which you can use from any language that supports COM (including VBA in
Excel). Check out the section of the .NET framework documentation titled
"COM Interoperability in Visual Basic and Visual C#", located at (watch for
line wrap):

http://msdn.microsoft.com/library/d.../html/vbconcominteropinvisualbasicvisualc.asp

Also, you can look into creating a COM Add-in for Excel, which can be
loaded in Excel to provide services to everyone using Excel.

Hope this helps.
 
To create Xscel file from C# you will have to create a reference to the
Excel COM obect within your C# project, after which you can use it at will.
Make sure you have the documentation installed!

To reverse the situation and call managed code from excel you will have to
use COM Interop to create a COM component out of your assembly.
 
Back
Top