Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.poi.hssf.usermodel
Class HSSFConditionalFormatting

    java.lang.Object
      org.apache.poi.hssf.usermodel.HSSFConditionalFormatting

All Implemented Interfaces:
  ConditionalFormatting

    public final class HSSFConditionalFormatting

extends java.lang.Object
implements ConditionalFormatting

HSSFConditionalFormatting class encapsulates all settings of Conditional Formatting. The class can be used

- to make a copy HSSFConditionalFormatting settings.
For example:

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

- or to modify existing Conditional Formatting settings (formatting regions and/or rules).

Use `HSSFSheet.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.
     HSSFConditionalFormattingRule rule = sheet.createConditionalFormattingRule(
         ComparisonOperator.GE,
         "100.0", // 1st formula
         null     // 2nd formula is not used for comparison operator GE
     );

     // Create pattern with red background
     HSSFPatternFormatting patternFmt = rule.cretePatternFormatting();
     patternFormatting.setFillBackgroundColor(HSSFColor.RED.index);

     // 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
`void` | `addRule(ConditionalFormattingRule cfRule)` Add a Conditional Formatting rule.
`void` | `addRule(HSSFConditionalFormattingRule cfRule)` add a Conditional Formatting rule.
`CellRangeAddress[]` | `getFormattingRanges()`
`int` | `getNumberOfRules()`
`HSSFConditionalFormattingRule` | `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.
`void` | `setRule(int idx, HSSFConditionalFormattingRule cfRule)` Replaces an existing Conditional Formatting rule at position idx.
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### getFormattingRanges

    public CellRangeAddress[] getFormattingRanges()

  Specified by:
    `getFormattingRanges` in interface `ConditionalFormatting`
  Returns:
    array of `CellRangeAddress`s. never `null`

### setFormattingRanges

    public void setFormattingRanges(CellRangeAddress[] ranges)

  Description copied from interface: `ConditionalFormatting`
  Sets the cell ranges the rule conditional formatting must be applied to.

  Specified by:
    `setFormattingRanges` in interface `ConditionalFormatting`
  Parameters:
    `ranges` - non-null array of `CellRangeAddress`s

### setRule

    public void setRule(int idx,
                        HSSFConditionalFormattingRule cfRule)

  Replaces an existing Conditional Formatting rule at position idx. Older versions of Excel only allow up to 3 Conditional Formatting rules, and will ignore rules beyond that, while newer versions are fine. This method can be useful to modify existing Conditional Formatting rules.

  Parameters:
    `idx` - position of the rule. Should be between 0 and 2 for older Excel versions
    `cfRule` - - Conditional Formatting rule

### setRule

    public void setRule(int idx,
                        ConditionalFormattingRule cfRule)

  Description copied from interface: `ConditionalFormatting`
  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.

  Specified by:
    `setRule` in interface `ConditionalFormatting`
  Parameters:
    `idx` - position of the rule. Should be between 0 and 2 for Excel before 2007, otherwise 0+.
    `cfRule` - - Conditional Formatting rule

### addRule

    public void addRule(HSSFConditionalFormattingRule cfRule)

  add a Conditional Formatting rule. Excel allows to create up to 3 Conditional Formatting rules.

  Parameters:
    `cfRule` - - Conditional Formatting rule

### addRule

    public void addRule(ConditionalFormattingRule cfRule)

  Description copied from interface: `ConditionalFormatting`
  Add a Conditional Formatting rule. Excel pre-2007 allows to create up to 3 Conditional Formatting rules.

  Specified by:
    `addRule` in interface `ConditionalFormatting`
  Parameters:
    `cfRule` - - Conditional Formatting rule

### getRule

    public HSSFConditionalFormattingRule getRule(int idx)

  Specified by:
    `getRule` in interface `ConditionalFormatting`
  Returns:
    the Conditional Formatting rule at position idx.

### getNumberOfRules

    public int getNumberOfRules()

  Specified by:
    `getNumberOfRules` in interface `ConditionalFormatting`
  Returns:
    number of Conditional Formatting rules.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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