Browse Source

提供api能控制是否继续解析Cell

master
Echen 4 years ago
parent
commit
5251a8c877
  1. 3
      src/main/java/com/alibaba/excel/analysis/v07/handlers/AbstractXlsxTagHandler.java
  2. 14
      src/main/java/com/alibaba/excel/read/metadata/ReadWorkbook.java
  3. 17
      src/main/java/com/alibaba/excel/read/metadata/holder/ReadWorkbookHolder.java

3
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

14
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<CellExtraTypeEnum> getExtraReadSet() {
return extraReadSet;
}

17
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<CellExtraTypeEnum>();
} 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<CellExtraTypeEnum> getExtraReadSet() {
return extraReadSet;
}

Loading…
Cancel
Save