Back to Devexpress

XlCondFmtRuleBlanks Class

corelibraries-devexpress-dot-export-dot-xl-aaab2dcd.md

latest3.3 KB
Original Source

XlCondFmtRuleBlanks Class

Represents the conditional formatting rule that highlights blank/non-blank cells.

Namespace : DevExpress.Export.Xl

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

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public class XlCondFmtRuleBlanks :
    XlCondFmtRuleWithFormatting
vb
Public Class XlCondFmtRuleBlanks
    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:A10).
formatting.Ranges.Add(XlCellRange.FromLTRB(0, 0, 0, 9));
// Create the rule to highlight blank cells in the range.
XlCondFmtRuleBlanks rule = new XlCondFmtRuleBlanks(true);
// 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 non-blank cells in the range.
rule = new XlCondFmtRuleBlanks(false);
// 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);
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:A10).
formatting.Ranges.Add(XlCellRange.FromLTRB(0, 0, 0, 9))
' Create the rule to highlight blank cells in the range.
Dim rule As New XlCondFmtRuleBlanks(True)
' 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 non-blank cells in the range.
rule = New XlCondFmtRuleBlanks(False)
' 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)

Inheritance

Object XlCondFmtRule XlCondFmtRuleWithFormatting XlCondFmtRuleBlanks

See Also

XlCondFmtRuleBlanks Members

DevExpress.Export.Xl Namespace