首页 新闻 会员 周边

导出到CSV文件乱码的问题

0
悬赏园豆:50 [已关闭问题]

我是英文系统,代码如下,即使我把编码方式改成GB2312也还是乱码,怎么解决
                  response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", strFile));
                response.Charset = "utf-8";
                response.ContentType = "application/ms-excel";
                response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                response.Write(sw);
                response.Flush();
                response.End();

绝体绝命的主页 绝体绝命 | 初学一级 | 园豆:150
提问于:2009-03-18 13:40
< >
分享
其他回答(2)
0

不太懂,给你看个东西,希望有帮助!http://zhidao.baidu.com/question/23545761.html

子夜星辰 | 园豆:1613 (小虾三级) | 2009-03-18 13:57
0

不要直接把 CSV 文件输出出去,可以先把CSV  文件读入到字符串中再  response

参考下面文章,他做了和你类似的事情

http://www.devtoolshed.com/node/56

eaglet | 园豆:17139 (专家六级) | 2009-03-18 14:34
0

response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", strFile));
Response.ContentType = "application/excel";

这两句改为:
Response.Write("<meta http-equiv=Content-Type content=text/html;charset=gb2312>");
Response.AppendHeader("content-disposition", "attachment;filename=\"" + System.Web.HttpUtility.UrlEncode("中文名", System.Text.Encoding.UTF8) + ".xls\"");
使用类似的方法试试看
生鱼片 | 园豆:5757 (大侠五级) | 2009-03-18 20:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册