diff options
author | PJ Fanning <fanningpj@apache.org> | 2023-09-17 14:49:16 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2023-09-17 14:49:16 +0000 |
commit | 8514b659aef47a210d38ccbe59978a6926af5075 (patch) | |
tree | a8cc1b503a7dd2be25c91bb0ba452c441c8b933a | |
parent | 9e2ce70d2bbe6f1a1d982f280c42be7078b3e8be (diff) | |
download | poi-8514b659aef47a210d38ccbe59978a6926af5075.tar.gz poi-8514b659aef47a210d38ccbe59978a6926af5075.zip |
[bug-67442] add test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912366 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheet.java | 28 | ||||
-rw-r--r-- | test-data/spreadsheet/testSharedFormulasRangeSetBlankBug.xlsx | bin | 0 -> 12428 bytes |
2 files changed, 28 insertions, 0 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheet.java index 9504b20ac8..762ef821a7 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -35,6 +35,7 @@ import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -2386,4 +2387,31 @@ public final class TestXSSFSheet extends BaseTestXSheet { sheet.addHyperlink(hyperlink); return wb; } + + @Test + void testSetBlankOnNestedSharedFormulas() throws IOException { + try (XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("testSharedFormulasSetBlank.xlsx")) { + XSSFSheet s1 = wb1.getSheetAt(0); + assertNotNull(s1); + Iterator<Row> rowIterator = s1.rowIterator(); + int count = 0; + StringBuilder sb = new StringBuilder(); + while (rowIterator.hasNext()) { + Row row = rowIterator.next(); + Iterator<Cell> cellIterator = row.cellIterator(); + while (cellIterator.hasNext()) { + Cell cell = cellIterator.next(); + + // the toString is needed to exhibit the broken state + sb.append(cell.toString()).append(","); + count++; + + // breaks the sheet state + cell.setBlank(); + } + } + assertEquals(10, count); + assertEquals("2-1,2-1,1+2,2-1,2-1,3+3,3+3,3+3,2-1,2-1,", sb.toString()); + } + } } diff --git a/test-data/spreadsheet/testSharedFormulasRangeSetBlankBug.xlsx b/test-data/spreadsheet/testSharedFormulasRangeSetBlankBug.xlsx Binary files differnew file mode 100644 index 0000000000..92593b413a --- /dev/null +++ b/test-data/spreadsheet/testSharedFormulasRangeSetBlankBug.xlsx |