Updatepanel 中导出excel的解决办法

来源:互联网 发布:jquery链式编程 编辑:程序博客网 时间:2024/06/15 03:15

(1)在UpdatePanel中加以下代码  (测试过可以的):

   


ControlID为你导出Excel的按钮

(2)另外一种办法(没有测试过)

        GridView1.EnableViewState = false;         HttpContext.Current.Response.Charset = "GB2312";         HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF7;         HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());         HttpContext.Current.Response.ContentType = FileType;         this.EnableViewState = false;         StringWriter tw = new StringWriter();         HtmlTextWriter hw = new HtmlTextWriter(tw);         GridView1.RenderControl(hw);         HttpContext.Current.Response.Write(tw.ToString());         HttpContext.Current.Response.End();