officefileapi-devexpress-dot-spreadsheet-2f0ae22e.md
Represents a "date occurring…" conditional formatting rule.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
public interface TimePeriodConditionalFormatting :
ConditionalFormatting,
ISupportsFormatting
Public Interface TimePeriodConditionalFormatting
Inherits ConditionalFormatting,
ISupportsFormatting
The following members return TimePeriodConditionalFormatting objects:
The conditional formatting rule specified by the TimePeriodConditionalFormatting object highlights cells containing dates in the specified time period. The Worksheet.ConditionalFormattings property returns the ConditionalFormattingCollection collection that stores all conditional formatting rules specified on a worksheet. Use the methods of the ConditionalFormattingCollection object to apply (the ConditionalFormattingCollection.AddTimePeriodConditionalFormatting method) or remove (the ConditionalFormattingCollection.Remove method) the conditional format.
This example demonstrates how to apply a "date occurring…" conditional formatting rule.
To create a new conditional formatting rule represented by the TimePeriodConditionalFormatting object, access the collection of conditional formats from the Worksheet.ConditionalFormattings property and call the ConditionalFormattingCollection.AddTimePeriodConditionalFormatting method. Pass the following parameters:
Specify formatting options to be applied to cells if the condition is true using the ISupportsFormatting.Formatting property of the TimePeriodConditionalFormatting object.
Note
Transparency is not supported in conditional formatting.
To remove the TimePeriodConditionalFormatting object, use the ConditionalFormattingCollection.Remove, ConditionalFormattingCollection.RemoveAt or ConditionalFormattingCollection.Clear methods.
// Create the rule to highlight today's dates in cells B2 through B6.
TimePeriodConditionalFormatting cfRule =
worksheet.ConditionalFormattings.AddTimePeriodConditionalFormatting(worksheet.Range["$B$2:$B$6"], ConditionalFormattingTimePeriod.Today);
// Specify formatting options to be applied to cells if the condition is true.
// Set the background color to pink.
cfRule.Formatting.Fill.BackgroundColor = Color.FromArgb(255, 0xF2, 0xAE, 0xE3);
' Create the rule to highlight today's dates in cells B2 through B6.
Dim cfRule As TimePeriodConditionalFormatting = worksheet.ConditionalFormattings.AddTimePeriodConditionalFormatting(worksheet.Range("$B$2:$B$6"), ConditionalFormattingTimePeriod.Today)
' Specify formatting options to be applied to cells if the condition is true.
' Set the background color to pink.
cfRule.Formatting.Fill.BackgroundColor = Color.FromArgb(255, &HF2, &HAE, &HE3)
See Also