I am using Microsoft.Office.Interop.Excel to open the excel workbook to do some automation for a given project. When i run my build, i encountered this error
System.Runtime.InteropServices.COMException: 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)).
Which comes from this code in my visual studios. excel.Application x1app = new excel.Application();
I am able to run the test locally but when i run it in azure devops, it dosen't work. I believe it is because devops does not have excel inside thus unable to execute the code.
- Is there any way i can solve this error while still using interop?
Are there any alternatives i can try besides EPPlus.
excel.Application x1app = new excel.Application(); x1app.SheetsInNewWorkbook = 1; x1app.Visible = true; excel.Workbook x1workbook = x1app.Workbooks.Open(); excel.Workbook NewWorkBook = x1app.Workbooks.Add(); for (sheets) { excel._Worksheet x1worksheet = x1workbook.Sheets[x]; x1worksheet.Copy(Type.Missing, After: NewWorkBook.Sheets[x - 3]); } Thread.Sleep(2000);
I should be able to run the build successfully on devops