0

I need to add a line between two existing lines. I need a new blank line. Is there some method in poi package for this?

 public void endossar(String controle) {
    Iterator ite = null;
    try {
        ite = c.conectar("sheet").iterator();
    } catch (IOException ex) {

    }
    while (ite.hasNext()) {
        XSSFRow row = (XSSFRow) ite.next();
        if (row.getCell(0).toString().equals(controle)) {

            row.setRowNum(row.getRowNum()+1);

            // help here, include a new blank line

        }
    }
}
  • Have you checked SO already? Here is the [**link**](http://stackoverflow.com/questions/5785724/how-to-insert-a-row-between-two-rows-in-an-existing-excel-with-hssf-apache-poi). – ManishChristian Jun 21 '16 at 15:51

1 Answers1

0

Try to set the row number to the current row number + 2. This should create an empty row:

while (ite.hasNext()) {
    XSSFRow row = (XSSFRow) ite.next();
    if (row.getCell(0).toString().equals(controle)) {
        row.setRowNum(row.getRowNum()+2);
    }
}
Matthew Diana
  • 1,106
  • 7
  • 14