- java.lang.Object
-
- org.dhatim.fastexcel.StyleSetter
-
public class StyleSetter extends Object
Helper class to set style elements on a cell or range of cells. This class implements the builder pattern to easily modify a bunch of attributes.For example:
Worksheet ws = ... ws.range(1, 1, 1, 10).style().borderStyle("thin").bold().fillColor(Color.GRAY4).horizontalAlignment("center").set();
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description STYLE_SETTERbold()Use bold text.STYLE_SETTERborderColor(String borderColor)Set cell border color.STYLE_SETTERborderColor(BorderSide side, String borderColor)Set cell border color.STYLE_SETTERborderStyle(String borderStyle)Apply cell border style on all sides, except diagonal.STYLE_SETTERborderStyle(BorderSide side, String borderStyle)Apply cell border style on a side.STYLE_SETTERborderStyle(BorderSide side, BorderStyle borderStyle)Apply cell border style on a side.STYLE_SETTERborderStyle(BorderStyle borderStyle)Apply cell border style on all sides, except diagonal.STYLE_SETTERdiagonalProperty(DiagonalProperty diagonalProperty)Set cell diagonal property.STYLE_SETTERfillColor(String rgb)Set fill color.STYLE_SETTERfontColor(String rgb)Set font color.STYLE_SETTERfontName(String name)Set font name.STYLE_SETTERfontSize(int size)Set font size.STYLE_SETTERfontSize(BigDecimal size)Set font size.STYLE_SETTERformat(String numberingFormat)Set numbering format.STYLE_SETTERhorizontalAlignment(String alignment)Define horizontal alignment.STYLE_SETTERindent(int indent)Set cell text indentation.STYLE_SETTERitalic()Use italic text.StyleSettermerge()Merge cells in this style setter's range.STYLE_SETTERprotectionOption(ProtectionOption option, Boolean value)Sets the value for a protection option.STYLE_SETTERrotation(int degrees)Set cell text rotation in degrees.voidset()Apply style elements.voidset(ConditionalFormattingRule conditionalFormattingRule)Apply style elements conditionallySTYLE_SETTERshadeAlternateRows(String rgb)Shade alternate rows.STYLE_SETTERshadeRows(String rgb, int eachNRows)Shade Nth rows.STYLE_SETTERstrikethrough()Use strikethrough text.STYLE_SETTERunderlined()Use underlined text.STYLE_SETTERverticalAlignment(String alignment)Define vertical alignment.STYLE_SETTERwrapText(boolean wrapText)Enable or disable text wrapping in cells.
-
-
-
Method Detail
-
merge
public StyleSetter merge()
Merge cells in this style setter's range.- Returns:
- This style setter.
-
set
public void set()
Apply style elements. Do not forget to call this method when you are done otherwise style changes are lost!
-
format
public STYLE_SETTER format(String numberingFormat)
Set numbering format.- Parameters:
numberingFormat- Numbering format. For more information, refer to this page.- Returns:
- This style setter.
-
fillColor
public STYLE_SETTER fillColor(String rgb)
Set fill color.- Parameters:
rgb- RGB fill color. SeeColorfor predefined values.- Returns:
- This style setter.
-
shadeAlternateRows
public STYLE_SETTER shadeAlternateRows(String rgb)
Shade alternate rows.- Parameters:
rgb- RGB shading color.- Returns:
- This style setter.
-
shadeRows
public STYLE_SETTER shadeRows(String rgb, int eachNRows)
Shade Nth rows.- Parameters:
rgb- RGB shading color.eachNRows- shading frequency.- Returns:
- This style setter.
-
fontColor
public STYLE_SETTER fontColor(String rgb)
Set font color.- Parameters:
rgb- RGB font color.- Returns:
- This style setter.
-
fontName
public STYLE_SETTER fontName(String name)
Set font name.- Parameters:
name- Font name.- Returns:
- This style setter.
-
fontSize
public STYLE_SETTER fontSize(BigDecimal size)
Set font size.- Parameters:
size- Font size, in points.- Returns:
- This style setter.
-
fontSize
public STYLE_SETTER fontSize(int size)
Set font size.- Parameters:
size- Font size, in points.- Returns:
- This style setter.
-
bold
public STYLE_SETTER bold()
Use bold text.- Returns:
- This style setter.
-
italic
public STYLE_SETTER italic()
Use italic text.- Returns:
- This style setter.
-
underlined
public STYLE_SETTER underlined()
Use underlined text.- Returns:
- This style setter.
-
strikethrough
public STYLE_SETTER strikethrough()
Use strikethrough text.- Returns:
- This style setter.
-
horizontalAlignment
public STYLE_SETTER horizontalAlignment(String alignment)
Define horizontal alignment.- Parameters:
alignment- Horizontal alignment. Possible values are defined here.- Returns:
- This style setter.
-
verticalAlignment
public STYLE_SETTER verticalAlignment(String alignment)
Define vertical alignment.- Parameters:
alignment- Vertical alignment. Possible values are defined here.- Returns:
- This style setter.
-
wrapText
public STYLE_SETTER wrapText(boolean wrapText)
Enable or disable text wrapping in cells.- Parameters:
wrapText-trueto enable text wrapping (default isfalse).- Returns:
- This style setter.
-
rotation
public STYLE_SETTER rotation(int degrees)
Set cell text rotation in degrees.- Parameters:
degrees- rotation of text in cell- Returns:
- This style setter
-
indent
public STYLE_SETTER indent(int indent)
Set cell text indentation.- Parameters:
indent- indentation of text in cell- Returns:
- This style setter
-
borderStyle
public STYLE_SETTER borderStyle(BorderStyle borderStyle)
Apply cell border style on all sides, except diagonal.- Parameters:
borderStyle- Border style.- Returns:
- This style setter.
-
borderStyle
public STYLE_SETTER borderStyle(String borderStyle)
Apply cell border style on all sides, except diagonal.- Parameters:
borderStyle- Border style. Possible values are defined here.- Returns:
- This style setter.
-
borderStyle
public STYLE_SETTER borderStyle(BorderSide side, BorderStyle borderStyle)
Apply cell border style on a side.- Parameters:
side- Border side where to apply the given style.borderStyle- Border style.- Returns:
- This style setter.
-
borderStyle
public STYLE_SETTER borderStyle(BorderSide side, String borderStyle)
Apply cell border style on a side.- Parameters:
side- Border side where to apply the given style.borderStyle- Border style. Possible values are defined here.- Returns:
- This style setter.
-
borderColor
public STYLE_SETTER borderColor(String borderColor)
Set cell border color.- Parameters:
borderColor- RGB border color.- Returns:
- This style setter.
-
borderColor
public STYLE_SETTER borderColor(BorderSide side, String borderColor)
Set cell border color.- Parameters:
side- Border side where to apply the given border color.borderColor- RGB border color.- Returns:
- This style setter.
-
diagonalProperty
public STYLE_SETTER diagonalProperty(DiagonalProperty diagonalProperty)
Set cell diagonal property.- Parameters:
diagonalProperty- Diagonal border property which should be aplied to a cell- Returns:
- This style setter.
-
protectionOption
public STYLE_SETTER protectionOption(ProtectionOption option, Boolean value)
Sets the value for a protection option.- Parameters:
option- The option to setvalue- The value to set for the given option.- Returns:
- This style setter.
-
set
public void set(ConditionalFormattingRule conditionalFormattingRule)
Apply style elements conditionally- Parameters:
conditionalFormattingRule- Conditional formatting rule to apply
-
-