excel - org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException in POI API after an .xls file is updated with Libre Office -


i reading excel using poi api, use following code read excel file.

    public class excelworkbook {          private static excelworkbook excelworkbook = null;         private static string filepath;         private static xssfworkbook workbook;          /**          *  constructor used initialize {@link excelworkbook}          * @throws ioexception          */         private excelworkbook() throws ioexception {             try {                 workbook = new xssfworkbook(getfile());             } catch (filenotfoundexception ex) {                 logger.getlogger(excelworkbook.class.getname()).log(level.severe, null, ex);             }         }          /**          * method create new object {@link excelworkbook}          * @return {@link excelworkbook}          * @throws ioexception          */         public static excelworkbook getinstance() throws ioexception {             excelworkbook = new excelworkbook();             return excelworkbook;         }          /**          * method create {@link fileinputstream}          * @return {@link fileinputstream}          * @throws filenotfoundexception          */         private fileinputstream getfile() throws filenotfoundexception {           fileinputstream file = new fileinputstream(new file(filepath));           return file;         }         .         .         .         . 

but throwing following exception in particular file created using ms office 2010 , undated using libre office. problem. stack trace of exception attached below

 org.apache.poi.poixmlexception: java.lang.reflect.invocationtargetexception     @ org.apache.poi.xssf.usermodel.xssffactory.createdocumentpart(xssffactory.java:61) ~[poi-ooxml-3.7.jar:3.7]     @ org.apache.poi.poixmldocumentpart.read(poixmldocumentpart.java:277) ~[poi-ooxml-3.7.jar:3.7]     @ org.apache.poi.poixmldocumentpart.read(poixmldocumentpart.java:282) ~[poi-ooxml-3.7.jar:3.7]     @ org.apache.poi.poixmldocument.load(poixmldocument.java:186) ~[poi-ooxml-3.7.jar:3.7]     @ org.apache.poi.xssf.usermodel.xssfworkbook.<init>(xssfworkbook.java:189) ~[poi-ooxml-3.7.jar:3.7]     @ com.excel.excelworkbook.<init>(excelworkbook.java:48)      @ com.excel.excelworkbook.getinstance(excelworkbook.java:60)      @ com.excel.excelparser.<init>(excelparser.java:64)      @ com.database.databaseloader.process(databaseloader.java:85)      @ com.fileuploader.fileuploadhandler.dopost(fileuploadhandler.java:116)  . . . .     @ java.lang.thread.run(thread.java:662) [na:1.6.0_45] [stdout] caused by: java.lang.reflect.invocationtargetexception: null [stdout]    @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) ~[na:1.6.0_45] [stdout]    @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:39) ~[na:1.6.0_45] [stdout]    @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:27) ~[na:1.6.0_45] [stdout]    @ java.lang.reflect.constructor.newinstance(constructor.java:513) ~[na:1.6.0_45] [stdout]    @ org.apache.poi.xssf.usermodel.xssffactory.createdocumentpart(xssffactory.java:59) ~[poi-ooxml-3.7.jar:3.7] [stdout]    ... 42 common frames omitted [stdout] caused by: org.apache.xmlbeans.xmlexception: error: duplicate attribute 'type' [stdout]    @ org.apache.xmlbeans.impl.store.locale$saxloader.load(locale.java:3471) ~[xmlbeans-2.3.0.jar:na] [stdout]    @ org.apache.xmlbeans.impl.store.locale.parsetoxmlobject(locale.java:1270) ~[xmlbeans-2.3.0.jar:na] [stdout]    @ org.apache.xmlbeans.impl.store.locale.parsetoxmlobject(locale.java:1257) ~[xmlbeans-2.3.0.jar:na] [stdout]    @ org.apache.xmlbeans.impl.schema.schematypeloaderbase.parse(schematypeloaderbase.java:345) ~[xmlbeans-2.3.0.jar:na] [stdout]    @ org.apache.xmlbeans.xmlobject$factory.parse(xmlobject.java:663) ~[xmlbeans-2.3.0.jar:2.3.0-r540734] [stdout]    @ org.apache.poi.xssf.usermodel.xssfvmldrawing.read(xssfvmldrawing.java:107) ~[poi-ooxml-3.7.jar:3.7] [stdout]    @ org.apache.poi.xssf.usermodel.xssfvmldrawing.<init>(xssfvmldrawing.java:102) ~[poi-ooxml-3.7.jar:3.7] [stdout]    ... 47 common frames omitted [stdout] caused by: org.xml.sax.saxparseexception: duplicate attribute 'type' [stdout]    @ org.apache.xmlbeans.impl.piccolo.xml.piccolo.reportfatalerror(piccolo.java:1038) ~[xmlbeans-2.3.0.jar:na] [stdout]    @ org.apache.xmlbeans.impl.piccolo.xml.piccolo.parse(piccolo.java:723) ~[xmlbeans-2.3.0.jar:na] [stdout]    @ org.apache.xmlbeans.impl.store.locale$saxloader.load(locale.java:3439) ~[xmlbeans-2.3.0.jar:na] [stdout]    ... 53 common frames omitted 

i had same exception after edited libe office .xlsx file containing comments. removal of comments solved issue.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -