1

Creating a CSV file in a winforms application, it is to be improted into Excel.

The file output looks like:

"header1", "header2", "header3", 1,2,3, 4,5,6

What should I use to signify a newline character when generating the CSV file?

0

4 Answers 4

6

I'd suggest using Environment.NewLine.

Sign up to request clarification or add additional context in comments.

Comments

1

RFC 4108

While there are various specifications and implementations for the CSV format (for ex. [4], [5], [6] and [7]), there is no formal specification in existence, which allows for a wide variety of interpretations of CSV files. This section documents the format that seems to be followed by most implementations:

  1. Each record is located on a separate line, delimited by a line break (CRLF). For example:

    aaa,bbb,ccc CRLF
    zzz,yyy,xxx CRLF

Comments

0

use \r\n although it will work with just \n

Comments

0

I generally stick with "\n" - because it will be "correct" for the platform on which it is used.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.