Search code examples
c#.net-4.0

Detect Microsoft.Office.Interop.Excel Availability


I am working on an application that can import data from several different formats. I would like to include CSV and other flat-file types (easy) as well as XLS and XLSX.
It looks like my best option is to use Interop.Excel which I understand is only available if Excel is installed.
Is there a way to check whether Interop.Excel is available and tell the user that Excel must be installed to import from XLS/XLSX?


Solution

  • Microsoft.Office.Interop.Excel is an Office Primary Interop Assembly that you could ship with your application no matter whether the client has Office installed or not. It won't do any harm until you start using it. So before using it you could look at the registry to see if Office is installed.