Hello,

I need to evaluate all the formulas in a workbook which has references to other 
workbooks. Based on my findings I found that I had to use 
FormulaEvaluator#setupReferencedWorkbooks in order to link all the workbooks, 
but that did not work, and still resulted in a RuntimeException saying "Could 
not resolve external workbook name 'file.xlsx'. Workbook environment has not 
been set up."

I managed to work around the problem through some hacks with reflection. 

BaseFormulaEvaluator seems to use static members of 
CollaboratingWorkbooksEnvironment, which creates instances of 
CollaboratingWorkbooksEnvironment. However, these instances seem to be 
constructed but not used (see CollaboratingWorkbooksEnvironment.java:75 -- [new 
CollaboratingWorkbooksEnvironment(evaluatorsByName, evaluators);])

I copied the contents of those methods to create a 
CollaboratingWorkbooksEnvironment, and forced it into the 
_collaboratingWorkbookEnvironment field of my WorkbookEvaluator instance. This 
solved my problem entirely.

Since this solved my issue I suspect this is a bug, so decided to share it here 
in the hopes it may get fixed in the official repository.

Best regards,
Wim 

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

Reply via email to