]> source.dussan.org Git - poi.git/commitdiff
further issue with clone
authorPJ Fanning <fanningpj@apache.org>
Sat, 13 Aug 2022 20:05:34 +0000 (20:05 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sat, 13 Aug 2022 20:05:34 +0000 (20:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903400 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java

index f3a91566094f30ec42f503b1e1ca312231d9a834..c62183a493147d6f0352ceca7bc49ff602d9d0ba 100644 (file)
@@ -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);
                         }
                     }
                 }