![](/img/trans.png)
[英]Is there a format to set thousand separator and also set two decimal places using Apache poi?
[英]Format a cell to two decimal places POI
我正在尝试将单元格格式化为点后有两位数。 但是有些东西对我不起作用
row.getCell(updatedMDColumnIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK).setCellValue(countValue);
CellStyle style = row.getSheet().getWorkbook().createCellStyle();
style.setDataFormat(row.getSheet().getWorkbook().createDataFormat().getFormat("0.00"));
row.setRowStyle(style);
我认为这是因为您试图将 CellStyle 应用到行中。 考虑将样式应用到 Cell object 中,如下所示:
Cell cell = ...// get the Cell you want.
cell.setCellStyle(style); // The style is the CellStyle you created.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.