GC.Collect()
我试了这个,也没有用啊:(

解决方案 »

  1.   

    try
    {
    sheet = null;
    sheets = null;
    this.oBook .Close (System.Reflection .Missing .Value ,System.Reflection .Missing .Value,System.Reflection .Missing .Value);
    this.oBook = null;
    oExcel.Quit();
    oExcel = null;
    GC.Collect ();
    }
    catch
    {
    oExcel.Quit();
    oExcel = null;
    GC.Collect ();
    }
    肯定行,我试过了!
      

  2.   

    你最好再你调用这个函数的控件的CLICK事件中调用GC.Collect();
    例如:
    Button_Click(...){
    ...
    GC.Collect();
    }
      

  3.   

    我是自己写一个类来处理Excel的,在类处理完了Excel后再把类=null,才调用GC.Collect()的,成功把Excel进程关了。
      

  4.   

    oExcel.Quit();
    System.Runtime.InteropServices.Marshal.ReleaseComObject(tempRange);
    System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet);
    System.Runtime.InteropServices.Marshal.ReleaseComObject(sheets);
    System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook);
    System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel);oMissing=null;
    sheets=null;
    tempRange=null;
    worksheet=null;
    oBook=null;
    oExcel=null;
    GC.Collect();
    ??我也是看到别人的,不过我没有出现你说的问题
      

  5.   

    我的程序在生成文件后也不能关闭,后来查询资料,据说是Win2000和excel2000版本不够,升级后依然不能关闭。但是后来我发现只要不调用保存就没有问题,因此我现在都是使用Saveas来存盘,然后关闭就没有问题了,你可以试试。