Sylvain
Sylvain

Reputation: 19249

How to take a dependency on Excel in .Net for maximum compatibility

One of our clients asked for a "View in Excel" feature in our Windows Forms App. So now we have to take a dependency on Excel. I have several questions about how to correctly reference Excel.

My feature only relies on APIs that have always been offered in Excel so technically Office XP would be fine. I cannot predict which version of Excel my clients will have. It is also possible that Excel will not be installed at all. I have to detect that and simply disable the "View in Excel" feature.

Questions:

What version of the Office Primary Interop Assemblies (PIA) should I take a dependency on for maximum compatibility with all versions of Excel? Should I use the oldest PIAs or the latest ones?

Will it work and is it legal to distribute the PIA dlls as part of my application (in my own application folder), without installing the official "Office PIA Redistributable" package?

How do I detect if Excel is installed? Also, won't loading the assemblies crash when it will not find Office?

Can you think of any other issues that I should consider?

Upvotes: 2

Views: 577

Answers (1)

wal
wal

Reputation: 17729

In the past I have added a reference to Microsoft.Office.Interop.Excel.dll, Version 14.0.0.0

enter image description here

which corresponds to Office 2010.

I am doing some pretty basic stuff, reading/writing to excel and named ranges and adding a reference to this library (and no other versions) works with Excel back to 2003. (I have test beds running XP and Excel 2003)

Upvotes: 1

Related Questions