You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2009/06/11 21:58:55 UTC

DO NOT REPLY [Bug 47358] New: Could not resolve external workbook name. Workbook environment has not been set up

https://issues.apache.org/bugzilla/show_bug.cgi?id=47358

           Summary: Could not resolve external workbook name. Workbook
                    environment has not been set up
           Product: POI
           Version: 3.5-dev
          Platform: PC
        OS/Version: Windows Vista
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: kevinrmckee@hotmail.com


I'm trying to run the sample code found at the bottom of
http://poi.apache.org/spreadsheet/eval.html for re-calculating all formulas in
a workbook (I had to modify the code to the following to get it to compile).

FileInputStream fis = new FileInputStream(filename);
        FileOutputStream out = new
FileOutputStream(filename.replaceAll(".xls","temp.xls"));
        org.apache.poi.ss.usermodel.Workbook wb = new HSSFWorkbook(fis); //or
new XSSFWorkbook("/somepath/test.xls")
        FormulaEvaluator evaluator =
wb.getCreationHelper().createFormulaEvaluator();
        for(int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++) {
            org.apache.poi.ss.usermodel.Sheet sheet = wb.getSheetAt(sheetNum);
            RoadmapGUIView.updateProgressText("Updating sheet " + sheetNum);
            for(org.apache.poi.ss.usermodel.Row r : sheet) {
                for(org.apache.poi.ss.usermodel.Cell c : r) {
                    if(c.getCellType() ==
org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA) {
                        evaluator.evaluateFormulaCell(c);
                    }
                }
            }
        }
        wb.write(out);
        out.close();

When I run the program, I'm getting the error java.lang.RuntimeException: Could
not resolve external workbook name 'rm0509.xls'. Workbook environment has not
been set up.

rm0509.xls is a linked spreadsheet within the spreadsheet I'm trying to update.

I can't find any information on this error.

Can you help?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47358] Could not resolve external workbook name. Workbook environment has not been set up

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47358





--- Comment #1 from kevinrmckee@hotmail.com  2009-06-11 12:59:33 PST ---
P.S. I've tried poi-3.5-beta6-20090402.jar and poi-3.5-beta7-20090611.jar

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 47358] Could not resolve external workbook name. Workbook environment has not been set up

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47358


Josh Micich <jo...@gildedtree.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




--- Comment #2 from Josh Micich <jo...@gildedtree.com>  2009-06-11 13:18:06 PST ---
You need to tell POI about all workbooks involved in the evaluation.  This is
done with the method HSSFFormulaEvaluator.setupEnvironment()

You can get away with not doing this if the cell you are evaluation does not
depend on the other workbook(s).  However, in your case the other workbook is
required (hence the error).

----    ----
Here is some sample code:

String dirName = "c:/somedir/";
String bookNameA = "test.xls";
String bookNameB = "rm0509.xls";


HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(dirName + bookNameA));
HSSFWorkbook wbB = new HSSFWorkbook(new FileInputStream(dirName + bookNameB));

HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
HSSFFormulaEvaluator feB = new HSSFFormulaEvaluator(wbB);

// Set up the workbook environment for evaluation
String[] workbookNames = { bookNameA, bookNameB, };
HSSFFormulaEvaluator[] evaluators = { evaluator, feB, };
HSSFFormulaEvaluator.setupEnvironment(workbookNames, evaluators);

// do an evaluation
HSSFCell cell = wb.getSheetAt(0).getRow(0).getCell(0);
evaluator.evaluateFormulaCell(cell);

----    ----

This feature is currently only implemented for HSSF.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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