Apache POI无法创建excel XSSFWorkbook

时间:2015-06-04 09:49:27

标签: java apache-poi

我无法创建XSSFWorkbook的实例。我的代码失败了:

XSSFWorkbook workbook = new XSSFWorkbook();

这里有例外追踪:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.getMethod(SchemaTypeLoaderBase.java:73)
    at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.<clinit>(SchemaTypeLoaderBase.java:66)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.xmlbeans.XmlBeans.getNoType(XmlBeans.java:856)
    at org.apache.xmlbeans.XmlBeans.<clinit>(XmlBeans.java:881)
    at org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook$Factory.newInstance(Unknown Source)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.onWorkbookCreate(XSSFWorkbook.java:407)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:219)
    at excel.readExcelFile(excel.java:24)
    at client.readInputFile(client.java:66)
    at client.main(client.java:55)
Caused by: java.lang.NullPointerException
    at org.apache.xmlbeans.impl.store.Path.<clinit>(Path.java:70)
    ... 16 more

这里我添加到项目中的罐子:

  • POI-3.12-20150511
  • POI-OOXML-3.12-20150511
  • POI-OOXML-架构 - 3.12-20150511
  • 的xmlbeans-2.6.0
  • 公地编解码器-1.9
  • 共享记录-1.1.3
  • 的log4j-1.2.17

在阅读了一些信息后,我也尝试添加:

  • DOM4J-1.6.1.jar
  • POI-excelant-3.12-20150511.jar
  • STAX-API-1.0.1.jar

没有效果。可能是什么原因?

更新 问题是我在用户lib中添加了jar并将其添加到项目构建路径中。但是一旦我将它们直接添加到构建传递中 - 错误消失

0 个答案:

没有答案