com.y3tu.tool.poi.excel.sax.Excel03SaxReader Maven / Gradle / Ivy
package com.y3tu.tool.poi.excel.sax;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import com.y3tu.tool.core.text.StringUtils;
import com.y3tu.tool.poi.excel.sax.handler.RowHandler;
import com.y3tu.tool.poi.exceptions.POIException;
import org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener;
import org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener;
import org.apache.poi.hssf.eventusermodel.HSSFEventFactory;
import org.apache.poi.hssf.eventusermodel.HSSFListener;
import org.apache.poi.hssf.eventusermodel.HSSFRequest;
import org.apache.poi.hssf.eventusermodel.MissingRecordAwareHSSFListener;
import org.apache.poi.hssf.eventusermodel.dummyrecord.LastCellOfRowDummyRecord;
import org.apache.poi.hssf.eventusermodel.dummyrecord.MissingCellDummyRecord;
import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.record.BOFRecord;
import org.apache.poi.hssf.record.BlankRecord;
import org.apache.poi.hssf.record.BoolErrRecord;
import org.apache.poi.hssf.record.BoundSheetRecord;
import org.apache.poi.hssf.record.FormulaRecord;
import org.apache.poi.hssf.record.LabelRecord;
import org.apache.poi.hssf.record.LabelSSTRecord;
import org.apache.poi.hssf.record.NumberRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.SSTRecord;
import org.apache.poi.hssf.record.StringRecord;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
/**
* Excel2003格式的事件-用户模型方式读取器,在Hutool中,统一将此归类为Sax读取
* 参考:http://www.cnblogs.com/wshsdlau/p/5643862.html
*
* @author looly
*/
public class Excel03SaxReader extends AbstractExcelSaxReader implements HSSFListener {
/**
* 如果为公式,true表示输出公式计算后的结果值,false表示输出公式本身
*/
private boolean isOutputFormulaValues = true;
/**
* 用于解析公式
*/
private SheetRecordCollectingListener workbookBuildingListener;
/**
* 子工作簿,用于公式计算
*/
private HSSFWorkbook stubWorkbook;
/**
* 静态字符串表
*/
private SSTRecord sstRecord;
private FormatTrackingHSSFListener formatListener;
/**
* Sheet边界记录,此Record中可以获得Sheet名
*/
private List boundSheetRecords = new ArrayList<>();
private boolean isOutputNextStringRecord;
// 存储行记录的容器
private List