2

I know this question has been posted before... but I haven't found any answer yet (besides from the generic answers about how XLL are actually DLL, etc). Has anybody out there been successful calling a XLL from say C# (using DllImport) without having to load Excel with the XLL loaded as an addin?

Basically, you would have to create a special XLCALL32.DLL that simulates the Excel host. It sounds like a lot of work... has anybody done this? Or seen a product to do it?

Thanks

Joel Spolsky
  • 33,372
  • 17
  • 89
  • 105
Nestor
  • 13,706
  • 11
  • 78
  • 119
  • See the answer to http://stackoverflow.com/questions/278025/calling-an-xll-from-unmanaged-c?rq=1 – Keith A. Lewis Nov 19 '12 at 14:07
  • Read goverts answer - XLL Plus is the way to go, if money is not an issue - http://stackoverflow.com/questions/1940747/calling-excel-dll-xll-functions-from-c-sharp?rq=1 – quixver Dec 02 '14 at 14:50
  • P.S. It is a LOT of work. Stubbing excel is not as easy as it sounds. – quixver Dec 02 '14 at 14:52

2 Answers2

0

Evaluating this XLL+ library (which is not free, running on trial atm) which hels to "mock"/"simulate" XLCALC32.dll calls (as it only needs 2 methods from it as far as i understand). Will let you know if I get somewhere.

Bek Raupov
  • 3,782
  • 3
  • 24
  • 42
0

You're on the right track with needing to create your own XLCall32.dll and simulate Excel. That's non-trivial given what you can do via the interface that XLLs use to talk to Excel. It becomes easier the less of Excel that you need to use from within your XLL, so I guess if you have a known selection of XLLs that you need to use and you know what bits of Excel they access via the XLL interface then you can just replace the bits you need...

Why do you want to do this?

Len Holgate
  • 21,282
  • 4
  • 45
  • 92
  • i have an XLL I wrote a while back. I lost the source code. And I'd love to be able to call it's functions from c#. – Nestor Apr 21 '10 at 18:08
  • IMHO, it would be easier for you to rewrite the XLL in a form that you can call from C# than it would be to write a substitute XLCall32.dll and simulate Excel... Then again I guess that depends on how much you were using Excel to do your work, but I expect you can remember that so you should at least know which parts of Excel you need to simulate. Then there's the just the question of loading the xll, marshalling your c# types to the appropriate XLOPERs and calling the entry points... – Len Holgate Apr 21 '10 at 20:11