Class ColumnStyleSetter


  • public class ColumnStyleSetter
    extends Object
    Helper class to set style elements on a column. 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_SETTER bold()
      Use bold text.
      STYLE_SETTER borderColor​(String borderColor)
      Set cell border color.
      STYLE_SETTER borderColor​(BorderSide side, String borderColor)
      Set cell border color.
      STYLE_SETTER borderStyle​(String borderStyle)
      Apply cell border style on all sides, except diagonal.
      STYLE_SETTER borderStyle​(BorderSide side, String borderStyle)
      Apply cell border style on a side.
      STYLE_SETTER borderStyle​(BorderSide side, BorderStyle borderStyle)
      Apply cell border style on a side.
      STYLE_SETTER borderStyle​(BorderStyle borderStyle)
      Apply cell border style on all sides, except diagonal.
      STYLE_SETTER diagonalProperty​(DiagonalProperty diagonalProperty)
      Set cell diagonal property.
      STYLE_SETTER fillColor​(String rgb)
      Set fill color.
      STYLE_SETTER fontColor​(String rgb)
      Set font color.
      STYLE_SETTER fontName​(String name)
      Set font name.
      STYLE_SETTER fontSize​(int size)
      Set font size.
      STYLE_SETTER fontSize​(BigDecimal size)
      Set font size.
      STYLE_SETTER format​(String numberingFormat)
      Set numbering format.
      STYLE_SETTER horizontalAlignment​(String alignment)
      Define horizontal alignment.
      STYLE_SETTER indent​(int indent)
      Set cell text indentation.
      STYLE_SETTER italic()
      Use italic text.
      STYLE_SETTER protectionOption​(ProtectionOption option, Boolean value)
      Sets the value for a protection option.
      STYLE_SETTER rotation​(int degrees)
      Set cell text rotation in degrees.
      void set()
      Apply style elements.
      void set​(ConditionalFormattingRule conditionalFormattingRule)
      Apply style elements conditionally
      STYLE_SETTER shadeAlternateRows​(String rgb)
      Shade alternate rows.
      STYLE_SETTER shadeRows​(String rgb, int eachNRows)
      Shade Nth rows.
      STYLE_SETTER strikethrough()
      Use strikethrough text.
      STYLE_SETTER underlined()
      Use underlined text.
      STYLE_SETTER verticalAlignment​(String alignment)
      Define vertical alignment.
      STYLE_SETTER wrapText​(boolean wrapText)
      Enable or disable text wrapping in cells.
    • Method Detail

      • 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. See Color for 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 - true to enable text wrapping (default is false).
        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 set
        value - 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