title: FormulaEvaluator.evaluateAll() with external references in Excel cells returns RuntimeException using Apache POI
body: <p>For the past couple of days, this has been driving me crazy.</p>
  
  <p>Please consider the two Excel files:
  <a href="http://i.stack.imgur.com/w4dah.jpg" rel="nofollow">a.xlsx</a> and <a href="http://i.stack.imgur.com/YmBMh.jpg" rel="nofollow">b.xlsx</a></p>
  
  <p>Here are the codes that are supposed to evaluate cells in <strong>a.xlsx</strong> including the external reference to <strong>b.xlsx</strong>.</p>
  
  <pre><code>import java.io.FileInputStream;
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.Map;
  import org.apache.poi.ss.usermodel.FormulaEvaluator;
  import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  
  public class Test {
  
      public static void main(String[] args) {
          try {
              FileInputStream file1 = new FileInputStream("C:\\Users\\Abid\\Desktop\\a.xlsx");
              FileInputStream file2 = new FileInputStream("C:\\Users\\Abid\\Desktop\\b.xlsx");
  
              XSSFWorkbook workbook1 = new XSSFWorkbook(file1);
              XSSFWorkbook workbook2 = new XSSFWorkbook(file2);
  
              FormulaEvaluator evaluator1 = workbook1.getCreationHelper().createFormulaEvaluator();
              FormulaEvaluator evaluator2 = workbook2.getCreationHelper().createFormulaEvaluator();
  
              Map&lt;String, FormulaEvaluator&gt; workbooks = new HashMap&lt;String, FormulaEvaluator&gt;();
  
              workbooks.put("a.xlsx", evaluator1);
              workbooks.put("b.xlsx", evaluator2);
  
              evaluator1.setupReferencedWorkbooks(workbooks);
              evaluator1.evaluateAll();
  
              file1.close();
              file2.close();
  
              workbook1.close();
              workbook2.close();
  
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  
  }
  </code></pre>
  
  <p>Unfortunately this is what I get upon execution:</p>
  
  <pre><code>    Exception in thread "main" java.lang.RuntimeException: Could not resolve external workbook name 'b.xlsx'. Workbook environment has not been set up.
      at org.apache.poi.ss.formula.OperationEvaluationContext.createExternSheetRefEvaluator(OperationEvaluationContext.java:113)
      at org.apache.poi.ss.formula.OperationEvaluationContext.createExternSheetRefEvaluator(OperationEvaluationContext.java:84)
      at org.apache.poi.ss.formula.OperationEvaluationContext.getRef3DEval(OperationEvaluationContext.java:313)
      at org.apache.poi.ss.formula.WorkbookEvaluator.getEvalForPtg(WorkbookEvaluator.java:634)
      at org.apache.poi.ss.formula.WorkbookEvaluator.evaluateFormula(WorkbookEvaluator.java:505)
      at org.apache.poi.ss.formula.WorkbookEvaluator.evaluateAny(WorkbookEvaluator.java:263)
      at org.apache.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:205)
      at org.apache.poi.xssf.usermodel.BaseXSSFFormulaEvaluator.evaluateFormulaCellValue(BaseXSSFFormulaEvaluator.java:189)
      at org.apache.poi.xssf.usermodel.BaseXSSFFormulaEvaluator.evaluateFormulaCell(BaseXSSFFormulaEvaluator.java:117)
      at org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateAllFormulaCells(HSSFFormulaEvaluator.java:346)
      at org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateAllFormulaCells(HSSFFormulaEvaluator.java:337)
      at org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluateAll(XSSFFormulaEvaluator.java:105)
      at Test.main(Test.java:28)
  Caused by: org.apache.poi.ss.formula.CollaboratingWorkbooksEnvironment$WorkbookNotFoundException: Could not resolve external workbook name 'b.xlsx'. Workbook environment has not been set up.
      at org.apache.poi.ss.formula.CollaboratingWorkbooksEnvironment.getWorkbookEvaluator(CollaboratingWorkbooksEnvironment.java:195)
      at org.apache.poi.ss.formula.WorkbookEvaluator.getOtherWorkbookEvaluator(WorkbookEvaluator.java:156)
      at org.apache.poi.ss.formula.OperationEvaluationContext.createExternSheetRefEvaluator(OperationEvaluationContext.java:111)
      ... 12 more
  </code></pre>