java - I'm getting the formula instead of the cell content -
this question has answer here:
- apache poi evaluate formula 4 answers
i have code:
string fname = "c:/users/slim/desktop/xlsxfiles/plan.xlsx"; inputstream inp = new fileinputstream(fname); workbook wb = new xssfworkbook(inp); sheet sheet = wb.getsheetat(0); (row row : sheet) { system.out.println(row.getcell(0)); system.out.println(row.getcell(11)); }
the problem i'm facing seems kinda weird me, because first time dealing poi.
the content of cell 0
date , have no problems @ all, content of cell 11
wich supposed number returning formula used content. here sample output:
31-aug-2013 l3/5 30-sep-2013 l3*2/5 31-oct-2013 l3*3/5 30-nov-2013 l3*4/5 31-dec-2013 l3 31-jan-2014 p8 28-feb-2014 p9 31-mar-2014 p10
and on...
what need show actual content of cell, not formula. i'm sure i'm missing small, complete beginner, i'm not able spot it.
the actual content of cell formula; excel doesn't show (instead, shows result of evaluating formula).
this document explains how calculate formula often, isn't necessary because excel saves last calculated value along formula.
so getcell(11).getnumericcellvalue()
might enough.
note method throws exceptions when being used on cells text.
Comments
Post a Comment