Add disabled unit tests for bug #56737, which currently fails (differently) for HSSF and XSSF

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1611400 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2014-07-17 16:18:39 +00:00
parent 696b9d6406
commit c9d90732e5
4 changed files with 78 additions and 0 deletions

View File

@ -1653,6 +1653,45 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
assertEquals("0", formatter.formatCellValue(cell));
}
/**
* Formulas which reference named ranges, either in other
* sheets, or workbook scoped but in other workbooks.
* Currently failing with errors like
* org.apache.poi.ss.formula.FormulaParseException: Cell reference expected after sheet name at index 9
* org.apache.poi.ss.formula.FormulaParseException: Parse error near char 0 '[' in specified formula '[0]!NR_Global_B2'. Expected number, string, or defined name
*/
@Ignore
@Test
public void bug56737() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56737.xlsx");
// Check the named range definitions
Name nSheetScope = wb.getName("NR_To_A1");
Name nWBScope = wb.getName("NR_Global_B2");
assertNotNull(nSheetScope);
assertNotNull(nWBScope);
assertEquals("Defines!$A$1", nSheetScope.getRefersToFormula());
assertEquals("Defines!$B$2", nWBScope.getRefersToFormula());
// Check the different kinds of formulas
Sheet s = wb.getSheetAt(0);
Cell cRefSName = s.getRow(1).getCell(3);
Cell cRefWName = s.getRow(2).getCell(3);
assertEquals("Defines!NR_To_A1", cRefSName.getCellFormula());
assertEquals("[0]!NR_Global_B2", cRefWName.getCellFormula());
// Try to evaluate them
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
assertEquals("Test A1", eval.evaluate(cRefSName).getStringValue());
assertEquals(142, (int)eval.evaluate(cRefWName).getNumberValue());
// Try to evaluate everything
eval.evaluateAll();
}
private void saveAndReloadReport(Workbook wb, File outFile) throws IOException {
// run some method on the font to verify if it is "disconnected" already
//for(short i = 0;i < 256;i++)

View File

@ -67,6 +67,7 @@ import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
@ -2611,4 +2612,42 @@ public final class TestBugs extends BaseTestBugzillaIssues {
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
assertEquals(0, wb.getNumberOfSheets());
}
/**
* Formulas which reference named ranges, either in other
* sheets, or workbook scoped but in other workbooks.
* Currently failing with
* java.lang.RuntimeException: Unexpected eval class (org.apache.poi.ss.formula.eval.NameXEval)
*/
@Ignore
@Test
public void bug56737() throws IOException {
Workbook wb = openSample("56737.xls");
// Check the named range definitions
Name nSheetScope = wb.getName("NR_To_A1");
Name nWBScope = wb.getName("NR_Global_B2");
assertNotNull(nSheetScope);
assertNotNull(nWBScope);
assertEquals("Defines!$A$1", nSheetScope.getRefersToFormula());
assertEquals("Defines!$B$2", nWBScope.getRefersToFormula());
// Check the different kinds of formulas
Sheet s = wb.getSheetAt(0);
Cell cRefSName = s.getRow(1).getCell(3);
Cell cRefWName = s.getRow(2).getCell(3);
assertEquals("Defines!NR_To_A1", cRefSName.getCellFormula());
assertEquals("'56737.xls'!NR_Global_B2", cRefWName.getCellFormula());
// Try to evaluate them
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
assertEquals("Test A1", eval.evaluate(cRefSName).getStringValue());
assertEquals(142, (int)eval.evaluate(cRefWName).getNumberValue());
// Try to evaluate everything
eval.evaluateAll();
}
}

Binary file not shown.

Binary file not shown.