資源簡介
使用Poi讀取大數據量excel的方法
支持2003和2007的版本

代碼片段和文件信息
package?com.harlan.poi.excelutil;
import?java.io.FileInputStream;
import?java.io.IOException;
import?java.io.InputStream;
import?java.util.ArrayList;
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.NoteRecord;
import?org.apache.poi.hssf.record.NumberRecord;
import?org.apache.poi.hssf.record.RKRecord;
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;
/**
?*?Excel-2003行級處理器,ExcelRowProcessor的實現類
?*?@author?zhangchaofeng
?*?@version?1.0
?*?@date?Sep?28?2011
?*/
public?abstract?class?Excel2003RowProcessor?implements?ExcelRowProcessor{
private?MyHSSFListener?hssfListener;
private?String?fileName;
private?InputStream?is;
private?POIFSFileSystem?fs;
private?int?lastRowNumber;
private?int?lastColumnNumber;
/**?Should?we?output?the?formula?or?the?value?it?has??*/
private?boolean?outputFormulaValues?=?true;
/**?For?parsing?Formulas?*/
private?SheetRecordCollectingListener?workbookBuildingListener;
private?HSSFWorkbook?stubWorkbook;
//?Records?we?pick?up?as?we?process
private?SSTRecord?sstRecord;
private?FormatTrackingHSSFListener?formatListener;
/**?So?we?known?which?sheet?we‘re?on?*/
private?int?sheetIndex?=?-1;
private?int?optSheetIndex=-1;
private?BoundSheetRecord[]?orderedBSRs;
private?ArrayList?boundSheetRecords?=?new?ArrayList();
//?For?handling?formulas?with?string?results
private?int?nextRow;
private?int?nextColumn;
private?boolean?outputNextStringRecord;
private?XRow?row=new?XRow();
/**
?*?構造Excel-2003行級解析器
?*?@param?filename?excel完整文件名
?*?@throws?IOException
?*/
public?Excel2003RowProcessor(String?filename)?throws?Exception{
if(filename.endsWith(“.xlsx“)){
throw?new?Exception(“Excel板式與解析器不匹配,解析器僅支持Excel-2003及以下版本。“);
}
this.fileName=filename;
this.hssfListener=new?MyHSS
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-02-09?10:52??HarlanPoi\
?????文件?????????662??2015-01-28?17:01??HarlanPoi\.classpath
?????文件?????????385??2015-02-09?10:52??HarlanPoi\.project
?????目錄???????????0??2015-02-09?10:52??HarlanPoi\.settings\
?????文件?????????598??2015-01-28?16:23??HarlanPoi\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2015-02-09?10:52??HarlanPoi\bin\
?????目錄???????????0??2015-02-09?10:52??HarlanPoi\bin\com\
?????目錄???????????0??2015-02-09?10:52??HarlanPoi\bin\com\harlan\
?????目錄???????????0??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\
?????目錄???????????0??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\
?????文件????????8087??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\Excel2003RowProcessor$MyHSSFListener.class
?????文件????????7165??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\Excel2003RowProcessor.class
?????文件????????4767??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\Excel2007RowProcessor$MyHander.class
?????文件????????4576??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\Excel2007RowProcessor.class
?????文件????????1060??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\ExcelProcessor$MyExcel2003RowProcessor.class
?????文件????????1060??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\ExcelProcessor$MyExcel2007RowProcessor.class
?????文件????????1981??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\ExcelProcessor.class
?????文件?????????350??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\ExcelRowProcessor.class
?????文件????????1723??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\ReadExcelUtil.class
?????文件????????1366??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\StringUtil.class
?????文件?????????957??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\XCell.class
?????文件????????1242??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\excelutil\XRow.class
?????目錄???????????0??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\util\
?????目錄???????????0??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\util\xls\
?????文件????????8304??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\util\xls\HxlsAbstract.class
?????文件????????5243??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\util\xls\XxlsAbstract.class
?????目錄???????????0??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\xls\
?????文件????????4248??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\xls\HxlsBig.class
?????文件????????1763??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\xls\HxlsPrint.class
?????文件????????2068??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\xls\Xls2Do.class
?????文件????????3717??2015-02-09?10:52??HarlanPoi\bin\com\harlan\poi\xls\XxlsBig.class
............此處省略30個文件信息
- 上一篇:服務器主板說明書
- 下一篇:《電力系統分析》何仰贊課后習題及答案
評論
共有 條評論