How to insert programmatically a new line in an Excel cell in C#?

User picture User · Jul 24, 2009 · Viewed 123k times · Source

I'm using the Aspose library to create an Excel document. Somewhere in some cell I need to insert a new line between two parts of the text.

I tried "\r\n" but it doesn't work, just displays two square symbols in cell. I can however press Alt+Enter to create a new line in that same cell.

How do I insert a new line programmatically?

Answer

Ahmad Mageed picture Ahmad Mageed · Jul 24, 2009

From the Aspose Cells forums: How to use new line char with in a cell?

After you supply text you should set the cell's IsTextWrapped style to true

worksheet.Cells[0, 0].Style.WrapText = true;