public final class ConditionalFormatRuleCollection extends Object implements Iterable<ConditionalFormatRule>
Represents a collection of a conditional formatting rules.
Rules are applied in the order they appear in the collection (first rule has highest priority and last rule has lowest priority).
Newly added rules are inserted at the beginning of the collection so they are first applied.
Modifier and Type | Method and Description |
---|---|
ColorScaleCondition |
add2ColorScale(String appliesTo)
Adds a '2-Color Scale' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
ColorScaleCondition |
add3ColorScale(String appliesTo)
Adds a '3-Color Scale' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
AboveOrBelowAverageCondition |
addAboveOrBelowAverage(String appliesTo,
boolean below)
Adds an 'Above or Below Average' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
ContainCondition |
addContain(String appliesTo,
ContainConditionType containConditionType)
Adds a 'Cells with Blanks' or 'Cells with No Blanks' or 'Cells with Errors' or 'Cells with No Errors' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
ContainDateCondition |
addContainDate(String appliesTo,
ContainDateOperator operator)
Adds a 'Cells with Dates Occurring' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
ContainTextCondition |
addContainText(String appliesTo,
ContainTextOperator operator,
String value)
Adds a 'Cells with Specific Text' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
ContainValueCondition |
addContainValue(String appliesTo,
ContainValueOperator operator,
Object value)
Adds a 'Cells with Cell Value' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
ContainValueCondition |
addContainValue(String appliesTo,
ContainValueOperator operator,
Object value,
Object value2)
Adds a 'Cells with Cell Value' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
DataBarCondition |
addDataBar(String appliesTo)
Adds a 'Data Bar' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
FormulaCondition |
addFormula(String appliesTo,
String formula)
Adds a 'Formula' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
IconSetCondition |
addIconSet(String appliesTo)
Adds an 'Icon Set' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
TopOrBottomRankedCondition |
addTopOrBottomRanked(String appliesTo,
boolean bottom,
int rank)
Adds a 'Top or Bottom Ranked' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
UniqueOrDuplicateCondition |
addUniqueOrDuplicate(String appliesTo,
boolean duplicate)
Adds a 'Unique or Duplicate' conditional formatting rule applied to a specified sequence of references to cell ranges.
|
ConditionalFormatRule |
get(int index)
Gets the
ConditionalFormatRule at the specified index. |
Iterator<ConditionalFormatRule> |
iterator()
Returns an iterator that iterates through the
ConditionalFormatRuleCollection . |
void |
move(int oldIndex,
int newIndex)
Moves the
ConditionalFormatRule at the specified index to a new location in the ConditionalFormatRuleCollection . |
boolean |
remove(ConditionalFormatRule rule)
Removes the specified
ConditionalFormatRule from the ConditionalFormatRuleCollection . |
boolean |
remove(FormatCondition condition)
Removes a
ConditionalFormatRule associated with the specified FormatCondition from the ConditionalFormatRuleCollection . |
void |
remove(int index)
Removes the
ConditionalFormatRule at the specified index of the ConditionalFormatRuleCollection . |
int |
size()
Gets the number of
ConditionalFormatRule s contained in the ConditionalFormatRuleCollection . |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public ColorScaleCondition add2ColorScale(String appliesTo)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
Newly added rule has the same default settings as in MS Excel.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.ColorScaleCondition
set to a newly created conditional formatting rule which can be used to further customize the formatting condition.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.public ColorScaleCondition add3ColorScale(String appliesTo)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
Newly added rule has the same default settings as in MS Excel.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.ColorScaleCondition
set to a newly created conditional formatting rule which can be used to further customize the formatting condition.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.public AboveOrBelowAverageCondition addAboveOrBelowAverage(String appliesTo, boolean below)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.below
- if set to true
format cells with values below average; otherwise, format cells with values above average.AboveOrBelowAverageCondition
set to a newly created conditional formatting rule which can be used to further customize the formatting condition.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.public ContainCondition addContain(String appliesTo, ContainConditionType containConditionType)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.containConditionType
- The contain condition type (ContainConditionType.BLANKS
or ContainConditionType.NO_BLANKS
or ContainConditionType.ERRORS
or ContainConditionType.NO_ERRORS
).ContainCondition
set to a newly created conditional formatting rule which can be used to customize the formatting.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.IllegalArgumentException
- Parameter containConditionType
is not ContainConditionType.BLANKS
or ContainConditionType.NO_BLANKS
or ContainConditionType.ERRORS
or ContainConditionType.NO_ERRORS
.public ContainDateCondition addContainDate(String appliesTo, ContainDateOperator operator)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.operator
- The date operator.ContainDateCondition
set to a newly created conditional formatting rule which can be used to customize the formatting.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.public ContainTextCondition addContainText(String appliesTo, ContainTextOperator operator, String value)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
Value can be either constant or formula.
If value is constant, then it cannot be null
.
If value is formula, it must start with '='.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.operator
- The textual operator.value
- The value (constant string or formula).ContainTextCondition
set to a newly created conditional formatting rule which can be used to customize the formatting.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.NullPointerException
- Parameter value
is null
.public ContainValueCondition addContainValue(String appliesTo, ContainValueOperator operator, Object value)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
Value can be either constant or formula.
If value is constant, then it cannot be null
and value's type must be supported in ExcelCell's value
(types supported in ExcelFile.supportsType(Class)
).
If value is formula, then value type must be String
and it must start with '='.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.operator
- The operator (all except ContainValueOperator.BETWEEN
and ContainValueOperator.NOT_BETWEEN
).value
- The value (constant or formula).ContainValueCondition
set to a newly created conditional formatting rule which can be used to customize the formatting.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.IllegalArgumentException
- Parameter operator
is ContainValueOperator.BETWEEN
or ContainValueOperator.NOT_BETWEEN
. Use other method overload for these operators.NullPointerException
- Parameter value
is null
.IllegalArgumentException
- Parameter value
type is not supported.public ContainValueCondition addContainValue(String appliesTo, ContainValueOperator operator, Object value, Object value2)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
Values can be either constant or formula.
If value is constant, then it cannot be null
and value's type must be supported in ExcelCell's value
(types supported in ExcelFile.supportsType(Class)
).
If value is formula, then value type must be String
and it must start with '='.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.operator
- The operator (ContainValueOperator.BETWEEN
or ContainValueOperator.NOT_BETWEEN
).value
- The value (constant or formula).value2
- The second value (constant or formula).ContainValueCondition
set to a newly created conditional formatting rule which can be used to customize the formatting.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.IllegalArgumentException
- Parameter operator
is not ContainValueOperator.BETWEEN
nor ContainValueOperator.NOT_BETWEEN
. Use other method overload for other operators.NullPointerException
- Parameter value
or value2
is null
.IllegalArgumentException
- Parameter value
or value2
type is not supported.public DataBarCondition addDataBar(String appliesTo)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
Newly added rule has the same default settings as in MS Excel.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.DataBarCondition
set to a newly created conditional formatting rule which can be used to further customize the formatting condition.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.public FormulaCondition addFormula(String appliesTo, String formula)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.formula
- The formula used to determine which cells to format (only cells for which the formula result evaluates to true
are formatted).FormulaCondition
set to a newly created conditional formatting rule which can be used to customize the formatting.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.IllegalArgumentException
- Parameter formula
is null
or empty string.public IconSetCondition addIconSet(String appliesTo)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
Newly added rule has the same default settings as in MS Excel.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.IconSetCondition
set to a newly created conditional formatting rule which can be used to further customize the formatting condition.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.public TopOrBottomRankedCondition addTopOrBottomRanked(String appliesTo, boolean bottom, int rank)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.bottom
- if set to true
format cells with bottom ranked values; otherwise, format cells with top ranked values.rank
- The number of top or bottom ranked cells which are formatted.TopOrBottomRankedCondition
set to a newly created conditional formatting rule which can be used to further customize the formatting condition.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.IndexOutOfBoundsException
- Parameter rank
is less than or equal to zero.public UniqueOrDuplicateCondition addUniqueOrDuplicate(String appliesTo, boolean duplicate)
Newly added rule is inserted at the beginning of the collection so it has the highest priority and is first applied.
appliesTo
- The sequence of references to cell ranges over which the newly added conditional formatting rule is applied.duplicate
- if set to true
format cells with duplicate values; otherwise, format cells with unique values.UniqueOrDuplicateCondition
set to a newly created conditional formatting rule which can be used to customize the formatting.IllegalArgumentException
- Parameter appliesTo
is null
or empty string.public ConditionalFormatRule get(int index)
ConditionalFormatRule
at the specified index.index
- The zero-based index of the ConditionalFormatRule
to get.ConditionalFormatRule
at the specified index.IndexOutOfBoundsException
- index
is less than 0 or is equal to or greater than size()
.public Iterator<ConditionalFormatRule> iterator()
ConditionalFormatRuleCollection
.iterator
in interface Iterable<ConditionalFormatRule>
ConditionalFormatRuleCollection
.public void move(int oldIndex, int newIndex)
ConditionalFormatRule
at the specified index to a new location in the ConditionalFormatRuleCollection
.oldIndex
- The zero-based index specifying the location of the ConditionalFormatRule
to be moved.newIndex
- The zero-based index specifying the new location of the ConditionalFormatRule
.IndexOutOfBoundsException
- oldIndex
is less than 0 or is equal to or greater than size()
.IndexOutOfBoundsException
- newIndex
is less than 0 or is equal to or greater than size()
.public boolean remove(ConditionalFormatRule rule)
ConditionalFormatRule
from the ConditionalFormatRuleCollection
.
This method also returns false
if ConditionalFormatRule
was not found in the ConditionalFormatRuleCollection
.
rule
- The ConditionalFormatRule
to remove from the ConditionalFormatRuleCollection
.true
if ConditionalFormatRule
is successfully removed; otherwise, false
.public boolean remove(FormatCondition condition)
ConditionalFormatRule
associated with the specified FormatCondition
from the ConditionalFormatRuleCollection
.
This method also returns false
if ConditionalFormatRule
associated with the specified FormatCondition
was not found in the ConditionalFormatRuleCollection
.
condition
- The FormatCondition
which associated ConditionalFormatRule
to remove from the ConditionalFormatRuleCollection
.true
if ConditionalFormatRule
associated with the specified FormatCondition
is successfully removed; otherwise, false
.public void remove(int index)
ConditionalFormatRule
at the specified index of the ConditionalFormatRuleCollection
.index
- The zero-based index of the ConditionalFormatRule
to remove.IndexOutOfBoundsException
- index
is less than 0 or is equal to or greater than size()
.public int size()
ConditionalFormatRule
s contained in the ConditionalFormatRuleCollection
.ConditionalFormatRule
s contained in the ConditionalFormatRuleCollection
.© GemBox d.o.o. — All rights reserved.