From: PJ Fanning Date: Sun, 14 Aug 2022 09:50:00 +0000 (+0000) Subject: [bug-66213] hack clone table code to avoid failing with edge cases X-Git-Tag: REL_5_2_3~68 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e8f53b308406dcbca7e4029c7856dc7613411e78;p=poi.git [bug-66213] hack clone table code to avoid failing with edge cases git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903410 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index b2b41ce7f8..8efbfcf557 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -4948,8 +4948,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx int c = clonedTable.getStartCellReference().getCol() + i; sheet.getWorkbook().setCellFormulaValidation(false); 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); + XSSFRow row = sheet.getRow(r); + if (row == null) row = sheet.createRow(r); + XSSFCell cell = row.getCell(c, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); cell.setCellFormula(clonedFormula); } }