CellBorders Class |
Namespace: GemBox.Spreadsheet
The CellBorders type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | Item |
Gets the CellBorder which contains the color and line style for the specified individual border of a cell.
|
Name | Description | |
---|---|---|
![]() | GetUnresolvedBorder |
Gets the unresolved (direct) CellBorder which contains the color and line style for the specified individual border of a cell.
|
![]() ![]() | SetBorders |
Sets the color and line style for the specified multiple borders of a cell.
|
![]() | ToString |
Returns a String that represents this CellBorders instance.
(Overrides ObjectToString.) |
Diagonal-up (DiagonalUp / DiagonalUp) and diagonal-down (DiagonalDown / DiagonalDown) always share the same color and line style.
Conceptually, cell formatting is divided into following groups:
Additional CellStyle properties not associated with any formatting group are:
Workbook contains a set of master styles which can be referenced by multiple cells.
Workbook must always contain at least one master style which cannot be removed and is, by default, referenced by all cells. This default style is Normal.
Workbook style can either be built-in or user-defined. Built-in style is accessible from workbook styles via BuiltInCellStyleName enumeration.
Cell formatting group (Number, Alignment, Font, Border, Fill or Protection) (and its associated properties) is resolved from referenced workbook (master) style, unless cell formatting group or its associated property is modified.
Cell formatting is available for one or more cells through Style property which is available on ExcelCell and CellRange types. Cell formatting specified on ExcelColumn and ExcelRow types through Style property is simply propagated to cell formatting of its Cells.
![]() |
---|
For performance reasons, cell formatting on CellRange is resolved based just on its top-left cell formatting, except borders which are resolved based on corner cells depending on border side. Setting cell formatting property on CellRange is propagated to each cell in a range. |
To set workbook (master) style to one or more cells, simply assign it to Style property.
![]() |
---|
Preferable way to modify formatting property of multiple cells is to get CellRange to which all those cells belong, and use Style property of that range to make the modification. If modifying multiple formatting properties of a CellRange, without preserving unmodified formatting properties, preferable way is to create new instance of CellStyle, make modifications on it, and assign it to Style property of that range. |
GemBox.Spreadsheet internally takes care not to allocate unnecessary cells when formatting a range of cells (for example, when formatting all worksheet cells) and to cache formatting information of equally formatted cells, at the appropriate time, to reduce memory footprint.
Following code demonstrates border formatting: