日期:2014-05-18  浏览次数:20454 次

(特急,在线等.超级郁闷)ASP.NET中常规下用Excel 的.com组件导出为Excel速度超级慢,有无改进方法
各位兄弟,高手朋友们,近日做了一个关于在ASP.NET中导出为Excel的功能,但功能实现后发现这斯速度太慢了,如果导出1000条以下还马马虎虎,如果超出1000条,那速度可真是够慢,让人难以接爱,但是为了输出表格的样式和可控性,又必须用Excel组件.请问各位有什么让速度快些的方法.

听别说在OFFICE2003中用什么方法速度非常快,听说要用到模板,将数据一次复制到模板中.但不知如何实现,特请教高手们,十分感谢,分不多请原谅!在线等!!


------解决方案--------------------
类似于这种方式 public static void ExportExcel(ref System.Web.UI.WebControls.Repeater rp, string strFileName) { // DataTable dt = (DataTable)this.Session[ "GridToExcel "]; // if (dt==null) return; strFileName = System.Web.HttpUtility.UrlEncode(strFileName,System.Text.Encoding.UTF8); //dtgList.DataSource = DataClass.ExecuteDataTable(dtgList.strSQL).DefaultView; //dtgList.EnableViewState =false; System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.Buffer = true; System.Web.HttpContext.Current.Response.Charset = "gb2312 "; System.Web.HttpContext.Current.Response.AppendHeader( "Content-Disposition ", "online; filename= " + strFileName + ".xls "); System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding( "gb2312 "); System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel "; //System.Web.HttpContext.Current.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); //oHtmlTextWriter.Write( " <table width= '100% ' border= '1 '> "); rp.RenderControl(oHtmlTextWriter); //oHtmlTextWriter.Write( " </table> "); rp = null; System.Web.HttpContext.Current.Response.Write(oStringWriter.ToString().Replace( " <td ", " <td STYLE= 'MSO-NUMBER-FORMAT:\\@ ' ")); System.Web.HttpContext.Current.Response.Buffer = false; System.Web.HttpContext.Current.Response.End(); }
------解决方案--------------------
用这个方法试试
http://www.wsoft.net/Index/Catalog53/225.aspx

这个是应用在广域网上的,速度还行啊