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

前端 未结 3 1748

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:31

    This is the result of my testing with Excel 2013.

    If you're stuck with UTF-8, there is a workaround which consists of BOM + data + sep=;

    Input (written with UTF8 encoding)

    \ufeffSome;Header;Columns
    Wîth;Fàncÿ;Stûff
    sep=;
    

    Output

    |Some|Header|Columns|
    |Wîth|Fàncÿ |Stûff  |
    |sep=|      |       |
    

    The issue with solution is that while Excel interprets sep=; properly, it displays sep= (yes, it swallows the ;) in the first column of the last row.

    However, if you can write the file as UTF16-LE, then there is an actual solution. Use the \t delimiter without specifying sep and Excel will play ball.

    Input (written with UTF16-LE encoding)

    \ufeffSome;Header;Columns
    Wîth;Fàncÿ;Stûff
    

    Output

    |Some|Header|Columns|
    |Wîth|Fàncÿ |Stûff  |
    

提交回复
热议问题