Syncfusion.XlsIO.Base
Example 


Operator Property (IConditionalFormat)

Gets or sets the comparison operator for the conditional format.
Syntax
'Declaration
 
Property Operator As ExcelComparisonOperator
'Usage
 
Dim instance As IConditionalFormat
Dim value As ExcelComparisonOperator
 
instance.Operator = value
 
value = instance.Operator
ExcelComparisonOperator Operator {get; set;}
Example
If conditional formats applied based on the ExcelCFType.CellValue then the Operator should be used to apply conditional formats based on the value present in the cell. We can choose condition that is required from the ExcelComparisonOperator enumeration. Here for example, we apply borders for the cells which have values between "20" and "60". For Operator we set ExcelComparisonOperator.Between to apply conditional formats for the cells with values within the range "20" and "60".
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"].Number = 10;
            worksheet["B3"].Number = 20;
            worksheet["B4"].Number = 30;
            worksheet["B5"].Number = 40;
            worksheet["B6"].Number = 50;
            worksheet["B7"].Number = 60;
            worksheet["B8"].Number = 70;
            worksheet["B9"].Number = 80;
            worksheet["B10"].Number = 90;
            worksheet["B11"].Number = 100;
            
            //Create instance of IConditonalFormat and IConditionalFormats.
            IConditionalFormats formats = worksheet["B2:B11"].ConditionalFormats;
            IConditionalFormat format = formats.AddCondition();
            
            //Set Condition.
            format.FirstFormula = "60";
            format.SecondFormula = "20";
            
            //Set Operator.
            format.Operator = ExcelComparisonOperator.Between;
            
            //Apply Conditional format.
            format.BottomBorderStyle = ExcelLineStyle.Thick;
            format.LeftBorderStyle = ExcelLineStyle.Thick;
            format.TopBorderStyle = ExcelLineStyle.Thick;
            format.RightBorderStyle = ExcelLineStyle.Thick;
                
            //Set Border color.
            format.BottomBorderColor = ExcelKnownColors.Red;
            format.LeftBorderColor = ExcelKnownColors.Red;
            format.TopBorderColor = ExcelKnownColors.Red;
            format.RightBorderColor = ExcelKnownColors.Red;
            
            //Save and Dispose.
            workbook.SaveAs("ConditionalFormats.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.2460.0.34

See Also