最新的导出文档方法



// 最新的导出文档方法
说明:参数 dt 可以是Html字符串

public void ExportToExcel(string FieldType, string FileName, string dt) { System.Web.HttpContext.Current.Response.Charset = "utf-8"; System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString()); System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); System.Web.HttpContext.Current.Response.ContentType = FieldType; StringWriter tw = new StringWriter(); System.Web.HttpContext.Current.Response.Output.Write(dt); System.Web.HttpContext.Current.Response.Flush(); System.Web.HttpContext.Current.Response.End(); }
原文地址:https://www.cnblogs.com/ly77461/p/6934634.html