Why do I get System Exception thrown only with Excel 2007?

0

I have a List that holds some objects, which properties I want to write in a en Excel. The code works perfectly with Excel 2013. The issue comes when I try to run it in a computer that only has Excel 2007.

I already looked in different links and discussions but none of them seem to have the solution to this issue. I already changes the Microsoft.Office.Interop.Excel reference to the one located in the correct path and different methods.

I get this error:

Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

In computers with newer versions of Excel, the code runs perfectly and I get the output I wish, but with 2007 Excel I get the previously mentioned exception.

Any solutions or ideas?

c#
excel
exception
excel-interop
asked on Stack Overflow May 7, 2019 by JMGP

1 Answer

-1

I would suggest you to use EPPlus as it does not require interop.

answered on Stack Overflow May 7, 2019 by D.W

User contributions licensed under CC BY-SA 3.0