0
votes

Hi i am using c# code for creating xlsx file. i have added the reference to my bin for Microsoft.Office.Interop.Excel Version 12.0.0.0

It Works ok on my local machine. But when i upload it to the server it throws the error in the page where i am creating the xlsx file "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)). " can anybody plz help

2
As Ben Robinson suggests, this error would indicate that Excel is not installed on the server. One thing you could do to remove this dependency, if it's an option, is to create CSVs instead of xlsx; this is an open format and can be opened and manipulated by Excel. - Guy Starbuck
In general you shouldn't be using Excel automation on a server. There's plenty of libraries in this question you can use instead. - Rup

2 Answers

3
votes

You are getting the error because excel isn't installed on the server.

1
votes

You shouldn't be automating Office in ASP.NET. It can lead to myriad performance and scale issues on your server. Office itself is designed for interactive desktop usage, not unattended execution in a non-GUI app. Here is the authoritative reference from MS on the matter:

http://support.microsoft.com/kb/257757

With that being said, there are third-party libraries designed specifically for manipulation of Excel in ASP.NET. OfficeWriter is one example:

http://www.officewriter.com