瀏覽代碼

对于定义为数字型的列,支持个别单元格格式转为字符串。

4.1.3.A
Jkanon 6 年之前
父節點
當前提交
3ae52355fe
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. +8
    -2
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportService.java

+ 8
- 2
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportService.java 查看文件

@@ -280,10 +280,16 @@ public abstract class BaseExportService extends ExportCommonService {
public void createDoubleCell(Row row, int index, String text, CellStyle style, public void createDoubleCell(Row row, int index, String text, CellStyle style,
ExcelExportEntity entity) { ExcelExportEntity entity) {
Cell cell = row.createCell(index); Cell cell = row.createCell(index);
cell.setCellType(CellType.NUMERIC);
if (text != null && text.length() > 0) { if (text != null && text.length() > 0) {
cell.setCellValue(Double.parseDouble(text));
try {
cell.setCellValue(Double.parseDouble(text));
} catch (NumberFormatException e) {
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue(text);
}
} }
cell.setCellType(CellType.NUMERIC);
if (style != null) { if (style != null) {
cell.setCellStyle(style); cell.setCellStyle(style);
} }


Loading…
取消
儲存