-1

I am trying to generate an excel file from my database it working locally but when I try to run it on IIS its giving me this error:

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.

Here is the code that I am using

    Microsoft.Office.Interop.Excel.ApplicationClass ExcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
    Microsoft.Office.Interop.Excel.Worksheet ExcelWorkSheet = new Microsoft.Office.Interop.Excel.Worksheet();
    Microsoft.Office.Interop.Excel.Workbook ExcelWorkbook = null;
try
{
  List<Information> InfoList = InfoManager.GetAllInfo);
  .......

 }

It is always giving me an error on

Microsoft.Office.Interop.Excel.ApplicationClass 
ExcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
Damith
  • 62,401
  • 13
  • 102
  • 153
wandos
  • 1,581
  • 2
  • 20
  • 39
  • 1
    Really don't do that. There's a MS KB that says you shouldn't use Office components like that on a server (i.e. without an interactive session). Lots of alternatives here: http://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c-sharp – Rup Nov 08 '11 at 13:12
  • 1
    possible duplicate http://stackoverflow.com/questions/881132/retrieving-the-com-class-factory-for-component-failed – huMpty duMpty Nov 08 '11 at 13:15
  • FYI 0x80070005 is ERROR_ACCESS_DENIED. – Rup Nov 08 '11 at 13:18

1 Answers1

0

You need to install AccessDataBaseEngine.exe in your server hosting your application. This will work for both .xls ans xslx.

http://www.microsoft.com/download/en/details.aspx?id=23734

Regards,

Sayed

Amin Sayed
  • 1,240
  • 2
  • 13
  • 26