gpt4 book ai didi

c# - 为什么 excel 保持打开状态?

转载 作者:行者123 更新时间:2023-11-30 19:13:58 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to properly clean up Excel interop objects in C#

我有这个函数用来计算一些数据的线性趋势:

private string Trend(object conocido_y, object conocido_x, object nueva_matriz_x)
{
string result = String.Empty;
try {
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
result = ((Array)xlApp.WorksheetFunction.Trend(conocido_y, conocido_x, nueva_matriz_x, true)).GetValue(1).ToString();
xlApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);
xlApp = null;
}
catch (System.Runtime.InteropServices.COMException ex) {
DError.ReportarError(ex, false);
}
catch (Exception ex) {
DError.ReportarError(ex);
}
return result;
}

结果很好,但 excel 应用程序没有关闭,如果我打开任务管理器,进程仍在运行,为什么?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com