我正在使用Apache POI库来读取excell文件。
当我创建HSSFWorkbook()时,我得到以下异常:
org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance
Caused by: java.lang.OutOfMemoryError: Java heap space
at org.apache.poi.util.StringUtil.readCompressedUnicode(StringUtil.java:124)
at org.apache.poi.util.StringUtil.readUnicodeString(StringUtil.java:142)
at org.apache.poi.ss.formula.constant.ConstantValueParser.readAConstantValue(ConstantValueParse r.java:66)
at org.apache.poi.ss.formula.constant.ConstantValueParser.parse(ConstantValueParser.java:52)
at org.apache.poi.hssf.record.CRNRecord.<init>(CRNRecord.java:52)
at sun.reflect.GeneratedConstructorAccessor11.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl. java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.apache.poi.hssf.record.RecordFactory$ReflectionConstructorRecordCreator.create(RecordFac tory.java:57)
at org.apache.poi.hssf.record.RecordFactory.createSingleRecord(RecordFactory.java:301)
at org.apache.poi.hssf.record.RecordFactoryInputStream.readNextRecord(RecordFactoryInputStream. java:285)
at org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java :251)
at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:443)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:280)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:243)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:187)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:322)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:303)
at mypackage.common.utils.ExcelFileUtils.getLine(ExcelFileUtils.java:87)
所以这里有一些代码:
filePath = config.getRepertoireExcel() + fichierExcell;
file = new FileInputStream(new File(filePath));
System.out.println("create workbook ");
workbook = new HSSFWorkbook(file); // fail HERE
System.out.println("create HSSFFormulaEvaluator ");
if(workbook == null){
return dossList;
}
formEval = new HSSFFormulaEvaluator(workbook);
System.out.println("get Sheet 0 ");
sheet = workbook.getSheetAt(0);
你对这个问题有所了解吗?
非常感谢
Edit1:添加完整的堆栈跟踪。
Edit2:现在看来有一个内存不足的问题!!!
编辑3:添加我的一些代码