From 5251a8c877273398f94d5e805d9810cc7aeac33e Mon Sep 17 00:00:00 2001 From: Echen Date: Tue, 10 Nov 2020 16:31:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BE=9Bapi=E8=83=BD=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E6=98=AF=E5=90=A6=E7=BB=A7=E7=BB=AD=E8=A7=A3=E6=9E=90?= =?UTF-8?q?Cell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v07/handlers/AbstractXlsxTagHandler.java | 3 ++- .../excel/read/metadata/ReadWorkbook.java | 14 ++++++++++++++ .../metadata/holder/ReadWorkbookHolder.java | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/alibaba/excel/analysis/v07/handlers/AbstractXlsxTagHandler.java b/src/main/java/com/alibaba/excel/analysis/v07/handlers/AbstractXlsxTagHandler.java index 169fe00..10ee975 100644 --- a/src/main/java/com/alibaba/excel/analysis/v07/handlers/AbstractXlsxTagHandler.java +++ b/src/main/java/com/alibaba/excel/analysis/v07/handlers/AbstractXlsxTagHandler.java @@ -1,5 +1,6 @@ package com.alibaba.excel.analysis.v07.handlers; +import com.alibaba.excel.enums.CellExtraTypeEnum; import org.xml.sax.Attributes; import com.alibaba.excel.context.xlsx.XlsxReadContext; @@ -12,7 +13,7 @@ import com.alibaba.excel.context.xlsx.XlsxReadContext; public abstract class AbstractXlsxTagHandler implements XlsxTagHandler { @Override public boolean support(XlsxReadContext xlsxReadContext) { - return true; + return xlsxReadContext.readWorkbookHolder().getParseCell(); } @Override diff --git a/src/main/java/com/alibaba/excel/read/metadata/ReadWorkbook.java b/src/main/java/com/alibaba/excel/read/metadata/ReadWorkbook.java index c9e4db9..4dc3875 100644 --- a/src/main/java/com/alibaba/excel/read/metadata/ReadWorkbook.java +++ b/src/main/java/com/alibaba/excel/read/metadata/ReadWorkbook.java @@ -85,6 +85,12 @@ public class ReadWorkbook extends ReadBasicParameter { * The {@link ModelBuildEventListener} is loaded by default to convert the object. */ private Boolean useDefaultListener; + + /** + * Whether to parse CellData. Default is true. + */ + private Boolean parseCell; + /** * Read some additional fields. None are read by default. * @@ -221,6 +227,14 @@ public class ReadWorkbook extends ReadBasicParameter { this.useDefaultListener = useDefaultListener; } + public Boolean getParseCell() { + return parseCell; + } + + public void setParseCell(Boolean parseCell) { + this.parseCell = parseCell; + } + public Set getExtraReadSet() { return extraReadSet; } diff --git a/src/main/java/com/alibaba/excel/read/metadata/holder/ReadWorkbookHolder.java b/src/main/java/com/alibaba/excel/read/metadata/holder/ReadWorkbookHolder.java index 375e32c..64be355 100644 --- a/src/main/java/com/alibaba/excel/read/metadata/holder/ReadWorkbookHolder.java +++ b/src/main/java/com/alibaba/excel/read/metadata/holder/ReadWorkbookHolder.java @@ -82,6 +82,10 @@ public class ReadWorkbookHolder extends AbstractReadHolder { * Whether the encryption */ private String password; + /** + * Whether to parse CellData + */ + private Boolean parseCell; /** * Read some additional fields. None are read by default. * @@ -162,6 +166,11 @@ public class ReadWorkbookHolder extends AbstractReadHolder { } else { this.defaultReturnMap = readWorkbook.getDefaultReturnMap(); } + if (readWorkbook.getParseCell() == null) { + this.parseCell = Boolean.TRUE; + } else { + this.parseCell = readWorkbook.getParseCell(); + } if (readWorkbook.getExtraReadSet() == null) { this.extraReadSet = new HashSet(); } else { @@ -291,6 +300,14 @@ public class ReadWorkbookHolder extends AbstractReadHolder { this.password = password; } + public Boolean getParseCell() { + return parseCell; + } + + public void setParseCell(Boolean parseCell) { + this.parseCell = parseCell; + } + public Set getExtraReadSet() { return extraReadSet; }