CSV for Excel, Including Both Leading Zeros and Commas

后端 未结 12 933
再見小時候
再見小時候 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:30

    All the suggested answers don't seem to work for me right now ("=""blahblah""" and others) in all current Excel versions or Numbers app on OS X.

    The only solution I found to be working by fiddling around is to add an escaped null character at the beginning of the string (which is \0 in PHP or C based languages). Everything ends up treated as is without being calculated or processed by the software when opening the calc sheet.

    echo "\0" . $data;
    

提交回复
热议问题