【www.gdgbn.com--excel】

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.gdgbn.com/bangongshuma/4305/