Line break in cell not working

I am trying to wrap two strings in one cell with a line break between those two strings.

Expected result:

stringA
stringB


Actual result:

stringAstringB


I am using this code:

worksheet.Range[$"B{row}"].CellStyle.WrapText = true;

worksheet.Range[$"B{row}"].Text = stringA + "/n" + stringB;

// I now it's not / but \, but this textbox doesn't allow \ for some reason 

I also tried to format the string, to use new line (environment var) and to use cell value. None of these solutions worked,


Thanks for your he


1 Reply

KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team October 1, 2021 07:13 AM UTC

Hi Antonio, 

Greetings from Syncfusion. 

We suggest you to set the Text in below format to achieve your requirement. 

Code Snippet: 

sheet.Range["A1"].CellStyle.WrapText = true;  
sheet.Range["A1"].Text = String.Format("StringA\nStringB"); 

Please go through the below link. 

Kindly try the suggestion and let us know if this helps. 

Regards, 
Keerthi. 


Loader.
Up arrow icon