java - Poi ' characted seem to be added automatically -
i utilize poi 3.1 generate xlsx file.
this character ' added automcally in cell
cell = row.createcell(0); cell.setcellvalue(atm.getenvelop()); cell = row.createcell(1); cell.setcelltype(cell.cell_type_numeric); cell.setcellvalue(atm.getamount().replace(".", ",")); atm.getenvelop() , atm.getamount() string
atm.getenvelop() value 8635 when check in file generated get:' 8635
same thing other one
value 200,00 '200,00
any idea?
your problem you're calling cell.setcellvalue(string), automatically sets cell type string
if want set numeric cell type (so there's no ' prefixed in excel), need give apache poi number not string.
this code set '200.00 in excel:
string s200 = "200.00"; cell.setcellvalue(s200); while 1 give 200.00 in excel:
// 1 time per workbook - tell excel format with 2 decimal points dataformat fmt = wb.createdataformat() cellstyle cs = wb.createcellstyle(); cs.setdataformat(fmt.getformat("0.00")); // 1 time per cell double d200 = 200.0; cell.setcellvalue(d200); cell.setcellstyle(cs); for case, number seems coming in string, you'll need parser number (eg double) before giving poi
java excel apache-poi
No comments:
Post a Comment