How to add text with a newline in it?

If I set text in an excel workbook that has a newline in it, the resulting workbook just shows a square where the \n was in the source text.

I am using

string myStr = "hello\nthere";
IRange.Text = myStr;

How can I make this work?

1 Reply

MW Melba Winshia Syncfusion Team December 21, 2006 10:54 AM UTC

Hi Daniel,

Could you Please try using \n inserted at the place where you need the line break and set the WrapText property to true.

[C#]

// New Line
sheet.Range["A1"].Text = "Hello\nWorld";
sheet.Range["A1"].CellStyle.WrapText= true;

Here is the sample for your reference:
WrapText.zip


Please take a look at the sample above and let me know if you have any other questions.

Best Regards,
Melba






Loader.
Up arrow icon