0

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

Nipun
  • 1,465
  • 4
  • 20
  • 28
  • 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 Jan 25 '12 at 14:45
  • 1
    In general you shouldn't be using Excel automation on a server. There's plenty of libraries [in this question](http://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c-sharp) you can use instead. – Rup Jan 25 '12 at 15:02

2 Answers2

3

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

Ben Robinson
  • 21,601
  • 5
  • 62
  • 79
1

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

Eisbaer
  • 189
  • 1
  • 6