CSV encoding issues (Microsoft Excel)

后端 未结 3 607
一生所求
一生所求 2021-01-04 23:42

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

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-05 00:18

    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));
    

提交回复
热议问题