服务器 导出excel

来源:互联网 发布:mac 装安卓 编辑:程序博客网 时间:2024/06/18 00:27
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)
    {
    }