From 3ae52355fe4f8af19d7855f56fd624ddb80bbb45 Mon Sep 17 00:00:00 2001 From: Jkanon <812119305@qq.com> Date: Fri, 12 Oct 2018 16:33:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E4=BA=8E=E5=AE=9A=E4=B9=89=E4=B8=BA?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E5=9E=8B=E7=9A=84=E5=88=97=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=B8=AA=E5=88=AB=E5=8D=95=E5=85=83=E6=A0=BC=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E8=BD=AC=E4=B8=BA=E5=AD=97=E7=AC=A6=E4=B8=B2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../easypoi/excel/export/base/BaseExportService.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportService.java b/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportService.java index 35c59a4..86d1efc 100644 --- a/easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportService.java +++ b/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, ExcelExportEntity entity) { Cell cell = row.createCell(index); + cell.setCellType(CellType.NUMERIC); 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) { cell.setCellStyle(style); }