https://bz.apache.org/bugzilla/show_bug.cgi?id=60219
--- Comment #5 from IgnacioHR <[email protected]> --- I'm sorry to be so active at this time. o.a.p.hssf.usermodel.TestHSSFFormulaEvaluator.java#testXRefs suggest me that the preferred option is (2) (the external workbook must be added to the linkTable before the setFormula is called) This means the code o.a.p.hssf.usermodel.TestBugs#bug45970 MUST always fail and the current situation (the test pass without a fail) pass because the resolution of the formula reference contains a bug and the external workbook is recognised as a worksheet of the current workbook. In order to fix code in bug45970. The changes should be like this: ------------------------------------------------------------------- // Link our new workbook wb1.linkExternalWorkbook("$http://gagravarr.org/FormulaRefs2.xls", new String[] {"Sheet1"}); // Change 4 row.getCell(1).setCellFormula("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2"); row.getCell(1).setCellValue(123.0); // Link our new workbook wb1.linkExternalWorkbook("$http://example.com/FormulaRefs.xls", new String[] {"Sheet1"}); // 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); ------------------------------------------------------------------- Note I'm adding the external workbook to the current workbook prior to set a formula that uses cells in that workbook. The current implementation of linkExternalWorkbook requires the external workbook to be instantiated as a Workbook object. In order to support referencing external workbooks that are now already instantiated a new method linkExternalWorkbook(String name, String sheetNames[]) is required. The attached new patch contains all required changes and passes complete conformance suite. The changes include: added linkExternalWorkbook(String name, String sheetNames[]) to src/java/org/apache/poi/ss/usermodel/Workbook.java and added implementation of derived classes. Note XSSF... does not implements external workbooks at all. TestBugs now can uncomment two final tests (that pass OK) to check the external references. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
