Syncfusion.XlsIO.Base
Example 


TimePeriodType Property

Gets or sets one of the constants of CFTimePeriods enumeration which represents the type of the time period.
Syntax
'Declaration
 
Property TimePeriodType As CFTimePeriods
'Usage
 
Dim instance As IConditionalFormat
Dim value As CFTimePeriods
 
instance.TimePeriodType = value
 
value = instance.TimePeriodType
CFTimePeriods TimePeriodType {get; set;}
Remarks
The applicable time period in a "date occurring�" conditional formatting rule. This can be ignored if FormatType is not equal to TimePeriod.
Example
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.
            workbook.SaveAs("ConditionalFormats.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.1460.0.32

See Also