How to fix the error for the interop when you dont have microsoft office installed

0

I have this code on my service:

Application xlsApp = new Application();
xlsApp.Visible = false;
Workbook wb = xlsApp.Workbooks.Open(dictionaryPath);
Sheets sheets = wb.Worksheets;
Worksheet ws = (Worksheet)sheets.get_Item(1);
var numberOfRows = ws.UsedRange.Columns["A"].Rows.Count;
var firstCol = ws.Range[dictionaryColumn + "1:" + dictionaryColumn + numberOfRows];
values = firstCol.Value as Array;

And when I run because I don't have Microsoft Office installed on my server I get this error:

System.Runtime.InteropServices.COMException (0x80040154): Retrieving 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)).

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)

at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)

at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)

at System.Activator.CreateInstance(Type type, Boolean nonPublic)

at System.Activator.CreateInstance(Type type)

And I know that one of the solutions is to install the Microsoft Office but I am not allowed to do that so is there any other way to access the excel and not to install Microsoft Office. I use COM Interop and it is included in the project I also tried installing Open XML SDK 2.5 but for some reasons it didn't work. Can some one help me find a solution

c#
service
com-interop
excel-interop
asked on Stack Overflow Jul 25, 2019 by Argjent

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0