org.apache.poi.ss.usermodel
Interface SheetConditionalFormatting

All Known Implementing Classes:
HSSFSheetConditionalFormatting, XSSFSheetConditionalFormatting

public interface SheetConditionalFormatting

The 'Conditional Formatting' facet of Sheet

Since:
3.8
Author:
Dmitriy Kumshayev, Yegor Kozlov

Method Summary
 int addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule rule)
          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 a ConditionalFormatting object to the sheet
 ConditionalFormattingRule 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 *
 ConditionalFormattingRule 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
 ConditionalFormattingRule createConditionalFormattingRule(java.lang.String formula)
          Create a conditional formatting rule based on a Boolean formula.
 ConditionalFormatting getConditionalFormattingAt(int index)
          Gets Conditional Formatting object at a particular index
 int getNumConditionalFormattings()
           
 void removeConditionalFormatting(int index)
          Removes a Conditional Formatting object by index
 

Method Detail

addConditionalFormatting

int addConditionalFormatting(CellRangeAddress[] regions,
                             ConditionalFormattingRule rule)
Add a new Conditional Formatting to the sheet.

Parameters:
regions - - list of rectangular regions to apply conditional formatting rules
rule - - the rule to apply
Returns:
index of the newly created Conditional Formatting object

addConditionalFormatting

int addConditionalFormatting(CellRangeAddress[] regions,
                             ConditionalFormattingRule rule1,
                             ConditionalFormattingRule rule2)
Add a new Conditional Formatting consisting of two rules.

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

int addConditionalFormatting(CellRangeAddress[] regions,
                             ConditionalFormattingRule[] cfRules)
Add a new Conditional Formatting set to the sheet.

Parameters:
regions - - list of rectangular regions to apply conditional formatting rules
cfRules - - set of up to three conditional formatting rules
Returns:
index of the newly created Conditional Formatting object

addConditionalFormatting

int addConditionalFormatting(ConditionalFormatting cf)
Adds a copy of a ConditionalFormatting object to the sheet

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

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

Parameters:
cf - the Conditional Formatting to clone
Returns:
index of the new Conditional Formatting object

createConditionalFormattingRule

ConditionalFormattingRule 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

The created conditional formatting rule compares a cell value to a formula calculated result, using the specified operator. The type of the created condition is ConditionalFormattingRule.CONDITION_TYPE_CELL_VALUE_IS

Parameters:
comparisonOperation - - MUST be a constant value from 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

ConditionalFormattingRule 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 *

The type of the created condition is ConditionalFormattingRule.CONDITION_TYPE_CELL_VALUE_IS

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

ConditionalFormattingRule createConditionalFormattingRule(java.lang.String formula)
Create a conditional formatting rule based on a Boolean formula. When the formula result is true, the cell is highlighted.

The type of the created format condition is ConditionalFormattingRule.CONDITION_TYPE_FORMULA

Parameters:
formula - the formula to evaluate. MUST be a Boolean function.

getConditionalFormattingAt

ConditionalFormatting getConditionalFormattingAt(int index)
Gets Conditional Formatting object at a particular index

Parameters:
index - 0-based index of the Conditional Formatting object to fetch
Returns:
Conditional Formatting object or null if not found
Throws:
java.lang.IllegalArgumentException - if the index is outside of the allowable range (0 ... numberOfFormats-1)

getNumConditionalFormattings

int getNumConditionalFormattings()
Returns:
the number of conditional formats in this sheet

removeConditionalFormatting

void removeConditionalFormatting(int index)
Removes a Conditional Formatting object by index

Parameters:
index - 0-based index of the Conditional Formatting object to remove
Throws:
java.lang.IllegalArgumentException - if the index is outside of the allowable range (0 ... numberOfFormats-1)


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