sep=“;” statement breaks utf8 BOM in CSV file which is generated by XSL

前端 未结 3 1750

I\'m currently developing CSV export with XSLT. And CSV file will be used %99 percent with Excel in my case, so I have to consider Excel behavior.

My first problem

3条回答
  •  [愿得一人]
    2020-12-08 05:15

    You are right, there is no way in Excel 2007 to get it load both the encoding and the seperator correctly across different locales when someone double clicks a CSV file.

    It seems like when you specify sep= after the BOM it forgets the BOM has told it that it is UTF-8.

    You have to specify the BOM because in certain locales Excel does not detect the seperator. For instance in danish, the default seperator is ;. If you output tab or comma seperated text then it does not detect the seperator and in other locales if you seperate with semi-colon it doesn't load. You can test this by changing the locae format in windows settings - excel then picks this up.

    From this question: Is it possible to force Excel recognize UTF-8 CSV files automatically?

    and the answers it seems the only way is to use UTF16 le encoding with BOM.

    Note also that as per http://wiki.scn.sap.com/wiki/display/ABAP/CSV+tests+of+encoding+and+column+separator?original_fqdn=wiki.sdn.sap.com it seems that if you use utf16-le with tab seperators then it works.

    I've wondered if excel reads sep=; and then re-calls the method to get the CSV text and loses the BOM - I've tried giving incorrect text and I can't find any work around that tells excel to take both the sep and the encoding.

提交回复
热议问题