CSV编码问题(Microsoft Excel中) [英] CSV encoding issues (Microsoft Excel)
问题描述
我动态创建使用C#的CSV文件,我遇到了一些奇怪的编码问题。我目前使用的ASCII编码,这在Excel 2010中,这是我在家里和我的工作机器上使用正常工作。但是,客户使用Excel 2007中,对他们也有一些奇怪的格式问题,即认为£号(英镑符号)前面有重音A字。
I am dynamically creating CSV files using C#, and I am encountering some strange encoding issues. I currently use the ASCII encoding, which works fine in Excel 2010, which I use at home and on my work machine. However, the customer uses Excel 2007, and for them there are some strange formatting issues, namely that the '£' sign (UK pound sign) is preceded with an accented 'A' character.
我应该使用什么编码?恼人的是,我几乎不能测试这些补丁,因为我没有访问到Excel 2007!
What encoding should I use? The annoying thing is that I can hardly test these fixes as I don't have access to Excel 2007!
推荐答案
我使用Windows ANSI代码1252没有我明确改变这一点,因为你看到了同样的问题,在Excel 2003中的任何问题。
I'm using Windows ANSI codepage 1252 without any problems on Excel 2003. I explicitly changed to this because of the same issue you are seeing.
private const int WIN_1252_CP = 1252; // Windows ANSI codepage 1252
this._writer = new StreamWriter(fileName, false, Encoding.GetEncoding(WIN_1252_CP));
这篇关于CSV编码问题(Microsoft Excel中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!