`
vern
  • 浏览: 15198 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

C# excel句柄释放

阅读更多

转载自http://topic.csdn.net/u/20081117/11/2cf68184-87b8-4e12-b3b9-b8c2ecf635d8.html

 

powerpoint也一样,"System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);"释放所有引用,最后System.GC.Collect();

C# code
object objmissing = System.Reflection.Missing.Value; Excel.ApplicationClass application = new ApplicationClass(); Excel.Workbook book = application.Workbooks.Add(objmissing); Excel.Worksheet sheet = (Excel.Worksheet)book.Worksheets.Add(objmissing,objmissing,objmissing,objmissing); //操作过程 ^&%&×&……&%&&…… //释放 sheet.SaveAs(path,objmissing,objmissing,objmissing,objmissing,objmissing,objmissing,objmissing,objmissing); System.Runtime.InteropServices.Marshal.ReleaseComObject((object)sheet); System.Runtime.InteropServices.Marshal.ReleaseComObject((object)book); application.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject((object)application); System.GC.Collect();
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics