由于以下错误,检索具有clsid ...的组件的COM类工厂失败:80040154 [英] Retrieving the COM class factory for component with clsid...failed due to the following error: 80040154

查看:306
本文介绍了由于以下错误,检索具有clsid ...的组件的COM类工厂失败:80040154的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string filepath = Server.MapPath(@〜/ MSME_Admin / CMA_Data / Book1.xls);

//从文件夹打开现有Excel

应用程序ExcelObj = new Excel.Application();

工作簿WBook = ExcelObj.Workbooks.Add(filepath);

工作表WSheet =(Excel.Worksheet)WBook.Sheets.get_Item(1);

范围= null;



我尝试了什么:



i我收到此错误,为什么会出现此错误我不明白。请给出一些解决方案。

string filepath = Server.MapPath(@"~/MSME_Admin/CMA_Data/Book1.xls");
// To Open existing Excel From Folder
Application ExcelObj = new Excel.Application();
Workbook WBook = ExcelObj.Workbooks.Add(filepath);
Worksheet WSheet = (Excel.Worksheet)WBook.Sheets.get_Item(1);
Range range = null;

What I have tried:

i am getting this error, why are coming this error i din't understand. Please Give some solution.

推荐答案

错误80040154表示服务器上没有安装Office。



你还应阅读以下Microsoft知识库文章:

Error 80040154 means Office is not installed on the server.

You should also read the following Microsoft knowledgebase article:

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文档( .xls ),你需要使用NPOI:

GitHub - tonyqus / npoi:一个.NET库,可以读取/写入没有安装Microsoft Office的Office格式。没有COM +,没有互操作。 [ ^ ]



对于新式文件( .xlsx ),还有其他几种选择:

  • EPPlus [ ^ ];
  • ClosedXML [ ^ ];
  • ExcelDataReader [ ^ ];
  • OpenXML SDK [ ^ ];


  • Since you're trying to read an old-style Excel document (.xls), you'll need to use NPOI:
    GitHub - tonyqus/npoi: a .NET library that can read/write Office formats without Microsoft Office installed. No COM+, no interop.[^]

    For new-style documents (.xlsx), there are several other alternatives:

    • EPPlus[^];
    • ClosedXML[^];
    • ExcelDataReader[^];
    • The OpenXML SDK[^];

    • asp.net不支持自动化Excel,你需要使用其他一些操作Excel文件的方法,如EPPlus,XML SDK,Aspose,Excel ODBC Driver等。
      Automating Excel is not supported under asp.net, you'll need to use some other way to manipulate your Excel files such as EPPlus, XML SDK, Aspose, Excel ODBC Driver etc.


      错误0x80040154是Class not registered。



      要知道哪个类没有注册,我们必须从你的错误信息中知道CLSID。



      因为它在尝试使用Excel时发生Interop,我猜你的系统上没有(正确)安装Excel。然后解决方案是执行Excel / Office设置以(重新)安装/修复。
      Error 0x80040154 is "Class not registered".

      To know which class is not registered, we would have to know the CLSID from your error message.

      Because it occurs when trying to use Excel Interop, I guess that Excel is not (properly) installed on your system. Then the solution is to execute the Excel / Office setup to (re-)install / repair.


      这篇关于由于以下错误,检索具有clsid ...的组件的COM类工厂失败:80040154的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆