backColorRgb property

  1. @override
Color get backColorRgb
override

Gets/sets back color Rgb.

final Workbook workbook = Workbook();
final Worksheet sheet = workbook.worksheets[0];
final CellStyle cellStyle1 = CellStyle(workbook);
cellStyle1.name = 'Style1';
// set backcolor Rgb.
cellStyle1.backColorRgb = Color.fromARgb(255, 56, 250, 0);
workbook.styles.addStyle(cellStyle1);
final Range range1 = sheet.getRangeByIndex(1, 1);
range1.cellStyle = cellStyle1;
final List<int> bytes = workbook.saveAsStream();
File('CellStyle.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

@override
Color get backColorRgb {
  Color backColorStyle = const Color.fromARGB(255, 0, 0, 0);
  bool first = true;

  final int last = _arrRanges.length;
  for (int index = 0; index < last; index++) {
    final Range range = _arrRanges[index];

    if (first) {
      backColorStyle = range.cellStyle.backColorRgb;
      first = false;
    } else if (range.cellStyle.backColorRgb != backColorStyle) {
      return const Color.fromARGB(255, 0, 0, 0);
    }
  }
  return backColorStyle;
}
  1. @override
set backColorRgb (Color value)
override

Gets/sets back color Rgb.

final Workbook workbook = Workbook();
final Worksheet sheet = workbook.worksheets[0];
final CellStyle cellStyle1 = CellStyle(workbook);
cellStyle1.name = 'Style1';
// set backcolor Rgb.
cellStyle1.backColorRgb = Color.fromARgb(255, 56, 250, 0);
workbook.styles.addStyle(cellStyle1);
final Range range1 = sheet.getRangeByIndex(1, 1);
range1.cellStyle = cellStyle1;
final List<int> bytes = workbook.saveAsStream();
File('CellStyle.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

@override
set backColorRgb(Color value) {
  final int last = _arrRanges.length;
  for (int index = 0; index < last; index++) {
    final Range range = _arrRanges[index];
    range.cellStyle.backColorRgb = value;
  }
}