0
votes

I have WPF application which reads excel file data and display it in on UI. I am using Microsoft.Office.Interop to read excel file data mainly .xlsx. On dev machine application is working fine but intalling and running this app on some computers it giving me this error:

ExcelRetrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG) What could be possible solution for this?

2
Do you have Excel installed on the target machine? Without Excel you can't use Office.Interop. There is a good alternative here epplus.codeplex.com - Steve
yes. MS Office installed on target machine. - SST
I can only suggest to try to install PIA 2010 for Microsoft Office 2010 from here, also have you checked if your app is compiled for x86 and target machine is x64 or viceversa. - Steve
Intalled PIA. issue remains the same.Yes app is compiled for x86. but dev machine and target machine both are 64 bit. On dev machine is working fine. - SST
On target machine do you have office64 or office32? - Steve

2 Answers

1
votes

The Interop library has a number of massive disadvantages; the first is that you need a copy of Excel installed on the target machine for it to work.

For this reason, our team never uses it. I'd suggest the following alternatives.

http://npoi.codeplex.com ( older library for MS 2003 files .xls).

http://epplus.codeplex.com ( newer library with easier API that handles 2007 files .xlsx )

Neither requires Excel to be on the server.

1
votes

Also Microsoft Access Database Engine 2010 Redistributable

  • allows simple queries (Linq too) over Excel files,
  • it's free and easy to install it on the server where you deploy your application,
  • does not require Office installed on terget machine.