Search code examples
c#export-to-csv

how to use comma in csv columns


Possible Duplicate:
Dealing with commas in a CSV file

We are exporting a bulk data into a csv file for one of our projects. So in this case we have to export values like a,b,c,d which all have to be remain in one column. But the comma will separate them to different columns.

Like if we export some values entered in textarea or editor which contains character like \r\n will be exported as separate rows in csv. How can i solve this problem??


Solution

  • The most common way to handle this is to use "" around the field, but depending on who is consuming your files it can be handled in a number of ways. You can delimit the commas, you can change the commas to a special value or use a different delimiter, but the most command