Compartilhar via


ConditionalFormattingRule Class

Conditional Formatting Rule.When the object is serialized out as xml, its qualified name is x:cfRule.

Inheritance Hierarchy

System.Object
  DocumentFormat.OpenXml.OpenXmlElement
    DocumentFormat.OpenXml.OpenXmlCompositeElement
      DocumentFormat.OpenXml.Spreadsheet.ConditionalFormattingRule

Namespace:  DocumentFormat.OpenXml.Spreadsheet
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

Syntax

'Declaration
<ChildElementInfoAttribute(GetType(ColorScale))> _
<ChildElementInfoAttribute(GetType(ConditionalFormattingRuleExtensionList))> _
<ChildElementInfoAttribute(GetType(Formula))> _
<ChildElementInfoAttribute(GetType(DataBar))> _
<ChildElementInfoAttribute(GetType(IconSet))> _
Public Class ConditionalFormattingRule _
    Inherits OpenXmlCompositeElement
'Usage
Dim instance As ConditionalFormattingRule
[ChildElementInfoAttribute(typeof(ColorScale))]
[ChildElementInfoAttribute(typeof(ConditionalFormattingRuleExtensionList))]
[ChildElementInfoAttribute(typeof(Formula))]
[ChildElementInfoAttribute(typeof(DataBar))]
[ChildElementInfoAttribute(typeof(IconSet))]
public class ConditionalFormattingRule : OpenXmlCompositeElement

Remarks

The following table lists the possible child types:

  • Formula <x:formula>

  • ColorScale <x:colorScale>

  • DataBar <x:dataBar>

  • IconSet <x:iconSet>

  • ConditionalFormattingRuleExtensionList <x:extLst>

[ISO/IEC 29500-1 1st Edition]

18.3.1.10 cfRule (Conditional Formatting Rule)

This collection represents a description of a conditional formatting rule.

[Example:

This example shows a conditional formatting rule highlighting cells whose values are greater than 0.5. Note that in this case the content of <formula> is a static value, but can also be a formula expression.

<conditionalFormatting sqref="E3:E9">
<cfRule type="cellIs" dxfId="0" priority="1" operator="greaterThan">
<formula>0.5</formula>
</cfRule>
</conditionalFormatting>

end example]

Only rules with a type attribute value of expression support formula syntax.

Parent Elements

conditionalFormatting (§18.3.1.18)

Child Elements

Subclause

colorScale (Color Scale)

§18.3.1.16

dataBar (Data Bar)

§18.3.1.28

extLst (Future Feature Data Storage Area)

§18.2.10

formula (Formula)

§18.3.1.43

iconSet (Icon Set)

§18.3.1.49

Attributes

Description

aboveAverage (Above Or Below Average)

Indicates whether the rule is an "above average" rule. '1' indicates 'above average'. This attribute is ignored if type is not equal to aboveAverage.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.

bottom (Bottom N)

Indicates whether a "top/bottom n" rule is a "bottom n" rule. '1' indicates 'bottom'. This attribute is ignored if type is not equal to top10.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.

dxfId (Differential Formatting Id)

This is an index to a dxf element in the Styles Part indicating which cell formatting to apply when the conditional formatting rule criteria is met.

The possible values for this attribute are defined by the ST_DxfId simple type (§18.18.25).

equalAverage (Equal Average)

Flag indicating whether the 'aboveAverage' and 'belowAverage' criteria is inclusive of the average itself, or exclusive of that value. '1' indicates to include the average value in the criteria. This attribute is ignored if type is not equal to aboveAverage.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.

operator (Operator)

The operator in a "cell value is" conditional formatting rule. This attribute is ignored if type is not equal to cellIs

The possible values for this attribute are defined by the ST_ConditionalFormattingOperator simple type (§18.18.15).

percent (Top 10 Percent)

Indicates whether a "top/bottom n" rule is a "top/bottom n percent" rule. This attribute is ignored if type is not equal to top10.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.

priority (Priority)

The priority of this conditional formatting rule. This value is used to determine which format should be evaluated and rendered. Lower numeric values are higher priority than higher numeric values, where '1' is the highest priority.

The possible values for this attribute are defined by the W3C XML Schema int datatype.

rank (Rank)

The value of "n" in a "top/bottom n" conditional formatting rule. This attribute is ignored if type is not equal to top10.

The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.

stdDev (StdDev)

The number of standard deviations to include above or below the average in the conditional formatting rule. This attribute is ignored if type is not equal to aboveAverage. If a value is present for stdDev and the rule type = aboveAverage, then this rule is automatically an "above or below N standard deviations" rule.

The possible values for this attribute are defined by the W3C XML Schema int datatype.

stopIfTrue (Stop If True)

If this flag is '1', no rules with lower priority shall be applied over this rule, when this rule evaluates to true.

The possible values for this attribute are defined by the W3C XML Schema boolean datatype.

text (Text)

The text value in a "text contains" conditional formatting rule. This attribute is ignored if type is not equal to containsText.

The possible values for this attribute are defined by the W3C XML Schema string datatype.

timePeriod (Time Period)

The applicable time period in a "date occurring…" conditional formatting rule. This attribute is ignored if type is not equal to timePeriod.

The possible values for this attribute are defined by the ST_TimePeriod simple type (§18.18.82).

type (Type)

Type of conditional formatting rule.

The possible values for this attribute are defined by the ST_CfType simple type (§18.18.12).

[Note: The W3C XML Schema definition of this element’s content model (CT_CfRule) is located in §A.2. end note]

© ISO/IEC29500: 2008.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ConditionalFormattingRule Members

DocumentFormat.OpenXml.Spreadsheet Namespace