Read Excel Numeric cell values as they are in Java -
when reading excel numeric cell values, getting output decimals. eg: 79 reading 79.0, 0.00 reading 0.0. code application have written is:
int type = cell.getcelltype(); if (type == hssfcell.cell_type_numeric) system.out.println(cell.getnumericcellvalue());
this question comes lot on stack overflow, you'd advised through many of similar ones see there answers!
excel stores numbers in file format floating point values, why poi give double numeric cell that's there. if want in excel, need apply formatting rules defined against cell number. thus, want same thing as in answer here. quote:
what want use dataformatter class. pass cell, , best return string containing excel show cell. if pass string cell, you'll string back. if pass numeric cell formatting rules applied, format number based on them , give string back.
for case, i'd assume numeric cells have integer formatting rule applied them. if ask dataformatter format cells, it'll give string integer string in it.
all need is:
// need 1 of these dataformatter fmt = new dataformatter(); // once per cell string valueasseeninexcel = fmt.formatcellvalue(cell);
Comments
Post a Comment