Class HSSFSheetConditionalFormatting
- java.lang.Object
-
- org.apache.poi.hssf.usermodel.HSSFSheetConditionalFormatting
-
- All Implemented Interfaces:
SheetConditionalFormatting
public final class HSSFSheetConditionalFormatting extends Object implements SheetConditionalFormatting
The 'Conditional Formatting' facet of HSSFSheet
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addConditionalFormatting(HSSFConditionalFormatting cf)
Adds a copy of HSSFConditionalFormatting object to the sheetint
addConditionalFormatting(ConditionalFormatting cf)
Adds a copy of a ConditionalFormatting object to the sheetint
addConditionalFormatting(CellRangeAddress[] regions, HSSFConditionalFormattingRule rule1)
int
addConditionalFormatting(CellRangeAddress[] regions, HSSFConditionalFormattingRule[] cfRules)
Allows to add a new Conditional Formatting set to the sheet.int
addConditionalFormatting(CellRangeAddress[] regions, HSSFConditionalFormattingRule rule1, HSSFConditionalFormattingRule rule2)
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.HSSFConditionalFormattingRule
createConditionalFormattingColorScaleRule()
Create a Color Scale / Color Gradient conditional formatting rule.HSSFConditionalFormattingRule
createConditionalFormattingRule(byte comparisonOperation, String formula1)
Create a conditional formatting rule that compares a cell value to a formula calculated result, using an operator *HSSFConditionalFormattingRule
createConditionalFormattingRule(byte comparisonOperation, String formula1, String formula2)
A factory method allowing to create a conditional formatting rule with a cell comparison operatorHSSFConditionalFormattingRule
createConditionalFormattingRule(String formula)
A factory method allowing to create a conditional formatting rule with a formula.
The formatting rules are applied by Excel when the value of the formula not equal to 0.HSSFConditionalFormattingRule
createConditionalFormattingRule(HSSFExtendedColor color)
Create a Databar conditional formatting rule.HSSFConditionalFormattingRule
createConditionalFormattingRule(ExtendedColor color)
Create a Databar conditional formatting rule.HSSFConditionalFormattingRule
createConditionalFormattingRule(IconMultiStateFormatting.IconSet iconSet)
A factory method allowing the creation of conditional formatting rules using an Icon Set / Multi-State formatting.HSSFConditionalFormatting
getConditionalFormattingAt(int index)
gets Conditional Formatting object at a particular indexint
getNumConditionalFormattings()
void
removeConditionalFormatting(int index)
removes a Conditional Formatting object by index
-
-
-
Method Detail
-
createConditionalFormattingRule
public HSSFConditionalFormattingRule createConditionalFormattingRule(byte comparisonOperation, String formula1, String formula2)
A factory method allowing to create a conditional formatting rule with a cell comparison operatorTODO - formulas containing cell references are currently not parsed properly
- Specified by:
createConditionalFormattingRule
in interfaceSheetConditionalFormatting
- Parameters:
comparisonOperation
- - a constant value fromCFRuleBase.ComparisonOperator
:- BETWEEN
- NOT_BETWEEN
- EQUAL
- NOT_EQUAL
- GT
- LT
- GE
- LE
formula1
- - formula for the valued, compared with the cellformula2
- - second formula (only used withCFRuleBase.ComparisonOperator.BETWEEN
) andCFRuleBase.ComparisonOperator.NOT_BETWEEN
operations)
-
createConditionalFormattingRule
public HSSFConditionalFormattingRule createConditionalFormattingRule(byte comparisonOperation, String formula1)
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 interfaceSheetConditionalFormatting
- Parameters:
comparisonOperation
- MUST be a constant value fromComparisonOperator
except BETWEEN and NOT_BETWEENformula1
- the formula to determine if the conditional formatting is applied
-
createConditionalFormattingRule
public HSSFConditionalFormattingRule createConditionalFormattingRule(String formula)
A factory method allowing to create a conditional formatting rule with a formula.
The formatting rules are applied by Excel when the value of the formula not equal to 0.TODO - formulas containing cell references are currently not parsed properly
- Specified by:
createConditionalFormattingRule
in interfaceSheetConditionalFormatting
- Parameters:
formula
- - formula for the valued, compared with the cell
-
createConditionalFormattingRule
public HSSFConditionalFormattingRule 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 withHSSFConditionalFormattingRule.getMultiStateFormatting()
thenHSSFIconMultiStateFormatting.getThresholds()
- Specified by:
createConditionalFormattingRule
in interfaceSheetConditionalFormatting
-
createConditionalFormattingRule
public HSSFConditionalFormattingRule createConditionalFormattingRule(HSSFExtendedColor color)
Create a Databar conditional formatting rule.The thresholds and colour for it will be created, but will be empty and require configuring with
HSSFConditionalFormattingRule.getDataBarFormatting()
thenHSSFDataBarFormatting.getMinThreshold()
andHSSFDataBarFormatting.getMaxThreshold()
-
createConditionalFormattingRule
public HSSFConditionalFormattingRule 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()
thenDataBarFormatting.getMinThreshold()
andDataBarFormatting.getMaxThreshold()
- Specified by:
createConditionalFormattingRule
in interfaceSheetConditionalFormatting
-
createConditionalFormattingColorScaleRule
public HSSFConditionalFormattingRule 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
HSSFConditionalFormattingRule.getColorScaleFormatting()
thenHSSFColorScaleFormatting.getThresholds()
andHSSFColorScaleFormatting.getColors()
- Specified by:
createConditionalFormattingColorScaleRule
in interfaceSheetConditionalFormatting
-
addConditionalFormatting
public int addConditionalFormatting(HSSFConditionalFormatting cf)
Adds a copy of HSSFConditionalFormatting object to the sheetThis method could be used to copy HSSFConditionalFormatting object from one sheet to another. For example:
HSSFConditionalFormatting cf = sheet.getConditionalFormattingAt(index); newSheet.addConditionalFormatting(cf);
- Parameters:
cf
- HSSFConditionalFormatting object- Returns:
- index of the new Conditional Formatting object
-
addConditionalFormatting
public int addConditionalFormatting(ConditionalFormatting cf)
Description copied from interface:SheetConditionalFormatting
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);
- Specified by:
addConditionalFormatting
in interfaceSheetConditionalFormatting
- Parameters:
cf
- the Conditional Formatting to clone- Returns:
- index of the new Conditional Formatting object
-
addConditionalFormatting
public int addConditionalFormatting(CellRangeAddress[] regions, HSSFConditionalFormattingRule[] cfRules)
Allows to add a new Conditional Formatting set to the sheet.- Parameters:
regions
- - list of rectangular regions to apply conditional formatting rulescfRules
- - set of up to three conditional formatting rules- Returns:
- index of the newly created Conditional Formatting object
-
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 interfaceSheetConditionalFormatting
- 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
public int addConditionalFormatting(CellRangeAddress[] regions, HSSFConditionalFormattingRule rule1)
-
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 interfaceSheetConditionalFormatting
- Parameters:
regions
- - list of rectangular regions to apply conditional formatting rulesrule1
- - the rule to apply- Returns:
- index of the newly created Conditional Formatting object
-
addConditionalFormatting
public int addConditionalFormatting(CellRangeAddress[] regions, HSSFConditionalFormattingRule rule1, HSSFConditionalFormattingRule rule2)
-
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 interfaceSheetConditionalFormatting
- 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
-
getConditionalFormattingAt
public HSSFConditionalFormatting getConditionalFormattingAt(int index)
gets Conditional Formatting object at a particular index- Specified by:
getConditionalFormattingAt
in interfaceSheetConditionalFormatting
- Parameters:
index
- of the Conditional Formatting object to fetch- Returns:
- Conditional Formatting object
-
getNumConditionalFormattings
public int getNumConditionalFormattings()
- Specified by:
getNumConditionalFormattings
in interfaceSheetConditionalFormatting
- 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 interfaceSheetConditionalFormatting
- Parameters:
index
- of a Conditional Formatting object to remove
-
-