用文件流导出,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(); }