Browse Source

Merge pull request #3838 from alibaba/developing

Developing
pull/3875/head v4.0.0
Jiaju Zhuang 5 months ago committed by GitHub
parent
commit
fa592214b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .github/workflows/ci.yml
  2. 2
      README.md
  3. 4
      easyexcel-core/pom.xml
  4. 14
      easyexcel-core/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java
  5. 5
      easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvCell.java
  6. 43
      easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvCellStyle.java
  7. 17
      easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java
  8. 51
      easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvWorkbook.java
  9. 7
      easyexcel-core/src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java
  10. 4
      easyexcel-core/src/main/java/com/alibaba/excel/util/BeanMapUtils.java
  11. 2
      easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java
  12. 3
      easyexcel-core/src/main/java/com/alibaba/excel/util/FieldUtils.java
  13. 4
      easyexcel-core/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java
  14. 2
      easyexcel-support/pom.xml
  15. 9
      easyexcel-test/pom.xml
  16. 2
      easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
  17. 3
      easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/StyleTest.java
  18. 4
      easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/Xls03Test.java
  19. 13
      easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/dataformat/DataFormatter1.java
  20. 2
      easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/write/TempWriteTest.java
  21. 64
      pom.xml
  22. 8
      update.md

2
.github/workflows/ci.yml

@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
java: [ 8, 11, 17] java: [ 8, 11, 17, 21]
distribution: [ 'adopt' ] distribution: [ 'adopt' ]
fail-fast: false fail-fast: false
max-parallel: 4 max-parallel: 4

2
README.md

@ -33,7 +33,7 @@ easyexcel重写了poi对07版Excel的解析,一个3M的excel用POI sax解析
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
<version>3.3.4</version> <version>4.0.0</version>
</dependency> </dependency>
``` ```

4
easyexcel-core/pom.xml

@ -28,10 +28,6 @@
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId> <artifactId>poi-ooxml</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId> <artifactId>commons-csv</artifactId>

14
easyexcel-core/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java

@ -33,7 +33,6 @@ import com.alibaba.excel.util.SheetUtils;
import com.alibaba.excel.util.StringUtils; import com.alibaba.excel.util.StringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess; import org.apache.poi.openxml4j.opc.PackageAccess;
@ -43,10 +42,9 @@ import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.openxml4j.opc.PackagingURIHelper; import org.apache.poi.openxml4j.opc.PackagingURIHelper;
import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.xssf.eventusermodel.XSSFReader; import org.apache.poi.xssf.eventusermodel.XSSFReader;
import org.apache.poi.xssf.model.Comments;
import org.apache.poi.xssf.model.CommentsTable; import org.apache.poi.xssf.model.CommentsTable;
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.xssf.usermodel.XSSFComment; import org.apache.poi.xssf.usermodel.XSSFComment;
import org.apache.poi.xssf.usermodel.XSSFRelation;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.WorkbookDocument; import org.openxmlformats.schemas.spreadsheetml.x2006.main.WorkbookDocument;
@ -123,9 +121,9 @@ public class XlsxSaxAnalyser implements ExcelReadExecutor {
sheetList.add(new ReadSheet(index, ite.getSheetName())); sheetList.add(new ReadSheet(index, ite.getSheetName()));
sheetMap.put(index, inputStream); sheetMap.put(index, inputStream);
if (xlsxReadContext.readWorkbookHolder().getExtraReadSet().contains(CellExtraTypeEnum.COMMENT)) { if (xlsxReadContext.readWorkbookHolder().getExtraReadSet().contains(CellExtraTypeEnum.COMMENT)) {
CommentsTable commentsTable = ite.getSheetComments(); Comments comments = ite.getSheetComments();
if (null != commentsTable) { if (comments instanceof CommentsTable) {
commentsTableMap.put(index, commentsTable); commentsTableMap.put(index, (CommentsTable) comments);
} }
} }
if (xlsxReadContext.readWorkbookHolder().getExtraReadSet().contains(CellExtraTypeEnum.HYPERLINK)) { if (xlsxReadContext.readWorkbookHolder().getExtraReadSet().contains(CellExtraTypeEnum.HYPERLINK)) {
@ -181,7 +179,7 @@ public class XlsxSaxAnalyser implements ExcelReadExecutor {
} }
private void analysisSharedStringsTable(InputStream sharedStringsTableInputStream, private void analysisSharedStringsTable(InputStream sharedStringsTableInputStream,
XlsxReadWorkbookHolder xlsxReadWorkbookHolder) throws Exception { XlsxReadWorkbookHolder xlsxReadWorkbookHolder) {
ContentHandler handler = new SharedStringsTableHandler(xlsxReadWorkbookHolder.getReadCache()); ContentHandler handler = new SharedStringsTableHandler(xlsxReadWorkbookHolder.getReadCache());
parseXmlSource(sharedStringsTableInputStream, handler); parseXmlSource(sharedStringsTableInputStream, handler);
xlsxReadWorkbookHolder.getReadCache().putFinished(); xlsxReadWorkbookHolder.getReadCache().putFinished();
@ -201,7 +199,7 @@ public class XlsxSaxAnalyser implements ExcelReadExecutor {
} }
File readTempFile = FileUtils.createCacheTmpFile(); File readTempFile = FileUtils.createCacheTmpFile();
xlsxReadWorkbookHolder.setTempFile(readTempFile); xlsxReadWorkbookHolder.setTempFile(readTempFile);
File tempFile = new File(readTempFile.getPath(), UUID.randomUUID().toString() + ".xlsx"); File tempFile = new File(readTempFile.getPath(), UUID.randomUUID() + ".xlsx");
if (decryptedStream != null) { if (decryptedStream != null) {
FileUtils.writeToFile(tempFile, decryptedStream, false); FileUtils.writeToFile(tempFile, decryptedStream, false);
} else { } else {

5
easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvCell.java

@ -227,11 +227,6 @@ public class CsvCell extends CellBase {
return getCellType(); return getCellType();
} }
@Override
public CellType getCachedFormulaResultTypeEnum() {
return getCellType();
}
@Override @Override
public String getCellFormula() { public String getCellFormula() {
if (formulaData == null) { if (formulaData == null) {

43
easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvCellStyle.java

@ -76,7 +76,7 @@ public class CsvCellStyle implements CellStyle {
} }
@Override @Override
public short getFontIndex() { public int getFontIndex() {
return 0; return 0;
} }
@ -125,11 +125,6 @@ public class CsvCellStyle implements CellStyle {
return null; return null;
} }
@Override
public HorizontalAlignment getAlignmentEnum() {
return null;
}
@Override @Override
public void setWrapText(boolean wrapped) { public void setWrapText(boolean wrapped) {
@ -150,11 +145,6 @@ public class CsvCellStyle implements CellStyle {
return null; return null;
} }
@Override
public VerticalAlignment getVerticalAlignmentEnum() {
return null;
}
@Override @Override
public void setRotation(short rotation) { public void setRotation(short rotation) {
@ -185,11 +175,6 @@ public class CsvCellStyle implements CellStyle {
return null; return null;
} }
@Override
public BorderStyle getBorderLeftEnum() {
return null;
}
@Override @Override
public void setBorderRight(BorderStyle border) { public void setBorderRight(BorderStyle border) {
@ -200,11 +185,6 @@ public class CsvCellStyle implements CellStyle {
return null; return null;
} }
@Override
public BorderStyle getBorderRightEnum() {
return null;
}
@Override @Override
public void setBorderTop(BorderStyle border) { public void setBorderTop(BorderStyle border) {
@ -215,11 +195,6 @@ public class CsvCellStyle implements CellStyle {
return null; return null;
} }
@Override
public BorderStyle getBorderTopEnum() {
return null;
}
@Override @Override
public void setBorderBottom(BorderStyle border) { public void setBorderBottom(BorderStyle border) {
@ -230,11 +205,6 @@ public class CsvCellStyle implements CellStyle {
return null; return null;
} }
@Override
public BorderStyle getBorderBottomEnum() {
return null;
}
@Override @Override
public void setLeftBorderColor(short color) { public void setLeftBorderColor(short color) {
@ -286,12 +256,12 @@ public class CsvCellStyle implements CellStyle {
} }
@Override @Override
public FillPatternType getFillPatternEnum() { public void setFillBackgroundColor(short bg) {
return null;
} }
@Override @Override
public void setFillBackgroundColor(short bg) { public void setFillBackgroundColor(Color color) {
} }
@ -310,6 +280,11 @@ public class CsvCellStyle implements CellStyle {
} }
@Override
public void setFillForegroundColor(Color color) {
}
@Override @Override
public short getFillForegroundColor() { public short getFillForegroundColor() {
return 0; return 0;

17
easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java

@ -39,6 +39,8 @@ import org.apache.poi.ss.usermodel.Drawing;
import org.apache.poi.ss.usermodel.Footer; import org.apache.poi.ss.usermodel.Footer;
import org.apache.poi.ss.usermodel.Header; import org.apache.poi.ss.usermodel.Header;
import org.apache.poi.ss.usermodel.Hyperlink; import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.ss.usermodel.PageMargin;
import org.apache.poi.ss.usermodel.PaneType;
import org.apache.poi.ss.usermodel.PrintSetup; import org.apache.poi.ss.usermodel.PrintSetup;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
@ -411,11 +413,21 @@ public class CsvSheet implements Sheet, Closeable {
return 0; return 0;
} }
@Override
public double getMargin(PageMargin pageMargin) {
return 0;
}
@Override @Override
public void setMargin(short margin, double size) { public void setMargin(short margin, double size) {
} }
@Override
public void setMargin(PageMargin pageMargin, double v) {
}
@Override @Override
public boolean getProtect() { public boolean getProtect() {
return false; return false;
@ -481,6 +493,11 @@ public class CsvSheet implements Sheet, Closeable {
} }
@Override
public void createSplitPane(int i, int i1, int i2, int i3, PaneType paneType) {
}
@Override @Override
public PaneInformation getPaneInformation() { public PaneInformation getPaneInformation() {
return null; return null;

51
easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvWorkbook.java

@ -12,7 +12,9 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.apache.commons.compress.utils.Lists; import org.apache.commons.compress.utils.Lists;
import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.EvaluationWorkbook;
import org.apache.poi.ss.formula.udf.UDFFinder; import org.apache.poi.ss.formula.udf.UDFFinder;
import org.apache.poi.ss.usermodel.CellReferenceType;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CreationHelper; import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.DataFormat; import org.apache.poi.ss.usermodel.DataFormat;
@ -40,10 +42,9 @@ public class CsvWorkbook implements Workbook {
/** /**
* true if date uses 1904 windowing, or false if using 1900 date windowing. * true if date uses 1904 windowing, or false if using 1900 date windowing.
* * <p>
* default is false * default is false
* *
* @return
*/ */
private Boolean use1904windowing; private Boolean use1904windowing;
@ -54,7 +55,7 @@ public class CsvWorkbook implements Workbook {
/** /**
* Whether to use scientific Format. * Whether to use scientific Format.
* * <p>
* default is false * default is false
*/ */
private Boolean useScientificFormat; private Boolean useScientificFormat;
@ -200,7 +201,7 @@ public class CsvWorkbook implements Workbook {
} }
@Override @Override
public short getNumberOfFonts() { public int getNumberOfFonts() {
return 0; return 0;
} }
@ -209,11 +210,6 @@ public class CsvWorkbook implements Workbook {
return 0; return 0;
} }
@Override
public Font getFontAt(short idx) {
return null;
}
@Override @Override
public Font getFontAt(int idx) { public Font getFontAt(int idx) {
return null; return null;
@ -272,31 +268,11 @@ public class CsvWorkbook implements Workbook {
return null; return null;
} }
@Override
public Name getNameAt(int nameIndex) {
return null;
}
@Override @Override
public Name createName() { public Name createName() {
return null; return null;
} }
@Override
public int getNameIndex(String name) {
return 0;
}
@Override
public void removeName(int index) {
}
@Override
public void removeName(String name) {
}
@Override @Override
public void removeName(Name name) { public void removeName(Name name) {
@ -417,10 +393,25 @@ public class CsvWorkbook implements Workbook {
} }
@Override @Override
public int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException { public int addOlePackage(byte[] oleData, String label, String fileName, String command) {
return 0; return 0;
} }
@Override
public EvaluationWorkbook createEvaluationWorkbook() {
return null;
}
@Override
public CellReferenceType getCellReferenceType() {
return null;
}
@Override
public void setCellReferenceType(CellReferenceType cellReferenceType) {
}
@Override @Override
public Iterator<Sheet> iterator() { public Iterator<Sheet> iterator() {
return null; return null;

7
easyexcel-core/src/main/java/com/alibaba/excel/read/listener/ModelBuildEventListener.java

@ -4,9 +4,6 @@ import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Map; import java.util.Map;
import javax.print.DocFlavor.STRING;
import com.alibaba.excel.constant.EasyExcelConstants;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.enums.CellDataTypeEnum; import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.enums.HeadKindEnum; import com.alibaba.excel.enums.HeadKindEnum;
@ -17,15 +14,13 @@ import com.alibaba.excel.metadata.data.DataFormatData;
import com.alibaba.excel.metadata.data.ReadCellData; import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.read.metadata.holder.ReadSheetHolder; import com.alibaba.excel.read.metadata.holder.ReadSheetHolder;
import com.alibaba.excel.read.metadata.property.ExcelReadHeadProperty; import com.alibaba.excel.read.metadata.property.ExcelReadHeadProperty;
import com.alibaba.excel.support.cglib.beans.BeanMap;
import com.alibaba.excel.util.BeanMapUtils; import com.alibaba.excel.util.BeanMapUtils;
import com.alibaba.excel.util.BooleanUtils;
import com.alibaba.excel.util.ClassUtils; import com.alibaba.excel.util.ClassUtils;
import com.alibaba.excel.util.ConverterUtils; import com.alibaba.excel.util.ConverterUtils;
import com.alibaba.excel.util.DateUtils; import com.alibaba.excel.util.DateUtils;
import com.alibaba.excel.util.MapUtils; import com.alibaba.excel.util.MapUtils;
import com.alibaba.excel.util.StringUtils;
import org.springframework.cglib.beans.BeanMap;
/** /**
* Convert to the object the user needs * Convert to the object the user needs

4
easyexcel-core/src/main/java/com/alibaba/excel/util/BeanMapUtils.java

@ -1,7 +1,7 @@
package com.alibaba.excel.util; package com.alibaba.excel.util;
import org.springframework.cglib.beans.BeanMap; import com.alibaba.excel.support.cglib.beans.BeanMap;
import org.springframework.cglib.core.DefaultNamingPolicy; import com.alibaba.excel.support.cglib.core.DefaultNamingPolicy;
/** /**
* bean utils * bean utils

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

@ -33,6 +33,7 @@ import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.metadata.property.FontProperty; import com.alibaba.excel.metadata.property.FontProperty;
import com.alibaba.excel.metadata.property.NumberFormatProperty; import com.alibaba.excel.metadata.property.NumberFormatProperty;
import com.alibaba.excel.metadata.property.StyleProperty; import com.alibaba.excel.metadata.property.StyleProperty;
import com.alibaba.excel.support.cglib.beans.BeanMap;
import com.alibaba.excel.write.metadata.holder.WriteHolder; import com.alibaba.excel.write.metadata.holder.WriteHolder;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -41,7 +42,6 @@ import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.cglib.beans.BeanMap;
/** /**
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more

3
easyexcel-core/src/main/java/com/alibaba/excel/util/FieldUtils.java

@ -5,8 +5,7 @@ import java.lang.reflect.Modifier;
import java.util.Map; import java.util.Map;
import com.alibaba.excel.metadata.NullObject; import com.alibaba.excel.metadata.NullObject;
import com.alibaba.excel.support.cglib.beans.BeanMap;
import org.springframework.cglib.beans.BeanMap;
/** /**
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more

4
easyexcel-core/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java

@ -1,12 +1,10 @@
package com.alibaba.excel.write.executor; package com.alibaba.excel.write.executor;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap;
import com.alibaba.excel.context.WriteContext; import com.alibaba.excel.context.WriteContext;
import com.alibaba.excel.enums.HeadKindEnum; import com.alibaba.excel.enums.HeadKindEnum;
@ -14,6 +12,7 @@ import com.alibaba.excel.metadata.FieldCache;
import com.alibaba.excel.metadata.FieldWrapper; import com.alibaba.excel.metadata.FieldWrapper;
import com.alibaba.excel.metadata.Head; import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.metadata.property.ExcelContentProperty; import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.excel.support.cglib.beans.BeanMap;
import com.alibaba.excel.util.BeanMapUtils; import com.alibaba.excel.util.BeanMapUtils;
import com.alibaba.excel.util.ClassUtils; import com.alibaba.excel.util.ClassUtils;
import com.alibaba.excel.util.FieldUtils; import com.alibaba.excel.util.FieldUtils;
@ -30,7 +29,6 @@ import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.springframework.cglib.beans.BeanMap;
/** /**
* Add the data into excel * Add the data into excel

2
easyexcel-support/pom.xml

@ -21,7 +21,7 @@
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId> <artifactId>spring-core</artifactId>
<version>5.3.27</version> <version>5.3.37</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>

9
easyexcel-test/pom.xml

@ -21,6 +21,7 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>easyexcel-core</artifactId> <artifactId>easyexcel-core</artifactId>
@ -28,17 +29,17 @@
<dependency> <dependency>
<groupId>com.alibaba.fastjson2</groupId> <groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId> <artifactId>fastjson2</artifactId>
<version>2.0.29</version> <version>2.0.51</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>2.7.11</version> <version>2.7.18</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<version>2.7.11</version> <version>2.7.18</version>
</dependency> </dependency>
<!-- logback --> <!-- logback -->
@ -60,7 +61,7 @@
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<version>1.2.12</version> <version>1.5.6</version>
</dependency> </dependency>
</dependencies> </dependencies>

2
easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java

@ -26,7 +26,7 @@ import com.alibaba.fastjson2.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.hssf.util.CellReference; import org.apache.poi.ss.util.CellReference;
import org.apache.poi.ss.usermodel.DateUtil; import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.FillPatternType; import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.IndexedColors;

3
easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/StyleTest.java

@ -10,7 +10,6 @@ import java.util.List;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@ -180,7 +179,7 @@ public class StyleTest {
private void isDate(Cell cell) { private void isDate(Cell cell) {
System.out.println( System.out.println(
DateUtil.isADateFormat(cell.getCellStyle().getDataFormat(), cell.getCellStyle().getDataFormatString())); DateUtil.isADateFormat(cell.getCellStyle().getDataFormat(), cell.getCellStyle().getDataFormatString()));
System.out.println(HSSFDateUtil.isCellDateFormatted(cell)); //System.out.println(HSSFDateUtil.isCellDateFormatted(cell));
DataFormatter f = new DataFormatter(); DataFormatter f = new DataFormatter();
System.out.println(f.formatCellValue(cell)); System.out.println(f.formatCellValue(cell));

4
easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/Xls03Test.java

@ -3,14 +3,14 @@ package com.alibaba.easyexcel.test.temp;
import java.util.List; import java.util.List;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.cglib.beans.BeanMap;
import com.alibaba.excel.support.cglib.core.DebuggingClassWriter;
import com.alibaba.excel.util.BeanMapUtils; import com.alibaba.excel.util.BeanMapUtils;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.cglib.core.DebuggingClassWriter;
/** /**
* 临时测试 * 临时测试

13
easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/dataformat/DataFormatter1.java

@ -38,6 +38,7 @@ import java.util.Observer;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.alibaba.excel.analysis.ExcelAnalyserImpl;
import org.apache.poi.ss.format.CellFormat; import org.apache.poi.ss.format.CellFormat;
import org.apache.poi.ss.format.CellFormatResult; import org.apache.poi.ss.format.CellFormatResult;
import org.apache.poi.ss.formula.ConditionalFormattingEvaluator; import org.apache.poi.ss.formula.ConditionalFormattingEvaluator;
@ -54,8 +55,8 @@ import org.apache.poi.ss.usermodel.FractionFormat;
import org.apache.poi.ss.util.DateFormatConverter; import org.apache.poi.ss.util.DateFormatConverter;
import org.apache.poi.ss.util.NumberToTextConverter; import org.apache.poi.ss.util.NumberToTextConverter;
import org.apache.poi.util.LocaleUtil; import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.POILogFactory; import org.slf4j.Logger;
import org.apache.poi.util.POILogger; import org.slf4j.LoggerFactory;
/** /**
* DataFormatter contains methods for formatting the value stored in an Cell. This can be useful for reports and GUI * DataFormatter contains methods for formatting the value stored in an Cell. This can be useful for reports and GUI
@ -245,7 +246,7 @@ public class DataFormatter1 implements Observer {
/** /**
* For logging any problems we find * For logging any problems we find
*/ */
private static POILogger logger = POILogFactory.getLogger(DataFormatter.class); private static final Logger logger = LoggerFactory.getLogger(ExcelAnalyserImpl.class);
/** /**
* Creates a formatter using the {@link Locale#getDefault() default locale}. * Creates a formatter using the {@link Locale#getDefault() default locale}.
@ -358,7 +359,7 @@ public class DataFormatter1 implements Observer {
// Wrap and return (non-cachable - CellFormat does that) // Wrap and return (non-cachable - CellFormat does that)
return new CellFormatResultWrapper(cfmt.apply(cellValueO)); return new CellFormatResultWrapper(cfmt.apply(cellValueO));
} catch (Exception e) { } catch (Exception e) {
logger.log(POILogger.WARN, "Formatting failed for format " + formatStr + ", falling back", e); logger.warn("Formatting failed for format {}, falling back", formatStr, e);
} }
} }
@ -598,7 +599,7 @@ public class DataFormatter1 implements Observer {
try { try {
return new ExcelStyleDateFormatter(formatStr, dateSymbols); return new ExcelStyleDateFormatter(formatStr, dateSymbols);
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
logger.log(POILogger.DEBUG, "Formatting failed for format " + formatStr + ", falling back", iae); logger.debug("Formatting failed for format {}, falling back", formatStr, iae);
// the pattern could not be parsed correctly, // the pattern could not be parsed correctly,
// so fall back to the default number format // so fall back to the default number format
return getDefaultFormat(cellValue); return getDefaultFormat(cellValue);
@ -759,7 +760,7 @@ public class DataFormatter1 implements Observer {
try { try {
return new InternalDecimalFormatWithScale(format, symbols); return new InternalDecimalFormatWithScale(format, symbols);
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
logger.log(POILogger.DEBUG, "Formatting failed for format " + formatStr + ", falling back", iae); logger.debug("Formatting failed for format {}, falling back", formatStr, iae);
// the pattern could not be parsed correctly, // the pattern could not be parsed correctly,
// so fall back to the default number format // so fall back to the default number format
return getDefaultFormat(cellValue); return getDefaultFormat(cellValue);

2
easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/write/TempWriteTest.java

@ -8,6 +8,7 @@ import java.util.Map;
import com.alibaba.easyexcel.test.demo.read.CustomStringStringConverter; import com.alibaba.easyexcel.test.demo.read.CustomStringStringConverter;
import com.alibaba.easyexcel.test.util.TestFileUtil; import com.alibaba.easyexcel.test.util.TestFileUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.cglib.beans.BeanMap;
import com.alibaba.excel.util.BeanMapUtils; import com.alibaba.excel.util.BeanMapUtils;
import com.alibaba.excel.util.FileUtils; import com.alibaba.excel.util.FileUtils;
import com.alibaba.excel.util.ListUtils; import com.alibaba.excel.util.ListUtils;
@ -24,7 +25,6 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.cglib.beans.BeanMap;
@Slf4j @Slf4j
public class TempWriteTest { public class TempWriteTest {

64
pom.xml

@ -20,7 +20,7 @@
<properties> <properties>
<revision>3.3.4</revision> <revision>4.0.0</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.8</jdk.version> <jdk.version>1.8</jdk.version>
<gpg.skip>true</gpg.skip> <gpg.skip>true</gpg.skip>
@ -90,49 +90,46 @@
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>easyexcel-support</artifactId> <artifactId>easyexcel-support</artifactId>
<version>${revision}</version> <version>3.3.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
<version>4.1.2</version> <version>5.2.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId> <artifactId>poi-ooxml</artifactId>
<version>4.1.2</version> <version>5.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId> <artifactId>commons-csv</artifactId>
<version>1.8</version> <version>1.11.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.32</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.ehcache</groupId> <groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId> <artifactId>ehcache</artifactId>
<version>3.9.9</version> <version>3.9.11</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.11.0</version> <version>2.11.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<!-- provided -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -321,31 +318,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.springframework</pattern>
<shadedPattern>com.alibaba.excel.support</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>

8
update.md

@ -1,3 +1,11 @@
# 4.0.0
* `poi`由`4.1.2`升级到`5.2.5`
* `commons-csv`由`1.1.0`升级到`1.10.0`
* `slf4j-api`由`1.7.32`升级到`1.7.36`
* `ehcache`由`3.9.9`升级到`3.9.11`
* 支持`jdk21`
# 3.3.4 # 3.3.4
* 支持停止单个`sheet`以后继续读取其他`sheet`,使用`ExcelAnalysisStopSheetException` * 支持停止单个`sheet`以后继续读取其他`sheet`,使用`ExcelAnalysisStopSheetException`

Loading…
Cancel
Save