Class ConditionType
Represents a type of a conditional formatting rule
Inheritance
Namespace: IronXL.Formatting
Assembly: IronXL.dll
Syntax
public class ConditionType : Object
ConditionType names the kind of test a conditional formatting rule runs, so a developer chooses whether a rule compares a cell value, paints a color scale, draws a data bar, or evaluates a formula. It is the type-safe set of condition categories that sits behind a ConditionalFormattingRule, and it answers the "what triggers this rule" question a developer faces when styling a spreadsheet by criteria.
A ConditionType reaches a rule through the ConditionType property on ConditionalFormattingRule. When a rule is created through CreateConditionalFormattingRule, IronXL sets the appropriate condition category for that rule; reading the property tells a developer which test the rule performs. The value belongs to the rule that conditional formatting on a worksheet applies to a cell range.
The members cover the conditional formatting categories Excel supports. CellValueIs compares the cell against a constant with a comparison operator, the everyday case for "less than 8" or "greater than 100". Formula evaluates a custom expression. ColorScale, DataBar, and IconSet drive the graphical condition types that shade cells, draw in-cell bars, or place status icons. Filter covers top/bottom and similar filter conditions. Each value exposes a numeric Id and a Type, and the static ForId method resolves a ConditionType from its byte or integer id when a rule is read back from a loaded file. Most code does not name ConditionType directly, because CreateConditionalFormattingRule selects it, so reach for it when inspecting or branching on a rule's category.
using IronXL;
using IronXL.Formatting;
WorkBook book = WorkBook.Load("report.xlsx");
WorkSheet sheet = book.DefaultWorkSheet;
ConditionalFormattingRule rule =
sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.LessThan, "8");
Console.WriteLine(rule.ConditionType.Type);The conditional formatting how-to walks through building rules, the conditional formatting example shows a working rule applied to a range, and the style cells example covers the styles a rule can apply.
Fields
CellValueIs
This conditional formatting rule compares a cell value to a formula calculated result, using an operator
Declaration
public static ConditionType CellValueIs
Field Value
| Type | Description |
|---|---|
| ConditionType |
ColorScale
Declaration
public static ConditionType ColorScale
Field Value
| Type | Description |
|---|---|
| ConditionType |
DataBar
This conditional formatting rule sets a data bar, with the cell populated with bars based on their values
Declaration
public static ConditionType DataBar
Field Value
| Type | Description |
|---|---|
| ConditionType |
Filter
This conditional formatting rule that files the values
Declaration
public static ConditionType Filter
Field Value
| Type | Description |
|---|---|
| ConditionType |
Formula
This conditional formatting rule contains a formula to evaluate. When the formula result is true, the cell is highlighted.
Declaration
public static ConditionType Formula
Field Value
| Type | Description |
|---|---|
| ConditionType |
IconSet
This conditional formatting rule sets a data bar, with the cell populated with bars based on their values
Declaration
public static ConditionType IconSet
Field Value
| Type | Description |
|---|---|
| ConditionType |
Properties
Id
Type's numeric id
Declaration
public byte Id { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
Type
Internal condition type name
Declaration
public string Type { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
Equals(Object)
Determines whether the specified object is equal to the current ConditionType.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | The object to compare with the current ConditionType. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the specified object is equal to the current object; otherwise, false. |
ForId(Byte)
Get ConditionType for specified id
Declaration
public static ConditionType ForId(byte id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte | id | ConditionType id |
Returns
| Type | Description |
|---|---|
| ConditionType | ConditionType that corresponds to specified id |
ForId(Int32)
Get ConditionType for specified id
Declaration
public static ConditionType ForId(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | id | ConditionType id |
Returns
| Type | Description |
|---|---|
| ConditionType | ConditionType that corresponds to specified id |
GetHashCode()
Hash function
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | Hash code for current ConditionType |
ToString()
Represents ConditionType in a string format
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String |
Operators
Explicit(ConditionType to <b7b8378d-f600-4305-960a-074ac349f14c>ConditionType)
Declaration
public static explicit operator < b7b8378d - f600 - 4305 - 960 a - 074 ac349f14c > ConditionType(ConditionType obj)
Parameters
| Type | Name | Description |
|---|---|---|
| ConditionType | obj |
Returns
| Type | Description |
|---|---|
| NPOI.SS.UserModel.<b7b8378d-f600-4305-960a-074ac349f14c>ConditionType |
Explicit(<b7b8378d-f600-4305-960a-074ac349f14c>ConditionType to ConditionType)
Declaration
public static explicit operator ConditionType( < b7b8378d - f600 - 4305 - 960 a - 074 ac349f14c > ConditionType obj)
Parameters
| Type | Name | Description |
|---|---|---|
| NPOI.SS.UserModel.<b7b8378d-f600-4305-960a-074ac349f14c>ConditionType | obj |
Returns
| Type | Description |
|---|---|
| ConditionType |