Friday, 13 September 2013

round off digits in apache poi ss workbook

round off digits in apache poi ss workbook

I am trying to round off the decimal number with precisaion value 2, but
it is not working, let me know the problem in my below code:
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);
}
}

No comments:

Post a Comment