TimePeriodType Property

Gets or sets one of the constants of CFTimePeriods enumeration which represents the type of the time period.
Property TimePeriodType As CFTimePeriods
Dim instance As IConditionalFormat
Dim value As CFTimePeriods
instance.TimePeriodType = value
value = instance.TimePeriodType
CFTimePeriods TimePeriodType {get; set;}
The applicable time period in a "date occurring�" conditional formatting rule. This can be ignored if FormatType is not equal to TimePeriod.
For ExcelCFType.TimePeriod conditional formatting type we can set the criteria by setting a value from CFTimePeriods enumeration to TimePeriodType property. Here for example, we set CFTimePeriods.ThisMonth to TimePeriodType property.
using Syncfusion.XlsIO;
using System;
class Example
    static void Main()
        using (ExcelEngine excelEngine = new ExcelEngine())
            //Create a worksheet.        
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            //Load data to Apply Conditional Formatting.
            worksheet["B1"].Text = "Conditional Formats";
            worksheet["B2"].DateTime = DateTime.Today;
            worksheet["B3"].DateTime = DateTime.Parse("1/18/2015");
            worksheet["B4"].DateTime = DateTime.Today;
            worksheet["B5"].DateTime = DateTime.Today;
            worksheet["B6"].DateTime = DateTime.Parse("1/18/2016");
            worksheet["B7"].DateTime = DateTime.Today;
            worksheet["B8"].DateTime = DateTime.Today;
            worksheet["B9"].DateTime = DateTime.Parse("1/18/2017");
            worksheet["B10"].DateTime = DateTime.Today;
            worksheet["B11"].DateTime = DateTime.Today;
            //Create instance of IConditonalFormat and IConditionalFormats.
            IConditionalFormats formats = worksheet["B2:B11"].ConditionalFormats;
            IConditionalFormat format = formats.AddCondition();
            //Set FormatType.
            format.FormatType = ExcelCFType.TimePeriod;
            //Set TimePeriodType. (Condition)
            format.TimePeriodType = CFTimePeriods.ThisMonth;
            //Set NumberFormat.
            format.NumberFormat = "d-mmm";
            //Set color.
            format.BackColor = ExcelKnownColors.Red;
            //Save and Dispose.

Syncfusion.XlsIO.Base: 17.2460.0.34

See Also