CSV for Excel, Including Both Leading Zeros and Commas

后端 未结 12 952
再見小時候
再見小時候 2020-12-02 18:45

I want to generate a CSV file for user to use Excel to open it.

If I want to escape the comma in values, I can write it as \"640,480\".

If I want to keep the

12条回答
  •  执念已碎
    2020-12-02 19:34

    Since no-one mentioned it already, figured it was worth mentioning it in this old post.

    If you add a horizontal tab character \t before the number, then MS Excel will also show the leading zero's. And the tab character doesn't show in the excel sheet. Even if it's surrounded by double-quotes. (F.e. \"\t001,002\")

    It also looks nicer in Notepad++, compared to putting a \0 aka NULL before such number.

提交回复
热议问题