excel
excel copied to clipboard
How to Preserve Cell Formatting When Updating Cell Values Using the Excel Packag
When using the Excel package, whenever a cell's value is updated, the cell's formatting style disappears and reverts back to the default style. How can I solve this issue?
I faced the same issue, but solved it by using sheetObject.updateCell(), which has a cellStyle argument:
final cell = sheetObject.cell(CellIndex.indexByString('A1');
sheetObject.updateCell(
cell.cellIndex,
TextCellValue('My new value'),
cellStyle: cell.cellStyle,
);