public class ConditionalFormatter extends Object implements Serializable
Rules are parsed into CSS rules with individual class names. Class names for each cell can then be fetched from this class.
For now, only XSSF formatting rules are supported because of bugs in POI.
| Modifier and Type | Field and Description |
|---|---|
protected ColorConverter |
colorConverter |
| Constructor and Description |
|---|
ConditionalFormatter(Spreadsheet spreadsheet)
Constructs a new ConditionalFormatter targeting the given Spreadsheet.
|
| Modifier and Type | Method and Description |
|---|---|
void |
createConditionalFormatterRules()
Creates the necessary CSS rules and runs evaluations on all affected
cells.
|
Set<Integer> |
getCellFormattingIndex(org.apache.poi.ss.usermodel.Cell cell)
Each cell can have multiple matching rules, hence a collection.
|
protected org.apache.poi.ss.usermodel.FormulaEvaluator |
getFormulaEvaluator()
Get the common
FormulaEvaluator instance from Spreadsheet |
protected boolean |
matches(org.apache.poi.ss.usermodel.Cell cell,
org.apache.poi.ss.usermodel.ConditionalFormattingRule rule,
int deltaColumn,
int deltaRow)
Checks if the given cell value matches the given conditional formatting
rule.
|
protected boolean |
matchesFormula(org.apache.poi.ss.usermodel.Cell cell,
org.apache.poi.ss.usermodel.ConditionalFormattingRule rule,
int deltaColumn,
int deltaRow)
Checks if the formula in the given rule evaluates to
true. |
protected boolean |
matchesValue(org.apache.poi.ss.usermodel.Cell cell,
org.apache.poi.ss.usermodel.ConditionalFormattingRule rule,
int deltaColumn,
int deltaRow)
Checks if the given cell value matches a
ConditionalFormattingRule of VALUE_IS type. |
protected void |
runCellMatcher(org.apache.poi.ss.usermodel.ConditionalFormatting cf,
org.apache.poi.ss.usermodel.ConditionalFormattingRule rule,
int classNameIndex)
Goes through the cells specified in the given formatting, and checks if
each rule matches.
|
protected ColorConverter colorConverter
public ConditionalFormatter(Spreadsheet spreadsheet)
spreadsheet - Target spreadsheetpublic Set<Integer> getCellFormattingIndex(org.apache.poi.ss.usermodel.Cell cell)
cell - Target cellpublic void createConditionalFormatterRules()
protected org.apache.poi.ss.usermodel.FormulaEvaluator getFormulaEvaluator()
FormulaEvaluator instance from Spreadsheetprotected void runCellMatcher(org.apache.poi.ss.usermodel.ConditionalFormatting cf,
org.apache.poi.ss.usermodel.ConditionalFormattingRule rule,
int classNameIndex)
cellToIndex.cf - ConditionalFormatting that specifies the affected
cellsrule - The rule to be evaluatedclassNameIndex - The index of the class name that was generated for this rule,
to be added to cellToIndexprotected boolean matches(org.apache.poi.ss.usermodel.Cell cell,
org.apache.poi.ss.usermodel.ConditionalFormattingRule rule,
int deltaColumn,
int deltaRow)
cell - Target cellrule - Conditional formatting rule to check againsttrue for the
given cell.protected boolean matchesFormula(org.apache.poi.ss.usermodel.Cell cell,
org.apache.poi.ss.usermodel.ConditionalFormattingRule rule,
int deltaColumn,
int deltaRow)
true.
NOTE: Does not support HSSF files currently.
cell - Cell with conditional formattingrule - Conditional formatting rule based on formulaprotected boolean matchesValue(org.apache.poi.ss.usermodel.Cell cell,
org.apache.poi.ss.usermodel.ConditionalFormattingRule rule,
int deltaColumn,
int deltaRow)
ConditionalFormattingRule of VALUE_IS type. Covers
all cell types and comparison operations.cell - Target cellrule - Conditional formatting rule to match against.deltaColumn - delta (on column axis) between cell and the origin celldeltaRow - delta (on row axis) between cell and the origin cellVALUE_IS rule, false otherwiseCopyright © 2013–2026 Vaadin Ltd. All rights reserved.