]> source.dussan.org Git - poi.git/commitdiff
Fixed formula parser to handle names with backslashes
authorYegor Kozlov <yegor@apache.org>
Sun, 15 Feb 2009 20:45:24 +0000 (20:45 +0000)
committerYegor Kozlov <yegor@apache.org>
Sun, 15 Feb 2009 20:45:24 +0000 (20:45 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@744749 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/changes.xml
src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/ss/formula/FormulaParser.java
src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java

index 8728066237d0c7fed201aa6d26f295fa2022907a..c59adc2e729faa72be79002ad2c62f0b567d2f4b 100644 (file)
@@ -37,6 +37,7 @@
 
                <!-- Don't forget to update status.xml too! -->
         <release version="3.5-beta6" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">Fixed formula parser to handle names with backslashes</action>
            <action dev="POI-DEVELOPERS" type="add">46660 - added Workbook getHidden() and setHidden(boolean)</action>
            <action dev="POI-DEVELOPERS" type="fix">46693 - Fixed bugs serialization bugs in records: CHARTFORMAT, SHTPROPS, SXVD and SXVDEX</action>
            <action dev="POI-DEVELOPERS" type="fix">46627 - Fixed offset of added images if Pictures stream contains pictures with zero length</action>
index 791ff90291c1da86a5ff57cf7683b226943a9f4a..386c5f998fa0cf065a27f3a5d0179d9219d6db39 100644 (file)
@@ -34,6 +34,7 @@
        <!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.5-beta6" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">Fixed formula parser to handle names with backslashes</action>
            <action dev="POI-DEVELOPERS" type="add">46660 - added Workbook getHidden() and setHidden(boolean)</action>
            <action dev="POI-DEVELOPERS" type="fix">46693 - Fixed bugs serialization bugs in records: CHARTFORMAT, SHTPROPS, SXVD and SXVDEX</action>
            <action dev="POI-DEVELOPERS" type="fix">46627 - Fixed offset of added images if Pictures stream contains pictures with zero length</action>
index e67e6b302311d795fcfa1c844d7216fea505143a..98c93e0e5c62c66e2ccdafbfc62f256352c32f72 100644 (file)
@@ -298,7 +298,7 @@ public final class FormulaParser {
         } else {
             // allow for any sequence of dots and identifier chars
             // special case of two consecutive dots is best treated in the calling code
-            while (IsAlNum(look) || look == '.' || look == '[' || look == ']') {
+            while (IsAlNum(look) || look == '.' || look == '[' || look == ']' || look == '\\') {
                 sb.append(look);
                 GetChar();
             }
index a6ff9fd5192c99818f202bc56fca82e15f7b16bf..21edfa37e250e7dabdab5d35c17b7847e8a73eeb 100644 (file)
@@ -996,4 +996,25 @@ public final class TestFormulaParser extends TestCase {
                MemFuncPtg mf = (MemFuncPtg)ptgs[0];
                assertEquals(15, mf.getLenRefSubexpression());
        }
+
+    /** Named ranges with backslashes, e.g. 'POI\\2009' */
+    public void testBackSlashInNames() {
+        HSSFWorkbook wb = new HSSFWorkbook();
+
+        HSSFName name = wb.createName();
+        name.setNameName("POI\\2009");
+        name.setRefersToFormula("Sheet1!$A$1");
+
+        HSSFSheet sheet = wb.createSheet();
+        HSSFRow row = sheet.createRow(0);
+
+        HSSFCell cell_C1 =  row.createCell(2);
+        cell_C1.setCellFormula("POI\\2009");
+        assertEquals("POI\\2009", cell_C1.getCellFormula());
+
+        HSSFCell cell_D1 = row.createCell(2);
+        cell_D1.setCellFormula("NOT(POI\\2009=\"3.5-final\")");
+        assertEquals("NOT(POI\\2009=\"3.5-final\")", cell_D1.getCellFormula());
+    }
+
 }