服务器 导出excel

    技术2022-05-20  46

    System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw); this.reptStaff.RenderControl(hw); Response.Clear(); Response.ContentType = "application/vnd.ms-excel"; Response.Charset = ""; Page.EnableViewState = false; Response.AppendHeader("Content-Disposition", "attachment;filename=Teacher.xls"); Response.Write("<html><head><meta http-equiv=Content-Type content=/"text/html; charset=utf-8/"><title> Copyright by SDU</title></head><body><center>"); Response.Write(sw.ToString()); Response.Write("</center></body></html>"); Response.End(); //防止服务器控件导出exce时报错 public override void VerifyRenderingInServerForm(Control control)    {    } 

    最新回复(0)