Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; EnableViewState = false; System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(tw); Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("统计.xls", System.Text.Encoding.UTF8)); gvData.RenderControl(hw); Response.Write(tw.ToString()); Response.End();
将GridView数据直接导出为EXCEL(保留样式),适用GV不分页的情况,布布扣,bubuko.com
时间: 2024-10-26 11:37:14