java POI中的空指针异常

时间:2013-11-27 09:06:40

标签: java apache-poi

这是代码

FileInputStream fileInputStream = new FileInputStream(new File("D:\\xyz.xls"));
 HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);
HSSFSheet worksheet = workbook.getSheetAt(0);

并且在执行时我得到以下异常

java.lang.NullPointerException
        at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.construct(ValueRecordsAggregate.java:173)
        at org.apache.poi.hssf.model.Sheet.createSheet(Sheet.java:206)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:216)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:153)
        at com.tcs.sgv.SLB.util.ExportSLBExcel.exportTargetCondForm(ExportSLBExcel.java:18448)
        at com.tcs.sgv.SLB.DAO.SLBIndicatorDAOImpl.getTargetModelData(SLBIndicatorDAOImpl.java:604)
        at com.tcs.sgv.SLB.handler.SLBIndicatorRequestHandler.processAction(SLBIndicatorRequestHandler.java:282)

Excel文件是97-2003格式,请帮忙解决.Thnx提前。

0 个答案:

没有答案