corelibraries-devexpress-dot-export-dot-xl-af82ea79.md
Represents the “Date Occurring…” conditional formatting rule.
Namespace : DevExpress.Export.Xl
Assembly : DevExpress.Printing.v25.2.Core.dll
NuGet Package : DevExpress.Printing.Core
public class XlCondFmtRuleTimePeriod :
XlCondFmtRuleWithFormatting
Public Class XlCondFmtRuleTimePeriod
Inherits XlCondFmtRuleWithFormatting
The conditional formatting rule specified by the XlCondFmtRuleTimePeriod object highlights cells containing dates in the specified time period.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/excel-export-api-examples
// 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 yesterday's dates in the cell range.
XlCondFmtRuleTimePeriod rule = new XlCondFmtRuleTimePeriod();
rule.TimePeriod = XlCondFmtTimePeriod.Yesterday;
// 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 today's dates in the cell range.
rule = new XlCondFmtRuleTimePeriod();
rule.TimePeriod = XlCondFmtTimePeriod.Today;
// Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Good;
formatting.Rules.Add(rule);
// Create the rule to highlight tomorrows's dates in the cell range.
rule = new XlCondFmtRuleTimePeriod();
rule.TimePeriod = XlCondFmtTimePeriod.Tomorrow;
// Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Neutral;
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.
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 yesterday's dates in the cell range.
Dim rule As New XlCondFmtRuleTimePeriod()
rule.TimePeriod = XlCondFmtTimePeriod.Yesterday
' 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 today's dates in the cell range.
rule = New XlCondFmtRuleTimePeriod()
rule.TimePeriod = XlCondFmtTimePeriod.Today
' Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Good
formatting.Rules.Add(rule)
' Create the rule to highlight tomorrows's dates in the cell range.
rule = New XlCondFmtRuleTimePeriod()
rule.TimePeriod = XlCondFmtTimePeriod.Tomorrow
' Specify formatting settings to be applied to cells if the condition is true.
rule.Formatting = XlCellFormatting.Neutral
formatting.Rules.Add(rule)
' Add the specified format options to the worksheet collection of conditional formats.
sheet.ConditionalFormattings.Add(formatting)
Object XlCondFmtRule XlCondFmtRuleWithFormatting XlCondFmtRuleTimePeriod
See Also