应将ApplicationClass.Quit(); 放在所有的
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);后面,如:
if (xlApp != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);
xlApp = null;
}
workBook.Close(false, null, null);
xlApp.Workbooks.Close();
xlApp.Quit(); //自动打开Excel,抛异常