0

Edit

I don't believe this is an duplicate.....If you read the first 5 words("I'm using the Aspose library"). You will see he is using some 3rd party library. I am not. I am rendering a csv file that I want to open in excel.


I a C# application that generates a csv file. When I open up the csv file I notice that in columnA my text is in a single line. I would like to break it up into multiple lines(still in the same column).

I know if I use alt + enter in excel that will make new lines.

I know if I press enter in notepad++ it makes a label of (CR LF).

What code can I use to make it so I can have new lines that I can inject into my strings when in my C# application?

I tried

\n
\n\r
Enivroment.NewLine

Nothing works.

chobo2
  • 83,322
  • 195
  • 530
  • 832
  • For clarification: in NP++ you _can_ customize what it uses for newlines. CRLF is a likely default. – TheZ Aug 10 '12 at 18:35
  • I am probably using the default as I did not know it could be changed. – chobo2 Aug 10 '12 at 18:36
  • In the end it seems like Excel respects whatever notepad++ is using but when I try to inject it through c# code to make new lines it treats it as string value. – chobo2 Aug 10 '12 at 18:37
  • LineFeed (Ascii char 10) should do it. Try saving an example csv from excel and confirm that's what it uses... – Tim Williams Aug 10 '12 at 19:08
  • Notepad marks it as LF. So how do I use Ascii char 10 in a string and still have it recognize it as a code? – chobo2 Aug 10 '12 at 19:10
  • (char)10 should work. It's the same as newline though, which you said didn't work when you tried it. Maybe there's something else going on? – Tim Williams Aug 10 '12 at 21:02

0 Answers0