When you read Excel content with a poi, you often encounter data formatting problems.
For example: The number 12365 will change to 12365.0, the string number 123 will also become 123.0, and even be turned into a scientific notation. In addition, date formatting is also a headache. In fact, the most desirable way is what Excel is, that poi out of what is, do not engage in any conversion.
After collecting various formats online, find the most satisfying one:
ImportOrg.apache.poi.hssf.usermodel.HSSFDataFormatter;ImportOrg.apache.poi.hssf.usermodel.HSSFDateUtil; PublicObject getValue (cell cell) {if(Cell = =NULL) return""; //if it is a date type (POI will turn the date to a number) if(Cell.getcelltype () = =cell. Cell_type_numeric) {//Check If a cell contains a date if(hssfdateutil.iscelldateformatted (cell)) {Date D=hssfdateutil.getjavadate (Cell.getnumericcellvalue ()); return NewSimpleDateFormat ("Yyyy-mm-dd"). Format (d); }} hssfdataformatter DF=NewHssfdataformatter (); returnDf.formatcellvalue (cell);}
That way, the data will be all the same.
Poi reads Excel content formatting