From 87eed3a8b15f5fba279d39216ef210426a5a8ec8 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 10 Oct 2021 08:02:20 +0000 Subject: [PATCH] [bug-65306] try to fix broken test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894093 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java | 5 ++++- .../poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) 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 48436bb826..9b02b08066 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 @@ -3055,7 +3055,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { // check if we should remove this row as it will be overwritten by the data later if (shouldRemoveRow(startRow, endRow, n, rownum)) { for (Cell c : row) { - c.setBlank(); + if (!c.isPartOfArrayFormulaGroup()) { + //the support for deleting cells that are part of array formulas is not implemented yet + c.setBlank(); + } } // remove row from worksheet.getSheetData row array // Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java index 2cb1acdfbe..8f67877635 100644 --- a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java +++ b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java @@ -495,7 +495,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { //we cannot set individual formulas for cells included in an array formula sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3")); IllegalStateException e = assertThrows(IllegalStateException.class, () -> sheet.shiftRows(0, 0, 1)); - String msg = "Cell Sheet0!C2 is part of a multi-cell array formula. You cannot change part of an array."; + String msg = "Row[rownum=0] contains cell(s) included in a multi-cell array formula. You cannot change part of an array."; assertEquals(msg, e.getMessage()); /* TODO: enable shifting the whole array -- 2.39.5