type property

  1. @override
ConditionValueType get type
override

Gets or sets the condition value type which specifies how the threshold values for a data bar, color scale, or icon set conditional format are determined. Read-only.

Implementation

@override

/// Gets or sets the condition value type
/// which specifies how the threshold values for a data bar, color scale,
/// or icon set conditional format are determined. Read-only.
ConditionValueType get type {
  return wrapped.type;
}
  1. @override
set type (ConditionValueType value)
override

Gets or sets a condition value which specifies how the threshold values for a DataBar, ColorScale and IconSet conditional format are determined. By default for IconSets ConditionValue.type property is set to ConditionValueType.percent. Here for example, we set ConditionValueType.percentile to ConditionValue.type property.

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

sheet.getRangeByName('A1').number = 125;
sheet.getRangeByName('A2').number = 279;
sheet.getRangeByName('A3').number = 42;
sheet.getRangeByName('A4').number = 384;
sheet.getRangeByName('A5').number = 129;
sheet.getRangeByName('A6').number = 212;
sheet.getRangeByName('A7').number = 131;
sheet.getRangeByName('A8').number = 230;

//Create iconset for the data in specified range.
final ConditionalFormats conditionalFormats =
    sheet.getRangeByName('A1:A8').conditionalFormats;
final ConditionalFormat conditionalFormat =
    conditionalFormats.addCondition();

//Set FormatType as IconSet.
conditionalFormat.formatType = ExcelCFType.iconSet;
final IconSet iconSet = conditionalFormat.iconSet;

//Set conditions for IconCriteria.
//Set icon set.
iconSet.iconSet = ExcelIconSetType.threeSymbols;
// Set Type and Value.
iconSet.iconCriteria[1].type = ConditionValueType.percentile;
iconSet.iconCriteria[1].value = "30";
iconSet.iconCriteria[2].type = ConditionValueType.percentile;
iconSet.iconCriteria[2].value = "60";

final List<int> bytes = workbook.saveAsStream();
File('IconSet.xlsx').writeAsBytes(bytes);
 workbook.dispose();

For DataBars the ConditionValue.type is set to ConditionValueType.automatic by default. Here for example, we set ConditionValueType.percent to ConditionValue.type property.

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

sheet.getRangeByName('A1').number = 125;
sheet.getRangeByName('A2').number = 279;
sheet.getRangeByName('A3').number = 42;
sheet.getRangeByName('A4').number = 384;
sheet.getRangeByName('A5').number = 129;
sheet.getRangeByName('A6').number = 212;
sheet.getRangeByName('A7').number = 131;
sheet.getRangeByName('A8').number = 230;

//Create dataBar for the data in specified range.
final ConditionalFormats conditionalFormats =
    sheet.getRangeByName('A1:A8').conditionalFormats;
final ConditionalFormat conditionalFormat =
    conditionalFormats.addCondition();

//Set conditions.
conditionalFormat.formatType = ExcelCFType.dataBar;
final DataBar dataBar = conditionalFormat.dataBar;

//Set the type and value.
dataBar.minPoint.type = ConditionValueType.percent;
dataBar.minPoint.value ='10';
dataBar.maxPoint.type = ConditionValueType.percent;
dataBar.maxPoint.value ='80';
//Set color for DataBar
dataBar.barColor = '#FF7C80';

//Hide the data bar values
dataBar.showValue = false;

final List<int> bytes = workbook.saveAsStream();
File('DataBar.xlsx').writeAsBytes(bytes);
workbook.dispose();

To set the ConditionValueType for ColorScale refer ColorConditionValue.Type property.

Implementation

@override
set type(ConditionValueType value) {
  _beginUpdate();
  wrapped.type = value;
  _endUpdate();
}