How should I escape commas and speech marks in CSV files so they work in Excel?

后端 未结 5 1155
说谎
说谎 2020-11-29 00:20

I\'m generating a CSV file (delimited by commas rather than tabs). My users will most likely open the CSV file in Excel by double clicking it. My data may contain commas and

5条回答
  •  清酒与你
    2020-11-29 00:29

    Single quotes work fine too, even without escaping the double quotes, at least in Excel 2016:

    'text with spaces, and a comma','more text with spaces','spaces and "quoted text" and more spaces','nospaces','NOSPACES1234'
    

    Excel will put that in 5 columns (if you choose the single quote as "Text qualifier" in the "Text to columns" wizard)

提交回复
热议问题