excel - org.apache.poi writing xls formula of cells sum -
i have write xls formula sum few cells 1 column. output in xls of formula that:
sum(f5;f9;f13;f16)
i've created formula in org.apache.poi library.
cell cell = rowsum.createcell(j); cell.setcelltype(cell.cell_type_numeric); // column number (a or b) in excel use in formula string x = cellreference.convertnumtocolstring(j); cell.setcelltype(hssfcell.cell_type_formula); // total sum row string totalsumformula = "sum("; for(int s=0; s<sumrownumbers.size(); s++) { int tempsumrownumber = sumrownumbers.get(s); tempsumrownumber++; totalsumformula += (x + tempsumrownumber); if(s+1 != sumrownumbers.size()) { totalsumformula += ";"; } else { totalsumformula += ")"; } } cell.setcellformula(totalsumformula);
but unfortunatelly getting error cant understand:
[formulaparseexception: parse error near char 6 ';' in specified formula 'sum(f5;f9;f13;f16)'. expected ',' or ')']
can give me advise? how deal it?
hey found solution problem. i've should use seperator: "," instead of ";".
now works charm. proper generated formula in library:
sum(f5,f9,f13,f16)
which generates formula in excel file:
=sum(f5;f9;f13;f16)
Comments
Post a Comment