创建WorkBook

时间:2015-09-25 12:38:28

标签: java apache-poi

我在创建Workbook时遇到问题。我有以下用于阅读工作簿的代码:

wb = WorkbookFactory.create(file);
Sheet sheet = wb.getSheetAt(0);

这很简单。 但是在运行时,我得到了运行时异常:

  

线程中的异常"线程-7"   org.apache.poi.hssf.record.RecordFormatException:无法构造   记录实例   org.apache.poi.hssf.record.RecordFactory $ ReflectionConstructorRecordCreator.create(RecordFactory.java:101)     在   org.apache.poi.hssf.record.RecordFactory.createSingleRecord(RecordFactory.java:338)     在   org.apache.poi.hssf.record.RecordFactoryInputStream.readNextRecord(RecordFactoryInputStream.java:310)     在   org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:276)     在   org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:480)     在   org.apache.poi.hssf.usermodel.HSSFWorkbook。(HSSFWorkbook.java:325)     在   org.apache.poi.hssf.usermodel.HSSFWorkbook。(HSSFWorkbook.java:288)     在   org.apache.poi.hssf.usermodel.HSSFWorkbook。(HSSFWorkbook.java:223)     在   org.apache.poi.hssf.usermodel.HSSFWorkbook。(HSSFWorkbook.java:381)     在   org.apache.poi.hssf.usermodel.HSSFWorkbook。(HSSFWorkbook.java:363)

     

引起:java.lang.RuntimeException:超出数据读取范围   CellRangeAddress在   org.apache.poi.ss.util.CellRangeAddress.readUShortAndCheck(CellRangeAddress.java:78)     在   org.apache.poi.ss.util.CellRangeAddress。(CellRangeAddress.java:72)     在org.apache.poi.hssf.record.FeatRecord。(FeatRecord.java:82)     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native   方法)at   sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)     在   sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)     在   org.apache.poi.hssf.record.RecordFactory $ ReflectionConstructorRecordCreator.create(RecordFactory.java:87)     ......还有12个

我可能在目标xls文件中有错误,但我不确定,因为excel打开它没有任何问题。有谁知道什么是异常的原因?

提前致谢

0 个答案:

没有答案