用文件流导出,500条记录,只需1秒钟
.net的System.IO支持excel导出private void Button1_Click(object sender, System.EventArgs e)
{
//this.BindDataGrid();
Response.AddHeader("Content-Disposition", "attachment; filename=rsamember");
Response.Charset = "UTF-8";
Response.ContentType = "application/vnd.ms-excel";
//Remove the charset from the Content-Type header.
Response.Charset = "";
//Turn off the view state.
this.EnableViewState= false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
//Get the HTML for the control.
this.DataGrid1.RenderControl(hw);
//Write the HTML back to the browser.
Response.Write(tw.ToString());
//End the response.
Response.End(); }
.net的System.IO支持excel导出private void Button1_Click(object sender, System.EventArgs e)
{
//this.BindDataGrid();
Response.AddHeader("Content-Disposition", "attachment; filename=rsamember");
Response.Charset = "UTF-8";
Response.ContentType = "application/vnd.ms-excel";
//Remove the charset from the Content-Type header.
Response.Charset = "";
//Turn off the view state.
this.EnableViewState= false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
//Get the HTML for the control.
this.DataGrid1.RenderControl(hw);
//Write the HTML back to the browser.
Response.Write(tw.ToString());
//End the response.
Response.End(); }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货