Java failed to read in data from evaluated excel formula using apache poi -


i want use excel calculate cdf of normal distribution input x excel , read output of cdf(x) excel. excel can created , calculated correctly. java cannot read result excel correctly.

here relevant code:

private double cdfxls1(double x) throws ioexception{     double cdf=0;      hssfworkbook wb = new hssfworkbook();     hssfsheet sheet = wb.createsheet("1");     hssfrow row = sheet.createrow(0);     hssfcell input = row.createcell(0);     input.setcellvalue(x);     hssfcell output = row.createcell(1);     output.setcellformula("normdist(a1,0,1,1)");      wb.setforceformularecalculation(true);       /* using formulaevaluator, still doesn't work     cell tempoutput=row.getcell(1);     tempoutput.setcelltype(cell.cell_type_numeric);          formulaevaluator evaluator = wb.getcreationhelper().createformulaevaluator();     evaluator.evaluateincell(tempoutput);     evaluator.evaluateformulacell(tempoutput);     system.out.println("tempoutput "+tempoutput.getnumericcellvalue());     system.out.println("output "+output.getnumericcellvalue());     */      //using evaluateall, doesn't work either     //  hssfformulaevaluator.evaluateallformulacells(wb);       fileoutputstream fileout = new fileoutputstream("cdf_cal.xls");     wb.write(fileout);     fileout.close();     cdf=output.getnumericcellvalue();             return cdf; } 

i tried 3 methods recalculating formula. however, none of them worked. tried close , reopen excel. doesn't work well. tried use '.csv' output file instead of '.xls'. doesn't work either , cell in csv file contains formula. when opened spreadsheet created, formula , value correct. however, java can output 0, initial value, me.

update:

the error message shows: caused by: org.apache.poi.ss.formula.eval.notimplementedexception: normdist @ org.apache.poi.ss.formula.functions.notimplementedfunction.evaluate(notimplementedfunction.java:42)

these means normdist function has not been supported , need implement myself. see list of function supported here: http://poi.apache.org/spreadsheet/eval-devguide.html

is there way let excel calculate , read result excel sheet?


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -