XSSFCell.setCellFormula exception : "not implemented yet"

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

XSSFCell.setCellFormula exception : "not implemented yet"

Holden
Hello,

I'm using apache poi for handling an excel file  
 

When I   do this:

[CODE]   destCell.setCellFormula(sourceCell.getCellFormula()); [/CODE]

[CODE]

 private void copyCell(Cell sourceCell, Cell destCell, Workbook destWb)
throws Exception {
        int type = sourceCell.getCellType();
        destCell.setCellType(type);
        switch (type) {
            case Cell.CELL_TYPE_FORMULA:
                destCell.setCellFormula(sourceCell.getCellFormula());
                break;
            case Cell.CELL_TYPE_BOOLEAN:
                ...
        }
}

[/CODE]


And then I have a exception:


java.lang.RuntimeException: not implemented yet
        at
org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook.getExternalSheetIndex(XSSFEvaluationWorkbook.java:127)
        at
org.apache.poi.ss.formula.FormulaParser.createAreaRefParseNode(FormulaParser.java:615)
        at
org.apache.poi.ss.formula.FormulaParser.parseRangeable(FormulaParser.java:462)
        at
org.apache.poi.ss.formula.FormulaParser.parseRangeExpression(FormulaParser.java:268)
        at
org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1119)
        at
org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1079)
        at
org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1066)
        at org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1426)
        at
org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1526)
        at
org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1510)
        at
org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1467)
        at
org.apache.poi.ss.formula.FormulaParser.Arguments(FormulaParser.java:1051)
        at org.apache.poi.ss.formula.FormulaParser.function(FormulaParser.java:936)
        at
org.apache.poi.ss.formula.FormulaParser.parseNonRange(FormulaParser.java:558)
        at
org.apache.poi.ss.formula.FormulaParser.parseRangeable(FormulaParser.java:429)
        at
org.apache.poi.ss.formula.FormulaParser.parseRangeExpression(FormulaParser.java:268)
        at
org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1119)
        at
org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1079)
        at
org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1066)
        at org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1426)
        at
org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1526)
        at
org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1510)
        at
org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1467)
        at
org.apache.poi.ss.formula.FormulaParser.Arguments(FormulaParser.java:1051)
        at org.apache.poi.ss.formula.FormulaParser.function(FormulaParser.java:936)
        at
org.apache.poi.ss.formula.FormulaParser.parseNonRange(FormulaParser.java:558)
        at
org.apache.poi.ss.formula.FormulaParser.parseRangeable(FormulaParser.java:517)
        at
org.apache.poi.ss.formula.FormulaParser.parseRangeExpression(FormulaParser.java:268)
        at
org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1119)
        at
org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1079)
        at
org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1066)
        at org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1426)
        at
org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1526)
        at
org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1510)
        at
org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1467)
        at
org.apache.poi.ss.formula.FormulaParser.Arguments(FormulaParser.java:1051)
        at org.apache.poi.ss.formula.FormulaParser.function(FormulaParser.java:936)
        at
org.apache.poi.ss.formula.FormulaParser.parseNonRange(FormulaParser.java:558)
        at
org.apache.poi.ss.formula.FormulaParser.parseRangeable(FormulaParser.java:429)
        at
org.apache.poi.ss.formula.FormulaParser.parseRangeExpression(FormulaParser.java:268)
        at
org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1119)
        at
org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1079)
        at
org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1066)
        at org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1426)
        at
org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1526)
        at
org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1510)
        at
org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1467)
        at
org.apache.poi.ss.formula.FormulaParser.unionExpression(FormulaParser.java:1447)
        at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:1568)
        at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:176)
        at org.apache.poi.xssf.usermodel.XSSFCell.setFormula(XSSFCell.java:439)



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: XSSFCell.setCellFormula exception : "not implemented yet"

Greg Woolsey
That error means the formula references a different workbook.  What version
of POI are you using?  That stack trace doesn't match the latest release
version as far as I can see.

What you need to do is use the latest POI, 3.17, and register all external
workbooks referenced in formulas via

setupReferencedWorkbooks(Map<String,FormulaEvaluator> workbooks)

See the JavaDoc for details on the Map parameter, and the unit tests for
examples.

Without giving POI a reference by name to the FormulaEvaluator instances
for all external workbooks, POI can't evaluate formulas that use external
references.  POI needs to be able to evaluate the formula in order to set
the cell cached value properly when setting a cell formula.

On Wed, Aug 22, 2018 at 10:19 AM Holden <[hidden email]> wrote:

> Hello,
>
> I'm using apache poi for handling an excel file
>
>
> When I   do this:
>
> [CODE]   destCell.setCellFormula(sourceCell.getCellFormula()); [/CODE]
>
> [CODE]
>
>  private void copyCell(Cell sourceCell, Cell destCell, Workbook destWb)
> throws Exception {
>         int type = sourceCell.getCellType();
>         destCell.setCellType(type);
>         switch (type) {
>             case Cell.CELL_TYPE_FORMULA:
>                 destCell.setCellFormula(sourceCell.getCellFormula());
>                 break;
>             case Cell.CELL_TYPE_BOOLEAN:
>                 ...
>         }
> }
>
> [/CODE]
>
>
> And then I have a exception:
>
>
> java.lang.RuntimeException: not implemented yet
>         at
>
> org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook.getExternalSheetIndex(XSSFEvaluationWorkbook.java:127)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.createAreaRefParseNode(FormulaParser.java:615)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseRangeable(FormulaParser.java:462)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseRangeExpression(FormulaParser.java:268)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1119)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1079)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1066)
>         at
> org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1426)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1526)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1510)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1467)
>         at
> org.apache.poi.ss.formula.FormulaParser.Arguments(FormulaParser.java:1051)
>         at
> org.apache.poi.ss.formula.FormulaParser.function(FormulaParser.java:936)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseNonRange(FormulaParser.java:558)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseRangeable(FormulaParser.java:429)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseRangeExpression(FormulaParser.java:268)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1119)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1079)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1066)
>         at
> org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1426)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1526)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1510)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1467)
>         at
> org.apache.poi.ss.formula.FormulaParser.Arguments(FormulaParser.java:1051)
>         at
> org.apache.poi.ss.formula.FormulaParser.function(FormulaParser.java:936)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseNonRange(FormulaParser.java:558)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseRangeable(FormulaParser.java:517)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseRangeExpression(FormulaParser.java:268)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1119)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1079)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1066)
>         at
> org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1426)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1526)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1510)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1467)
>         at
> org.apache.poi.ss.formula.FormulaParser.Arguments(FormulaParser.java:1051)
>         at
> org.apache.poi.ss.formula.FormulaParser.function(FormulaParser.java:936)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseNonRange(FormulaParser.java:558)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseRangeable(FormulaParser.java:429)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseRangeExpression(FormulaParser.java:268)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1119)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1079)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1066)
>         at
> org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1426)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1526)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1510)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1467)
>         at
>
> org.apache.poi.ss.formula.FormulaParser.unionExpression(FormulaParser.java:1447)
>         at
> org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:1568)
>         at
> org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:176)
>         at
> org.apache.poi.xssf.usermodel.XSSFCell.setFormula(XSSFCell.java:439)
>
>
>
> --
> Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>