日期:2014-05-17 浏览次数:20836 次
public override void VerifyRenderingInServerForm(Control control) { } protected void LinkButton2_Click(object sender, EventArgs e) { Response.Clear(); Response.Buffer = true; Response.Charset = "gb2312"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); Response.AppendHeader("content-disposition", "attachment;filename=\"" + System.Web.HttpUtility.UrlEncode("数据导出", System.Text.Encoding.UTF8) + ".xls\""); Response.ContentType = "Application/ms-excel"; System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); this.Label1.RenderControl(oHtmlTextWriter); this.GridView1.RenderControl(oHtmlTextWriter); Response.Output.Write(oStringWriter.ToString()); Response.Flush(); Response.End(); }