java - Error loading Excel file with images in POI -
writing android app uses excel files , ran bump in road. loads files without pictures fine, moment try load excel file has pictures embedded in it, errror:
01-16 14:50:37.927 28377-28377/com.dcheeseman.csvflashcards w/system.err: org.apache.poi.poixmlexception: java.lang.reflect.invocationtargetexception 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ org.apache.poi.xssf.usermodel.xssffactory.createdocumentpart(xssffactory.java:62) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ org.apache.poi.poixmldocumentpart.read(poixmldocumentpart.java:426) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ org.apache.poi.poixmldocumentpart.read(poixmldocumentpart.java:431) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ org.apache.poi.poixmldocument.load(poixmldocument.java:155) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ org.apache.poi.xssf.usermodel.xssfworkbook.<init>(xssfworkbook.java:221) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ com.dcheeseman.csvflashcards.spreadsheetreader.getpicturesxlsx(spreadsheetreader.java:119) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ com.dcheeseman.csvflashcards.flashcardactivity.onactivityresult(flashcardactivity.java:215) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ android.app.activity.dispatchactivityresult(activity.java:6549) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ android.app.activitythread.deliverresults(activitythread.java:4084) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ android.app.activitythread.handlesendresult(activitythread.java:4131) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ android.app.activitythread.access$1400(activitythread.java:179) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ android.app.activitythread$h.handlemessage(activitythread.java:1511) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ android.os.handler.dispatchmessage(handler.java:102) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ android.os.looper.loop(looper.java:145) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ android.app.activitythread.main(activitythread.java:5972) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ java.lang.reflect.method.invoke(native method) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ java.lang.reflect.method.invoke(method.java:372) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1399) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1194) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: caused by: java.lang.reflect.invocationtargetexception 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ java.lang.reflect.constructor.newinstance(native method) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ java.lang.reflect.constructor.newinstance(constructor.java:288) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ org.apache.poi.xssf.usermodel.xssffactory.createdocumentpart(xssffactory.java:60) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: ... 18 more 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: caused by: java.lang.classcastexception: org.apache.xmlbeans.impl.values.xmlcomplexcontentimpl cannot cast org.openxmlformats.schemas.drawingml.x2006.spreadsheetdrawing.ctdrawing 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ org.openxmlformats.schemas.drawingml.x2006.spreadsheetdrawing.ctdrawing$factory.parse(unknown source) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: @ org.apache.poi.xssf.usermodel.xssfdrawing.<init>(xssfdrawing.java:84) 01-16 14:50:37.947 28377-28377/com.dcheeseman.csvflashcards w/system.err: ... 21 more
my concern class cast exception @ end. it's pain getting poi compile in android environment , had use version 3.9 of poi. i'm wondering if bug hasn't been fixed yet.
here's short code segment related it:
string fpath = data.getdatastring(); inputstream is2 = getcontentresolver().openinputstream(uri.parse(fpath)); list<xssfpicturedata> lst = spreadsheetreader.getpicturesxlsx(is2); public static list<xssfpicturedata> getpicturesxlsx(inputstream is) { list<xssfpicturedata> lst = null; xssfworkbook wb = null; try { wb = new xssfworkbook(is); lst = wb.getallpictures(); } catch (ioexception e) { e.printstacktrace(); } return lst; }
there error trips on 'wb = new xssfworkbook(is);' line, has worked fine excel files have no images. of note, @ point in code, no other application or code segment accessing file. in advance help.
Comments
Post a Comment