C#中文显示乱码问题。

我看了下没发现什么问题,现把代码发出来求高手解答
#region private void ExportToExcel()
private void ExportToExcel()
{
Response.Clear();
Response.Buffer = true;
Response.Charset = "utf-8";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + strModuleName + ".xls");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.ContentType = "application/ms-excel";
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter sw = new System.Web.UI.HtmlTextWriter(oStringWriter);
try
{
////////////////////////////////////////////////////////////////////////////////////

第1个回答  2016-02-12
把这条 StreamReader reader = new StreamReader(textfile, Encoding.Default); 改成 StreamReader reader = new StreamReader(textfile, Encoding.GetEncoding("gb2312")); 试试看。追问

你说的时把Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");改成StreamReader reader = new StreamReader(textfile, Encoding.GetEncoding("gb2312")); 这个吗?

本回答被网友采纳
第2个回答  2021-04-05

securecrt乱码怎么办

相似回答