percentMax property

int percentMax
getter/setter pair

Gets or sets a value that specifies the length of the longest data bar as a percentage of cell width.

// 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 minumum percentage.
dataBar.percentMax = 90;

//Set color for DataBar
dataBar.barColor = '#FF7C80';

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

Implementation

late int percentMax;