public final class Style extends CellStyle implements com.gembox.spreadsheet.internal.styles.CellFormatDataFormatHolder
Conceptually, cell formatting is divided into following groups:
CellStyle.setNumberFormat(java.lang.String)
.
CellStyle.setHorizontalAlignment(com.gembox.spreadsheet.HorizontalAlignmentStyle)
, CellStyle.setVerticalAlignment(com.gembox.spreadsheet.VerticalAlignmentStyle)
, CellStyle.setIndent(int)
, CellStyle.setRotation(int)
, CellStyle.setTextVertical(boolean)
, CellStyle.setWrapText(boolean)
and CellStyle.setShrinkToFit(boolean)
.
CellStyle.setFont(com.gembox.spreadsheet.ExcelFont)
.
CellStyle.setBorders(com.gembox.spreadsheet.CellBorders)
.
CellStyle.setFillPattern(com.gembox.spreadsheet.ExcelFillPattern)
.
CellStyle.setLocked(boolean)
and CellStyle.setFormulaHidden(boolean)
.
Additional CellStyle
methods not associated with any formatting group are:
CellStyle.getName()
- name of the referenced workbook style
.
CellStyle.setQuotePrefix(boolean)
- true
to store numeric value of a cell as text; otherwise, false
.
CellStyle.isDefault()
- true
if referenced
workbook style
is default (
CellStyleCollection.getNormal()
) and there are no additional modifications of cell formatting; otherwise, false
.
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
CellStyleCollection.getNormal()
.
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 methods) is resolved from referenced
workbook (master) style
, unless cell formatting group or its associated method is modified.
Cell formatting is available for one or more cells through AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method which is available on ExcelCell
and CellRange
types.
Cell formatting specified on ExcelColumn
and ExcelRow
types through ExcelColumnRowBase.setStyle(com.gembox.spreadsheet.CellStyle)
method is simply propagated to cell formatting of its ExcelColumnRowBase.getCells()
.
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 method on CellRange
is propagated to each cell in a range.
To set workbook (master) style
to one or more cells, simply assign it to AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method.
Preferable way to modify formatting method of multiple cells is to get CellRange
to which all those cells belong, and use AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method 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 using AbstractRange.setStyle(com.gembox.spreadsheet.CellStyle)
method 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.
CellStyleCollection
Modifier and Type | Method and Description |
---|---|
String |
getName()
Gets the name of this style.
|
boolean |
isHidden()
Gets a value indicating whether this style is hidden in the application UI.
|
boolean |
isIncludeAlignment()
Gets a value indicating whether the alignment formatting specified for this style will be used when this style is applied to a cell.
|
boolean |
isIncludeBorder()
Gets a value indicating whether the border formatting specified for this style will be used when this style is applied to a cell.
|
boolean |
isIncludeFill()
Gets a value indicating whether the fill formatting specified for this style will be used when this style is applied to a cell.
|
boolean |
isIncludeFont()
Gets a value indicating whether the font formatting specified for this style will be used when this style is applied to a cell.
|
boolean |
isIncludeNumber()
Gets a value indicating whether the number formatting specified for this style will be used when this style is applied to a cell.
|
boolean |
isIncludeProtection()
Gets a value indicating whether the protection formatting specified for this style will be used when this style is applied to a cell.
|
void |
setHidden(boolean hidden)
Sets a value indicating whether this style is hidden in the application UI.
|
void |
setIncludeAlignment(boolean includeAlignment)
Sets a value indicating whether the alignment formatting specified for this style will be used when this style is applied to a cell.
|
void |
setIncludeBorder(boolean includeBorder)
Sets a value indicating whether the border formatting specified for this style will be used when this style is applied to a cell.
|
void |
setIncludeFill(boolean includeFill)
Sets a value indicating whether the fill formatting specified for this style will be used when this style is applied to a cell.
|
void |
setIncludeFont(boolean includeFont)
Sets a value indicating whether the font formatting specified for this style will be used when this style is applied to a cell.
|
void |
setIncludeNumber(boolean includeNumber)
Sets a value indicating whether the number formatting specified for this style will be used when this style is applied to a cell.
|
void |
setIncludeProtection(boolean includeProtection)
Sets a value indicating whether the protection formatting specified for this style will be used when this style is applied to a cell.
|
void |
setName(String name)
Sets the name of this style.
|
getBorders, getFillPattern, getFont, getFormulaHidden, getHorizontalAlignment, getIndent, getNumberFormat, getNumberFormatLocal, getQuotePrefix, getRotation, getVerticalAlignment, isDefault, isLocked, isShrinkToFit, isTextVertical, isWrapText, setBorders, setFillPattern, setFont, setFormulaHidden, setHorizontalAlignment, setIndent, setLocked, setNumberFormat, setQuotePrefix, setRotation, setShrinkToFit, setTextVertical, setVerticalAlignment, setWrapText, toString
public String getName()
public boolean isHidden()
true
if this style is hidden in the application UI; otherwise, false
.public boolean isIncludeAlignment()
true
if alignment formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public boolean isIncludeBorder()
true
if border formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public boolean isIncludeFill()
true
if fill formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public boolean isIncludeFont()
true
if font formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public boolean isIncludeNumber()
true
if number formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public boolean isIncludeProtection()
true
if protection formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public void setHidden(boolean hidden)
hidden
- true
if this style is hidden in the application UI; otherwise, false
.public void setIncludeAlignment(boolean includeAlignment)
includeAlignment
- true
if alignment formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public void setIncludeBorder(boolean includeBorder)
includeBorder
- true
if border formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public void setIncludeFill(boolean includeFill)
includeFill
- true
if fill formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public void setIncludeFont(boolean includeFont)
includeFont
- true
if font formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public void setIncludeNumber(boolean includeNumber)
includeNumber
- true
if number formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public void setIncludeProtection(boolean includeProtection)
includeProtection
- true
if protection formatting specified for this style will be used when this style is applied to a cell; otherwise, false
.public void setName(String name)
name
- The name of this style.IllegalStateException
- Name cannot be changed if style is built-in.© GemBox Ltd. — All rights reserved.