Browse Source

Update Apache POI to 5.2.3 in preparation for GraalVM NativeTest

pull/2888/head
linghengqian 2 years ago
parent
commit
21e50a5064
  1. 4
      easyexcel-core/pom.xml
  2. 14
      easyexcel-core/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java
  3. 5
      easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvCell.java
  4. 43
      easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvCellStyle.java
  5. 17
      easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java
  6. 51
      easyexcel-core/src/main/java/com/alibaba/excel/metadata/csv/CsvWorkbook.java
  7. 2
      easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
  8. 13
      easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/dataformat/DataFormatter1.java
  9. 11
      pom.xml

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

@ -31,7 +31,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;
@ -41,10 +40,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;
@ -121,9 +119,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)) {
@ -179,7 +177,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();
@ -199,7 +197,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

@ -33,6 +33,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;
@ -397,11 +399,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;
@ -467,6 +479,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

@ -11,7 +11,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;
@ -39,10 +41,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;
@ -53,7 +54,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;
@ -185,7 +186,7 @@ public class CsvWorkbook implements Workbook {
} }
@Override @Override
public short getNumberOfFonts() { public int getNumberOfFonts() {
return 0; return 0;
} }
@ -194,11 +195,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;
@ -257,31 +253,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) {
@ -402,10 +378,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;

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

@ -15,9 +15,9 @@ import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.hssf.util.CellReference;
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;
import org.apache.poi.ss.util.CellReference;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

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
@ -227,7 +228,7 @@ public class DataFormatter1 implements Observer {
private final LocaleChangeObservable localeChangedObservable = new LocaleChangeObservable(); private final LocaleChangeObservable localeChangedObservable = new LocaleChangeObservable();
/** 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}.
@ -346,7 +347,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);
} }
} }
@ -589,7 +590,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);
@ -750,7 +751,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);

11
pom.xml

@ -96,22 +96,17 @@
<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.3</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.3</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.9.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>

Loading…
Cancel
Save