Edit Excel worksheet with C # in Microsoft Azure

0

I have a web application that reads an excel spreadsheet and imports the cell values into the database automatically. I am using COM, so it is necessary on the machine Microsoft Excel installed. When compiling locally it works without problems. However, I hosted in azure recently and the error is due to not having Excel installed. How can I work around this error? I do not understand much of the azure, so I wanted to know a way to install Microsoft Office Excel.

ERROR THAT APPEARS:

  

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)).

     

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more   information about the error and where it originated in the code.

     

Exception Details: 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)).

    
asked by anonymous 08.06.2017 / 01:46

1 answer

0

Just to summarize: Azure App Services WebApp is a Platform as a Service. This means that the total responsibility for maintaining the infrastructure is from Microsoft and not from the developer. But to be able to take on that role, they must make the hosting environment a lot of space, and open only really relevant points for the developer - and installing software on their servers is totally out of the question.

There is an option I highly recommend to work with Excel from .NET systems: SpreadSheet Light .

Although it is a library with procedural methods - it is not object oriented, intuitive and even elegant to work with. Here are some examples:

Read and modify data from a worksheet

// SpreadsheetLight works on the idea of a currently selected worksheet.
// If no worksheet name is provided on opening an existing spreadsheet,
// the first available worksheet is selected.

        SLDocument sl = new SLDocument("ModifyExistingSpreadsheetOriginal.xlsx", "Sheet2");

        sl.SetCellValue("E6", "Let's party!!!!111!!!1");

        sl.SelectWorksheet("Sheet3");
        sl.SetCellValue("E6", "Before anyone calls the popo!");

        sl.AddWorksheet("DanceFloor");
        sl.SetCellValue("B4", "Who let the dogs out?");
        sl.SetCellValue("B5", "Woof!");

        sl.SaveAs("ModifyExistingSpreadsheetModified.xlsx");

        Console.WriteLine("End of program");
        Console.ReadLine();

Here are more examples of how to work Excel spreadsheet with C # .

    
08.06.2017 / 09:42