excel icon indicating copy to clipboard operation
excel copied to clipboard

How to Preserve Cell Formatting When Updating Cell Values Using the Excel Packag

Open hidayet-poscu opened this issue 1 year ago • 1 comments

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?

hidayet-poscu avatar Aug 25 '24 07:08 hidayet-poscu

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,
);

pamtbaau avatar Jun 22 '25 17:06 pamtbaau