using EXCEL=Microsoft.Office.Interop.Excel;
private void Form1_Load(object sender, EventArgs e)
{
EXCEL.Application app = new EXCEL.Application();
EXCEL.Workbooks wbs = app.Workbooks;
EXCEL.Workbook wb = wbs.Add();
wb.Close(false);
app.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(wb); //通知COM控件,释放变量
System.Runtime.InteropServices.Marshal.ReleaseComObject(wbs);//所有用过的变量都要释放
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);//一个也不能少
wb = null;
wbs = null;
app = null;
System.GC.Collect(); //回收资源清内存
}
C#:EXCEL Quit后,EXCEL.EXE进程未退出的情况
最新推荐文章于 2022-09-07 11:24:14 发布