I need to display a value in an excel cell formatted like a percentage, e.g. like 12.3%.
By default the value is displayed as Text, but I need to display it as a number.
What is the appropriate method to achieve this?
I need to display a value in an excel cell formatted like a percentage, e.g. like 12.3%.
By default the value is displayed as Text, but I need to display it as a number.
What is the appropriate method to achieve this?
POI has built-in formats check this link first
and check this link for example
For percentage, it will be something like this
dataCell.setCellValue(.12)
CellStyle stylePercentage = workbook.createCellStyle();
stylePercentage.setDataFormat(workbook.createDataFormat()
.getFormat(BuiltinFormats.getBuiltinFormat( 10 )));
dataCell.setCellStyle(stylePercentage);