Writing a CSV file in .net

前端 未结 11 1385
生来不讨喜
生来不讨喜 2020-11-27 18:59

I have a requirement to export a dataset as a CSV file.

I have spent a while searching for a set of rules to go by and realised there are quite a few rules and exce

11条回答
  •  情话喂你
    2020-11-27 19:34

    If there are any commas in your cell, surround the entire cell with double quotes, eg:

    cell 1,cell 2,"This is one cell, even with a comma",cell4,etc
    

    And if you want a literal double quote, do two of them, eg:

    cell 1,cell 2,"This is my cell and it has ""quotes"" in it",cell 4,etc
    

    As for dates, stick to ISO format, and you should be fine (eg yyyy-mm-dd hh:mm:ss)

提交回复
热议问题