Package org.apache.poi.hssf.usermodel
Class HSSFConditionalFormattingRule
- java.lang.Object
-
- org.apache.poi.hssf.usermodel.HSSFConditionalFormattingRule
-
- All Implemented Interfaces:
ConditionalFormattingRule,DifferentialStyleProvider
public final class HSSFConditionalFormattingRule extends Object implements ConditionalFormattingRule
High level representation of Conditional Formatting Rule. It allows to specify formula based conditions for the Conditional Formatting and the formatting settings such as font, border and pattern.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HSSFBorderFormattingcreateBorderFormatting()create a new border formatting structure if it does not exist, otherwise just return existing object.HSSFColorScaleFormattingcreateColorScaleFormatting()create a new color scale / gradient formatting object if it does not exist, otherwise just return the existing object.HSSFDataBarFormattingcreateDataBarFormatting()create a new databar / data-bar formatting object if it does not exist, otherwise just return the existing object.HSSFFontFormattingcreateFontFormatting()create a new font formatting structure if it does not exist, otherwise just return existing object.HSSFIconMultiStateFormattingcreateMultiStateFormatting()create a new icon / multi-state formatting object if it does not exist, otherwise just return the existing object.HSSFPatternFormattingcreatePatternFormatting()create a new pattern formatting structure if it does not exist, otherwise just return existing object.HSSFBorderFormattinggetBorderFormatting()HSSFColorScaleFormattinggetColorScaleFormatting()bytegetComparisonOperation()The comparison function used when the type of conditional formatting is set toConditionType.CELL_VALUE_ISConditionFilterTypegetConditionFilterType()always null (not a filter condition) orConditionFilterType.FILTERif it is.ConditionTypegetConditionType()Type of conditional formatting rule.HSSFDataBarFormattinggetDataBarFormatting()ConditionFilterDatagetFilterConfiguration()This is null ifHSSFFontFormattinggetFontFormatting()StringgetFormula1()The formula used to evaluate the first operand for the conditional formatting rule.StringgetFormula2()The formula used to evaluate the second operand of the comparison when comparison type isConditionType.CELL_VALUE_ISand operator is eitherComparisonOperator.BETWEENorComparisonOperator.NOT_BETWEENHSSFIconMultiStateFormattinggetMultiStateFormatting()ExcelNumberFormatgetNumberFormat()Always null for HSSF records, until someone figures out where to find itHSSFPatternFormattinggetPatternFormatting()intgetPriority()Only newer style formatting rules have priorities.booleangetStopIfTrue()Always true for HSSF files, per Microsoft Excel documentationintgetStripeSize()Conditional format rules don't define stripes, so always 0StringgetText()XSSF rules store textual condition values as an attribute and also as a formula that needs shifting.
-
-
-
Method Detail
-
getPriority
public int getPriority()
Only newer style formatting rules have priorities. For older ones, we don't know priority for these, other than definition/model order, which appears to be what Excel uses.- Specified by:
getPriorityin interfaceConditionalFormattingRule- Returns:
- rule priority
-
getStopIfTrue
public boolean getStopIfTrue()
Always true for HSSF files, per Microsoft Excel documentation- Specified by:
getStopIfTruein interfaceConditionalFormattingRule- Returns:
- true if conditional formatting rule processing stops when this one is true, false if not
- See Also:
- Microsoft Excel help
-
getNumberFormat
public ExcelNumberFormat getNumberFormat()
Always null for HSSF records, until someone figures out where to find it- Specified by:
getNumberFormatin interfaceConditionalFormattingRule- Specified by:
getNumberFormatin interfaceDifferentialStyleProvider- Returns:
- number format defined for this rule, or null if the cell default should be used
-
getFontFormatting
public HSSFFontFormatting getFontFormatting()
- Specified by:
getFontFormattingin interfaceConditionalFormattingRule- Specified by:
getFontFormattingin interfaceDifferentialStyleProvider- Returns:
- - font formatting object if defined,
nullotherwise
-
createFontFormatting
public HSSFFontFormatting createFontFormatting()
create a new font formatting structure if it does not exist, otherwise just return existing object.- Specified by:
createFontFormattingin interfaceConditionalFormattingRule- Returns:
- - font formatting object, never returns
null.
-
getBorderFormatting
public HSSFBorderFormatting getBorderFormatting()
- Specified by:
getBorderFormattingin interfaceConditionalFormattingRule- Specified by:
getBorderFormattingin interfaceDifferentialStyleProvider- Returns:
- - border formatting object if defined,
nullotherwise
-
createBorderFormatting
public HSSFBorderFormatting createBorderFormatting()
create a new border formatting structure if it does not exist, otherwise just return existing object.- Specified by:
createBorderFormattingin interfaceConditionalFormattingRule- Returns:
- - border formatting object, never returns
null.
-
getPatternFormatting
public HSSFPatternFormatting getPatternFormatting()
- Specified by:
getPatternFormattingin interfaceConditionalFormattingRule- Specified by:
getPatternFormattingin interfaceDifferentialStyleProvider- Returns:
- - pattern formatting object if defined,
nullotherwise
-
createPatternFormatting
public HSSFPatternFormatting createPatternFormatting()
create a new pattern formatting structure if it does not exist, otherwise just return existing object.- Specified by:
createPatternFormattingin interfaceConditionalFormattingRule- Returns:
- - pattern formatting object, never returns
null.
-
getDataBarFormatting
public HSSFDataBarFormatting getDataBarFormatting()
- Specified by:
getDataBarFormattingin interfaceConditionalFormattingRule- Returns:
- databar / data-bar formatting object if defined,
nullotherwise
-
createDataBarFormatting
public HSSFDataBarFormatting createDataBarFormatting()
create a new databar / data-bar formatting object if it does not exist, otherwise just return the existing object.
-
getMultiStateFormatting
public HSSFIconMultiStateFormatting getMultiStateFormatting()
- Specified by:
getMultiStateFormattingin interfaceConditionalFormattingRule- Returns:
- icon / multi-state formatting object if defined,
nullotherwise
-
createMultiStateFormatting
public HSSFIconMultiStateFormatting createMultiStateFormatting()
create a new icon / multi-state formatting object if it does not exist, otherwise just return the existing object.
-
getColorScaleFormatting
public HSSFColorScaleFormatting getColorScaleFormatting()
- Specified by:
getColorScaleFormattingin interfaceConditionalFormattingRule- Returns:
- color scale / gradient formatting object if defined,
nullotherwise
-
createColorScaleFormatting
public HSSFColorScaleFormatting createColorScaleFormatting()
create a new color scale / gradient formatting object if it does not exist, otherwise just return the existing object.
-
getConditionType
public ConditionType getConditionType()
Description copied from interface:ConditionalFormattingRuleType of conditional formatting rule.- Specified by:
getConditionTypein interfaceConditionalFormattingRule- Returns:
- - the conditiontype for the cfrule
-
getConditionFilterType
public ConditionFilterType getConditionFilterType()
always null (not a filter condition) orConditionFilterType.FILTERif it is.- Specified by:
getConditionFilterTypein interfaceConditionalFormattingRule- Returns:
- filter type for filter rules, or null if not a filter rule.
-
getFilterConfiguration
public ConditionFilterData getFilterConfiguration()
Description copied from interface:ConditionalFormattingRuleThis is null ifConditionalFormattingRule.getConditionFilterType()== nullThis means it is always null for HSSF, which does not define the extended condition types.
This object contains the additional configuration information for XSSF filter conditions.
- Specified by:
getFilterConfigurationin interfaceConditionalFormattingRule- Returns:
- the Filter Configuration Data, or null if there isn't any
-
getComparisonOperation
public byte getComparisonOperation()
Description copied from interface:ConditionalFormattingRuleThe comparison function used when the type of conditional formatting is set toConditionType.CELL_VALUE_ISMUST be a constant from
ComparisonOperator- Specified by:
getComparisonOperationin interfaceConditionalFormattingRule- Returns:
- - the comparisionoperatation for the cfrule
-
getFormula1
public String getFormula1()
Description copied from interface:ConditionalFormattingRuleThe formula used to evaluate the first operand for the conditional formatting rule.If the condition type is
ConditionType.CELL_VALUE_IS, this field is the first operand of the comparison. If type isConditionType.FORMULA, this formula is used to determine if the conditional formatting is applied.If comparison type is
ConditionType.FORMULAthe formula MUST be a Boolean function- Specified by:
getFormula1in interfaceConditionalFormattingRule- Returns:
- the first formula
-
getFormula2
public String getFormula2()
Description copied from interface:ConditionalFormattingRuleThe formula used to evaluate the second operand of the comparison when comparison type isConditionType.CELL_VALUE_ISand operator is eitherComparisonOperator.BETWEENorComparisonOperator.NOT_BETWEEN- Specified by:
getFormula2in interfaceConditionalFormattingRule- Returns:
- the second formula
-
getText
public String getText()
Description copied from interface:ConditionalFormattingRuleXSSF rules store textual condition values as an attribute and also as a formula that needs shifting. Using the attribute is simpler/faster. HSSF rules don't have this and return null. We can fall back on the formula for those (AFAIK).- Specified by:
getTextin interfaceConditionalFormattingRule- Returns:
- condition text if it exists, or null
-
getStripeSize
public int getStripeSize()
Conditional format rules don't define stripes, so always 0- Specified by:
getStripeSizein interfaceDifferentialStyleProvider- Returns:
- number of rows/columns in a stripe for stripe styles, 0 for all others
- See Also:
DifferentialStyleProvider.getStripeSize()
-
-