From: Casey J. <cas...@jo...> - 2013-07-28 19:00:15
|
Hi All, I am hoping someone can shed some light on why I might be getting the following error when trying to use Apache POI on an InputStream obtained from BinaryValue.getInputStream(): Caused by: java.lang.IllegalArgumentException: Cannot create workbook from stream at com.jorsek.conversion.excel.ExcelToDITA.create(ExcelToDITA.java:115) at org.jorsek.modules.convert.ConvertFunction.convert(ConvertFunction.java:94) at org.jorsek.modules.convert.ConvertFunction.eval(ConvertFunction.java:83) at org.exist.xquery.BasicFunction.eval(BasicFunction.java:70) at org.jorsek.cm.JCMBasicFunction.eval(JCMBasicFunction.java:98) at org.exist.xquery.InternalFunctionCall.eval(InternalFunctionCall.java:55) at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71) at org.exist.xquery.PathExpr.eval(PathExpr.java:264) at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71) at org.exist.xquery.XQuery.execute(XQuery.java:257) at org.exist.xquery.XQuery.execute(XQuery.java:204) at org.jorsek.cm.API2.RESTServer.search(RESTServer.java:1286) at org.jorsek.cm.API2.RESTServer.doGet(RESTServer.java:365) at org.jorsek.cm.API2.JCMAPIServlet.doGet(JCMAPIServlet.java:269) ... 41 more Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13] at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:178) at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:662) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:269) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:73) at com.jorsek.conversion.excel.ExcelToDITA.create(ExcelToDITA.java:112) I can convert this file fine when I do it from the filesystem using regular FileInputStream etc. I modeled my code after the content extraction library: public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { String proccessorClass = (String)args[0].itemAt(0).getStringValue(); /* binary content */ BinaryValue binary = (BinaryValue) args[1].itemAt(0); System.out.println(proccessorClass); try { convert(binary); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new EmptySequence(); } public void convert(BinaryValue binaryValue) throws IOException{ InputStream is = binaryValue.getInputStream(); ExcelToDITA excelToDITA = ExcelToDITA.create(is,System.out); excelToDITA.setCompleteDITA(true); excelToDITA.printPage(); } Is there something I need to do to pre-process the data before sending it to something like POI/Tika? Thanks! -- -- Casey Jordan easyDITA a product of Jorsek LLC "CaseyDJordan" on LinkedIn, Twitter & Facebook (585) 348 7399 easydita.com This message is intended only for the use of the Addressee(s) and may contain information that is privileged, confidential, and/or exempt from disclosure under applicable law. If you are not the intended recipient, please be advised that any disclosure copying, distribution, or use of the information contained herein is prohibited. If you have received this communication in error, please destroy all copies of the message, whether in electronic or hard copy format, as well as attachments, and immediately contact the sender by replying to this e-mail or by phone. Thank you. |