poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 54125] Setting an external API formula in a cell
Date Fri, 09 Nov 2012 17:06:01 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=54125

Yegor Kozlov <yegor@dinom.ru> changed:

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

--- Comment #1 from Yegor Kozlov <yegor@dinom.ru> ---
You are doing it wrong, you need to register external functions in a toolpack
instead of using a named range:


        Workbook wb = new XSSFWorkbook();

        String[] functionNames = {"BDP"};
        FreeRefFunction[] functionImpls = {new FreeRefFunction() {
            public ValueEval evaluate(ValueEval[] args,
OperationEvaluationContext ec) {
              // don't care about the returned result. we are not going to
evaluate BDP  
              return ErrorEval.NA;
            }
        }};

        UDFFinder udfToolpack = new DefaultUDFFinder(functionNames,
functionImpls);

        // register the user-defined function in the workbook
        wb.addToolPack(udfToolpack);

        Sheet sheet = wb.createSheet();
        Cell cell = sheet.createRow(0).createCell(0);
        cell.setCellFormula("BDP(\"GOOG Equity\",\"CHG_PCT_YTD\")/100");

this way it should work.

Yegor

-- 
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


Mime
View raw message