Class CellStyle
Range.style() or Cell.style().
Apply one with Range.setStyle(CellStyle) or
Cell.setStyle(CellStyle).
setStyle replaces the cell's whole style; it does not merge. A
style built with builder() carries only the attributes you set, and
every other attribute takes a fixed default (see CellStyle.Builder). To change
one attribute and keep the rest, start from the current style with
toBuilder().
A style read from a cell has every attribute filled in. Colors keep their
kind: theme, indexed and automatic colors read back as that Color
kind, not as RGB. The engine stores identical styles once, so applying the
same style to many cells is cheap.
Formatting of single characters inside a cell is not part of the cell
style; see RichText.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbooleanbold()Whether the font is bold.One border edge: its line style plus color.The bottom border edge; same asborder(Side.BOTTOM).The diagonal border edge; its direction comes fromdiagonalDown()anddiagonalUp().The left border edge; same asborder(Side.LEFT).The right border edge; same asborder(Side.RIGHT).The top border edge; same asborder(Side.TOP).static CellStyle.Builderbuilder()An empty builder.booleanWhether the diagonal border runs from top-left to bottom-right.booleanWhether the diagonal border runs from bottom-left to top-right.booleanTwo styles are equal when they hold the same attributes with the same values, whether built, read from a cell or decoded from JSON.The fill background color, drawn behind the pattern of a non-solid fill.The fill foreground color: the visible color of aPatternType.SOLIDfill, or the pattern color of the other patterns.The fill pattern.intThe font character set code, 0-255 (0 = ANSI, 1 = DEFAULT, 128 = Shift-JIS, …); 0 when unset.The font color: RGB, theme, indexed or automatic.intThe font family class: 0 = not applicable, 1 = Roman, 2 = Swiss, 3 = Modern, 4 = Script, 5 = Decorative.fontName()The font family name, e.g.The theme font scheme the font belongs to.doublefontSize()The font size in points (1/72 inch), to 1/100 pt.The font position: baseline, superscript or subscript;FontVertical.BASELINEwhen unset.static CellStyleRebuilds a style from the engine's resolved-style JSON.intThe gradient rotation in whole degrees (ECMA-376 Part 1 §18.8.24gradientFill/@degree), or-1when the fill is not a gradient.The gradient color stops in position order (ECMA-376 §18.8.38).The gradient kind:"linear"(rotated bygradientDegree()) or"path"(shape-bounded, fromCellStyle.Builder.pathGradientFill(io.keikai.axyra.sheets.style.Color...)), ornullwhen the fill is not a gradient.booleanWhether this style has a gradient fill; thengradientStops()lists its colors.inthashCode()booleanhidden()Whether the formula is hidden from the formula bar while the sheet is protected.The horizontal alignment;HAlign.GENERALwhen unset.intindent()The indent level; 0 when unset.booleanitalic()Whether the font is italic.booleanlocked()Whether the cell is locked while the sheet is protected.The Excel number format code, e.g.booleanWhether the cell's text was entered with a leading apostrophe (ECMA-376 §18.8.45xf@quotePrefix), which keeps a number-looking value as text.booleanWhether text shrinks to fit the cell rather than wrapping or overflowing (ECMA-376 §18.8.1alignment@shrinkToFit).booleanWhether the text is struck through.intThe text rotation in the ECMA-376 §18.8.1 encoding.A builder pre-loaded with every attribute of this style.toJson()The flat style JSON sent to the engine.The underline style;Underline.NONEwhen unset.The vertical alignment;VAlign.BOTTOMwhen unset.booleanwrapText()Whether text wraps onto several lines inside the cell.
-
Method Details
-
builder
An empty builder. Every attribute you do not set takes the fixed default listed onCellStyle.Builder, not the cell's current value. UsetoBuilder()to edit an existing style.- Returns:
- a new builder
-
toBuilder
A builder pre-loaded with every attribute of this style. Use it to change a few attributes and keep the rest, e.g.cell.setStyle(cell.style().toBuilder().bold().build()).- Returns:
- a new builder; changes to it do not affect this style
-
toJson
The flat style JSON sent to the engine. Not intended for application code; public only for the SDK's own packages.- Returns:
- the JSON text
-
fromJson
Rebuilds a style from the engine's resolved-style JSON. Not intended for application code; public only for the SDK's own packages.- Parameters:
json- the JSON text- Returns:
- the style
- Throws:
AxyraException- if the JSON is malformed
-
equals
Two styles are equal when they hold the same attributes with the same values, whether built, read from a cell or decoded from JSON. A style read from a cell holds every attribute, while a built one holds only those that were set, so the two are equal only when the builder set every attribute; compare a read style with another read style. -
hashCode
public int hashCode() -
fontName
The font family name, e.g."Calibri".- Returns:
- the name; an empty string on a builder-made style that did not set it
-
fontSize
public double fontSize()The font size in points (1/72 inch), to 1/100 pt.- Returns:
- the size; 0 on a builder-made style that did not set it
-
bold
public boolean bold()Whether the font is bold. -
italic
public boolean italic()Whether the font is italic. -
strikethrough
public boolean strikethrough()Whether the text is struck through. -
underline
The underline style;Underline.NONEwhen unset. -
fontColor
The font color: RGB, theme, indexed or automatic.- Returns:
- the color; on a style read from a cell never
null, and an unset color isColor.auto();nullonly on a builder-made style that never set it
-
fillColor
The fill foreground color: the visible color of aPatternType.SOLIDfill, or the pattern color of the other patterns.- Returns:
- the color; on a style read from a cell never
null, and an unset color isColor.auto();nullonly on a builder-made style that never set it
-
fillBackgroundColor
The fill background color, drawn behind the pattern of a non-solid fill.- Returns:
- the color; on a style read from a cell never
null, and an unset color isColor.auto();nullonly on a builder-made style that never set it
-
fillPattern
The fill pattern. A gradient fill is reported separately byhasGradientFill().- Returns:
- the pattern;
PatternType.NONEwhen there is no pattern fill
-
fontVertical
The font position: baseline, superscript or subscript;FontVertical.BASELINEwhen unset. -
fontCharset
public int fontCharset()The font character set code, 0-255 (0 = ANSI, 1 = DEFAULT, 128 = Shift-JIS, …); 0 when unset. -
fontFamily
public int fontFamily()The font family class: 0 = not applicable, 1 = Roman, 2 = Swiss, 3 = Modern, 4 = Script, 5 = Decorative. -
fontScheme
The theme font scheme the font belongs to.- Returns:
"major","minor", or an empty string when the font is not a theme font
-
horizontalAlign
The horizontal alignment;HAlign.GENERALwhen unset. -
verticalAlign
The vertical alignment;VAlign.BOTTOMwhen unset. -
shrinkToFit
public boolean shrinkToFit()Whether text shrinks to fit the cell rather than wrapping or overflowing (ECMA-376 §18.8.1alignment@shrinkToFit). -
quotePrefix
public boolean quotePrefix()Whether the cell's text was entered with a leading apostrophe (ECMA-376 §18.8.45xf@quotePrefix), which keeps a number-looking value as text. Excel hides the apostrophe but records the flag.Read-only: it records how a value was typed, so applying a style must not stamp one onto a cell that was never entered that way. There is deliberately no builder method.
-
wrapText
public boolean wrapText()Whether text wraps onto several lines inside the cell. -
textRotation
public int textRotation()The text rotation in the ECMA-376 §18.8.1 encoding.- Returns:
- 0-90 for counter-clockwise degrees, 91-180 for clockwise by (value - 90) degrees, 255 for vertically stacked text; 0 when unset
-
indent
public int indent()The indent level; 0 when unset. SeeCellStyle.Builder.indent(int). -
numberFormat
The Excel number format code, e.g."#,##0.00".- Returns:
- the code;
"General"when unset
-
hasGradientFill
public boolean hasGradientFill()Whether this style has a gradient fill; thengradientStops()lists its colors. -
gradientType
The gradient kind:"linear"(rotated bygradientDegree()) or"path"(shape-bounded, fromCellStyle.Builder.pathGradientFill(io.keikai.axyra.sheets.style.Color...)), ornullwhen the fill is not a gradient. -
gradientDegree
public int gradientDegree()The gradient rotation in whole degrees (ECMA-376 Part 1 §18.8.24gradientFill/@degree), or-1when the fill is not a gradient. -
gradientStops
The gradient color stops in position order (ECMA-376 §18.8.38). Stop colors read from a cell are always RGB: a theme-colored stop in a source file reads back as its resolved RGB value. The read-back counterpart ofCellStyle.Builder.gradientFill(int, Color...).- Returns:
- a new list on each call; empty when the fill is not a gradient
-
border
One border edge: its line style plus color.On a style read from a cell, an absent edge is
BorderStyle.NONEwithColor.auto(), not with anullcolor. On a style built withbuilder()that never set this edge, the color isnull. TestBorderEdge.isPresent()rather than the color.- Parameters:
side- the edge to read- Returns:
- the edge; never
null
-
borderTop
The top border edge; same asborder(Side.TOP). -
borderBottom
The bottom border edge; same asborder(Side.BOTTOM). -
borderLeft
The left border edge; same asborder(Side.LEFT). -
borderRight
The right border edge; same asborder(Side.RIGHT). -
borderDiagonal
The diagonal border edge; its direction comes fromdiagonalDown()anddiagonalUp(). -
diagonalDown
public boolean diagonalDown()Whether the diagonal border runs from top-left to bottom-right. -
diagonalUp
public boolean diagonalUp()Whether the diagonal border runs from bottom-left to top-right. -
locked
public boolean locked()Whether the cell is locked while the sheet is protected. It has no effect until sheet protection is on.- Returns:
truewhen unset, as in Excel
-