From 6f6e1c41656c2f7282bae1ce9dae21f7458c3631 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 13 Aug 2022 20:05:34 +0000 Subject: [PATCH] further issue with clone git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903400 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 f3a9156609..c62183a493 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 @@ -4938,7 +4938,12 @@ 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++) { - sheet.getRow(r).getCell(c).setCellFormula(clonedFormula); + 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); } } } -- 2.39.5