Interface SheetConditionalFormatting
- All Known Implementing Classes:
HSSFSheetConditionalFormatting
,XSSFSheetConditionalFormatting
- Since:
- 3.8
-
Method Summary
Modifier and TypeMethodDescriptionint
Adds a copy of a ConditionalFormatting object to the sheetint
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.Create a Color Scale / Color Gradient conditional formatting rule.createConditionalFormattingRule
(byte comparisonOperation, String formula) Create a conditional formatting rule that compares a cell value to a formula calculated result, using an operator *createConditionalFormattingRule
(byte comparisonOperation, String formula1, String formula2) A factory method allowing to create a conditional formatting rule with a cell comparison operatorcreateConditionalFormattingRule
(String formula) Create a conditional formatting rule based on a Boolean formula.Create a Databar conditional formatting rule.Create an Icon Set / Multi-State conditional formatting rule.getConditionalFormattingAt
(int index) Gets Conditional Formatting object at a particular indexint
void
removeConditionalFormatting
(int index) Removes a Conditional Formatting object by index
-
Method Details
-
addConditionalFormatting
Add a new Conditional Formatting to the sheet.- Parameters:
regions
- - list of rectangular regions to apply conditional formatting rulesrule
- - 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 rulesrule1
- - the first rulerule2
- - the second rule- Returns:
- index of the newly created Conditional Formatting object
-
addConditionalFormatting
Add a new Conditional Formatting set to the sheet.- Parameters:
regions
- - list of rectangular regions to apply conditional formatting rulescfRules
- - set of up to conditional formatting rules (max 3 for Excel pre-2007)- Returns:
- index of the newly created Conditional Formatting object
-
addConditionalFormatting
Adds a copy of a ConditionalFormatting object to the sheetThis 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, String formula1, String formula2) A factory method allowing to create a conditional formatting rule with a cell comparison operatorThe created conditional formatting rule compares a cell value to a formula calculated result, using the specified operator. The type of the created condition is
ConditionType.CELL_VALUE_IS
- Parameters:
comparisonOperation
- - MUST be a constant value fromComparisonOperator
:- BETWEEN
- NOT_BETWEEN
- EQUAL
- NOT_EQUAL
- GT
- LT
- GE
- LE
formula1
- - formula for the valued, compared with the cellformula2
- - second formula (only used withComparisonOperator.BETWEEN
) andComparisonOperator.NOT_BETWEEN
operations)
-
createConditionalFormattingRule
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
- Parameters:
comparisonOperation
- MUST be a constant value fromComparisonOperator
except BETWEEN and NOT_BETWEENformula
- the formula to determine if the conditional formatting is applied
-
createConditionalFormattingRule
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
ConditionType.FORMULA
- Parameters:
formula
- the formula to evaluate. MUST be a Boolean function.
-
createConditionalFormattingRule
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()
thenDataBarFormatting.getMinThreshold()
andDataBarFormatting.getMaxThreshold()
-
createConditionalFormattingRule
Create an Icon Set / Multi-State conditional formatting rule.The thresholds for it will be created, but will be empty and require configuring with
ConditionalFormattingRule.getMultiStateFormatting()
thenIconMultiStateFormatting.getThresholds()
-
createConditionalFormattingColorScaleRule
ConditionalFormattingRule 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
ConditionalFormattingRule.getColorScaleFormatting()
thenColorScaleFormatting.getThresholds()
andColorScaleFormatting.getColors()
-
getConditionalFormattingAt
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:
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:
IllegalArgumentException
- if the index is outside of the allowable range (0 ... numberOfFormats-1)
-