tdmichael 2022-08-25 17:47 采纳率: 0%
浏览 247
已结题

C# 调用 EXCEL COM 出错

生成EXCEL 的时候有时候会出错

img

Server Error in '/MTL' Application.
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
Source Error:

Line 1408: {
Line 1409: object missing = System.Reflection.Missing.Value;
Line 1410: Excel.Application excel = new Excel.Application();//lauch excel application
Line 1411: Excel._Workbook xBk = null;
Line 1412: Excel._Worksheet xSt = null;
Source File: e:\SSL\MTL\ApplyMaterialTestEdit.aspx.cs Line: 1410
Stack Trace:
[COMException (0x80080005): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).]
ApplyMaterialTestEdit.UpdateExcel(String strFileName) in e:\SSL\MTL\ApplyMaterialTestEdit.aspx.cs:1410
ApplyMaterialTestEdit.btnExcel_Click(Object sender, EventArgs e) in e:\SSL\MTL\ApplyMaterialTestEdit.aspx.cs:1405
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9796650
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +211
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1696
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4494.0

  • 写回答

16条回答 默认 最新

  • tdmichael 2022-08-25 18:17
    关注

    System.IO.IOException: The process cannot access the file 'E:\SSL\MTL\App_Data\Excel\WLm20220824142.xls' because it is being used by another process.

    评论

报告相同问题?

问题事件

  • 系统已结题 9月2日
  • 创建了问题 8月25日