Class ConditionalFormattingCollection
Represents the collection of conditional formattings on a worksheet.
Inherited Members
Namespace: DRIT.Spreadsheet.ConditionalFormatting
Assembly: DRIT.Spreadsheet.dll
Syntax
public class ConditionalFormattingCollection : IEnumerable<ConditionalFormatting>, IEnumerable
Fields
Items
Gets the list of conditional formatting items in this collection.
Declaration
public List<ConditionalFormatting> Items
Field Value
| Type | Description |
|---|---|
| List<ConditionalFormatting> |
Properties
Count
Gets the number of conditional formatting items in the collection.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Add(ConditionalFormatting)
Adds an existing conditional formatting item to the collection.
Declaration
public void Add(ConditionalFormatting item)
Parameters
| Type | Name | Description |
|---|---|---|
| ConditionalFormatting | item | The conditional formatting item to add. |
Add(string)
Adds a new conditional formatting for the specified range.
Declaration
public ConditionalFormatting Add(string range)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string (e.g., "A1:B10"). |
Returns
| Type | Description |
|---|---|
| ConditionalFormatting | The newly created ConditionalFormatting instance. |
Add(string, params ConditionalFormattingRule[])
Adds a new conditional formatting for the specified range with the given rules.
Declaration
public void Add(string range, params ConditionalFormattingRule[] rules)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string (e.g., "A1:B10"). |
| ConditionalFormattingRule[] | rules | The conditional formatting rules to add. |
AddAboveAverage(string, bool)
Adds an above average conditional formatting rule.
Declaration
public AboveAverageFormattingRule AddAboveAverage(string range, bool aboveAverage)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
| bool | aboveAverage | Whether to format cells above average. |
Returns
| Type | Description |
|---|---|
| AboveAverageFormattingRule | The newly created AboveAverageFormattingRule instance. |
AddCellValue(string, ConditionalFormattingOperator, params double[])
Adds a cell value conditional formatting rule.
Declaration
public CellIsFormattingRule AddCellValue(string range, ConditionalFormattingOperator conditionalFormattingOperator, params double[] values)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
| ConditionalFormattingOperator | conditionalFormattingOperator | The comparison operator. |
| double[] | values | The values to compare against. |
Returns
| Type | Description |
|---|---|
| CellIsFormattingRule | The newly created CellIsFormattingRule instance. |
AddDataBar(string, SpreadsheetColor)
Adds a data bar conditional formatting rule.
Declaration
public DataBarFormattingRule AddDataBar(string range, SpreadsheetColor color)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
| SpreadsheetColor | color | The color for the data bar. |
Returns
| Type | Description |
|---|---|
| DataBarFormattingRule | The newly created DataBarFormattingRule instance. |
AddDatesOccurring(string, TimePeriod)
Adds a dates occurring conditional formatting rule.
Declaration
public DatesOccurringFormattingRule AddDatesOccurring(string range, TimePeriod timePeriod)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
| TimePeriod | timePeriod | The time period for the rule. |
Returns
| Type | Description |
|---|---|
| DatesOccurringFormattingRule | The newly created DatesOccurringFormattingRule instance. |
AddDuplicateValues(string)
Adds a duplicate values conditional formatting rule.
Declaration
public DuplicateValuesFormattingRule AddDuplicateValues(string range)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
Returns
| Type | Description |
|---|---|
| DuplicateValuesFormattingRule | The newly created DuplicateValuesFormattingRule instance. |
AddExpression(string, string)
Adds an expression conditional formatting rule.
Declaration
public ExpressionFormattingRule AddExpression(string range, string formula)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
| string | formula | The formula for the rule. |
Returns
| Type | Description |
|---|---|
| ExpressionFormattingRule | The newly created ExpressionFormattingRule instance. |
AddIconSet(string, IconSetType)
Adds an icon set conditional formatting rule.
Declaration
public IconSetFormattingRule AddIconSet(string range, IconSetType type)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
| IconSetType | type | The icon set type. |
Returns
| Type | Description |
|---|---|
| IconSetFormattingRule | The newly created IconSetFormattingRule instance. |
AddSpecificText(string, SpecificTextFormattingRuleType, string)
Adds a specific text conditional formatting rule.
Declaration
public SpecificTextFormattingRule AddSpecificText(string range, SpecificTextFormattingRuleType textOperator, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
| SpecificTextFormattingRuleType | textOperator | The text operator type. |
| string | value | The text value to match. |
Returns
| Type | Description |
|---|---|
| SpecificTextFormattingRule | The newly created SpecificTextFormattingRule instance. |
AddThreeColorScale(string, SpreadsheetColor, SpreadsheetColor, SpreadsheetColor)
Adds a three-color scale conditional formatting rule.
Declaration
public ThreeColorScaleFormattingRule AddThreeColorScale(string range, SpreadsheetColor minColor, SpreadsheetColor midColor, SpreadsheetColor maxColor)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
| SpreadsheetColor | minColor | The minimum color. |
| SpreadsheetColor | midColor | The midpoint color. |
| SpreadsheetColor | maxColor | The maximum color. |
Returns
| Type | Description |
|---|---|
| ThreeColorScaleFormattingRule | The newly created ThreeColorScaleFormattingRule instance. |
AddTop10(string, int)
Adds a top 10 conditional formatting rule.
Declaration
public Top10FormattingRule AddTop10(string range, int rank)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
| int | rank | The rank value (1-10). |
Returns
| Type | Description |
|---|---|
| Top10FormattingRule | The newly created Top10FormattingRule instance. |
AddTwoColorScale(string, SpreadsheetColor, SpreadsheetColor)
Adds a two-color scale conditional formatting rule.
Declaration
public TwoColorScaleFormattingRule AddTwoColorScale(string range, SpreadsheetColor minColor, SpreadsheetColor maxColor)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
| SpreadsheetColor | minColor | The minimum color. |
| SpreadsheetColor | maxColor | The maximum color. |
Returns
| Type | Description |
|---|---|
| TwoColorScaleFormattingRule | The newly created TwoColorScaleFormattingRule instance. |
AddUniqueValues(string)
Adds a unique values conditional formatting rule.
Declaration
public UniqueValuesFormattingRule AddUniqueValues(string range)
Parameters
| Type | Name | Description |
|---|---|---|
| string | range | The range address string. |
Returns
| Type | Description |
|---|---|
| UniqueValuesFormattingRule | The newly created UniqueValuesFormattingRule instance. |
Clear()
Removes all conditional formatting from the collection and unapplies them.
Declaration
public void Clear()
ClearRules(Range)
Clears all conditional formatting rules that intersect with the specified range.
Declaration
public void ClearRules(Range range)
Parameters
| Type | Name | Description |
|---|---|---|
| Range | range | The range to clear rules for. |
Contains(ConditionalFormatting)
Determines whether the collection contains the specified conditional formatting.
Declaration
public bool Contains(ConditionalFormatting item)
Parameters
| Type | Name | Description |
|---|---|---|
| ConditionalFormatting | item | The conditional formatting to locate. |
Returns
| Type | Description |
|---|---|
| bool |
|
Get(string)
Gets the conditional formatting that contains the specified range label.
Declaration
public ConditionalFormatting Get(string label)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | The range label to search for. |
Returns
| Type | Description |
|---|---|
| ConditionalFormatting | The matching ConditionalFormatting or |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<ConditionalFormatting> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<ConditionalFormatting> | An enumerator for the collection. |
Remove(ConditionalFormatting)
Removes the specified conditional formatting from the collection.
Declaration
public void Remove(ConditionalFormatting item)
Parameters
| Type | Name | Description |
|---|---|---|
| ConditionalFormatting | item | The conditional formatting to remove. |