views:

1072

answers:

6

Hello, I have a particular function in an Excel addin(xll). The addin is proprietary and we do not have access to the source code. However we need to call some functions contained within the addin and we would like to call it from a C# program.

Currently, I was thinking of writing a C++ interface calling the Excel function with xlopers, then calling this C++ interface from C#.

Does anybody who has prior experience of this kind of issues know what would be the best solution for that ?

Anthony

A: 

An Excell add-in DLL might be written in C#. If so, then you can probably bypass Excel altogether. Might need a wrapper though.

Hamish Grubijan
In this case I get the addin as-is.It is not developed by us and we do not access the source code however we would like to use some functions contained within the XLL in other langugages.I will edit my post to mention this fact.
BlueTrin
A: 

I'd use this dll instead: http://www.codeplex.com/ExcelDataReader

It's open source, it handles alot of formats, and it's easy to add and use

Theofanis Pantelides
I have used it for tens of thousands of rows of data, and it's rather fast too
Theofanis Pantelides
I am not sure it is what I need.How do you want to call the XLL function using ExcelDataReader ?Should I write a spreadsheet, fill the arguments, tell Excel to execute the computation and retrieve the results from ExcelDataReader ?
BlueTrin
Hi, I assumed that the Excel was already created; and you wanted to access the result. A quick but dirty solution would be, as you say, generate the excel, execute the command, and write your method to use the ExcelDataReader. This may or may not be recommended depending on how your application will be used.
Theofanis Pantelides
You could also read through the source code (http://exceldatareader.codeplex.com/sourcecontrol/changeset/view/27264?projectName=ExcelDataReader#569945) and see how it interacts with functions and make your own Excel.dll, with only the functionality you need
Theofanis Pantelides
Maybe even create a dummy excel with the function, and load the Excel, but instead of executing the function on Cells, you execute it on input
Theofanis Pantelides
A: 

check whether assembly is available in program files where you install the plguin, reference that assembly directly to your c# project - check the object browser for your class, method or object

Tumbleweed
Unfortunately it is not a managed XLL.
BlueTrin
A: 

You should be able to use reflection to get access to your addin. try using The Reflector to see what's available.

Proteux
It is not a .Net addin.
BlueTrin
+2  A: 

this is not answer, but important advice. When you need to work with COM components, it is MUCH more easy to do from VB.NET. Basic is not so complex, you just need to wring a lot of "begin" and "end" keywords, but it has old vb background, where com, ole was key features. From C# you need to do a lot of manual coding or generate proxy for each version of excel (and than do some code in your code to select proper version). In VB you can create and access any property without doing anything.

Sergey Osypchuk
+1  A: 

You might like to try XLL Plus http://www.planatechsolutions.com/xllplus/default.htm. It's a bit pricey, but the XLL Wrapper Libraries feature is exactly what you are looking for:

"Sometimes it is useful to be able to call your Excel add-in functions from other environments, such as command-line programs or interactive applications, written in C++, Java, C# or Visual Basic. The Xll Wrapper toolkit contains tools, a runtime library, samples and documentation to help with the development of COM modules and .NET assemblies that wrap Excel XLL add-ins"

Govert