.....................
......................
DataGrid1.DataBind();
数据绑定!
Response.Clear();
Response.Buffer=true;
Response.ContentType="application/vnd.ms-excel";
Response.Charset="";
this.EnableViewState=false;
System.IO.StringWriter sw = new StringWriter();
HtmlTextWriter htw=new HtmlTextWriter(sw);
DataGrid1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();