你使用多线程试试,把处理导入excel的方法放到多线程里

解决方案 »

  1.   

       楼主,引用EXCEL类库来导出吧!你那个输出文件流的个人感觉对大量数据不大行。EXCEL类库还可以顺便按自己想要的格式输出EXCEL呢,比如合并单元格,作图啊什么的。想看例子的话参考我以前的帖子:http://topic.csdn.net/u/20100325/21/c822a751-a321-4f50-9982-63a503848498.html
      

  2.   

    有个开源的框架NPOI 
    可以试试看
      

  3.   


    DLExitFormManage efm = new DLExitFormManage();
                DataTable dt = efm.GetDLNoNormalExitListDetail("", 1); // 得到要导出的数据
                StringWriter sw = new StringWriter();
                sw.WriteLine("部门\t姓名\t英文名\t工号\t性别\t入职日");
                foreach (DataRow dr in dt.Rows)
                {
                    sw.WriteLine(dr["deptcode"] + "\t" + dr["empcname"] + "\t" + dr["empename"] + "\t" + dr["empid"] + "\t" + dr["gender"] + "\t" +
                        dr["entrydate"]);
                }
                sw.Close();
                Response.AddHeader("Content-Disposition", "attachment;   filename=ExitListDetail.xls");
                Response.ContentType = "application/ms-excel";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
                Response.Write(sw);
                Response.End();
    Excel的最多记录数是int的最大值,再多就要分割了。
      

  4.   

    //filename为Excel的名字,ToExcelGrid就是数据源,在此为DataGrid数据源;private void ExportExcelFromDataGrid( string filename , System.Web.UI.WebControls.DataGrid ToExcelGrid ){    Response.Clear();    Response.Buffer=   true;         Response.Charset="utf-8";               Response.AppendHeader("Content-Disposition","attachment;filename="+Server.UrlEncode ( filename ) );         Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");//设置输出流为简体中文      Response.ContentType   =   "application/ms-excel";//设置输出文件类型为excel文件。        this.EnableViewState   =   false;               System.Globalization.CultureInfo   myCItrad   =   new   System.Globalization.CultureInfo("ZH-CN",true);       System.IO.StringWriter   oStringWriter   =   new   System.IO.StringWriter(myCItrad);         System.Web.UI.HtmlTextWriter   oHtmlTextWriter   =   new   System.Web.UI.HtmlTextWriter(oStringWriter);       ToExcelGrid.RenderControl(oHtmlTextWriter);         Response.Write(oStringWriter.ToString());       Response.End();}
    http://www.csharp360.com/bbs/viewthread.php?tid=142&extra=page%3D1
      

  5.   

    这样不好,如果gridview采用了分页的,那么到出execel也仅仅只有一页,还是用c/s那种导入的模式好