View | Details | Raw Unified | Return to bug 60219
Collapse All | Expand All

(-)src/java/org/apache/poi/ss/formula/FormulaParser.java (-10 / +17 lines)
Lines 1119-1124 Link Here
1119
            return sb.toString();
1119
            return sb.toString();
1120
        }
1120
        }
1121
    }
1121
    }
1122
    
1123
    private String getBookName() {
1124
        StringBuilder sb = new StringBuilder();
1125
        GetChar();
1126
        while (look != ']') {
1127
            sb.append(look);
1128
            GetChar();
1129
        }
1130
        GetChar();
1131
        return sb.toString();
1132
    }
1122
1133
1123
    /**
1134
    /**
1124
     * Note - caller should reset {@link #_pointer} upon <code>null</code> result
1135
     * Note - caller should reset {@link #_pointer} upon <code>null</code> result
Lines 1127-1148 Link Here
1127
    private SheetIdentifier parseSheetName() {
1138
    private SheetIdentifier parseSheetName() {
1128
        String bookName;
1139
        String bookName;
1129
        if (look == '[') {
1140
        if (look == '[') {
1130
            StringBuilder sb = new StringBuilder();
1141
        	bookName = getBookName();
1131
            GetChar();
1132
            while (look != ']') {
1133
                sb.append(look);
1134
                GetChar();
1135
            }
1136
            GetChar();
1137
            bookName = sb.toString();
1138
        } else {
1142
        } else {
1139
            bookName = null;
1143
            bookName = null;
1140
        }
1144
        }
1141
1145
1142
        if (look == '\'') {
1146
        if (look == '\'') {
1147
            Match('\'');
1148
            
1149
            if (look == '[')
1150
            	bookName = getBookName();
1151
            
1143
            StringBuffer sb = new StringBuffer();
1152
            StringBuffer sb = new StringBuffer();
1144
1145
            Match('\'');
1146
            boolean done = look == '\'';
1153
            boolean done = look == '\'';
1147
            while(!done) {
1154
            while(!done) {
1148
                sb.append(look);
1155
                sb.append(look);
(-)src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (-4 / +12 lines)
Lines 1848-1857 Link Here
1848
       assertEquals("'[$http://gagravarr.org/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
1848
       assertEquals("'[$http://gagravarr.org/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
1849
       assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
1849
       assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
1850
1850
1851
       // Link our new workbook
1852
       Workbook externalWb1 = new HSSFWorkbook();
1853
       externalWb1.createSheet("Sheet1");
1854
       wb1.linkExternalWorkbook("$http://gagravarr.org/FormulaRefs2.xls", externalWb1);
1855
       
1851
       // Change 4
1856
       // Change 4
1852
       row.getCell(1).setCellFormula("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2");
1857
       row.getCell(1).setCellFormula("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2");
1853
       row.getCell(1).setCellValue(123.0);
1858
       row.getCell(1).setCellValue(123.0);
1854
1859
1860
       // Link our new workbook
1861
       Workbook externalWb2 = new HSSFWorkbook();
1862
       externalWb2.createSheet("Sheet1");
1863
       wb1.linkExternalWorkbook("$http://example.com/FormulaRefs.xls", externalWb2);
1864
       
1855
       // Add 5
1865
       // Add 5
1856
       row = s.createRow(5);
1866
       row = s.createRow(5);
1857
       row.createCell(1, CellType.FORMULA);
1867
       row.createCell(1, CellType.FORMULA);
Lines 1858-1864 Link Here
1858
       row.getCell(1).setCellFormula("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1");
1868
       row.getCell(1).setCellFormula("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1");
1859
       row.getCell(1).setCellValue(234.0);
1869
       row.getCell(1).setCellValue(234.0);
1860
1870
1861
1862
       // Re-test
1871
       // Re-test
1863
       HSSFWorkbook wb2 = writeOutAndReadBack(wb1);
1872
       HSSFWorkbook wb2 = writeOutAndReadBack(wb1);
1864
       wb1.close();
1873
       wb1.close();
Lines 1883-1890 Link Here
1883
       assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula());
1892
       assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula());
1884
       assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
1893
       assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
1885
1894
1886
       // TODO - Fix these so they work...
1895
       row = s.getRow(4);
1887
       /*row = s.getRow(4);
1888
       assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
1896
       assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
1889
       assertEquals("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2", row.getCell(1).getCellFormula());
1897
       assertEquals("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2", row.getCell(1).getCellFormula());
1890
       assertEquals(123.0, row.getCell(1).getNumericCellValue(), 0);
1898
       assertEquals(123.0, row.getCell(1).getNumericCellValue(), 0);
Lines 1892-1898 Link Here
1892
       row = s.getRow(5);
1900
       row = s.getRow(5);
1893
       assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
1901
       assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
1894
       assertEquals("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
1902
       assertEquals("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
1895
       assertEquals(234.0, row.getCell(1).getNumericCellValue(), 0);*/
1903
       assertEquals(234.0, row.getCell(1).getNumericCellValue(), 0);
1896
       
1904
       
1897
       wb2.close();
1905
       wb2.close();
1898
    }
1906
    }

Return to bug 60219