https://bz.apache.org/bugzilla/show_bug.cgi?id=66213
--- Comment #4 from Axel Richter <[email protected]> --- Not clear what you have changed and why. I also changed my code of answer in https://stackoverflow.com/questions/73339524/xssfworkbook-clonesheet-corrupts-workbook-if-sheet-contains-a-table/73344100#73344100 to cover some edge cases: ... // clone calculated column formulas ... for (int r = rFirst; r <= rLast; r++) { XSSFRow row = sheet.getRow(r); if (row == null) row = sheet.createRow(r); XSSFCell cell = row.getCell(c); if (cell == null) cell = row.createCell(c); cell.setCellFormula(clonedFormula); } ... To avoid NPEs when there is no row and/or cell present in sheet for data row in table. And ... // clone table; XSSFTable.setArea fails and throws exception for too small tables XSSFTable clonedTable = null; int rowCount = (table.getArea().getLastCell().getRow() - table.getArea().getFirstCell().getRow()) + 1; int headerRowCount = table.getHeaderRowCount(); if (headerRowCount == 0) headerRowCount = 1; int minimumRowCount = 1 + headerRowCount + table.getTotalsRowCount(); if (rowCount >= minimumRowCount) { clonedTable = sheet.createTable(table.getArea()); } if (clonedTable != null) { ... To cover the case of single-cell-tables. XSSFTable.setArea fails for this case as it expects at least one header row and one data row per table. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
