我将asp.net页面的数据到入到excel中,存到服务器中的一个临时文件中,可是现在当我转换完成后无法结束excel进程,这样每次都为遗留进程导致服务器excel.exe进程越来越多,请教下为什么,怎么解决?
 注:
Application app = new Application();   
WorkbookClass WorkBook = (WorkbookClass)app.Workbooks.Open(PhysicNewCopyFile, true, 
            0,true, false, false, true, true, true, true, true, true, true, true, true);
Worksheet WorkSheet = null;
WorkSheet = (Worksheet)WorkBook.Worksheets[sheetIndex];   
.....
...
.....
WorkBook.Save();
WorkBook.Close(true, PhysicNewCopyFile, true);       
app.Quit();

解决方案 »

  1.   

    System.Runtime.InteropServices.Marshal.ReleaseComObject( app );
    ObjCatalogClass = null;
    GC.Collect();-------------
    不知道能不能关闭。估计是不能。
    ---------
    记得以前看过一遍文章,上面说不能关闭进程有可以是工作区没有关闭导致的。楼主可try一下
      

  2.   

    m_Excel.Quit();
    m_Excel=null;
    GC.Collect();
    如果是window 2003这也是关闭不掉的
    需要
    在管理工具->组件服务->DCOM->MICROSOFT EXCEL->属性->安全->访问权限里要加上everyone
      

  3.   

    2种方法我都试过了都不行。我用的是2000server系统,当我在vs中调试的时候,进程都能正常结束,但是从IE直接访问就无法结束进程,是不是哪个地方设置有问题呢?