Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

When i am trying to upload excel on server that getting me following error:

please help me to solve the error:


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


Code:

string NewFileLocation = string.Empty;
NewFileLocation = string.Format("{0}{1}", FileLocation, "x");

if (System.IO.File.Exists(NewFileLocation))
System.IO.File.Delete(NewFileLocation);

Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
excelApp.Visible = false;

Microsoft.Office.Interop.Excel.Workbook eWorkbook = excelApp.Workbooks.Open(FileLocation, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

eWorkbook.SaveAs(NewFileLocation, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

eWorkbook.Close(false, Type.Missing, Type.Missing);

FileLocation = NewFileLocation;
FileExtension = ".xlsx";

Thanks,
Anil Shingala
Posted
Updated 22-Apr-15 1:21am
v2
Comments
ShahidRiaz 22-Apr-15 5:25am    
can you please share the code?
Anil Shingala 22-Apr-15 7:20am    
string NewFileLocation = string.Empty;
NewFileLocation = string.Format("{0}{1}", FileLocation, "x");

if (System.IO.File.Exists(NewFileLocation))
System.IO.File.Delete(NewFileLocation);

Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
excelApp.Visible = false;

Microsoft.Office.Interop.Excel.Workbook eWorkbook = excelApp.Workbooks.Open(FileLocation, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

eWorkbook.SaveAs(NewFileLocation, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

eWorkbook.Close(false, Type.Missing, Type.Missing);

FileLocation = NewFileLocation;
FileExtension = ".xlsx";

1 solution

Error 80040154 means Office is not installed on the server.

You should also read the following Microsoft knowledgebase article:

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.


There are various ways to create and read Excel spreadsheets on the server without using Office interop. For example:
 
Share this answer
 
Comments
Anil Shingala 22-Apr-15 8:02am    
after installation of office , its fire error of access_denied:

error:

ERROR – RETRIEVING THE COM CLASS FACTORY FOR COMPONENT WITH CLSID {00024500-0000-0000-C000-000000000046} FAILED DUE TO THE FOLLOWING ERROR: 80070005 ACCESS IS DENIED. (EXCEPTION FROM HRESULT: 0X80070005 (E_ACCESSDENIED)).
Richard Deeming 22-Apr-15 8:05am    
Which is one of the problems clearly documented in the Microsoft knowledgebase article[^] I linked to.

Server-side automation of Office is not supported. Rather than fighting against the system to try to get it to work, use one of the alternatives I suggested.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900