updateCell method
Updates the contents of sheet
of the cellIndex: CellIndex.indexByColumnRow(0, 0);
where indexing starts from 0
----or---- by cellIndex: CellIndex.indexByString("A3");
.
Styling of cell can be done by passing the CellStyle object to cellStyle
.
If sheet
does not exist then it will be automatically created.
Implementation
void updateCell(CellIndex cellIndex, dynamic value, {CellStyle? cellStyle}) {
int columnIndex = cellIndex._columnIndex;
int rowIndex = cellIndex._rowIndex;
if (columnIndex < 0 || rowIndex < 0) {
return;
}
_checkMaxCol(columnIndex);
_checkMaxRow(rowIndex);
int newRowIndex = rowIndex, newColumnIndex = columnIndex;
/// Check if this is lying in merged-cell cross-section
/// If yes then get the starting position of merged cells
if (_spanList.isNotEmpty) {
List updatedPosition = _isInsideSpanning(rowIndex, columnIndex);
newRowIndex = updatedPosition[0];
newColumnIndex = updatedPosition[1];
}
/// Puts Data
_putData(newRowIndex, newColumnIndex, value);
/// Puts the cellStyle
if (cellStyle != null) {
_sheetData[newRowIndex]![newColumnIndex]!._cellStyle = cellStyle;
_excel._colorChanges = true;
}
}