diff options
author | Dominik Stadler <centic@apache.org> | 2016-12-31 16:53:16 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2016-12-31 16:53:16 +0000 |
commit | 85300a6f83804e58f11434e41df08066602e698f (patch) | |
tree | 916502a019ecabaf9152580402c387f7b5eec6ed /src/testcases | |
parent | 70864c5a57842a0c56707d6416c8e8d9afdb1953 (diff) | |
download | poi-85300a6f83804e58f11434e41df08066602e698f.tar.gz poi-85300a6f83804e58f11434e41df08066602e698f.zip |
Bug 60219: FormulaParser can't parse external references when sheet name is quoted
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1776796 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
3 files changed, 23 insertions, 17 deletions
diff --git a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java index 82153fe09e..a6cb273430 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java +++ b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java @@ -218,7 +218,7 @@ public final class TestFormulaParser { } } - private final static void assertEqualsIgnoreCase(String expected, String actual) { + private static void assertEqualsIgnoreCase(String expected, String actual) { assertEquals(expected.toLowerCase(Locale.ROOT), actual.toLowerCase(Locale.ROOT)); } @@ -414,7 +414,7 @@ public final class TestFormulaParser { HSSFSheet sheet = wb.createSheet("Test"); HSSFRow row = sheet.createRow(0); HSSFCell cell = row.createCell(0); - String formula = null; + String formula; cell.setCellFormula("1.3E21/3"); formula = cell.getCellFormula(); @@ -488,7 +488,7 @@ public final class TestFormulaParser { HSSFSheet sheet = wb.createSheet("Test"); HSSFRow row = sheet.createRow(0); HSSFCell cell = row.createCell(0); - String formula = null; + String formula; // starts from decimal point @@ -530,7 +530,7 @@ public final class TestFormulaParser { HSSFSheet sheet = wb.createSheet("Test"); HSSFRow row = sheet.createRow(0); HSSFCell cell = row.createCell(0); - String formula = null; + String formula; cell.setCellFormula("A1.A2"); formula = cell.getCellFormula(); @@ -557,7 +557,7 @@ public final class TestFormulaParser { HSSFSheet sheet = wb.createSheet("Test"); HSSFRow row = sheet.createRow(0); HSSFCell cell = row.createCell(0); - String formula = null; + String formula; // References to a single cell: @@ -718,8 +718,8 @@ public final class TestFormulaParser { assertEquals(65534.6, np.getValue(), 0); } + @Test public void testMissingArgs() { - confirmTokenClasses("if(A1, ,C1)", RefPtg.class, AttrPtg.class, // tAttrIf @@ -1327,8 +1327,7 @@ public final class TestFormulaParser { } /** - * TODO - delete equiv test: - * {@link BaseTestBugzillaIssues#test42448()} + * See the related/similar test: {@link BaseTestBugzillaIssues#bug42448()} */ @Test public void testParseAbnormalSheetNamesAndRanges_bug42448() throws IOException { @@ -1373,11 +1372,10 @@ public final class TestFormulaParser { @Test public void testUnionOfFullCollFullRowRef() throws IOException { - Ptg[] ptgs; - ptgs = parseFormula("3:4"); - ptgs = parseFormula("$Z:$AC"); + parseFormula("3:4"); + Ptg[] ptgs = parseFormula("$Z:$AC"); confirmTokenClasses(ptgs, AreaPtg.class); - ptgs = parseFormula("B:B"); + parseFormula("B:B"); ptgs = parseFormula("$11:$13"); confirmTokenClasses(ptgs, AreaPtg.class); diff --git a/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java b/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java index 6147358bcc..558a5ec0ff 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java @@ -115,7 +115,7 @@ public final class TestWorkbook { } }; - /** + /* * register the two test UDFs in a UDF finder, to be passed to the evaluator */ UDFFinder udff1 = new DefaultUDFFinder(new String[] { "myFunc", }, diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 1308b2c113..862b6cec7d 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -1836,17 +1836,26 @@ public final class TestBugs extends BaseTestBugzillaIssues { assertEquals("'[$http://gagravarr.org/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula()); assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); + // Link our new workbook + Workbook externalWb1 = new HSSFWorkbook(); + externalWb1.createSheet("Sheet1"); + wb1.linkExternalWorkbook("$http://gagravarr.org/FormulaRefs2.xls", externalWb1); + // Change 4 row.getCell(1).setCellFormula("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2"); row.getCell(1).setCellValue(123.0); + // Link our new workbook + Workbook externalWb2 = new HSSFWorkbook(); + externalWb2.createSheet("Sheet1"); + wb1.linkExternalWorkbook("$http://example.com/FormulaRefs.xls", externalWb2); + // Add 5 row = s.createRow(5); row.createCell(1, CellType.FORMULA); row.getCell(1).setCellFormula("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1"); row.getCell(1).setCellValue(234.0); - // Re-test HSSFWorkbook wb2 = writeOutAndReadBack(wb1); wb1.close(); @@ -1871,8 +1880,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula()); assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); - // TODO - Fix these so they work... - /*row = s.getRow(4); + row = s.getRow(4); assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum()); assertEquals("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2", row.getCell(1).getCellFormula()); assertEquals(123.0, row.getCell(1).getNumericCellValue(), 0); @@ -1880,7 +1888,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { row = s.getRow(5); assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum()); assertEquals("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula()); - assertEquals(234.0, row.getCell(1).getNumericCellValue(), 0);*/ + assertEquals(234.0, row.getCell(1).getNumericCellValue(), 0); wb2.close(); } |