From 02268557290830bff1c6dc7202600811e157dfad Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Wed, 5 Aug 2009 17:54:56 +0000 Subject: [PATCH] Avoid FormulaParseException in XSSFWorkbook.setRepeatingRowsAndColumns when removing repeated rows and columns, see Bugzilla 47620 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@801339 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + .../poi/xssf/usermodel/XSSFWorkbook.java | 28 +++++++++++++------ .../poi/xssf/usermodel/TestXSSFName.java | 16 +++++++++++ 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index af0d90c143..e38256b67f 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -33,6 +33,7 @@ + 47620 - Avoid FormulaParseException in XSSFWorkbook.setRepeatingRowsAndColumns when removing repeated rows and columns 47606 - Fixed XSSFCell to correctly parse column indexes greater than 702 (ZZ) 47598 - Improved formula evaluator number comparison 47571 - Fixed XWPFWordExtractor to extract inserted/deleted text diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index e3961a51d8..d08cbc5eea 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -937,17 +937,18 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable 0 && r.length() > 0) rng.append(','); + rng.append(r); + return rng.toString(); } private static String getReferencePrintArea(String sheetName, int startC, int endC, int startR, int endR) { diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java index 14bfdc790b..f2e8ecddc8 100755 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFName.java @@ -39,6 +39,8 @@ public final class TestXSSFName extends BaseTestNamedRange { XSSFWorkbook wb = getTestDataProvider().createWorkbook(); XSSFSheet sheet = wb.createSheet("First Sheet"); + wb.setRepeatingRowsAndColumns(0, -1, -1, -1, -1); + // set repeating rows and columns twice for the first sheet for (int i = 0; i < 2; i++) { wb.setRepeatingRowsAndColumns(0, 0, 0, 0, 3); @@ -50,6 +52,20 @@ public final class TestXSSFName extends BaseTestNamedRange { assertEquals(XSSFName.BUILTIN_PRINT_TITLE, nr1.getNameName()); assertEquals("'First Sheet'!$A:$A,'First Sheet'!$1:$4", nr1.getRefersToFormula()); + //remove the columns part + wb.setRepeatingRowsAndColumns(0, -1, -1, 0, 3); + assertEquals("'First Sheet'!$1:$4", nr1.getRefersToFormula()); + + //revert + wb.setRepeatingRowsAndColumns(0, 0, 0, 0, 3); + + //remove the rows part + wb.setRepeatingRowsAndColumns(0, 0, 0, -1, -1); + assertEquals("'First Sheet'!$A:$A", nr1.getRefersToFormula()); + + //revert + wb.setRepeatingRowsAndColumns(0, 0, 0, 0, 3); + // Save and re-open XSSFWorkbook nwb = XSSFTestDataSamples.writeOutAndReadBack(wb); -- 2.39.5