DataGrid1导出到Excel.txt

发表于:2007-06-30来源:作者:点击数: 标签:

Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false ;
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(sw);
this.DataGrid1.RenderControl(hw);
Response.Write(sw.ToString());
Response.End();

原文转自:http://www.ltesting.net