Syncfusion.XlsIO.Base
Example 


StopIfTrue Property

Gets or sets a boolean value that determines if additional formatting rules on the cell should be evaluated if the current rule evaluates to True.
Syntax
'Declaration
 
Property StopIfTrue As Boolean
'Usage
 
Dim instance As IConditionalFormat
Dim value As Boolean
 
instance.StopIfTrue = value
 
value = instance.StopIfTrue
bool StopIfTrue {get; set;}
Example
StopIfTrue is set to False by default. If we set it to True formatting is applied based on the priority. If a higher priority rule for particular cells gets satisfied then the preceding rules are not applied for those cells.
using Syncfusion.XlsIO;
using System;
using System.Drawing;
             
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();
            IConditionalFormat format2 = formats.AddCondition();
            IConditionalFormat format3 = formats.AddCondition();
             
            //Set Condition.
            format.FirstFormula = "60";
            format.SecondFormula = "20";
            format.Operator = ExcelComparisonOperator.Between;
             
            //Set Color.
            format.BackColor = ExcelKnownColors.Red;
             
            //Set StopIfTrue.
            format.StopIfTrue = true;
             
            //Set Condition.
            format2.FirstFormula = "30";
            format2.SecondFormula = "70";
            format2.Operator = ExcelComparisonOperator.Between;
             
             //Set Color.            
            format2.BackColor = ExcelKnownColors.Blue;
             
            //Set StopIfTrue. 
            format2.StopIfTrue = true;
             
            //Set Condition.            
            format3.FirstFormula = "30";
            format3.SecondFormula = "50";
            format3.Operator = ExcelComparisonOperator.Between;
             
             //Set Color.            
            format3.BackColor = ExcelKnownColors.Green;
            
            //Set StopIfTrue.
            format3.StopIfTrue = true;
             
            //Save and Dispose.
            workbook.SaveAs("ConditionalFormats.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.1460.0.32

See Also