I would like to add text to a cell with a carriage return. I’ve tried using “\r\n”, “\r” and “\n” but none of them seem to work. How can I accompish this?
Cell.PutValue(“line1 \r\n line2”);
Hi,
Thanks for considering Aspose.
Well, you may use Style.IsTextWrapped property for your need.
I write the following sample code which may help you.
// Create a Workbook.
Workbook wb = new Workbook();
// Get the first sheet of the Workbook.
Worksheet sheet = wb.Worksheets[0];
// Put a text to F11 Cell.
sheet.Cells[10,5].PutValue("This is testing Wrapping\nText 123");
// Set the width of the column F
sheet.Cells.SetColumnWidth(5,25);
// Set the height of the row
sheet.Cells.SetRowHeight(10,28);
// Get the style of the cell
Style style = sheet.Cells["F11"].Style;
// Wrap the Text of the Cell.
style.IsTextWrapped = true;
// Save the excel file
wb.Save("d:\\test\\tstwraptext.xls");
Thank you.