You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ga...@gmail.com, ga...@gmail.com on 2018/12/15 15:34:40 UTC

Shall parsing missing local/external names throw?

Hello, this investigation began when I found out that external names looking like a column (say, [1]!EXT) are not parsed correctly (parser throws). But then I realized that the problem is deeper.

Currently FormulaParser doesn't allow to parse a formula that contains a missing name, although it's a perfectly valid scenario for Excel which allows to enter a formula containing a missing name and returns #REF!. Parsing and evaluating are connected but distinct things. 

Here's a use case:

XSSFWorkbook workbook = new XSSFWorkbook();
Cell cell = workbook.createSheet().createRow(0).createCell(0);
cell.setCellFormula("MISSING_NAME"); // shall not throw

// shall evaluate without exceptions and return REF_INVALID
workbook.getCreationHelper().createFormulaEvaluator().evaluateAll();
assertEquals(FormulaError.REF.getCode(), cell.getErrorCellValue());

// then we create a name...
Name name = workbook.createName();
name.setNameName("MISSING_NAME");
name.setRefersToFormula("4");

// re-evaluate...
workbook.getCreationHelper().createFormulaEvaluator().evaluateAll();
// and now it works!
assertEquals(4, cell.getNumericCellValue(), 0);

Are there any strong objections to this proposed behavior?
I am already working on the implementation and hopefully will be able to release it soon if the maintainers approve the new behavior.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: Shall parsing missing local/external names throw?

Posted by ga...@gmail.com, ga...@gmail.com.
My bad, a missing name should return #NAME.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org