How do I best generate a CSV (comma-delimited text file) for download with ASP.NET?

后端 未结 8 1168
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 18:46

This is what I\'ve got. It works. But, is there a simpler or better way?

One an ASPX page, I\'ve got the download link...



        
相关标签:
8条回答
  • 2020-12-14 19:28

    If you want a colon delimited value converter then there is a 3rd party open source called FileHelpers. I'm not sure about what open-source license it is under, but it has helped me quite a lot.

    0 讨论(0)
  • 2020-12-14 19:35

    In addition to what Simon said, you may want to read the CSV how-to guide and make sure your output doesn't run across any of the gotchas.

    To clarify something Simon said:

    Then surround this by quotes if you want

    Fields that contain doubled up double quotes ("") will need to be completely surrounded with double quotes. There shouldn't be any harm in just wrapping all fields with double quotes, unless you specifically want the parser to strip out leading and trailing whitespace (instead of trimming it yourself).

    0 讨论(0)
提交回复
热议问题