public void DestoryExcel()
{
oBook.Close( false, null, null );
oExcel.Workbooks.Close();
oExcel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject( oRange );
System.Runtime.InteropServices.Marshal.ReleaseComObject( oWorkSheet );
System.Runtime.InteropServices.Marshal.ReleaseComObject( oSheet );
System.Runtime.InteropServices.Marshal.ReleaseComObject( oBook );
System.Runtime.InteropServices.Marshal.ReleaseComObject( oExcel );
oRange = null;
oWorkSheet = null;
oSheet = null;
oBook = null;
oMissing = null;
oExcel = null;
GC.Collect();
}
{
oBook.Close( false, null, null );
oExcel.Workbooks.Close();
oExcel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject( oRange );
System.Runtime.InteropServices.Marshal.ReleaseComObject( oWorkSheet );
System.Runtime.InteropServices.Marshal.ReleaseComObject( oSheet );
System.Runtime.InteropServices.Marshal.ReleaseComObject( oBook );
System.Runtime.InteropServices.Marshal.ReleaseComObject( oExcel );
oRange = null;
oWorkSheet = null;
oSheet = null;
oBook = null;
oMissing = null;
oExcel = null;
GC.Collect();
}
解决方案 »
- 怎样把后台的变量,通过前台的超链接问号后的变量传到其它页面?
- 文本框onfocus在ie8下点击第二次才有光标
- 代码填写题!
- html基础问题
- sqldatasource和gridview结合删除数据时,如何屏蔽错误、异常信息?
- 用ADSL上网的没固定IP的电脑建立一个支持ASP.NET网站
- 在treeView里如何取得节点等级以及它的父节点的数据?
- 有关Asp.Net和IIS的兼容性问题(急啊)
- 请教:如何在一个图片的左上角生成一个编号,不用层,用GDI的那种?最好可给个源码
- ===怎样点击一按钮弹出一窗口,这个窗口是我用来放时间控件的===
- 救急!!!!无法结束Excel进程,请指点!!!
- 请教高人:怎样保证页面打开时是全屏!谢谢了!!
Missing.Value ,Missing.Value ,Excel.XlSaveAsAccessMode.xlNoChange,Missing.Value ,Missing.Value ,Missing.Value ,
Missing.Value );
workBook.Saved = true;
workBook.Close(false,null,null);
exApp.UserControl = false;
exApp.Quit ();
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(workSheet);
}
catch(Exception e1)
{
System.Diagnostics.Debug.WriteLine(e1.Message);
}
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(workBook);
}
catch(Exception e2)
{
System.Diagnostics.Debug.WriteLine(e2.Message);
}
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(exApp);
}
catch(Exception e3)
{
System.Diagnostics.Debug.WriteLine(e3.Message);
}
workSheet = null;
workBook = null;
exApp = null;
System.GC.Collect();