Syncfusion.XlsIO.Base
Example 


NumberFormat Property (IConditionalFormat)

Gets or sets number format of the conditional format rule.
Syntax
'Declaration
 
Property NumberFormat As String
'Usage
 
Dim instance As IConditionalFormat
Dim value As String
 
instance.NumberFormat = value
 
value = instance.NumberFormat
string NumberFormat {get; set;}
Example
Number format for the values in the cells within the conditional formatting range can be set by using NumberFormat property. Here for example, we set "d-mmm" to NumberFormat.
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.2460.0.34

See Also