在页面指令中更改区域性后,ASP.Net UTF-8 无法正确显示
我设计了一个导出到Excel页面,使用以下代码
数据显示在网格视图中,日期格式为显示为月/日/年 所以我将文化 en-GB 添加到页面指令以将日期显示为 d/M/yyyy
现在的日期正确显示 d/M/yyyy,并且 utf-8 在 gridview 中也能正确显示。
但是,一旦我导出到 Excel,当我从页面指令中删除区域性时,UTF-8 就会出现乱码
,名称显示正确,但是我再次面临 M/d/yyyy 问题。
我的问题是:有没有办法将日期显示为 d/M/yyyy,同时读取正确的 utf-8
任何想法将不胜感激
i designed an export to excel page that uses the following code
the data is displayed in grid view and the date format is displayed as M/d/yyyy
so i added the culture en-GB to page directive to display the date as d/M/yyyy
the date now displays correctly d/M/yyyy, and the utf-8 also display correctly in gridview.
however once i export to excel the utf-8 appears scrambled
when ever i remove the culture from page directives, names display correctly, however i face again the M/d/yyyy issue.
My question is: is there a way to display date as d/M/yyyy and at the same time reading correct utf-8
any ideas will be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您应该采取的措施来解决您的问题
1-从页面指令中删除区域性设置
这将在 Excel 中正确显示阿拉伯语名称,对吗?
2-要解决日期问题,请在gridview aspx代码中执行以下操作
,前面的代码应该插入到 中,它将阻止列自动生成,
现在您需要手动生成列,使用以下代码作为示例
here is what you should do to solve your issue
1-remove culture settings from page directive
this will output correct display of arabic names in excel, right?
2-to solve the date issue do the following in the gridview aspx code
the previous piece of code should be inserted in the , it will prevent column auto-generation
now you need to generate columns manually, use the following code as example