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

Argjent
  • 97
  • 8
  • You can't. If you just need the data (no formatting) use oledb – jdweng Jul 25 '19 at 15:15
  • Possible duplicate of [How to use Microsoft.Office.Interop.Excel on a machine without installed MS Office?](https://stackoverflow.com/questions/11448197/how-to-use-microsoft-office-interop-excel-on-a-machine-without-installed-ms-offi) – Sergey Sheff Jul 25 '19 at 17:48

0 Answers0