this.DataGrid1.AllowPaging=false;
Bind(DataGrid1,"select * from [work]");
Response.Clear();
Response.Charset="utf-8"; //输出
string Title = this.Title.Text;
Response.AppendHeader("Content-Disposition","attachment;filename="+System.Web.HttpUtility.UrlEncode(Title)+".xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312"); //设置输出编码
System.IO.StringWriter osw=new System.IO.StringWriter();//new System.IO.StringWriter(myinfo);
System.Web.UI.HtmlTextWriter ohtw=new System.Web.UI.HtmlTextWriter(osw);
DataGrid1.RenderControl(ohtw);
Response.Write(osw);
Response.End();
转载于:https://www.cnblogs.com/epwqgdnvrhok/archive/2009/07/15/1524291.html