1

I have an application that uses Microsoft.Office.Interop.Excel, when I deploy it on machines where there isn't any version of MS Office I get the following error

enter image description here

I tried installing VSTOR as indicated in this so answer COM object with CLSID {00024500-0000-0000-C000-000000000046} is either not valid or not registered but this didn't solve the issue.

Community
  • 1
  • 1
Kira
  • 1,153
  • 4
  • 28
  • 63

3 Answers3

3

If you need to work only with open XML documents (*.xslx) you may consider using the Open XML SDK. See Welcome to the Open XML SDK 2.5 for Office for more information.

In case of binary file format you need to use any third-party components that don't required Office/Excel installed on the machine.

Pay special attention to the following fact:

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.

Read more about that in the Considerations for server-side Automation of Office article.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
2

You can't use Microsoft Interop libraries if MS Office is not installed. You might want to look at alternative options to read Excel or Word files. There are many free and (paid) C# libraries you could use for this purpose, for example:

https://exceldatareader.codeplex.com/

https://github.com/ExcelDataReader/ExcelDataReader

Alex
  • 21,273
  • 10
  • 61
  • 73
0

You need download and install Microsoft Office {year}: Primary Interop Assemblies - it's free.

GRUNGER
  • 486
  • 3
  • 14
  • To add clarity for some user, the interop library is free to download. But we need to install the ms office licensed version to make the interop library to work. – Satheesh K Feb 16 '23 at 09:14