setValue method
Set value to the range.
Workbook workbook = new Workbook();
Worksheet sheet = workbook.worksheets[0];
Range range = sheet.getRangeByName('A1');
range.setValue('Hello World');
List<int> bytes = workbook.saveAsStream();
File('Value.xlsx').writeAsBytes(bytes);
workbook.dispose();
Implementation
void setValue(Object? value) {
if (value != null) {
if (isSingleRange) {
if (value is num) {
setNumber(value.toDouble());
} else if (value is DateTime) {
setDateTime(value);
} else if (value is String) {
setText(value);
} else {
setText(value.toString());
}
} else {
// ignore: prefer_final_locals
for (int iRow = row, iLastRow = lastRow; iRow <= iLastRow; iRow++) {
// ignore: prefer_final_locals
for (int iCol = column, iLastCol = lastColumn;
iCol <= iLastCol;
iCol++) {
worksheet.getRangeByIndex(iRow, iCol).value = value;
}
}
}
}
}