objectCacheMap();
-}
diff --git a/src/main/java/com/alibaba/excel/context/xls/DefaultXlsReadContext.java b/src/main/java/com/alibaba/excel/context/xls/DefaultXlsReadContext.java
new file mode 100644
index 00000000..698bf6a4
--- /dev/null
+++ b/src/main/java/com/alibaba/excel/context/xls/DefaultXlsReadContext.java
@@ -0,0 +1,30 @@
+package com.alibaba.excel.context.xls;
+
+import com.alibaba.excel.context.AnalysisContextImpl;
+import com.alibaba.excel.read.metadata.ReadWorkbook;
+import com.alibaba.excel.read.metadata.holder.xls.XlsReadSheetHolder;
+import com.alibaba.excel.read.metadata.holder.xls.XlsReadWorkbookHolder;
+import com.alibaba.excel.support.ExcelTypeEnum;
+
+/**
+ *
+ * A context is the main anchorage point of a ls xls reader.
+ *
+ * @author Jiaju Zhuang
+ */
+public class DefaultXlsReadContext extends AnalysisContextImpl implements XlsReadContext {
+
+ public DefaultXlsReadContext(ReadWorkbook readWorkbook, ExcelTypeEnum actualExcelType) {
+ super(readWorkbook, actualExcelType);
+ }
+
+ @Override
+ public XlsReadWorkbookHolder xlsReadWorkbookHolder() {
+ return (XlsReadWorkbookHolder)readWorkbookHolder();
+ }
+
+ @Override
+ public XlsReadSheetHolder xlsReadSheetHolder() {
+ return (XlsReadSheetHolder)readSheetHolder();
+ }
+}
diff --git a/src/main/java/com/alibaba/excel/context/xls/XlsReadContext.java b/src/main/java/com/alibaba/excel/context/xls/XlsReadContext.java
new file mode 100644
index 00000000..4d1bcdb2
--- /dev/null
+++ b/src/main/java/com/alibaba/excel/context/xls/XlsReadContext.java
@@ -0,0 +1,26 @@
+package com.alibaba.excel.context.xls;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.read.metadata.holder.xls.XlsReadSheetHolder;
+import com.alibaba.excel.read.metadata.holder.xls.XlsReadWorkbookHolder;
+
+/**
+ * A context is the main anchorage point of a ls xls reader.
+ *
+ * @author Jiaju Zhuang
+ **/
+public interface XlsReadContext extends AnalysisContext {
+ /**
+ * All information about the workbook you are currently working on.
+ *
+ * @return Current workbook holder
+ */
+ XlsReadWorkbookHolder xlsReadWorkbookHolder();
+
+ /**
+ * All information about the sheet you are currently working on.
+ *
+ * @return Current sheet holder
+ */
+ XlsReadSheetHolder xlsReadSheetHolder();
+}
diff --git a/src/main/java/com/alibaba/excel/context/xlsx/DefaultXlsxReadContext.java b/src/main/java/com/alibaba/excel/context/xlsx/DefaultXlsxReadContext.java
new file mode 100644
index 00000000..5c9d638d
--- /dev/null
+++ b/src/main/java/com/alibaba/excel/context/xlsx/DefaultXlsxReadContext.java
@@ -0,0 +1,30 @@
+package com.alibaba.excel.context.xlsx;
+
+import com.alibaba.excel.context.AnalysisContextImpl;
+import com.alibaba.excel.read.metadata.ReadWorkbook;
+import com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder;
+import com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadWorkbookHolder;
+import com.alibaba.excel.support.ExcelTypeEnum;
+
+/**
+ *
+ * A context is the main anchorage point of a ls xls reader.
+ *
+ * @author Jiaju Zhuang
+ */
+public class DefaultXlsxReadContext extends AnalysisContextImpl implements XlsxReadContext {
+
+ public DefaultXlsxReadContext(ReadWorkbook readWorkbook, ExcelTypeEnum actualExcelType) {
+ super(readWorkbook, actualExcelType);
+ }
+
+ @Override
+ public XlsxReadWorkbookHolder xlsxReadWorkbookHolder() {
+ return (XlsxReadWorkbookHolder)readWorkbookHolder();
+ }
+
+ @Override
+ public XlsxReadSheetHolder xlsxReadSheetHolder() {
+ return (XlsxReadSheetHolder)readSheetHolder();
+ }
+}
diff --git a/src/main/java/com/alibaba/excel/context/xlsx/XlsxReadContext.java b/src/main/java/com/alibaba/excel/context/xlsx/XlsxReadContext.java
new file mode 100644
index 00000000..924cafea
--- /dev/null
+++ b/src/main/java/com/alibaba/excel/context/xlsx/XlsxReadContext.java
@@ -0,0 +1,28 @@
+package com.alibaba.excel.context.xlsx;
+
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.read.metadata.holder.xls.XlsReadSheetHolder;
+import com.alibaba.excel.read.metadata.holder.xls.XlsReadWorkbookHolder;
+import com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder;
+import com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadWorkbookHolder;
+
+/**
+ * A context is the main anchorage point of a ls xlsx reader.
+ *
+ * @author Jiaju Zhuang
+ **/
+public interface XlsxReadContext extends AnalysisContext {
+ /**
+ * All information about the workbook you are currently working on.
+ *
+ * @return Current workbook holder
+ */
+ XlsxReadWorkbookHolder xlsxReadWorkbookHolder();
+
+ /**
+ * All information about the sheet you are currently working on.
+ *
+ * @return Current sheet holder
+ */
+ XlsxReadSheetHolder xlsxReadSheetHolder();
+}
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 b97395ec..1c1b2420 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
@@ -4,6 +4,7 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.InputStream;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.xml.parsers.SAXParserFactory;
@@ -20,6 +21,7 @@ import com.alibaba.excel.enums.ExtraReadEnum;
import com.alibaba.excel.enums.HolderEnum;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.exception.ExcelAnalysisException;
+import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.read.metadata.ReadWorkbook;
import com.alibaba.excel.support.ExcelTypeEnum;
@@ -86,23 +88,25 @@ public class ReadWorkbookHolder extends AbstractReadHolder {
* Whether the encryption
*/
private String password;
- /**
- * SAXParserFactory used when reading xlsx.
- *
- * The default will automatically find.
- *
- * Please pass in the name of a class ,like : "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"
- *
- * @see SAXParserFactory#newInstance()
- * @see SAXParserFactory#newInstance(String, ClassLoader)
- */
- private String xlsxSAXParserFactoryName;
/**
* Read some additional fields. None are read by default.
*
* @see ExtraReadEnum
*/
private Set extraReadSet;
+ /**
+ * Actual sheet data
+ */
+ private List actualSheetDataList;
+ /**
+ * Parameter sheet data
+ */
+ private List parametersheetDataList;
+ /**
+ * Read all
+ */
+ private Boolean readAll;
+
/**
* The default is all excel objects.if true , you can use {@link com.alibaba.excel.annotation.ExcelIgnore} ignore a
* field. if false , you must use {@link com.alibaba.excel.annotation.ExcelProperty} to use a filed.
@@ -122,14 +126,6 @@ public class ReadWorkbookHolder extends AbstractReadHolder {
* Prevent repeating sheet
*/
private Set hasReadSheet;
- /**
- * Package
- */
- private OPCPackage opcPackage;
- /**
- * File System
- */
- private POIFSFileSystem poifsFileSystem;
public ReadWorkbookHolder(ReadWorkbook readWorkbook) {
super(readWorkbook, null, readWorkbook.getConvertAllFiled());
@@ -184,7 +180,6 @@ public class ReadWorkbookHolder extends AbstractReadHolder {
} else {
this.defaultReturnMap = readWorkbook.getDefaultReturnMap();
}
- this.xlsxSAXParserFactoryName = readWorkbook.getXlsxSAXParserFactoryName();
if (readWorkbook.getExtraReadSet() == null) {
this.extraReadSet = new HashSet();
} else {
@@ -306,44 +301,44 @@ public class ReadWorkbookHolder extends AbstractReadHolder {
this.defaultReturnMap = defaultReturnMap;
}
- public OPCPackage getOpcPackage() {
- return opcPackage;
+ public String getPassword() {
+ return password;
}
- public void setOpcPackage(OPCPackage opcPackage) {
- this.opcPackage = opcPackage;
+ public void setPassword(String password) {
+ this.password = password;
}
- public POIFSFileSystem getPoifsFileSystem() {
- return poifsFileSystem;
+ public Set getExtraReadSet() {
+ return extraReadSet;
}
- public void setPoifsFileSystem(POIFSFileSystem poifsFileSystem) {
- this.poifsFileSystem = poifsFileSystem;
+ public void setExtraReadSet(Set extraReadSet) {
+ this.extraReadSet = extraReadSet;
}
- public String getPassword() {
- return password;
+ public List getActualSheetDataList() {
+ return actualSheetDataList;
}
- public void setPassword(String password) {
- this.password = password;
+ public void setActualSheetDataList(List actualSheetDataList) {
+ this.actualSheetDataList = actualSheetDataList;
}
- public String getXlsxSAXParserFactoryName() {
- return xlsxSAXParserFactoryName;
+ public List getParametersheetDataList() {
+ return parametersheetDataList;
}
- public void setXlsxSAXParserFactoryName(String xlsxSAXParserFactoryName) {
- this.xlsxSAXParserFactoryName = xlsxSAXParserFactoryName;
+ public void setParametersheetDataList(List parametersheetDataList) {
+ this.parametersheetDataList = parametersheetDataList;
}
- public Set getExtraReadSet() {
- return extraReadSet;
+ public Boolean getReadAll() {
+ return readAll;
}
- public void setExtraReadSet(Set extraReadSet) {
- this.extraReadSet = extraReadSet;
+ public void setReadAll(Boolean readAll) {
+ this.readAll = readAll;
}
@Override
diff --git a/src/main/java/com/alibaba/excel/read/metadata/holder/xls/XlsReadSheetHolder.java b/src/main/java/com/alibaba/excel/read/metadata/holder/xls/XlsReadSheetHolder.java
new file mode 100644
index 00000000..a77a8d38
--- /dev/null
+++ b/src/main/java/com/alibaba/excel/read/metadata/holder/xls/XlsReadSheetHolder.java
@@ -0,0 +1,112 @@
+package com.alibaba.excel.read.metadata.holder.xls;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import com.alibaba.excel.enums.RowTypeEnum;
+import com.alibaba.excel.metadata.Cell;
+import com.alibaba.excel.metadata.CellData;
+import com.alibaba.excel.read.metadata.ReadSheet;
+import com.alibaba.excel.read.metadata.holder.ReadSheetHolder;
+import com.alibaba.excel.read.metadata.holder.ReadWorkbookHolder;
+
+/**
+ * sheet holder
+ *
+ * @author Jiaju Zhuang
+ */
+public class XlsReadSheetHolder extends ReadSheetHolder {
+ /**
+ * Row type.Temporary storage, last set in ReadRowHolder
.
+ */
+ private RowTypeEnum tempRowType;
+ /**
+ * Data storage of the current row.
+ */
+ private Map cellMap;
+ /**
+ * Index of the current row.
+ */
+ private Integer rowIndex;
+ /**
+ * Ignore record.
+ */
+ private Boolean ignoreRecord;
+ /**
+ * Temp Cell Data.
+ */
+ private CellData tempCellData;
+ /**
+ * Temp object index.
+ */
+ private Integer tempObjectIndex;
+ /**
+ * Temp object index.
+ */
+ private Map objectCacheMap;
+
+ public XlsReadSheetHolder(ReadSheet readSheet, ReadWorkbookHolder readWorkbookHolder) {
+ super(readSheet, readWorkbookHolder);
+ cellMap = new LinkedHashMap();
+ ignoreRecord = Boolean.FALSE;
+ tempRowType = RowTypeEnum.EMPTY;
+ objectCacheMap = new HashMap(16);
+ }
+
+ public RowTypeEnum getTempRowType() {
+ return tempRowType;
+ }
+
+ public void setTempRowType(RowTypeEnum tempRowType) {
+ this.tempRowType = tempRowType;
+ }
+
+ public Map getCellMap() {
+ return cellMap;
+ }
+
+ public void setCellMap(Map cellMap) {
+ this.cellMap = cellMap;
+ }
+
+ public Integer getRowIndex() {
+ return rowIndex;
+ }
+
+ public void setRowIndex(Integer rowIndex) {
+ this.rowIndex = rowIndex;
+ }
+
+ public Boolean getIgnoreRecord() {
+ return ignoreRecord;
+ }
+
+ public void setIgnoreRecord(Boolean ignoreRecord) {
+ this.ignoreRecord = ignoreRecord;
+ }
+
+ public CellData getTempCellData() {
+ return tempCellData;
+ }
+
+ public void setTempCellData(CellData tempCellData) {
+ this.tempCellData = tempCellData;
+ }
+
+ public Integer getTempObjectIndex() {
+ return tempObjectIndex;
+ }
+
+ public void setTempObjectIndex(Integer tempObjectIndex) {
+ this.tempObjectIndex = tempObjectIndex;
+ }
+
+ public Map getObjectCacheMap() {
+ return objectCacheMap;
+ }
+
+ public void setObjectCacheMap(Map objectCacheMap) {
+ this.objectCacheMap = objectCacheMap;
+ }
+}
diff --git a/src/main/java/com/alibaba/excel/read/metadata/holder/xls/XlsReadWorkbookHolder.java b/src/main/java/com/alibaba/excel/read/metadata/holder/xls/XlsReadWorkbookHolder.java
new file mode 100644
index 00000000..c4b698cb
--- /dev/null
+++ b/src/main/java/com/alibaba/excel/read/metadata/holder/xls/XlsReadWorkbookHolder.java
@@ -0,0 +1,95 @@
+package com.alibaba.excel.read.metadata.holder.xls;
+
+import java.util.List;
+
+import org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener;
+import org.apache.poi.hssf.record.BoundSheetRecord;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+
+import com.alibaba.excel.read.metadata.ReadWorkbook;
+import com.alibaba.excel.read.metadata.holder.ReadWorkbookHolder;
+
+/**
+ * Workbook holder
+ *
+ * @author Jiaju Zhuang
+ */
+public class XlsReadWorkbookHolder extends ReadWorkbookHolder {
+ /**
+ * File System
+ */
+ private POIFSFileSystem poifsFileSystem;
+ /**
+ * Format tracking HSSFListener
+ */
+ private FormatTrackingHSSFListener formatTrackingHSSFListener;
+ /**
+ * HSSFWorkbook
+ */
+ private HSSFWorkbook hsffWorkbook;
+ /**
+ * Bound sheet record list.
+ */
+ private List boundSheetRecordList;
+ /**
+ * Need read sheet.
+ */
+ private Boolean needReadSheet;
+ /**
+ * Sheet Index
+ */
+ private Integer readSheetIndex;
+
+ public XlsReadWorkbookHolder(ReadWorkbook readWorkbook) {
+ super(readWorkbook);
+ }
+
+ public POIFSFileSystem getPoifsFileSystem() {
+ return poifsFileSystem;
+ }
+
+ public void setPoifsFileSystem(POIFSFileSystem poifsFileSystem) {
+ this.poifsFileSystem = poifsFileSystem;
+ }
+
+ public FormatTrackingHSSFListener getFormatTrackingHSSFListener() {
+ return formatTrackingHSSFListener;
+ }
+
+ public void setFormatTrackingHSSFListener(FormatTrackingHSSFListener formatTrackingHSSFListener) {
+ this.formatTrackingHSSFListener = formatTrackingHSSFListener;
+ }
+
+ public HSSFWorkbook getHsffWorkbook() {
+ return hsffWorkbook;
+ }
+
+ public void setHsffWorkbook(HSSFWorkbook hsffWorkbook) {
+ this.hsffWorkbook = hsffWorkbook;
+ }
+
+ public List getBoundSheetRecordList() {
+ return boundSheetRecordList;
+ }
+
+ public void setBoundSheetRecordList(List boundSheetRecordList) {
+ this.boundSheetRecordList = boundSheetRecordList;
+ }
+
+ public Boolean getNeedReadSheet() {
+ return needReadSheet;
+ }
+
+ public void setNeedReadSheet(Boolean needReadSheet) {
+ this.needReadSheet = needReadSheet;
+ }
+
+ public Integer getReadSheetIndex() {
+ return readSheetIndex;
+ }
+
+ public void setReadSheetIndex(Integer readSheetIndex) {
+ this.readSheetIndex = readSheetIndex;
+ }
+}
diff --git a/src/main/java/com/alibaba/excel/read/metadata/holder/xlsx/XlsxReadSheetHolder.java b/src/main/java/com/alibaba/excel/read/metadata/holder/xlsx/XlsxReadSheetHolder.java
new file mode 100644
index 00000000..b7439c39
--- /dev/null
+++ b/src/main/java/com/alibaba/excel/read/metadata/holder/xlsx/XlsxReadSheetHolder.java
@@ -0,0 +1,16 @@
+package com.alibaba.excel.read.metadata.holder.xlsx;
+
+import com.alibaba.excel.read.metadata.ReadSheet;
+import com.alibaba.excel.read.metadata.holder.ReadSheetHolder;
+import com.alibaba.excel.read.metadata.holder.ReadWorkbookHolder;
+
+/**
+ * sheet holder
+ *
+ * @author Jiaju Zhuang
+ */
+public class XlsxReadSheetHolder extends ReadSheetHolder {
+ public XlsxReadSheetHolder(ReadSheet readSheet, ReadWorkbookHolder readWorkbookHolder) {
+ super(readSheet, readWorkbookHolder);
+ }
+}
diff --git a/src/main/java/com/alibaba/excel/read/metadata/holder/xlsx/XlsxReadWorkbookHolder.java b/src/main/java/com/alibaba/excel/read/metadata/holder/xlsx/XlsxReadWorkbookHolder.java
new file mode 100644
index 00000000..34ec6ad1
--- /dev/null
+++ b/src/main/java/com/alibaba/excel/read/metadata/holder/xlsx/XlsxReadWorkbookHolder.java
@@ -0,0 +1,52 @@
+package com.alibaba.excel.read.metadata.holder.xlsx;
+
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.poi.openxml4j.opc.OPCPackage;
+
+import com.alibaba.excel.read.metadata.ReadWorkbook;
+import com.alibaba.excel.read.metadata.holder.ReadWorkbookHolder;
+
+/**
+ * Workbook holder
+ *
+ * @author Jiaju Zhuang
+ */
+public class XlsxReadWorkbookHolder extends ReadWorkbookHolder {
+ /**
+ * Package
+ */
+ private OPCPackage opcPackage;
+ /**
+ * SAXParserFactory used when reading xlsx.
+ *
+ * The default will automatically find.
+ *
+ * Please pass in the name of a class ,like : "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"
+ *
+ * @see SAXParserFactory#newInstance()
+ * @see SAXParserFactory#newInstance(String, ClassLoader)
+ */
+ private String saxParserFactoryName;
+
+ public XlsxReadWorkbookHolder(ReadWorkbook readWorkbook) {
+ super(readWorkbook);
+ this.saxParserFactoryName = readWorkbook.getXlsxSAXParserFactoryName();
+ }
+
+ public OPCPackage getOpcPackage() {
+ return opcPackage;
+ }
+
+ public void setOpcPackage(OPCPackage opcPackage) {
+ this.opcPackage = opcPackage;
+ }
+
+ public String getSaxParserFactoryName() {
+ return saxParserFactoryName;
+ }
+
+ public void setSaxParserFactoryName(String saxParserFactoryName) {
+ this.saxParserFactoryName = saxParserFactoryName;
+ }
+}
diff --git a/src/main/java/com/alibaba/excel/util/SheetUtils.java b/src/main/java/com/alibaba/excel/util/SheetUtils.java
index 398fe5a4..492789c3 100644
--- a/src/main/java/com/alibaba/excel/util/SheetUtils.java
+++ b/src/main/java/com/alibaba/excel/util/SheetUtils.java
@@ -3,7 +3,7 @@ package com.alibaba.excel.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.alibaba.excel.context.XlsReadContext;
+import com.alibaba.excel.context.xls.XlsReadContext;
import com.alibaba.excel.read.metadata.ReadSheet;
/**