请大虾帮忙,我用c#通过web方式打开excel文件然后,关闭文件,释放com对象,但是进程中怎么还出现excel.详细代码.
iif 2006-10-11 10:19:29 代码如下:
string ExcelFile=@"E:\tmp\template.xls";
object oMissiong;
Excel.Workbooks myBooks;
Excel.Workbook myBook;
Excel.Worksheet mySheet;
Excel.Application myApp=new Excel.ApplicationClass();
myApp.Visible = false;
oMissiong = System.Reflection.Missing.Value;
myBooks= myApp.Workbooks;
myBook = myBooks.Open(ExcelFile,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong);
mySheet=(Excel.Worksheet)myBook.Sheets[1];
if(myBook != null)
myBook.Close(true, ExcelFile, oMissiong);
// Quit Excel and clean up.
if(mySheet != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject (mySheet);
mySheet = null;
if(myBook != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject (myBook);
myBook = null;
if(myBooks != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject (myBooks);
myBooks = null;
if(myApp != null)
{
myApp.Workbooks.Close();
myApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject (myApp);
myApp = null;
}
GC.Collect();