Alignment.Indent Property
Gets or sets the cell content indention from the cell edge, dependent on the applied horizontal alignment.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v18.2.Core.dll
Declaration
Property Value
Type | Description |
---|---|
Int32 | An integer value that specifies a space between the cell content and cell edge. An indent increment is equal to three spaces of the Normal style font. |
Remarks
The Indent property value is applied as described below.
- If the used horizontal alignment is SpreadsheetHorizontalAlignment.Left, the Indent property specifies the space between the cell content and left edge of the cell.
- If the used horizontal alignment is SpreadsheetHorizontalAlignment.Right, the Indent property specifies the space between the cell content and right edge of the cell.
- If the used horizontal alignment is SpreadsheetHorizontalAlignment.Distributed, the Indent property specifies indents of the cell content from both right and left edges of the cell.
- If the used horizontal alignment is other than Left, Right or Distributed, setting the Indent property value will automatically reset the horizontal alignment to SpreadsheetHorizontalAlignment.Left. Setting the horizontal alignment type to a value other than Left, Right or Distributed after the Indent has been specified, resets the Indent to 0.
To set other alignment characteristics for a cell or range of cells (e.g., horizontal and vertical alignment, text rotation, a value indicating whether the text should be wrapped and shrunk in a cell), use the corresponding properties of the Alignment object. Access this object via the Formatting.Alignment property.
- To specify data alignment of an individual cell, access the Alignment object using the cell’s Formatting.Alignment property directly.
- To specify the data alignment of a cell range, modify the Alignment object within the Range.BeginUpdateFormatting - Range.EndUpdateFormatting method pair.
- To share the same alignment settings between multiple cells in one step, apply the style with the specified alignment to required cells. To specify the alignment for a cell style, access the Style object from the IWorkbook.Styles collection and use this style’s Formatting.Alignment property within the Formatting.BeginUpdate-Formatting.EndUpdate paired methods to access and modify the Alignment object.
For examples on how to specify formatting for an individual cell and cell range or modify a style, refer to the How to: Format a Cell or Range of Cells or How to: Create or Modify a Style documents, respectively.
Example
This example demonstrates how to specify the alignment of cell content by modifying the Alignment object accessed via the Formatting.Alignment property of the Cell object.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/spreadsheet-document-server-api-e4339
Cell cellA1 = worksheet.Cells["A1"];
cellA1.Value = "Right and top";
cellA1.Alignment.Horizontal = SpreadsheetHorizontalAlignment.Right;
cellA1.Alignment.Vertical = SpreadsheetVerticalAlignment.Top;
Cell cellA2 = worksheet.Cells["A2"];
cellA2.Value = "Center";
cellA2.Alignment.Horizontal = SpreadsheetHorizontalAlignment.Center;
cellA2.Alignment.Vertical = SpreadsheetVerticalAlignment.Center;
Cell cellA3 = worksheet.Cells["A3"];
cellA3.Value = "Left and bottom, indent";
cellA3.Alignment.Indent = 1;
Cell cellB1 = worksheet.Cells["B1"];
cellB1.Value = "The Alignment.ShrinkToFit property is applied";
cellB1.Alignment.ShrinkToFit = true;
Cell cellB2 = worksheet.Cells["B2"];
cellB2.Value = "Rotated Cell Contents";
cellB2.Alignment.Horizontal = SpreadsheetHorizontalAlignment.Center;
cellB2.Alignment.Vertical = SpreadsheetVerticalAlignment.Center;
cellB2.Alignment.RotationAngle = 15;
Cell cellB3 = worksheet.Cells["B3"];
cellB3.Value = "The Alignment.WrapText property is applied to wrap the text within a cell";
cellB3.Alignment.WrapText = true;