org.apache.poi.ss.usermodel

## Interface ConditionalFormatting

- All Known Implementing Classes:
    HSSFConditionalFormatting, XSSFConditionalFormatting

      public interface ConditionalFormatting

  The ConditionalFormatting class encapsulates all settings of Conditional Formatting. The class can be used
  - to make a copy ConditionalFormatting settings.
  For example:

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

  - or to modify existing Conditional Formatting settings (formatting regions and/or rules).
  Use `Sheet.getSheetConditionalFormatting()` to get access to an instance of this class.

  To create a new Conditional Formatting set use the following approach:

       // Define a Conditional Formatting rule, which triggers formatting
       // when cell's value is greater or equal than 100.0 and
       // applies patternFormatting defined below.
       ConditionalFormattingRule rule = sheet.createConditionalFormattingRule(
           ComparisonOperator.GE,
           "100.0", // 1st formula
           null     // 2nd formula is not used for comparison operator GE
       );

       // Create pattern with red background
       PatternFormatting patternFmt = rule.cretePatternFormatting();
       patternFormatting.setFillBackgroundColor(IndexedColor.RED.getIndex());

       // Define a region containing first column
       Region [] regions =
       {
           new Region(1,(short)1,-1,(short)1)
       };

       // Apply Conditional Formatting rule defined above to the regions
       sheet.addConditionalFormatting(regions, rule);

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRule(ConditionalFormattingRule cfRule)` Add a Conditional Formatting rule.
    `CellRangeAddress[]` | `getFormattingRanges()`
    `int` | `getNumberOfRules()`
    `ConditionalFormattingRule` | `getRule(int idx)`
    `void` | `setFormattingRanges(CellRangeAddress[] ranges)` Sets the cell ranges the rule conditional formatting must be applied to.
    `void` | `setRule(int idx, ConditionalFormattingRule cfRule)` Replaces an existing Conditional Formatting rule at position idx.

- - ### Method Detail

    - #### getFormattingRanges

          CellRangeAddress[] getFormattingRanges()

      Returns:
        array of `CellRangeAddress`s. Never `null`

    - #### setFormattingRanges

          void setFormattingRanges(CellRangeAddress[] ranges)

      Sets the cell ranges the rule conditional formatting must be applied to.
      Parameters:
        `ranges` - non-null array of `CellRangeAddress`s

    - #### setRule

          void setRule(int idx,
                       ConditionalFormattingRule cfRule)

      Replaces an existing Conditional Formatting rule at position idx. Excel pre-2007 allows to create up to 3 Conditional Formatting rules, 2007 and later allow unlimited numbers. This method can be useful to modify existing Conditional Formatting rules.
      Parameters:
        `idx` - position of the rule. Should be between 0 and 2 for Excel before 2007, otherwise 0+.
        `cfRule` - - Conditional Formatting rule

    - #### addRule

          void addRule(ConditionalFormattingRule cfRule)

      Add a Conditional Formatting rule. Excel pre-2007 allows to create up to 3 Conditional Formatting rules.
      Parameters:
        `cfRule` - - Conditional Formatting rule

    - #### getRule

          ConditionalFormattingRule getRule(int idx)

      Returns:
        the Conditional Formatting rule at position idx.

    - #### getNumberOfRules

          int getNumberOfRules()

      Returns:
        number of Conditional Formatting rules.

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