Apache POI:为什么同一个excel文件的副本有异常?

时间:2016-07-07 10:29:22

标签: java excel apache-poi

您好我正在处理xyz.xlsx个文件,我想阅读这些文件。我有一张原始工作表'xyz.xlsx',我的应用程序可以在其上获取数据,但是当我使用google工作表创建上述excel的副本'xyzcopy.xlsx'应用程序抛出

org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException

我无法弄清楚问题。

07-08 14:01:52.372 8005-7378/com.myapp W/System.err: org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:426)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:431)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:221)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at com.myapp.activities_dealer.UploadExcelCustomerActivity$MyExcelTask.run(UploadExcelCustomerActivity.java:350)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at java.lang.Thread.run(Thread.java:841)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err: Caused by: java.lang.reflect.InvocationTargetException
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at java.lang.reflect.Constructor.constructNative(Native Method)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:60)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:    ... 6 more
07-08 14:01:52.372 8005-7378/com.myapp W/System.err: Caused by: java.lang.ClassCastException: org.apache.xmlbeans.impl.values.XmlComplexContentImpl cannot be cast to org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTDrawing$Factory.parse(Unknown Source)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:     at org.apache.poi.xssf.usermodel.XSSFDrawing.<init>(XSSFDrawing.java:84)
07-08 14:01:52.372 8005-7378/com.myapp W/System.err:    ... 9 more

通过两种方式,我使用google sheet创建了给定文件的副本,

1] clicking File->Make a copy,
2] Ctrl + a & then Ctrl + v in a new sheet,

使用以下方法下载生成的文件:

File->Download as..-> Microsoft Excel .xlsx

上述两种方法创建的文件会引发异常。与此同时,最初的一个没有任何问题继续工作。

0 个答案:

没有答案