public override void VerifyRenderingInServerForm(Control control) { } protected void Unnamed1_Click(object sender, EventArgs e) { string FileName = "用稿统计表"; Response.Clear(); Response.Buffer = true; Response.Charset = "utf-8"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName) + ".xls"); Response.ContentEncoding = System.Text.Encoding.UTF8; Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); pannel.RenderControl(oHtmlTextWriter); //pannel为其容器ID Response.Output.Write(oStringWriter.ToString()); Response.Flush(); Response.End(); }