我们正在出口来自网站的应用程序的一些数据到Excel小号preadsheet,然而,当一个英镑符号使用,而不是输出£9.99加入它产生的A£9.99加入。
We're exporting some data from a website app into an Excel spreadsheet, however, when a GBP symbol is used, instead of outputting "£9.99" it produces "£9.99".
这里的codeA的同事写了生产的S preadsheet [tableOut是一个包含一个HTML表一个StringBuilder]:
Here's the code a colleague has written to produce the spreadsheet [tableOut is a StringBuilder that contains an HTML table]:
string filename = "EngageReplies.xls";
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader( "content-disposition", "attachment;filename=" + filename );
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.EnableViewState = false;
Response.Write( tableOut );
Response.End();
任何想法,我们如何才能得到需要的结果?
Any ideas how we can get the desired output?
P.S。不知道我是否应该分开处理成一个单独的问题,但产生的S preadsheet时,一条警告消息触发:
p.s. Not sure if I should separate this into a separate question, but when the spreadsheet is generated, a warning message is triggered:
正在试图打开该文件, 'EngageReplies.xls',是在不同的 比由文件指定的格式 扩展。验证该文件不 损坏,是来自可信源 之前打开文件。你想要吗 现在打开文件?
The file you are trying to open, 'EngageReplies.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?
我用Firefox和IE浏览器打开与Office文件2007单击是打开该文件还行,但我会preFER,如果我的用户没有受到它。
I've used Firefox and IE to Open the file with Office 2007. Clicking Yes opens the file okay, but I would prefer it if my users weren't subjected to it.
推荐答案
啊哈!
首先,我试图消除字符集和的characterEncoding,但仍然得到了错误的输出,所以后来我将它们设置为以下内容,它工作正常:
First I tried removing the Charset and CharacterEncoding, but still got the wrong output, so then I set them to the following and it has worked correctly:
Response.Charset = "";
Response.ContentEncoding = System.Text.Encoding.Default;
谢谢你的灵感罗兰!
Thanks for the inspiration Rowland!
相关推荐
最新文章