Gridview导出Excel时中文乱码问题
网上有挺多Gridview导出Excel的代码,大体内容都一样
版本一
...
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8)+".xls");
Response.ContentEncoding = System.Text.Encoding.UTF8;
...
版本二
...
Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName + ".xls");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
...
版本三
...
Response.ContentEncoding = System.Text.Encoding.UTF7;
...
前提:web.config中添加了<globalization requestEncoding="gb2312" responseEncoding="gb2312"/>
现状:版本一和版本二我都试成功过,版本三从来没成功过
问题:为什么有的时候版本一会乱码,有的时候版本二会乱码,原因是什么?请高手帮忙解释一下,o(∩_∩)o...谢谢!
版本一
...
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8)+".xls");
Response.ContentEncoding = System.Text.Encoding.UTF8;
...
版本二
...
Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName + ".xls");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
...
版本三
...
Response.ContentEncoding = System.Text.Encoding.UTF7;
...
前提:web.config中添加了<globalization requestEncoding="gb2312" responseEncoding="gb2312"/>
现状:版本一和版本二我都试成功过,版本三从来没成功过
问题:为什么有的时候版本一会乱码,有的时候版本二会乱码,原因是什么?请高手帮忙解释一下,o(∩_∩)o...谢谢!
...全文
相关推荐
导出excel汉字乱码以及GridView分页问题
本资源给出了解决导出excel汉字乱码以及GridView分页问题的方法,希望对你有帮助
ASP.NET中把Gridview导出为EXCEL
ASP.NET中把Gridview导出为EXCEL,解决中文乱码问题,详情请看视频
解决gridview的excel导出问题
解决gridview的excel导出问题! 值得下载看看!资源免费,大家分享!! 更多免费资源 http://ynsky.download.csdn.net/
asp.net实现Gradview绑定数据库数据并导出Excel的方法
主要介绍了asp.net实现Gradview绑定数据库数据并导出Excel的方法,涉及asp.net操作Gradview实现数据库绑定及数据导出的相关技巧,非常简单实用,需要的朋友可以参考下
Gridview导入到excel代码
Gridview导入到excel代码,实现把excel的单元格类型设置为文本型,即0010可以正常显示,不在是显示为10


