在这里不讨论那种声称html格式的数据然后更改扩展名的方式。
您给出的办法一定要在发布到IIS的站点上测试过在发上来。谢谢
另外:不管是讨论杀进程的方式还是其他方式,一定要发布到测试站点上进行,不能在VS项目中直接运行Web(关于DCOM组件权限的问题已经解决了),因为在VS项目中直接运行web程序和IIS方式的测试站点来运行对组件的权限解释方式不一样(具体的不清楚,但是肯定有很大的区别,因为发布到测试站点上取进程的Process.StartTime会抛出异常
Excel是通过Microsoft.Office.Interop.Excel.ApplicationClass方式new出来的。
简单说,下面的代码不起作用             finally
            {
                ((MicroExcel._Application)tempApp).Workbooks.Close();
                Int32 tempGeneration = GC.GetGeneration(tempApp);
                ((MicroExcel._Application)tempApp).Quit();
                GC.Collect(tempGeneration);
                //上面部分在Winform中就已经干掉EXCEL进程了,但是在asp.net中还不行           
                Process[] myProcesses;
                myProcesses = Process.GetProcessesByName("Excel");                //得不到Excel进程ID,暂时只能判断进程启动时间
                foreach (Process myProcess in myProcesses)
                {
                    try
                    {
                        DateTime startTime = myProcess.StartTime;                        if (startTime >= tempStart && startTime <= tempEnd)
                        {
                            myProcess.Kill();
                        }
                    }//直接在VS中运行网页就不会有取不到StartTime的问题
                    catch//有一些核心进程是不允许访问的,因此而引起的异常可以捕获并放弃处理
                    { } 
                }
                     
            }

解决方案 »

  1.   


            程序开始时执行次
            GC.Collect();
            ApplicationClass excel;
            _Workbook xBk;
            _Worksheet xSt;
            excel = new ApplicationClass();
            xBk = excel.Workbooks.Add(true);
            xSt = (_Worksheet)xBk.ActiveSheet;
               //自定义代码...
            //结束时
            xBk.Close(false, null, null);
            excel.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xBk);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xSt);
            xBk = null;
            excel = null;
            xSt = null;
      

  2.   


    接上在加上GC.Collect();
      

  3.   

    如上面方法无法结束excel进程联系我
      

  4.   

    http://www.cnblogs.com/bboy/archive/2007/12/19/1005768.html
      

  5.   

    写成windows服务呢?我没试,猜的,您可以忽略
      

  6.   


           程序开始时执行次
            GC.Collect();
            ApplicationClass excel;
            _Workbook xBk;
            _Worksheet xSt;
            excel = new ApplicationClass();
            xBk = excel.Workbooks.Add(true);
            xSt = (_Worksheet)xBk.ActiveSheet;
               //自定义代码...
            //结束时
            xBk.Close(false, null, null);
            excel.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xBk);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xSt);
            xBk = null;
            excel = null;
            xSt = null;
            GC.Collect();怎么可能,我做了半年多excel报表操作,从没有杀不掉的excel进程
      

  7.   

    须要在进程完全导出后在进行传说中的导出        /**自定义代码结束**/
            string sTimes = DateTime.Now.ToString("yyyyMMddHHmmss");
            string strFileName = "";
            System.IO.FileInfo file;
            strFileName = Server.MapPath("Uploads/qafiles/") + sTimes + ".xls";
            xBk.SaveCopyAs(strFileName);
            xBk.Close(false, null, null);
            excel.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xBk);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xSt);
            xBk = null;
            excel = null;
            xSt = null;
            //听说你是***中最好的一种,可为什么如此善良的你,却无情的闯了进来
            GC.Collect();
            file = new System.IO.FileInfo(strFileName);
            Response.Clear();
            Response.Charset = "GB2312";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
            Response.AddHeader("Content-Length", file.Length.ToString());
            Response.ContentType = "application/ms-excel";
            Response.WriteFile(file.FullName);
            Response.End();
      

  8.   

    把站点的application pool用administrastor运行
    xlApp.Workbooks.Close();
      xlApp.Quit();
      System.Runtime.InteropServices.Marshal.ReleaseComObject(ws);
      System.Runtime.InteropServices.Marshal.ReleaseComObject(wb);
      System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);
      xlApp = null;
      wb = null;
      ws = null;
    System.Diagnostics.Process myproc= new System.Diagnostics.Process();
    foreach (Process thisproc in Process.GetProcessesByName(processName)) {
    if(!thisproc.CloseMainWindow()){
    thisproc.Kill();
    }}
      

  9.   

    谢谢上面热心的朋友,我另开了新帖。里面有源代码,大家可以去看一看。
    到目前为止,在我的源代码上,这个问题还没解决(注意新帖中写的测试环境,一定要发布到IIS上面再验证)
    http://topic.csdn.net/u/20100728/16/1d4b7067-77b7-4c03-bfe3-1a6086fc5582.html
      

  10.   

    自己调试,你还指望别人帮你调通了发给你吗?呵呵。标准写法如下:http://support.microsoft.com/kb/306023当然,如果你采用Open XML格式的话,根本就不用担心这种问题了,因为压根就不会启动excel.exe。
    对于Office 2007以及之后的版本来讲,推荐的方法就是Open XML的方式,参考:http://support.microsoft.com/kb/931866