Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Issue with pictures and drawings #7

Open
theo744 opened this issue Apr 10, 2017 · 2 comments
Open

Issue with pictures and drawings #7

theo744 opened this issue Apr 10, 2017 · 2 comments

Comments

@theo744
Copy link

theo744 commented Apr 10, 2017

Hi,

I'm using your library on a Android 4.0.3 device and I have to read a template file and rewrite it with some data in it (text) on the external storage of the device.

The read / modify / write of a normal xlsx file works fine, but I need to have some macros, pictures and drawings (buttons) in my template file (it's now a xlsm file). And then, it' getting worst... Macros are well transcripted, but I'm getting errors with pictures and drawings.

Here's the Exception with a button in the file:

org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
04-10 23:57:00.958 23998-23998/com.vetropack W/System.err: at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
04-10 23:57:00.958 23998-23998/com.vetropack W/System.err: at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:426)
04-10 23:57:00.958 23998-23998/com.vetropack W/System.err: at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:431)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:155)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:221)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at com.vetropack.SessionDAO.ajoutFichier(SessionDAO.java:51)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at com.vetropack.ViewControle.creationFichier(ViewControle.java:232)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at com.vetropack.ViewControle$3$1.onClick(ViewControle.java:164)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at android.os.Looper.loop(Looper.java:137)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at android.app.ActivityThread.main(ActivityThread.java:4424)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at java.lang.reflect.Method.invokeNative(Native Method)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at java.lang.reflect.Method.invoke(Method.java:511)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-10 23:57:00.966 23998-23998/com.vetropack W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-10 23:57:00.974 23998-23998/com.vetropack W/System.err: at dalvik.system.NativeStart.main(Native Method)
04-10 23:57:00.974 23998-23998/com.vetropack W/System.err: Caused by: java.lang.reflect.InvocationTargetException
04-10 23:57:00.974 23998-23998/com.vetropack W/System.err: at java.lang.reflect.Constructor.constructNative(Native Method)
04-10 23:57:00.974 23998-23998/com.vetropack W/System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-10 23:57:00.974 23998-23998/com.vetropack W/System.err: at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:60)
04-10 23:57:00.974 23998-23998/com.vetropack W/System.err: ... 16 more
04-10 23:57:00.974 23998-23998/com.vetropack W/System.err: Caused by: java.lang.NoClassDefFoundError: schemasMicrosoftComOfficeOffice.CTShapeLayout$Factory
04-10 23:57:00.974 23998-23998/com.vetropack W/System.err: at org.apache.poi.xssf.usermodel.XSSFVMLDrawing.read(XSSFVMLDrawing.java:117)
04-10 23:57:00.974 23998-23998/com.vetropack W/System.err: at org.apache.poi.xssf.usermodel.XSSFVMLDrawing.(XSSFVMLDrawing.java:102)
04-10 23:57:00.981 23998-23998/com.vetropack W/System.err: ... 19 more

I checked, the CTShapeLayout$Factory seems to be in the ooxml jar like it should. Do you have any idea how to get it work ?

See attached the java file who creates the file (it's based on your example file), my gradle.build and the template.xlsm I need to copy. (I had to change rename files to .txt to upload them, just rename them back to have the original files).

Thanks in advance for your feedback.

build.gradle.txt
SessionDAO.java.txt
template.xlsm.txt

@andruhon
Copy link
Owner

Hi! Most of extra functionality was chopped off the original POI in order to fit it into 65K methods limit. Shapes and pictures were a part of these. You certainly cannot have full functionality on Android 4 with this approach. However you can try manually adding missing classes into a jar, if you only need shapes.

@theo744
Copy link
Author

theo744 commented Apr 11, 2017

Hi,
Thanks for your feedback. The CTShapeLayoutFactory seems to be in the jar, the NoClassDefFoundError is not a missing class error but an issue beetween compile and runtime, right ?

Do you know a way to make it work more completely with Android 4 ? Why not using full POI 3.10 with multi dex to avoid 65k limit ? Or maybe you know an other library to read XLSX with Android 4 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants