Daniel Infante
Daniel Infante

Reputation: 41

JAKARTA POI Remove entire row to a Excel (not only content)

I need to remove entirely a ROW using JAKARTA POI. I use this method:

HSSFSheet sheet= wb.getSheetAt(0);
HSSFRow row = hoja.getRow(15);
sheet.removeRow(row);

but the problem is that it only removes the content of the cells. Not de entire row.

Any ideas?

Upvotes: 0

Views: 231

Answers (2)

Daniel Infante
Daniel Infante

Reputation: 41

Thank you @CycDemo. I use this:

HSSFSheet hoja = wb.getSheetAt(0);
HSSFRow fila = hoja.getRow(numFila);
hoja.removeRow(fila);
hoja.shiftRows(numFila+1, hoja.getLastRowNum(), -1);

And it work fine!!!

Upvotes: 0

Zaw Than oo
Zaw Than oo

Reputation: 9935

Use HSSFSheet.shiftRows function. Example

 HSSFSheet.shiftRows(int startRow, int endRow, int n);

Upvotes: 2

Related Questions