在退出应用程序后,Excel.exe仍在任务管理器中运行。 我尝试了以下代码:
wb.Save(); //WB is workbook
wb.Close(true);
wbs.Close();
app.Quit(); //Excel application
Marshal.ReleaseComObject(ws);
Marshal.FinalReleaseComObject(ws);
Marshal.ReleaseComObject(wb);
Marshal.FinalReleaseComObject(wb);
Marshal.ReleaseComObject(wbs);
Marshal.FinalReleaseComObject(wbs);
Marshal.ReleaseComObject(app);
Marshal.FinalReleaseComObject(app);
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();