如何HTML EN code为csv出口 [英] How to HTML encode a csv export

查看:197
本文介绍了如何HTML EN code为csv出口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到

 Quattrode® 

这是一个字符串,它是HTML EN codeD为

From a string that is HTML encoded as

Quattrode® 

里面的Excel 2007中查看时

when viewing inside 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.HtmlDe code(stringBuilder.ToString()); 和我可以使用Visual Studio的文本可视化和看到字符串看起来是正确的(Quattrode®)。

Basically DataGridToCSV() uses HttpUtility.HtmlDecode(stringBuilder.ToString()); and I can use visual studio's text visualizer and see the string looks correct (Quattrode®).

因此​​,一些在响应程序或文件的Excel的跨pretation是不正确的。任何想法如何解决?

So something in the Response procedure or in Excel's interpretation of the file is not correct. Any idea how to fix?



更新

原来,这是Excel或写字板正确PTED不跨$ P $。我在记事本打开它,符号正确显示出来。


UPDATE
Turns out that this is not interpreted properly in Excel or WordPad. I open it up in Notepad and the symbol shows up properly.

推荐答案

也可以尝试这种

Response.ContentEncoding = Encoding.UTF32;

这篇关于如何HTML EN code为csv出口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆