0

sheet.setColumnWidth(13,(short)0); totally different

row.removeCell(13); doesn't work too.

What I should use for this goal?(delete cell)

Eldar
  • 13
  • 1
  • 8

1 Answers1

4

If you want to clear the data of a cell:

Option 1: set the cell's value to null. The advantage of this option is you don't need to get the cell style, alignment, font style, etc. for that cell.

row.getCell(13).setCellValue(null); 
Cell cell13 = cell.getCell(13);

Option 2: remove cell. When you take cell13 again, it will return null. That's why you need to create the cell and also the style.

 row.removeCell(13);
 Cell cell13 = cell.getCell(13);
Jonny Henly
  • 4,023
  • 4
  • 26
  • 43
Zaw Than oo
  • 9,651
  • 13
  • 83
  • 131
  • Your first option does not work as compiler says there are multiple ambiguous methods for .setCellValue(null) can be a date or boolean etc. – Fakipo Jan 11 '22 at 11:35