From 16f7f53eb3253a1c199df5fbc37b61959a3e0626 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Mon, 13 Sep 2021 20:10:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=88=E5=B9=B6=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java | 7 ++++--- .../com/alibaba/excel/util/NumberDataFormatterUtils.java | 7 +++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java b/src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java index fe35ab82..b002b6b4 100644 --- a/src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java +++ b/src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java @@ -2,6 +2,7 @@ package com.alibaba.excel.metadata.csv; import java.io.Closeable; import java.io.IOException; +import java.math.BigDecimal; import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -768,8 +769,8 @@ public class CsvSheet implements Sheet, Closeable { if (dataFormatString == null) { dataFormatString = csvWorkbook.createDataFormat().getFormat(dataFormat); } - return NumberDataFormatterUtils.format( - DateUtil.getExcelDate(csvCell.getDateValue(), csvWorkbook.getUse1904windowing()), + return NumberDataFormatterUtils.format(BigDecimal.valueOf( + DateUtil.getExcelDate(csvCell.getDateValue(), csvWorkbook.getUse1904windowing())), dataFormat, dataFormatString, csvWorkbook.getUse1904windowing(), csvWorkbook.getLocale(), csvWorkbook.getUseScientificFormat()); } else { @@ -784,7 +785,7 @@ public class CsvSheet implements Sheet, Closeable { if (dataFormatString == null) { dataFormatString = csvWorkbook.createDataFormat().getFormat(dataFormat); } - return NumberDataFormatterUtils.format(csvCell.getNumericCellValue(), dataFormat, dataFormatString, + return NumberDataFormatterUtils.format(csvCell.getNumberValue(), dataFormat, dataFormatString, csvWorkbook.getUse1904windowing(), csvWorkbook.getLocale(), csvWorkbook.getUseScientificFormat()); } diff --git a/src/main/java/com/alibaba/excel/util/NumberDataFormatterUtils.java b/src/main/java/com/alibaba/excel/util/NumberDataFormatterUtils.java index 640fd07f..83d7a23f 100644 --- a/src/main/java/com/alibaba/excel/util/NumberDataFormatterUtils.java +++ b/src/main/java/com/alibaba/excel/util/NumberDataFormatterUtils.java @@ -1,11 +1,10 @@ package com.alibaba.excel.util; -import java.util.Locale; - import java.math.BigDecimal; +import java.util.Locale; -import com.alibaba.excel.metadata.format.DataFormatter; import com.alibaba.excel.metadata.GlobalConfiguration; +import com.alibaba.excel.metadata.format.DataFormatter; /** * Convert number data, including date. @@ -48,7 +47,7 @@ public class NumberDataFormatterUtils { * @param useScientificFormat * @return */ - public static String format(Double data, Short dataFormat, String dataFormatString, Boolean use1904windowing, + public static String format(BigDecimal data, Short dataFormat, String dataFormatString, Boolean use1904windowing, Locale locale, Boolean useScientificFormat) { DataFormatter dataFormatter = DATA_FORMATTER_THREAD_LOCAL.get(); if (dataFormatter == null) {