org.apache.poi.xssf.usermodel

## Class XSSFSheetConditionalFormatting

- java.lang.Object
- - org.apache.poi.xssf.usermodel.XSSFSheetConditionalFormatting

- All Implemented Interfaces:
    SheetConditionalFormatting

      public class XSSFSheetConditionalFormatting
      extends java.lang.Object
      implements SheetConditionalFormatting

  XSSF Conditional Formattings

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `CF_EXT_2009_NS_X14` Office 2010 Conditional Formatting extensions namespace

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule rule1)` Add a new Conditional Formatting to the sheet.
    `int` | `addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule[] cfRules)` Add a new Conditional Formatting set to the sheet.
    `int` | `addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule rule1, ConditionalFormattingRule rule2)` Add a new Conditional Formatting consisting of two rules.
    `int` | `addConditionalFormatting(ConditionalFormatting cf)` Adds a copy of HSSFConditionalFormatting object to the sheet
    `XSSFConditionalFormattingRule` | `createConditionalFormattingColorScaleRule()` Create a Color Scale / Color Gradient conditional formatting rule.
    `XSSFConditionalFormattingRule` | `createConditionalFormattingRule(byte comparisonOperation, java.lang.String formula)` Create a conditional formatting rule that compares a cell value to a formula calculated result, using an operator *
    `XSSFConditionalFormattingRule` | `createConditionalFormattingRule(byte comparisonOperation, java.lang.String formula1, java.lang.String formula2)` A factory method allowing to create a conditional formatting rule with a cell comparison operator
    `XSSFConditionalFormattingRule` | `createConditionalFormattingRule(ExtendedColor color)` Create a Databar conditional formatting rule.
    `XSSFConditionalFormattingRule` | `createConditionalFormattingRule(IconMultiStateFormatting.IconSet iconSet)` A factory method allowing the creation of conditional formatting rules using an Icon Set / Multi-State formatting.
    `XSSFConditionalFormattingRule` | `createConditionalFormattingRule(java.lang.String formula)` A factory method allowing to create a conditional formatting rule with a formula.
    `XSSFConditionalFormattingRule` | `createConditionalFormattingRule(XSSFColor color)` Create a Databar conditional formatting rule.
    `XSSFConditionalFormatting` | `getConditionalFormattingAt(int index)` gets Conditional Formatting object at a particular index
    `int` | `getNumConditionalFormattings()`
    `void` | `removeConditionalFormatting(int index)` removes a Conditional Formatting object by index

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### CF_EXT_2009_NS_X14

          protected static final java.lang.String CF_EXT_2009_NS_X14

      Office 2010 Conditional Formatting extensions namespace
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### createConditionalFormattingRule

          public XSSFConditionalFormattingRule createConditionalFormattingRule(byte comparisonOperation,
                                                                               java.lang.String formula1,
                                                                               java.lang.String formula2)

      A factory method allowing to create a conditional formatting rule with a cell comparison operator

      TODO - formulas containing cell references are currently not parsed properly

      Specified by:
        `createConditionalFormattingRule` in interface `SheetConditionalFormatting`
      Parameters:
        `comparisonOperation` - - a constant value from ``CFRuleBase.ComparisonOperator``:

        - BETWEEN
        - NOT_BETWEEN
        - EQUAL
        - NOT_EQUAL
        - GT
        - LT
        - GE
        - LE
        `formula1` - - formula for the valued, compared with the cell
        `formula2` - - second formula (only used with `ComparisonOperator.BETWEEN`) and `ComparisonOperator.NOT_BETWEEN` operations)

    - #### createConditionalFormattingRule

          public XSSFConditionalFormattingRule createConditionalFormattingRule(byte comparisonOperation,
                                                                               java.lang.String formula)

      Description copied from interface: `SheetConditionalFormatting`
      Create a conditional formatting rule that compares a cell value to a formula calculated result, using an operator *

      The type of the created condition is `ConditionType.CELL_VALUE_IS`

      Specified by:
        `createConditionalFormattingRule` in interface `SheetConditionalFormatting`
      Parameters:
        `comparisonOperation` - MUST be a constant value from ``ComparisonOperator`` except BETWEEN and NOT_BETWEEN
        `formula` - the formula to determine if the conditional formatting is applied

    - #### createConditionalFormattingRule

          public XSSFConditionalFormattingRule createConditionalFormattingRule(java.lang.String formula)

      A factory method allowing to create a conditional formatting rule with a formula.
      Specified by:
        `createConditionalFormattingRule` in interface `SheetConditionalFormatting`
      Parameters:
        `formula` - - formula for the valued, compared with the cell

    - #### createConditionalFormattingRule

          public XSSFConditionalFormattingRule createConditionalFormattingRule(XSSFColor color)

      Create a Databar conditional formatting rule.

      The thresholds and colour for it will be created, but will be empty and require configuring with `XSSFConditionalFormattingRule.getDataBarFormatting()` then `XSSFDataBarFormatting.getMinThreshold()` and `XSSFDataBarFormatting.getMaxThreshold()`

    - #### createConditionalFormattingRule

          public XSSFConditionalFormattingRule createConditionalFormattingRule(ExtendedColor color)

      Description copied from interface: `SheetConditionalFormatting`
      Create a Databar conditional formatting rule.

      The thresholds and colour for it will be created, but will be empty and require configuring with `ConditionalFormattingRule.getDataBarFormatting()` then `DataBarFormatting.getMinThreshold()` and `DataBarFormatting.getMaxThreshold()`

      Specified by:
        `createConditionalFormattingRule` in interface `SheetConditionalFormatting`

    - #### createConditionalFormattingRule

          public XSSFConditionalFormattingRule createConditionalFormattingRule(IconMultiStateFormatting.IconSet iconSet)

      A factory method allowing the creation of conditional formatting rules using an Icon Set / Multi-State formatting. The thresholds for it will be created, but will be empty and require configuring with `XSSFConditionalFormattingRule.getMultiStateFormatting()` then `XSSFIconMultiStateFormatting.getThresholds()`
      Specified by:
        `createConditionalFormattingRule` in interface `SheetConditionalFormatting`

    - #### createConditionalFormattingColorScaleRule

          public XSSFConditionalFormattingRule createConditionalFormattingColorScaleRule()

      Create a Color Scale / Color Gradient conditional formatting rule.

      The thresholds and colours for it will be created, but will be empty and require configuring with `XSSFConditionalFormattingRule.getColorScaleFormatting()` then `XSSFColorScaleFormatting.getThresholds()` and `XSSFColorScaleFormatting.getColors()`

      Specified by:
        `createConditionalFormattingColorScaleRule` in interface `SheetConditionalFormatting`

    - #### addConditionalFormatting

          public int addConditionalFormatting(CellRangeAddress[] regions,
                                              ConditionalFormattingRule[] cfRules)

      Description copied from interface: `SheetConditionalFormatting`
      Add a new Conditional Formatting set to the sheet.
      Specified by:
        `addConditionalFormatting` in interface `SheetConditionalFormatting`
      Parameters:
        `regions` - - list of rectangular regions to apply conditional formatting rules
        `cfRules` - - set of up to conditional formatting rules (max 3 for Excel pre-2007)
      Returns:
        index of the newly created Conditional Formatting object

    - #### addConditionalFormatting

          public int addConditionalFormatting(CellRangeAddress[] regions,
                                              ConditionalFormattingRule rule1)

      Description copied from interface: `SheetConditionalFormatting`
      Add a new Conditional Formatting to the sheet.
      Specified by:
        `addConditionalFormatting` in interface `SheetConditionalFormatting`
      Parameters:
        `regions` - - list of rectangular regions to apply conditional formatting rules
        `rule1` - - the rule to apply
      Returns:
        index of the newly created Conditional Formatting object

    - #### addConditionalFormatting

          public int addConditionalFormatting(CellRangeAddress[] regions,
                                              ConditionalFormattingRule rule1,
                                              ConditionalFormattingRule rule2)

      Description copied from interface: `SheetConditionalFormatting`
      Add a new Conditional Formatting consisting of two rules.
      Specified by:
        `addConditionalFormatting` in interface `SheetConditionalFormatting`
      Parameters:
        `regions` - - list of rectangular regions to apply conditional formatting rules
        `rule1` - - the first rule
        `rule2` - - the second rule
      Returns:
        index of the newly created Conditional Formatting object

    - #### addConditionalFormatting

          public int addConditionalFormatting(ConditionalFormatting cf)

      Adds a copy of HSSFConditionalFormatting object to the sheet

      This method could be used to copy HSSFConditionalFormatting object from one sheet to another. For example:

           HSSFConditionalFormatting cf = sheet.getConditionalFormattingAt(index);
           newSheet.addConditionalFormatting(cf);

      Specified by:
        `addConditionalFormatting` in interface `SheetConditionalFormatting`
      Parameters:
        `cf` - HSSFConditionalFormatting object
      Returns:
        index of the new Conditional Formatting object

    - #### getConditionalFormattingAt

          public XSSFConditionalFormatting getConditionalFormattingAt(int index)

      gets Conditional Formatting object at a particular index
      Specified by:
        `getConditionalFormattingAt` in interface `SheetConditionalFormatting`
      Parameters:
        `index` - of the Conditional Formatting object to fetch
      Returns:
        Conditional Formatting object

    - #### getNumConditionalFormattings

          public int getNumConditionalFormattings()

      Specified by:
        `getNumConditionalFormattings` in interface `SheetConditionalFormatting`
      Returns:
        number of Conditional Formatting objects of the sheet

    - #### removeConditionalFormatting

          public void removeConditionalFormatting(int index)

      removes a Conditional Formatting object by index
      Specified by:
        `removeConditionalFormatting` in interface `SheetConditionalFormatting`
      Parameters:
        `index` - of a Conditional Formatting object to remove

Copyright 2020 The Apache Software Foundation or its licensors, as applicable.