ASP.NET 导出excel文件出现乱码的解决办法

string html =TABLE ;//<table>标签,可以是多张表
string modified = Regex.Replace(html, "<table >", "<table cellspacing="0"  rules="all" border="1" style="border-collapse:collapse;">");//用正则表达式进行规范
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode("文件名称.xls"));
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
Response.ContentType = "application/vnd.ms-excel";
Response.Cache.SetCacheability(HttpCacheability.NoCache); // not necessarily required
Response.Output.Write(modified);
Response.Flush();
Response.End();
原文地址:https://www.cnblogs.com/yh2015/p/5988350.html