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 Mon, 12 Nov 2012 08:08:20 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=54125

--- Comment #2 from aurimas.sabalys@outlook.com ---
Thanks a lot! It worked as you said

(In reply to comment #1)
> 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