打开并读取 Excel 文件后无法终止 EXCEL.EXE 进程
我通过以下流程打开并从 Excel 中读取数据:
ApplicationClass objApp = new ApplicationClass();
Workbooks objBooks = objApp.Workbooks;
Workbook objBook = objBooks.Open(..)
// Do something (read data...)
...
objBook.Close(false, Missing.Value, Missing.Value);
objApp.Quit();
Marshal.ReleaseComObject(objBooks);
Marshal.ReleaseComObject(objBook);
Marshal.ReleaseComObject(objApp);
objBook = null;
objApp = null;
GC.Collect();
GC.WaitForPendingFinalizers();
但是在上述过程之后,我检查任务管理器,EXCEL.EXE 进程仍然存在,不要被杀死。请告诉我原因,帮我解决一下!!!
I open and read data from excel by below flow:
ApplicationClass objApp = new ApplicationClass();
Workbooks objBooks = objApp.Workbooks;
Workbook objBook = objBooks.Open(..)
// Do something (read data...)
...
objBook.Close(false, Missing.Value, Missing.Value);
objApp.Quit();
Marshal.ReleaseComObject(objBooks);
Marshal.ReleaseComObject(objBook);
Marshal.ReleaseComObject(objApp);
objBook = null;
objApp = null;
GC.Collect();
GC.WaitForPendingFinalizers();
But after above process, i check in Task Manager, EXCEL.EXE process still alive, don't be killed. Please tell me why, help me a solution!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这段代码怎么样?
在您完成所有代码之后,当您认为不需要
excel
文件时,请编写此代码How about this code
After all your code and when you think there is no need of
excel
file write this code