1

I'm working with a task in which I need to insert data into an existing Excel file by finding its rows and cells. I did this thing at local by using Microsoft.Office.Interop.Excel dll at my end and its works excellent. But, when I upload it on server then its gives me error:

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

Is this error because we don't have Microsoft Excel installed in server or some other reason?
If it is because there is no Microsoft Excel on server then how we can complete it with out installing Microsoft Excel in the server?

Code:

Imports Microsoft.Office.Interop.Excel
-
-
-
-
-

Private mWorkBook As Microsoft.Office.Interop.Excel.Workbook
Private mWorkSheets As Microsoft.Office.Interop.Excel.Sheets
Private mWSheet1 As Microsoft.Office.Interop.Excel.Worksheet
Private oXL As Microsoft.Office.Interop.Excel.Application
-
-
-
-
-
-
oXL = New Microsoft.Office.Interop.Excel.Application() --- This line is causing error.
pnuts
  • 58,317
  • 11
  • 87
  • 139
Rahul
  • 5,603
  • 6
  • 34
  • 57
  • possible duplicate of [Create Excel (.XLS and .XLSX) file from C#](http://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c-sharp) –  Nov 19 '14 at 08:25

1 Answers1

1

Yes this error due to the Microsoft excel not installed in server.

As you said Microsoft.Office.Interop.Excel - this line causes the error.

Since, the Excel is not installed. But your app is trying to retrieve the component class factory from the server. So, its throwing the error.

You can avoid the Excel Installation in Server. But, you need to follow the different development approach, now you followed one way of approach to create an Excel.

Take a Look at this Thread from Stackoverflow.. In this question, its same as exact problem you face.

There are Two Highly voted answers. Either you could use one of them.

I have tried the ExcelLibrary - and i would like to suggest you too use this. It was working fine in our development test server without excel installation.

Community
  • 1
  • 1
RajeshKdev
  • 6,365
  • 6
  • 58
  • 80