0

Is it possible to add a line break within an excel cell using the GemBox Spreadsheet API? For example if you're in Excel you can press Alt+Enter and go to a new line in a cell. I'm having trouble finding a property on the CellStyle class in GemBox that allows this. Is it possible?

Thanks

Rich
  • 6,470
  • 15
  • 32
  • 53

1 Answers1

1

Yes, it is possible, for example try the following:

var ef = new ExcelFile();
var ws = ef.Worksheets.Add("Sheet1");

ws.Cells["A1"].Value = "Sample";
ws.Cells["A1"].Value += "\n" + "Sample";

ef.Save("Sample.xlsx");

In short, just use the new line character in ExcelCell.Value.
Note that when you're assigning such a value, GemBox.Spreadsheet will automatically set ExcelCell.Style.WrapText property to true.

Mario Z
  • 4,328
  • 2
  • 24
  • 38