dataBar property
Gets data bar conditional formatting rule.
// Create a new Excel Document.
final Workbook workbook = Workbook();
// Accessing sheet via index.
final Worksheet sheet = workbook.worksheets[0];
sheet.getRangeByName('A1').number = 12;
sheet.getRangeByName('A2').number = 29;
sheet.getRangeByName('A3').number = 41;
sheet.getRangeByName('A4').number = -84;
sheet.getRangeByName('A5').number = 90;
sheet.getRangeByName('A6').number = 112;
sheet.getRangeByName('A7').number = 131;
sheet.getRangeByName('A8').number = 20;
//Create data bars for the data in specified range.
final ConditionalFormats conditionalFormats =
sheet.getRangeByName('A1:A8').conditionalFormats;
final ConditionalFormat conditionalFormat = conditionalFormats.addCondition();
conditionalFormat.formatType = ExcelCFType.dataBar;
final DataBar dataBar = conditionalFormat.dataBar;
//Set type and value.
dataBar.minPoint.type = ConditionValueType.percent;
dataBar.minPoint.value = '20';
dataBar.maxPoint.type = ConditionValueType.percent;
dataBar.maxPoint.value = '90';
//Set color for DataBar
dataBar.barColor = '#FF7C80';
final List<int> bytes = workbook.saveAsStream();
File('DataBar.xlsx').writeAsBytes(bytes);
workbook.dispose();
Implementation
DataBar? dataBar;