operator property

ExcelComparisonOperator operator
getter/setter pair

Gets or sets the comparison operator for the conditional format.

  // 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();

  //Set formatType.
  condition1.formatType = ExcelCFType.cellValue;

  //Set operators.
  condition1.operator = ExcelComparisonOperator.greater;

  //Set firstFormula.
  condition1.firstFormula = '30';

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

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

Implementation

late ExcelComparisonOperator operator;