.net 调用Excel 这样关闭进程


环境:

windows server 2008r2 
iis7.5
.net4.0

/*这样流程后 Excel进程不再滞留*/

经反复测试,终于可以关闭了,里面有些代码也许多余,以后继续完善测试


            book.Save();

            book.Close(false, missing, missing);

            
           
              xlApp.Workbooks.Close();
              sheet = null;

              Marshal.ReleaseComObject(book);
              book = null;
            
             
              int generation = System.GC.GetGeneration(xlApp);
 
              xlApp.Quit();
              Marshal.ReleaseComObject(xlApp);

 
              System.GC.Collect(generation);
              xlApp = null;

 

 

 


豫ICP备12024565号-1   E-mail:admin@hlc8.com