asp.net 导出Excel 在Firefox中中文乱码的解决方法

来源:互联网 发布:外贸大数据分析 编辑:程序博客网 时间:2024/05/17 09:06

情况1,使用程序集:AppLibrary

            //保存的文件名            #region 解决火狐导出乱码问题            if (Request.ServerVariables["http_user_agent"].ToLower().IndexOf("firefox") != -1)            {                doc.FileName = string.Format("\"{0}\"", ExcelName); //解决Firefox中文文件名乱码            }            else            {                doc.FileName = System.Web.HttpUtility.UrlPathEncode(ExcelName); //解决其他浏览器日期短线-乱码            }            #endregion

情况2,使用response输出html

table.Append("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=utf-8\"></head><body>");
....
table.Append("</body></html>")


原创粉丝点击