index property

  1. @override
int get index
override

Represents cell style index.

final Workbook workbook = Workbook();
final Worksheet sheet = workbook.worksheets[0];
final Style style = workbook.styles.add('style');
style.backColor = '#37D8E9';
final Range range1 = sheet.getRangeByIndex(3, 4);
range1.number = 10;
range1.cellStyle = style;
// Check index.
print(workbook.styles[1].index);
final List<int> bytes = workbook.saveAsStream();
File('CellStyle.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

@override
int get index {
  int indexStyle = 0;
  bool first = true;
  final int last = _arrRanges.length;
  for (int index = 0; index < last; index++) {
    final Range range = _arrRanges[index];

    if (first) {
      indexStyle = range.cellStyle.index;
      first = false;
    } else if (range.cellStyle.index != indexStyle) {
      return 1;
    }
  }
  return indexStyle;
}
  1. @override
set index (int value)
override

Represents cell style index.

final Workbook workbook = Workbook();
final Worksheet sheet = workbook.worksheets[0];
final Style style = workbook.styles.add('style');
style.backColor = '#37D8E9';
final Range range1 = sheet.getRangeByIndex(3, 4);
range1.number = 10;
range1.cellStyle = style;
// Check index.
print(workbook.styles[1].index);
final List<int> bytes = workbook.saveAsStream();
File('CellStyle.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

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