From 36142247f4becf7417c2f28251c71b27634025ad Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 4 Nov 2014 16:03:25 +0000 Subject: [PATCH] More disabled unit tests relating to external workbook formula references git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1636626 13f79535-47bb-0310-9956-ffa450edef68 --- .../usermodel/TestXSSFFormulaEvaluation.java | 8 ++--- .../usermodel/TestHSSFFormulaEvaluator.java | 30 +++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java index b0aac98b19..508844fdd1 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java @@ -168,12 +168,12 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { assertEquals("142.0", evaluator.evaluate(cXSL_gNR).formatAsString()); /** - // Now add a formula that refers to a different workbook again + // Now add a formula that refers to yet another (different) workbook Cell cXSLX_nw_cell = rXSLX.createCell(42); - cXSLX_nw_cell.setCellFormula("[alt.xslx]Sheet1!$A$1"); + cXSLX_nw_cell.setCellFormula("[alt.xlsx]Sheet1!$A$1"); // Check it - TODO Is this correct? Or should it become [2]Sheet1!$A$1 ? - assertEquals("[alt.xslx]Sheet1!$A$1", cXSLX_nw_cell.getCellFormula()); + assertEquals("[alt.xlsx]Sheet1!$A$1", cXSLX_nw_cell.getCellFormula()); // Evaluate it, without a link to that workbook try { @@ -184,7 +184,7 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { // Add a link, check it does Workbook alt = new XSSFWorkbook(); alt.createSheet().createRow(0).createCell(0).setCellValue("In another workbook"); - evaluators.put("alt.xslx", alt.getCreationHelper().createFormulaEvaluator()); + evaluators.put("alt.xlsx", alt.getCreationHelper().createFormulaEvaluator()); evaluator.setupReferencedWorkbooks(evaluators); evaluator.evaluate(cXSLX_nw_cell); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java index 2388f88aed..22e7ca5493 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java @@ -230,6 +230,36 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator { assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType()); assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType()); assertEquals(36.90, cell.getNumericCellValue(), 0.0001); + +/* + // Now add a formula that refers to yet another (different) workbook + cell = wb.getSheetAt(0).getRow(1).createCell(42); + cell.setCellFormula("[alt.xls]Sheet1!$A$1"); + + // Check it - TODO Is this correct? Or should it become [2]Sheet1!$A$1 ? + assertEquals("[alt.xls]Sheet1!$A$1", cell.getCellFormula()); + + // Evaluate it, without a link to that workbook + try { + eval.evaluate(cell); + fail("No cached value and no link to workbook, shouldn't evaluate"); + } catch(Exception e) {} + + // Add a link, check it does + HSSFWorkbook alt = new HSSFWorkbook(); + alt.createSheet().createRow(0).createCell(0).setCellValue("In another workbook"); + HSSFFormulaEvaluator.setupEnvironment( + new String[] { "XRefCalc.xls", "XRefCalcData.xls", "alt.xls" }, + new HSSFFormulaEvaluator[] { + eval, + new HSSFFormulaEvaluator(wbData), + new HSSFFormulaEvaluator(alt) + } + ); + + eval.evaluate(cell); + assertEquals("In another workbook", cell.getStringCellValue()); +*/ } public void testSharedFormulas(){