numberFormat property
Gets/sets cell numberFormat.
final Workbook workbook = Workbook();
final Worksheet sheet = workbook.worksheets[0];
final Style style = workbook.styles.add('style');
// set number format.
style.numberFormat = '_(\$* #,##0_)';
final Range range1 = sheet.getRangeByIndex(3, 4);
range1.number = 10;
range1.cellStyle = style;
final List<int> bytes = workbook.saveAsStream();
File('CellStyle.xlsx').writeAsBytes(bytes);
workbook.dispose();
Implementation
@override
//Represent numberFormat
String? get numberFormat {
String? numberFormatStyle;
bool first = true;
final int last = _arrRanges.length;
for (int index = 0; index < last; index++) {
final Range range = _arrRanges[index];
if (first) {
numberFormatStyle = range.cellStyle.numberFormat;
first = false;
} else if (range.cellStyle.numberFormat != numberFormatStyle) {
return 'General';
}
}
return numberFormatStyle;
}
Gets/sets cell numberFormat.
final Workbook workbook = Workbook();
final Worksheet sheet = workbook.worksheets[0];
final Style style = workbook.styles.add('style');
// set number format.
style.numberFormat = '_(\$* #,##0_)';
final Range range1 = sheet.getRangeByIndex(3, 4);
range1.number = 10;
range1.cellStyle = style;
final List<int> bytes = workbook.saveAsStream();
File('CellStyle.xlsx').writeAsBytes(bytes);
workbook.dispose();
Implementation
@override
set numberFormat(String? value) {
final int last = _arrRanges.length;
for (int index = 0; index < last; index++) {
final Range range = _arrRanges[index];
range.cellStyle.numberFormat = value;
}
}