POI POI] [Problems the fractional-accuracy read cell xlsx

 

 

problem:

Cells within this text should be:

 

 POI to read the actual content is this:

 

Moreover, some reading normal, some abnormal reading.

Even if the xlsx format cells, has no effect

 

 

 

 

Solution:

if (cell.getCellType() == CellType.NUMERIC) {
            if (isDate == true) {
                return DateUtil.format(cell.getDateCellValue());
            } else {
                return String.valueOf(new BigDecimal(cell.getNumericCellValue()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
            }
        }

 

 

 

Extended:

BigDecimal.setScale usage summary

 

Guess you like

Origin www.cnblogs.com/sxdcgaq8080/p/12123651.html