From ea004caf677910e837a6d59a75ee61fe5e814e23 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Mon, 9 Jan 2023 15:48:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B2=BE=E7=AE=80=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E8=A7=86=E5=9B=BE=E6=98=BE=E7=A4=BA=E4=B8=8E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E6=95=B0=E6=8D=AE=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/commons/utils/ExcelXlsxReader.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java b/backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java index d144b05d7d..2300f7dded 100644 --- a/backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java +++ b/backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java @@ -359,8 +359,8 @@ public class ExcelXlsxReader extends DefaultHandler { formatIndex = style.getDataFormat(); formatString = style.getDataFormatString(); short format = this.formatIndex; - if ((14 <= format && format <= 17) || format == 20 || format == 22 || format == 31 || format == 35 || format == 45 || format == 46 || format == 47 || (57 <= format && format <= 59) - || (175 < format && format < 178) || (182 <= format && format <= 196) || (210 <= format && format <= 213) || (208 == format)) { // 日期 + if ((14 <= format && format <= 17) || format == 0 || format == 20 || format == 22 || format == 31 || format == 35 || (45 <= format && format <= 49) || format == 46 || format == 47 || (57 <= format && format <= 59) + || (59 < format && format <= 76) || (175 < format && format <= 196) || (210 <= format && format <= 213) || (208 == format)) { // 日期 isDateFormat = true; } @@ -418,7 +418,11 @@ public class ExcelXlsxReader extends DefaultHandler { break; case NUMBER: //数字 if (formatString != null && isDateFormat) { - thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, formatString).trim(); + if (obtainedNum != null) { + thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, formatString).trim(); + } else { + thisStr = formatter.formatRawCellContents(Double.parseDouble(value), formatIndex, "yyyy-mm-dd hh:mm:ss").trim(); + } } else { thisStr = value; }