(急)DataGrid导出为Excel (Anthem)
Cwst 2006-12-30 04:50:04 DataGrid1,Button1都是Anthem的。
页面只是闪一下,确没有导出?
知道的请赐教,谢谢!
private void Button1_Click(object sender, EventArgs e)
{
ExportOut();
}
[Anthem.Method]
public void ExportOut()
{
Response.Clear();
Response.Buffer= true;
Response.Charset="UTF-8";
Response.AppendHeader("Content-Disposition","attachment;filename=Excel.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("UTF-8");
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("EN-US",true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.DataGrid1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
}