org.apache.poi.POIXMLException:java.lang.reflect.InvocationTargetException在android 4中获取错误

时间:2016-10-05 11:48:19

标签: android apache-poi

我在Android版本4中遇到错误

 E/ExcelSheet: null
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
  at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
  at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:456)
  at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:162)
  at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:271)
  at com.example.vinove.excelsheetapp.Poi.ExcelSheet.readExcelSheet(ExcelSheet.java:63)
  at com.example.vinove.excelsheetapp.Activities.MainActivity$MyTask.doInBackground(MainActivity.java:137)
  at com.example.vinove.excelsheetapp.Activities.MainActivity$MyTask.doInBackground(MainActivity.java:107)
  at android.os.AsyncTask$2.call(AsyncTask.java:288)
  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
  at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.reflect.InvocationTargetException
  at java.lang.reflect.Constructor.constructNative(Native Method)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:60)
  at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:456) 
  at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:162) 
  at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:271) 
  at com.example.vinove.excelsheetapp.Poi.ExcelSheet.readExcelSheet(ExcelSheet.java:63) 
  at com.example.vinove.excelsheetapp.Activities.MainActivity$MyTask.doInBackground(MainActivity.java:137) 
  at com.example.vinove.excelsheetapp.Activities.MainActivity$MyTask.doInBackground(MainActivity.java:107) 
  at android.os.AsyncTask$2.call(AsyncTask.java:288) 
  at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
  at java.lang.Thread.run(Thread.java:841) 
Caused by: java.lang.NoClassDefFoundError: org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory
  at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:46)
  at java.lang.reflect.Constructor.constructNative(Native Method)

1 个答案:

答案 0 :(得分:2)

Apache POI在Android上无法正常使用,您将遇到各种问题。

有些项目可以在Android上使用部分Apache POI:

  1. https://github.com/andruhon/android5xlsx(适用于Android 5)和https://github.com/andruhon/AndroidReadXLSX(适用于Android 4)基于Apache POI 3.12
  2. https://github.com/centic9/poi-on-android/(适用于Android 5,由我维护),可与任何版本的POI一起使用,例如: 3.15目前