Line feed option

Apr 1, 2011 at 8: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?

Coordinator
Apr 1, 2011 at 10: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;

Coordinator
Apr 1, 2011 at 11:20 PM

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.