Compare commits

...

12 Commits

Author SHA1 Message Date
Jiaju Zhuang 5d31cb6041 Merge branch 'refs/heads/master' into image
# Conflicts:
#	easyexcel-core/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java
#	pom.xml
#	update.md
2024-04-11 20:06:38 +08:00
Jiaju Zhuang af7a9064a0 修改图片 2024-04-11 19:51:18 +08:00
Jiaju Zhuang 7929e366ae 修改cglib 2023-12-06 09:59:12 +08:00
Jiaju Zhuang 4f4a2e6ebc 修改编译报错 2023-12-05 19:34:53 +08:00
Jiaju Zhuang 65aadff8ec 修改合并异常 2023-12-05 19:30:51 +08:00
Jiaju Zhuang 87d805a4cd Merge branch 'master' into developing
# Conflicts:
#	easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/StyleTest.java
#	easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/dataformat/DataFormatter1.java
#	pom.xml
#	update.md
2023-12-05 17:38:53 +08:00
Jiaju Zhuang 4eca3328a7 引入jcl-over-slf4j 2023-02-13 19:59:04 +08:00
Jiaju Zhuang 8caa034f15 升级到4.0.0-beta1 2023-02-10 20:52:01 +08:00
Jiaju Zhuang 5264a5d56a 升级到4.0.0-beta1 2023-02-10 20:51:34 +08:00
Jiaju Zhuang 1b1ce12efe
Merge pull request #2888 from linghengqian/poi-new-version
Update Apache POI to 5.2.3 in preparation for GraalVM NativeTest
2023-02-10 20:19:50 +08:00
Ling Hengqian 77232af45b
Merge branch 'master' into poi-new-version 2023-01-19 19:24:32 +08:00
linghengqian 21e50a5064 Update Apache POI to 5.2.3 in preparation for GraalVM NativeTest 2022-12-27 23:13:35 +08:00
22 changed files with 231 additions and 156 deletions

View File

@ -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>

View File

@ -10,6 +10,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.regex.Pattern;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
@ -43,10 +44,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;
@ -83,6 +83,9 @@ public class XlsxSaxAnalyser implements ExcelReadExecutor {
*/
private final Map<Integer, CommentsTable> commentsTableMap;
private final Map<Integer, PackagePart> drawingMap;
private final Map<Integer, PackagePart> drawingResMap;
public XlsxSaxAnalyser(XlsxReadContext xlsxReadContext, InputStream decryptedStream) throws Exception {
this.xlsxReadContext = xlsxReadContext;
// Initialize cache
@ -110,6 +113,20 @@ public class XlsxSaxAnalyser implements ExcelReadExecutor {
sheetList = new ArrayList<>();
sheetMap = new HashMap<>();
commentsTableMap = new HashMap<>();
drawingMap = MapUtils.newHashMap();
drawingResMap = MapUtils.newHashMap();
// Reading images
if (xlsxReadContext.readWorkbookHolder().getExtraReadSet().contains(CellExtraTypeEnum.IMAGE)) {
List<PackagePart> drawingsPackagePartList = pkg.getPartsByName(
Pattern.compile("/xl/drawings/drawing[0-9]+.xml"));
if (CollectionUtils.isNotEmpty(drawingsPackagePartList)) {
for (PackagePart drawingPackagePart : drawingsPackagePartList) {
log.info("xx{}", drawingPackagePart);
}
}
}
Map<Integer, PackageRelationshipCollection> packageRelationshipCollectionMap = MapUtils.newHashMap();
xlsxReadWorkbookHolder.setPackageRelationshipCollectionMap(packageRelationshipCollectionMap);
@ -123,9 +140,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)) {
@ -181,7 +198,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();
@ -201,7 +218,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 {
@ -258,6 +275,12 @@ public class XlsxSaxAnalyser implements ExcelReadExecutor {
for (ReadSheet readSheet : sheetList) {
readSheet = SheetUtils.match(readSheet, xlsxReadContext);
if (readSheet != null) {
xlsxReadContext.currentSheet(readSheet);
parseXmlSource(sheetMap.get(readSheet.getSheetNo()), new XlsxRowHandler(xlsxReadContext));
// Read comments
readComments(readSheet);
// Read image
readImages(readSheet);
try {
xlsxReadContext.currentSheet(readSheet);
parseXmlSource(sheetMap.get(readSheet.getSheetNo()), new XlsxRowHandler(xlsxReadContext));
@ -274,6 +297,28 @@ public class XlsxSaxAnalyser implements ExcelReadExecutor {
}
}
private void readImages(ReadSheet readSheet) {
if (!xlsxReadContext.readWorkbookHolder().getExtraReadSet().contains(CellExtraTypeEnum.IMAGE)) {
return;
}
//xlsxReadContext.xlsxReadWorkbookHolder().getOpcPackage().getPart();
//
//CommentsTable commentsTable = commentsTableMap.get(readSheet.getSheetNo());
//if (commentsTable == null) {
// return;
//}
//Iterator<CellAddress> cellAddresses = commentsTable.getCellAddresses();
//while (cellAddresses.hasNext()) {
// CellAddress cellAddress = cellAddresses.next();
// XSSFComment cellComment = commentsTable.findCellComment(cellAddress);
// CellExtra cellExtra = new CellExtra(CellExtraTypeEnum.COMMENT, cellComment.getString().toString(),
// cellAddress.getRow(), cellAddress.getColumn());
// xlsxReadContext.readSheetHolder().setCellExtra(cellExtra);
// xlsxReadContext.analysisEventProcessor().extra(xlsxReadContext);
//}
}
private void readComments(ReadSheet readSheet) {
if (!xlsxReadContext.readWorkbookHolder().getExtraReadSet().contains(CellExtraTypeEnum.COMMENT)) {
return;

View File

@ -17,5 +17,12 @@ public enum CellExtraTypeEnum {
/**
* Merge
*/
MERGE,;
MERGE,
/**
* Image
*/
IMAGE,
;
}

View File

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

View File

@ -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;

View File

@ -39,6 +39,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;
@ -411,11 +413,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;
@ -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
public PaneInformation getPaneInformation() {
return null;

View File

@ -12,7 +12,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;
@ -40,10 +42,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;
@ -54,7 +55,7 @@ public class CsvWorkbook implements Workbook {
/**
* Whether to use scientific Format.
*
* <p>
* default is false
*/
private Boolean useScientificFormat;
@ -200,7 +201,7 @@ public class CsvWorkbook implements Workbook {
}
@Override
public short getNumberOfFonts() {
public int getNumberOfFonts() {
return 0;
}
@ -209,11 +210,6 @@ public class CsvWorkbook implements Workbook {
return 0;
}
@Override
public Font getFontAt(short idx) {
return null;
}
@Override
public Font getFontAt(int idx) {
return null;
@ -272,31 +268,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) {
@ -417,10 +393,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;

View File

@ -4,9 +4,6 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
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.enums.CellDataTypeEnum;
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.read.metadata.holder.ReadSheetHolder;
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.BooleanUtils;
import com.alibaba.excel.util.ClassUtils;
import com.alibaba.excel.util.ConverterUtils;
import com.alibaba.excel.util.DateUtils;
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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,10 @@
package com.alibaba.excel.write.executor;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import com.alibaba.excel.context.WriteContext;
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.Head;
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.ClassUtils;
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.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.springframework.cglib.beans.BeanMap;
/**
* Add the data into excel

View File

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

View File

@ -21,6 +21,7 @@
</properties>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel-core</artifactId>

View File

@ -17,7 +17,9 @@ import java.util.Map;
import com.alibaba.easyexcel.test.demo.write.DemoData;
import com.alibaba.easyexcel.test.util.TestFileUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.enums.CellExtraTypeEnum;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.util.PositionUtils;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
@ -26,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;
@ -52,9 +54,9 @@ public class Lock2Test {
File file = new File("/Users/zhuangjiaju/IdeaProjects/easyexcel/src/test/resources/converter/converter07.xlsx");
List<Object> list = EasyExcel.read(
"/Users/zhuangjiaju/IdeaProjects/easyexcel/easyexcel-test/target/test-classes"
+ "/simpleWrite1674051907397.xlsx")
"/Users/zhuangjiaju/测试数据/imagetest.xlsx")
//.useDefaultListener(false)
.extraRead(CellExtraTypeEnum.IMAGE)
.sheet(0)
.headRowNumber(0).doReadSync();
LOGGER.info("数据:{}", list.size());

View File

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

View File

@ -3,14 +3,13 @@ package com.alibaba.easyexcel.test.temp;
import java.util.List;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.cglib.beans.BeanMap;
import com.alibaba.excel.util.BeanMapUtils;
import com.alibaba.fastjson2.JSON;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.cglib.core.DebuggingClassWriter;
/**
* 临时测试
@ -32,8 +31,8 @@ public class Xls03Test {
@Test
public void test2() {
System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");
System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY,
"/Users/zhuangjiaju/IdeaProjects/easyexcel/target");
//System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY,
// "/Users/zhuangjiaju/IdeaProjects/easyexcel/target");
CamlData camlData = new CamlData();
//camlData.setTest("test2");

View File

@ -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
@ -245,7 +246,7 @@ public class DataFormatter1 implements Observer {
/**
* 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}.
@ -358,7 +359,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);
}
}
@ -598,7 +599,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);
@ -759,7 +760,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);

View File

@ -0,0 +1,75 @@
package com.alibaba.easyexcel.test.temp.poi;
import java.io.FileInputStream;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFPicture;
import org.apache.poi.hssf.usermodel.HSSFPictureData;
import org.apache.poi.hssf.usermodel.HSSFShape;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFDrawing;
import org.apache.poi.xssf.usermodel.XSSFPicture;
import org.apache.poi.xssf.usermodel.XSSFPictureData;
import org.apache.poi.xssf.usermodel.XSSFShape;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;
/**
* 测试poi
*
* @author Jiaju Zhuang
**/
@Slf4j
public class PoiImageTest {
@Test
public void xls() throws Exception {
FileInputStream fis = new FileInputStream("/Users/zhuangjiaju/测试数据/imagetest.xls");
HSSFWorkbook workbook = new HSSFWorkbook(fis);
HSSFSheet sheet = workbook.getSheetAt(0);
HSSFPatriarch patriarch = sheet.getDrawingPatriarch();
for (HSSFShape shape : patriarch.getChildren()) {
if (shape instanceof HSSFPicture) {
HSSFPicture picture = (HSSFPicture)shape;
HSSFPictureData pictureData = picture.getPictureData();
byte[] data = pictureData.getData();
log.info("图片:{}", data.length);
}
}
workbook.close();
fis.close();
}
@Test
public void xlsx() throws Exception {
FileInputStream fis = new FileInputStream("/Users/zhuangjiaju/测试数据/imagetest.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(fis);
XSSFSheet sheet = workbook.getSheetAt(0);
XSSFDrawing drawing = sheet.getDrawingPatriarch();
for (XSSFShape shape : drawing.getShapes()) {
if (shape instanceof XSSFPicture) {
XSSFPicture picture = (XSSFPicture)shape;
XSSFPictureData pictureData = picture.getPictureData();
byte[] data = pictureData.getData();
log.info("图片:{}", data.length);
log.info("图片:{}", pictureData.getPictureType());
log.info("图片:{}", pictureData.getMimeType());
log.info("图片:{}", pictureData.suggestFileExtension());
//log.info("图片:{}", pictureData.suggestFileExtension());
}
}
workbook.close();
fis.close();
}
}

View File

@ -8,6 +8,7 @@ import java.util.Map;
import com.alibaba.easyexcel.test.demo.read.CustomStringStringConverter;
import com.alibaba.easyexcel.test.util.TestFileUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.cglib.beans.BeanMap;
import com.alibaba.excel.util.BeanMapUtils;
import com.alibaba.excel.util.FileUtils;
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.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;
import org.springframework.cglib.beans.BeanMap;
@Slf4j
public class TempWriteTest {

61
pom.xml
View File

@ -20,7 +20,7 @@
<properties>
<revision>3.3.4</revision>
<revision>4.0.0-beta1</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.8</jdk.version>
<gpg.skip>true</gpg.skip>
@ -87,52 +87,50 @@
<version>${revision}</version>
</dependency>
<!-- Using the latest version of support simultaneously requires global use of the shade plugin, which is prone to errors, so changing to support will be lower than the overall -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel-support</artifactId>
<version>${revision}</version>
<version>3.3.2</version>
</dependency>
<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>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.8</version>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.32</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.9.9</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<!-- provided -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -321,31 +319,6 @@
</execution>
</executions>
</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>
<groupId>org.codehaus.mojo</groupId>

View File

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