Writing a CSV file in .net

前端 未结 11 1387
生来不讨喜
生来不讨喜 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:30

    I found this important link which is quite neat. Haven't tried it yet, will let you know how it goes!

    http://www.codeproject.com/KB/linq/LINQtoCSV.aspx

    Looking more closely, this implementation essentially only uses basic rules too:

    special chars = \n \" and the separator char.

    if found special characters, then surround with quotes. Replace quote with double quote.

    Essentially the rules Chris mentioned. I think the easiest way to do this is to create my helper method based on the simple rules and revise on a user-needs basis.

提交回复
热议问题