舍弃apache poi ss工作簿中的数字

我正在尝试使用precize值为2的十进制数,但它不起作用。 让我知道下面的代码中的问题:

CellStyle cs = wb.createCellStyle(); DataFormat df = wb.createDataFormat(); cs.setDataFormat(df.getFormat("0.0")); for (int i=14;i<rows;i++) { Cell y= wb.getSheetAt(0).getRow(i).getCell((short) colValue); if (y.getCellType() == Cell.CELL_TYPE_STRING) { } else if (y.getCellType() == Cell.CELL_TYPE_NUMERIC) { float d=(float) y.getNumericCellValue(); y.setCellStyle(cs); } } 

像这样使用:

 CellStyle cs = wb.createCellStyle(); cs.setDataFormat(wb .getCreationHelper() .createDataFormat() .getFormat("##.##")); y.setCellStyle(cs);