From 3ca1bd53e7121c4aa689c2db927f6d9263032304 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Mon, 23 Apr 2018 19:36:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6pulls=EF=BC=9Ahttps://gitee.c?= =?UTF-8?q?om/thinkgem/jeesite4/pulls/3=20ZP=20=E4=BF=AE=E6=94=B9=E5=86=85?= =?UTF-8?q?=E5=AE=B9=EF=BC=9A=201.=E5=AF=BC=E5=85=A5=E6=97=B6=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E9=81=87=E5=88=B0=E7=A9=BA=E8=A1=8C=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=BC=9A=E5=87=BA=E7=8E=B0=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=202.=E5=AF=BC=E5=85=A5=E6=97=B6=E5=AF=B9=E4=BA=8E?= =?UTF-8?q?=E5=B8=A6=E6=9C=89=E5=B0=8F=E6=95=B0=E9=83=A8=E5=88=86=E5=BE=97?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8F=AF=E8=83=BD=E5=87=BA=E7=8E=B0=E7=B2=BE?= =?UTF-8?q?=E5=BA=A6=E4=B8=A2=E5=A4=B1=E5=BE=97=E6=83=85=E5=86=B5=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8E=E7=B2=BE=E7=A1=AE=E5=88=B0=E5=B0=8F?= =?UTF-8?q?=E6=95=B0=E7=82=B9=E5=90=8E=E4=B8=A4=E4=BD=8D=EF=BC=8C=E6=AD=A4?= =?UTF-8?q?=E5=A4=84=E5=BA=94=E8=AF=A5=E5=8F=AF=E4=BB=A5=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E6=83=85=E5=86=B5=E6=9D=A5=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=E6=88=96=E8=80=85=E5=85=B6=E4=BB=96=E6=9B=B4=E5=8A=A0?= =?UTF-8?q?=E5=A5=BD=E7=9A=84=E6=96=B9=E6=B3=95=EF=BC=8C=E6=AF=94=E5=A6=82?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E6=89=80=E6=9C=89=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/utils/excel/ExcelImport.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/jeesite/common/utils/excel/ExcelImport.java b/common/src/main/java/com/jeesite/common/utils/excel/ExcelImport.java index e7a72dd3..3b94b771 100644 --- a/common/src/main/java/com/jeesite/common/utils/excel/ExcelImport.java +++ b/common/src/main/java/com/jeesite/common/utils/excel/ExcelImport.java @@ -194,6 +194,9 @@ public class ExcelImport { */ public Row getRow(int rownum){ Row row = this.sheet.getRow(rownum); + if (row == null){ + return null; + } // 验证是否是空行,如果空行返回null short cellNum = 0; short emptyNum = 0; @@ -254,11 +257,15 @@ public class ExcelImport { if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC){ val = cell.getNumericCellValue(); if (HSSFDateUtil.isCellDateFormatted(cell)) { - val = DateUtil.getJavaDate((Double)val); // POI Excel 日期格式转换 - }else{ - val = new DecimalFormat("0").format(val); - } - }else if (cell.getCellType() == Cell.CELL_TYPE_STRING){ + val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换 + }else{ + if ((Double) val % 1 > 0){ + val = new DecimalFormat("0.00").format(val); + }else{ + val = new DecimalFormat("0").format(val); + } + } + }else if (cell.getCellType() == Cell.CELL_TYPE_STRING) { val = cell.getStringCellValue(); }else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA){ try { @@ -481,7 +488,7 @@ public class ExcelImport { // Object val = ei.getCellValue(row, j); // System.out.print(val+", "); // } -// System.out.print("\n"); +// System.out.println(); // } // // }