stopIfTrue property

bool stopIfTrue
getter/setter pair

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.

// Create a new Excel Document.
final Workbook workbook = Workbook();
// Accessing sheet via index.
final Worksheet sheet = workbook.worksheets[0];

sheet.getRangeByIndex(1, 1).setText('Conditional Formts');
sheet.getRangeByIndex(2, 1).setNumber(10);
sheet.getRangeByIndex(3, 1).setNumber(20);
sheet.getRangeByIndex(4, 1).setNumber(30);
sheet.getRangeByIndex(5, 1).setNumber(40);
sheet.getRangeByIndex(6, 1).setNumber(50);
sheet.getRangeByIndex(7, 1).setNumber(60);
sheet.getRangeByIndex(8, 1).setNumber(70);
sheet.getRangeByIndex(9, 1).setNumber(80);
sheet.getRangeByIndex(10, 1).setNumber(90);
sheet.getRangeByIndex(11, 1).setNumber(100);

//Applying conditional formatting to "A1:A11".
final ConditionalFormats conditions =
    sheet.getRangeByName('A1:A11').conditionalFormats;
final ConditionalFormat condition1 = conditions.addCondition();
final ConditionalFormat condition2 = conditions.addCondition();
final ConditionalFormat condition3 = conditions.addCondition();

//set conditions
condition1.formatType = ExcelCFType.cellValue;
condition1.operator = ExcelComparisonOperator.between;
condition1.firstFormula = '10';
condition1.secondFormula = '40';

//Set color.
condition1.backColor = '#66FF99';

//set conditions
condition2.formatType = ExcelCFType.cellValue;
condition2.operator = ExcelComparisonOperator.between;
condition2.firstFormula = '30';
condition2.secondFormula = '60';
condition2.stopIfTrue = true;

//Set color.
condition2.backColor = '#99FF66';

//set conditions
condition3.formatType = ExcelCFType.cellValue;
condition3.operator = ExcelComparisonOperator.between;
condition3.firstFormula = '50';
condition3.secondFormula = '100';

//Set color.
condition3.backColor = '#FF9966';

//save and dispose.
final List<int> bytes = workbook.saveAsStream();
File('ConditionalFormatting.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

late bool stopIfTrue;