问题描述
Hello All,
当我尝试在服务器上上传excel时出现以下错误:
请帮我解决错误:
检索带有CLSID的组件的COM类工厂{00024500-0000-0000 -C000-000000000046}由于以下错误而失败:80040154未注册类(HRESULT异常:0x80040154(REGDB_E_CLASSNOTREG))。
代码:
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,
类型.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 ;
谢谢,
Anil S. hingala
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
推荐答案
Microsoft目前不建议也不支持从任何无人参与的非交互式客户端应用程序或组件(包括ASP,ASP.NET,DCOM和NT)自动化Microsoft Office应用程序服务),因为Office在此环境中运行时可能会出现不稳定的行为和/或死锁。
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.
那里有多种方法可以在服务器上创建和读取Excel电子表格,而无需使用Office互操作。例如:
- [];
- [];
- [];
- EPPlus[^];
- ClosedXML[^];
- The OpenXML SDK[^];
There are various ways to create and read Excel spreadsheets on the server without using Office interop. For example:
这篇关于Excel上传的Excel上传问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!