Bug 47845 - Cross-workbook name references evaluate to NameXEval
Summary: Cross-workbook name references evaluate to NameXEval
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.5-dev
Hardware: All All
: P2 major with 1 vote (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-15 14:10 UTC by Paul Bober
Modified: 2016-03-13 21:40 UTC (History)
3 users (show)



Attachments
reproduction of the bug (19.35 KB, application/zip)
2009-09-15 14:10 UTC, Paul Bober
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Bober 2009-09-15 14:10:14 UTC
Created attachment 24270 [details]
reproduction of the bug

I have multiple workbooks and am referencing names from one workbook in a
second workbook.  When evaluating formulas containing one of these cross
workbook name references using ForkedEvaluator I get the exception below.

I have reproduced the problem in the attached example.  Book1.xls and Book2.xls
each have one sheet (Sheet1) with one cell (A1).   Book1.xls has the name
"MyCell" which references "Sheet1!A1".  [Book1.xls]Sheet1!A1 contains the
constant 100 and [Book2.xls]Sheet1!A1 contains the formula "=[Book1.xls]MyCell
+ 1"  and thus should evaluate to 101 but instead yields an exception.

Note that if I take out the "+1" in the formula I no longer get the exception
but the result is a NameXEval object (not the expected NumberEval).

Note also if I rewrite the formula as "[Book1.xls]Sheet1!A1 + 1" it works.  But
I would like to use the named references.

Paul



Exception in thread "main" java.lang.RuntimeException: Unexpected arg eval type
(org.apache.poi.hssf.record.formula.eval.NameXEval)
    at
org.apache.poi.hssf.record.formula.eval.OperandResolver.coerceValueToDouble(OperandResolver.java:221)
    at
org.apache.poi.hssf.record.formula.eval.TwoOperandNumericOperation.singleOperandEvaluate(TwoOperandNumericOperation.java:27)
    at
org.apache.poi.hssf.record.formula.eval.TwoOperandNumericOperation.evaluate(TwoOperandNumericOperation.java:33)
    at
org.apache.poi.ss.formula.WorkbookEvaluator.invokeOperation(WorkbookEvaluator.java:398)
    at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateFormula(WorkbookEvaluator.java:333)
    at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluateAny(WorkbookEvaluator.java:216)
    at
org.apache.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:180)
    at
org.apache.poi.ss.formula.eval.forked.ForkedEvaluator.evaluate(ForkedEvaluator.java:109)
    at mypackage.poi.PoiBug.main(PoiBug.java:32)
Comment 1 dave.sprague 2010-03-18 22:41:42 UTC
I've discovered an issue (that appears to be similar to this issue) within an application that we have build (using POI 3.6). I can provide examples as needed, but is this specific issue slated for inclusion within POI 3.7?

Thanks,

Dave Sprague
Director, Product Management
Trintech
Comment 2 Javen O'Neal 2015-10-07 09:46:58 UTC
Does this problem still exist in POI 3.13? A lot of progress has been made with formula parsing and evaluation since POI 3.6.
Comment 3 Dominik Stadler 2016-03-13 21:40:18 UTC
No update in a long time and this may be fixed since a long time, setting this to resolved for now, please reopen if this is still a problem for you.