From e80ae0bb07ec59e8b76f213be9392f55487f23f0 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 17 Oct 2023 16:05:08 +0000 Subject: [PATCH] [bug-67784] add tests git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1913068 13f79535-47bb-0310-9956-ffa450edef68 --- .../TestXSSFEventBasedExcelExtractor.java | 27 ++++++++++++++++++ .../extractor/TestXSSFExcelExtractor.java | 11 +++++++ test-data/spreadsheet/bug67784.xlsx | Bin 0 -> 6211 bytes 3 files changed, 38 insertions(+) create mode 100644 test-data/spreadsheet/bug67784.xlsx diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/extractor/TestXSSFEventBasedExcelExtractor.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/extractor/TestXSSFEventBasedExcelExtractor.java index accaae3bea..fe543ef37b 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/extractor/TestXSSFEventBasedExcelExtractor.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/extractor/TestXSSFEventBasedExcelExtractor.java @@ -362,4 +362,31 @@ class TestXSSFEventBasedExcelExtractor { assertContains(text, "Bob\tBob"); } } + + @Test + void test67784() throws Exception { + try (XSSFEventBasedExcelExtractor ex = + new XSSFEventBasedExcelExtractor( + XSSFTestDataSamples.openSamplePackage("bug67784.xlsx"))) { + String text = ex.getText().replace("\r", ""); + String[] lines = text.split("\n"); + assertEquals("FALSE", lines[2]); + assertEquals("TRUE", lines[3]); + assertEquals("ERROR:#DIV/0!", lines[4]); + } + } + + @Test + void test67784Formulas() throws Exception { + try (XSSFEventBasedExcelExtractor ex = + new XSSFEventBasedExcelExtractor( + XSSFTestDataSamples.openSamplePackage("bug67784.xlsx"))) { + ex.setFormulasNotResults(true); + String text = ex.getText().replace("\r", ""); + String[] lines = text.split("\n"); + assertEquals("(2 > 5)", lines[2]); + assertEquals("(2 < 4)", lines[3]); + assertEquals("10/0", lines[4]); + } + } } diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java index 1e435753fa..40fc0602b7 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java @@ -245,6 +245,17 @@ class TestXSSFExcelExtractor { //in the extracted text assertNotContained(text, "\u30CB\u30DB\u30F3"); } + } + @Test + void test67784Formulas() throws Exception { + try (XSSFExcelExtractor extractor = getExtractor("bug67784.xlsx")) { + extractor.setFormulasNotResults(true); + String text = extractor.getText().replace("\r", ""); + String[] lines = text.split("\n"); + assertEquals("(2 > 5)", lines[2]); + assertEquals("(2 < 4)", lines[3]); + assertEquals("10/0", lines[4]); + } } } diff --git a/test-data/spreadsheet/bug67784.xlsx b/test-data/spreadsheet/bug67784.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..df5c63bc56080c371367068fdbe9b5e2fda1733f GIT binary patch literal 6211 zcmaJ_1zeQhwjE*sVd$1l=@O6p}V9R0cmNFknT`o1PN)7Mi3Z~5($y+ zH{<`l2hV%2dw$=v&^xrbP9-Zm>fZDtUpZDV$zs*lX;4E}Zan3xC@UDFZcRS_YKZP;6p@qVv)t(b^p+4Mds`s~IXY@@$-7J1j0p_x zJ@SfqzJ($!M7ZEEY_EB+Ut|BmP9h#9i0`Qq;cJG~?H;nRcQFhXiT&SGQiz)xSDhVA z_b~=rh(h=*U44|8{GKXqXOq(0HI{#=mv!F1O024Yi4~eAn6`}oVF(ofQ2nnk;Uj+G zX~*jUake#uKx}zD?d_s9dL3r@2w+E?==1j6MmAK*XxcGxfH{J~-qd(mGFvD~&u((= z)jT1Xg?&RBU$~cYDE&x8WiMTW1%^h!SqIgf#!tcI7;99WO}X$iIAR^B?a>-4ct%ir zSI52fnD2p2twR00mu98ifPAO->X|U-o27#i+3A$P9 z(xYlJ6N^hsY4XsX=L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