Cell text rotation

Set RotateAngle property of style object to rotate text inside cell, for example:

var cell = sheet.Cells["A1"];
cell.Data = "Hello World";
cell.Style.RotateAngle = 90;

345

Example: Rotate -90°

The range of rotation angle is from -90° to 90°. 353

Multi-line text rotation

To display multi-line text, set TextWrap property of style object to WordBreak.

var cell = sheet.Cells["A1"];
cell.Data = ".NET Spreadsheet\\nComponent";
cell.Style.TextWrap = TextWrapMode.WordBreak;
cell.Style.RotateAngle = -45;

354

Rotated text alignments

Horizontal alignment and vertical alignment also worked for rotated text, for example, it is possible to put the rotated text at left, center, and right.

cell = sheet.Cells["A1"];
cell.Data = "Hello World";
cell.Style.HAlign = ReoGridHorAlign.Left;
cell.Style.RotateAngle = 90;

cell = sheet.Cells["B1"];
cell.Data = "Hello World";
cell.Style.HAlign = ReoGridHorAlign.Center;
cell.Style.RotateAngle = 90;

cell = sheet.Cells["C1"];
cell.Data = "Hello World";
cell.Style.HAlign = ReoGridHorAlign.Right;
cell.Style.RotateAngle = 90;

355

Excel import/export support

The text rotation settings will saved into Excel and loaded from Excel file automatically. 356


Was the content of the page helpful?