Back to Devexpress

XlCondFmtRuleCellIs Class

corelibraries-devexpress-dot-export-dot-xl-6be83fdb.md

latest5.6 KB
Original Source

XlCondFmtRuleCellIs Class

Represents the conditional formatting rule that uses the relational operator.

Namespace : DevExpress.Export.Xl

Assembly : DevExpress.Printing.v25.2.Core.dll

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public class XlCondFmtRuleCellIs :
    XlCondFmtRuleWithFormatting
vb
Public Class XlCondFmtRuleCellIs
    Inherits XlCondFmtRuleWithFormatting

Example

Note

A complete sample project is available at https://github.com/DevExpress-Examples/excel-export-api-examples

csharp
// Create an instance of the XlConditionalFormatting class. 
XlConditionalFormatting formatting = new XlConditionalFormatting();
// Specify the cell range to which the conditional formatting rules should be applied (A1:A11).
formatting.Ranges.Add(XlCellRange.FromLTRB(0, 0, 0, 10));
// Create the rule to highlight cells whose values are less than 5.
XlCondFmtRuleCellIs rule = new XlCondFmtRuleCellIs();
rule.Operator = XlCondFmtOperator.LessThan;
rule.Value = 5;
// Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Bad;
formatting.Rules.Add(rule);
// Create the rule to highlight cells whose values are between 5 and 8.
rule = new XlCondFmtRuleCellIs();
rule.Operator = XlCondFmtOperator.Between;
rule.Value = 5;
rule.SecondValue = 8;
// Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Neutral;
formatting.Rules.Add(rule);
// Create the rule to highlight cells whose values are greater than 8.
rule = new XlCondFmtRuleCellIs();
rule.Operator = XlCondFmtOperator.GreaterThan;
rule.Value = 8;
// Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Good;
formatting.Rules.Add(rule);
// Add the specified format options to the worksheet collection of conditional formats.
sheet.ConditionalFormattings.Add(formatting);

// Create an instance of the XlConditionalFormatting class. 
formatting = new XlConditionalFormatting();
// Specify the cell range to which the conditional formatting rule should be applied (B1:B11).
formatting.Ranges.Add(XlCellRange.FromLTRB(1, 0, 1, 10));
// Create the rule to highlight cells whose values are greater than a value calculated by a formula. 
rule = new XlCondFmtRuleCellIs();
rule.Operator = XlCondFmtOperator.GreaterThan;
rule.Value = "=$A1+3";
// Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Bad;
formatting.Rules.Add(rule);
// Add the specified format options to the worksheet collection of conditional formats.
sheet.ConditionalFormattings.Add(formatting);
vb
' Create an instance of the XlConditionalFormatting class. 
Dim formatting As New XlConditionalFormatting()
' Specify the cell range to which the conditional formatting rules should be applied (A1:A11).
formatting.Ranges.Add(XlCellRange.FromLTRB(0, 0, 0, 10))
' Create the rule to highlight cells whose values are less than 5.
Dim rule As New XlCondFmtRuleCellIs()
rule.Operator = XlCondFmtOperator.LessThan
rule.Value = 5
' Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Bad
formatting.Rules.Add(rule)
' Create the rule to highlight cells whose values are between 5 and 8.
rule = New XlCondFmtRuleCellIs()
rule.Operator = XlCondFmtOperator.Between
rule.Value = 5
rule.SecondValue = 8
' Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Neutral
formatting.Rules.Add(rule)
' Create the rule to highlight cells whose values are greater than 8.
rule = New XlCondFmtRuleCellIs()
rule.Operator = XlCondFmtOperator.GreaterThan
rule.Value = 8
' Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Good
formatting.Rules.Add(rule)
' Add the specified format options to the worksheet collection of conditional formats.
sheet.ConditionalFormattings.Add(formatting)

' Create an instance of the XlConditionalFormatting class. 
formatting = New XlConditionalFormatting()
' Specify the cell range to which the conditional formatting rule should be applied (B1:B11).
formatting.Ranges.Add(XlCellRange.FromLTRB(1, 0, 1, 10))
' Create the rule to highlight cells whose values are greater than a value calculated by a formula. 
rule = New XlCondFmtRuleCellIs()
rule.Operator = XlCondFmtOperator.GreaterThan
rule.Value = "=$A1+3"
' Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Bad
formatting.Rules.Add(rule)
' Add the specified format options to the worksheet collection of conditional formats.
sheet.ConditionalFormattings.Add(formatting)

Inheritance

Object XlCondFmtRule XlCondFmtRuleWithFormatting XlCondFmtRuleCellIs

See Also

XlCondFmtRuleCellIs Members

DevExpress.Export.Xl Namespace