Browse Source

修改格式化

developing
Jiaju Zhuang 5 months ago
parent
commit
99e527e9b4
  1. 2
      easyexcel-core/src/main/java/com/alibaba/excel/util/FileUtils.java
  2. 2
      easyexcel-test/pom.xml
  3. 1
      easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/dataformat/DateFormatData.java
  4. 8
      easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/dataformat/DateFormatTest.java
  5. BIN
      easyexcel-test/src/test/resources/dataformat/dataformat.xls
  6. BIN
      easyexcel-test/src/test/resources/dataformat/dataformat.xlsx

2
easyexcel-core/src/main/java/com/alibaba/excel/util/FileUtils.java

@ -154,7 +154,7 @@ public class FileUtils {
} }
public static void createPoiFilesDirectory() { public static void createPoiFilesDirectory() {
TempFile.setTempFileCreationStrategy(new EasyExcelTempFileCreationStrategy()); //TempFile.setTempFileCreationStrategy(new EasyExcelTempFileCreationStrategy());
} }
public static File createCacheTmpFile() { public static File createCacheTmpFile() {

2
easyexcel-test/pom.xml

@ -74,7 +74,7 @@
<includes> <includes>
<include>/com/alibaba/easyexcel/test/core/**/*.java</include> <include>/com/alibaba/easyexcel/test/core/**/*.java</include>
</includes> </includes>
<testFailureIgnore>true</testFailureIgnore> <testFailureIgnore>false</testFailureIgnore>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

1
easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/dataformat/DateFormatData.java

@ -13,6 +13,7 @@ import lombok.Setter;
public class DateFormatData { public class DateFormatData {
private String date; private String date;
private String dateStringCn; private String dateStringCn;
private String dateStringCn2;
private String dateStringUs; private String dateStringUs;
private String number; private String number;
private String numberStringCn; private String numberStringCn;

8
easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/dataformat/DateFormatTest.java

@ -3,6 +3,7 @@ package com.alibaba.easyexcel.test.core.dataformat;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Objects;
import com.alibaba.easyexcel.test.util.TestFileUtil; import com.alibaba.easyexcel.test.util.TestFileUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
@ -54,7 +55,12 @@ public class DateFormatTest {
} }
} }
for (DateFormatData data : list) { for (DateFormatData data : list) {
Assertions.assertEquals(data.getDateStringCn(), data.getDate()); // The way dates are read in Chinese is different on Linux and Mac, so it is acceptable if it matches either one.
// For example, on Linux: 1-Jan -> 1-1月
// On Mac: 1-Jan -> 1-一月
Assertions.assertTrue(
Objects.equals(data.getDateStringCn(), data.getDate()) || Objects.equals(data.getDateStringCn2(),
data.getDate()));
Assertions.assertEquals(data.getNumberStringCn(), data.getNumber()); Assertions.assertEquals(data.getNumberStringCn(), data.getNumber());
} }
} }

BIN
easyexcel-test/src/test/resources/dataformat/dataformat.xls

Binary file not shown.

BIN
easyexcel-test/src/test/resources/dataformat/dataformat.xlsx

Binary file not shown.
Loading…
Cancel
Save