Browse Source

Merge pull request #2888 from linghengqian/poi-new-version

Update Apache POI to 5.2.3 in preparation for GraalVM NativeTest
pull/2565/merge
Jiaju Zhuang 2 years ago committed by GitHub
parent
commit
1b1ce12efe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
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.ss.util.CellAddress;
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.SharedStringsTable;
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.CTWorkbookPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.WorkbookDocument;
@ -121,9 +119,9 @@ public class XlsxSaxAnalyser implements ExcelReadExecutor {
sheetList.add(new ReadSheet(index, ite.getSheetName()));
sheetMap.put(index, inputStream);
if (xlsxReadContext.readWorkbookHolder().getExtraReadSet().contains(CellExtraTypeEnum.COMMENT)) {
CommentsTable commentsTable = ite.getSheetComments();
if (null != commentsTable) {
commentsTableMap.put(index, commentsTable);
Comments comments = ite.getSheetComments();
if (comments instanceof CommentsTable) {
commentsTableMap.put(index, (CommentsTable) comments);
}
}
if (xlsxReadContext.readWorkbookHolder().getExtraReadSet().contains(CellExtraTypeEnum.HYPERLINK)) {
@ -179,7 +177,7 @@ public class XlsxSaxAnalyser implements ExcelReadExecutor {
}
private void analysisSharedStringsTable(InputStream sharedStringsTableInputStream,
XlsxReadWorkbookHolder xlsxReadWorkbookHolder) throws Exception {
XlsxReadWorkbookHolder xlsxReadWorkbookHolder) {
ContentHandler handler = new SharedStringsTableHandler(xlsxReadWorkbookHolder.getReadCache());
parseXmlSource(sharedStringsTableInputStream, handler);
xlsxReadWorkbookHolder.getReadCache().putFinished();
@ -199,7 +197,7 @@ public class XlsxSaxAnalyser implements ExcelReadExecutor {
}
File readTempFile = FileUtils.createCacheTmpFile();
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) {
FileUtils.writeToFile(tempFile, decryptedStream, false);
} 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();
}
@Override
public CellType getCachedFormulaResultTypeEnum() {
return getCellType();
}
@Override
public String getCellFormula() {
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
public short getFontIndex() {
public int getFontIndex() {
return 0;
}
@ -125,11 +125,6 @@ public class CsvCellStyle implements CellStyle {
return null;
}
@Override
public HorizontalAlignment getAlignmentEnum() {
return null;
}
@Override
public void setWrapText(boolean wrapped) {
@ -150,11 +145,6 @@ public class CsvCellStyle implements CellStyle {
return null;
}
@Override
public VerticalAlignment getVerticalAlignmentEnum() {
return null;
}
@Override
public void setRotation(short rotation) {
@ -185,11 +175,6 @@ public class CsvCellStyle implements CellStyle {
return null;
}
@Override
public BorderStyle getBorderLeftEnum() {
return null;
}
@Override
public void setBorderRight(BorderStyle border) {
@ -200,11 +185,6 @@ public class CsvCellStyle implements CellStyle {
return null;
}
@Override
public BorderStyle getBorderRightEnum() {
return null;
}
@Override
public void setBorderTop(BorderStyle border) {
@ -215,11 +195,6 @@ public class CsvCellStyle implements CellStyle {
return null;
}
@Override
public BorderStyle getBorderTopEnum() {
return null;
}
@Override
public void setBorderBottom(BorderStyle border) {
@ -230,11 +205,6 @@ public class CsvCellStyle implements CellStyle {
return null;
}
@Override
public BorderStyle getBorderBottomEnum() {
return null;
}
@Override
public void setLeftBorderColor(short color) {
@ -286,12 +256,12 @@ public class CsvCellStyle implements CellStyle {
}
@Override
public FillPatternType getFillPatternEnum() {
return null;
public void setFillBackgroundColor(short bg) {
}
@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
public short getFillForegroundColor() {
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.Header;
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.Row;
import org.apache.poi.ss.usermodel.Sheet;
@ -397,11 +399,21 @@ public class CsvSheet implements Sheet, Closeable {
return 0;
}
@Override
public double getMargin(PageMargin pageMargin) {
return 0;
}
@Override
public void setMargin(short margin, double size) {
}
@Override
public void setMargin(PageMargin pageMargin, double v) {
}
@Override
public boolean getProtect() {
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
public PaneInformation getPaneInformation() {
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 org.apache.commons.compress.utils.Lists;
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.usermodel.CellReferenceType;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CreationHelper;
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.
*
* <p>
* default is false
*
* @return
*/
private Boolean use1904windowing;
@ -53,7 +54,7 @@ public class CsvWorkbook implements Workbook {
/**
* Whether to use scientific Format.
*
* <p>
* default is false
*/
private Boolean useScientificFormat;
@ -185,7 +186,7 @@ public class CsvWorkbook implements Workbook {
}
@Override
public short getNumberOfFonts() {
public int getNumberOfFonts() {
return 0;
}
@ -194,11 +195,6 @@ public class CsvWorkbook implements Workbook {
return 0;
}
@Override
public Font getFontAt(short idx) {
return null;
}
@Override
public Font getFontAt(int idx) {
return null;
@ -257,31 +253,11 @@ public class CsvWorkbook implements Workbook {
return null;
}
@Override
public Name getNameAt(int nameIndex) {
return null;
}
@Override
public Name createName() {
return null;
}
@Override
public int getNameIndex(String name) {
return 0;
}
@Override
public void removeName(int index) {
}
@Override
public void removeName(String name) {
}
@Override
public void removeName(Name name) {
@ -402,10 +378,25 @@ public class CsvWorkbook implements Workbook {
}
@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;
}
@Override
public EvaluationWorkbook createEvaluationWorkbook() {
return null;
}
@Override
public CellReferenceType getCellReferenceType() {
return null;
}
@Override
public void setCellReferenceType(CellReferenceType cellReferenceType) {
}
@Override
public Iterator<Sheet> iterator() {
return null;

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

@ -28,7 +28,7 @@ import com.alibaba.fastjson2.JSON;
import lombok.extern.slf4j.Slf4j;
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.FillPatternType;
import org.apache.poi.ss.usermodel.IndexedColors;

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.Pattern;
import com.alibaba.excel.analysis.ExcelAnalyserImpl;
import org.apache.poi.ss.format.CellFormat;
import org.apache.poi.ss.format.CellFormatResult;
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.NumberToTextConverter;
import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 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();
/** 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}.
@ -346,7 +347,7 @@ public class DataFormatter1 implements Observer {
// Wrap and return (non-cachable - CellFormat does that)
return new CellFormatResultWrapper(cfmt.apply(cellValueO));
} 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 {
return new ExcelStyleDateFormatter(formatStr, dateSymbols);
} 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,
// so fall back to the default number format
return getDefaultFormat(cellValue);
@ -750,7 +751,7 @@ public class DataFormatter1 implements Observer {
try {
return new InternalDecimalFormatWithScale(format, symbols);
} 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,
// so fall back to the default number format
return getDefaultFormat(cellValue);

11
pom.xml

@ -96,22 +96,17 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.8</version>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>

Loading…
Cancel
Save