我明白了
Quattrode®
从HTML编码为
Quattrode®
在Excel 2007中查看时。
例行程序
Response.Clear();
Response.Buffer = true;
Response.ContentType = "text/comma-separated-values";
Response.AddHeader("Content-Disposition", "attachment;filename=\"Expired.csv\"");
Response.RedirectLocation = "export.csv";
Response.Charset = "";
//Response.Charset = "UTF-8";//this does not work either.
EnableViewState = false;
ExportUtility util = new ExportUtility();
Response.Write(util.DataGridToCSV(gridViewExport, ","));
基本上
DataGridToCSV()
使用HttpUtility.HtmlDecode(stringBuilder.ToString());
并且我可以使用visual studio的文本可视化工具,看到字符串看起来是正确的(Quattrode)。因此
Response
过程或Excel对文件的解释中的某些内容是不正确的。知道怎么修吗?更新
结果发现这在Excel或WordPad中没有正确解释。我在记事本里打开它,符号就显示出来了。
最佳答案
所以试试这个
Response.ContentEncoding = Encoding.UTF32;
关于c# - 如何对CSV导出进行HTML编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6444926/