This project has moved and is read-only. For the latest updates, please go here.

Line feed option

Apr 1, 2011 at 9:33 AM

In Excel we can apply the Line feed option to a column or to a row, so a text which is:

"bla bla bla \n bla bla bla"

can be transofrmed like:

"bla bla bla

bla bla bla"

Is there any property to do the same thing?

Apr 1, 2011 at 11:17 PM

You need to turn wrap text on for Excel to recognize the new line feeds. When editing a cell in Excel if you press Alt + Enter, Excel will automatically turn on wrap text for you.

For example:

            // In one shot
            worksheet.Cell(1, 1).SetValue(String.Format("Hello{0}World", Environment.NewLine)).Style.Alignment.SetWrapText();

            // The usual way
            var cell = worksheet.Cell(1, 1);
            cell.Value = String.Format("Hello{0}World", Environment.NewLine);
            cell.Style.Alignment.WrapText = true;

Apr 2, 2011 at 12:20 AM

You know what, I feel that you shouldn't be worrying about the wrap text flag using this library, just like you don't have to worry about it in Excel.

The next release will set the wrap text flag automatically when you give a cell a text that has an Environment.NewLine.