Here's a scala example: https://gist.github.com/mrvisser/e0cba158eee939a105844e084f7ba6b8
This is just a port of the Jython example. Hopefully I'll have more create use cases soon ;) Cheers, Branden On Thu, Jul 14, 2016 at 8:30 PM, Branden Visser <mrvis...@gmail.com> wrote: > Sure, I'll write up a gist for you. > > On Thu, Jul 14, 2016 at 7:36 PM, Javen O'Neal <one...@apache.org> wrote: >> Any chance you'd be willing to type up a Scala example to add to >> https://poi.apache.org/poi-jvm-languages.html >> >> On Thu, Jul 14, 2016 at 5:04 PM, Branden Visser <mrvis...@gmail.com> wrote: >>> *facepalm* >>> >>> Adding the main "poi" dependency seems to fix it. This problem smelled >>> much different than a dependency issue so I didn't try it... >>> >>> Hopefully this helps someone else. >>> >>> Thanks, >>> Branden >>> >>> On Thu, Jul 14, 2016 at 5:01 PM, Branden Visser <mrvis...@gmail.com> wrote: >>>> Hello, >>>> >>>> First message, so this is bound to be extremely dumb mistake, it >>>> certainly feels that. >>>> >>>> (Note SBT and Scala syntax follows) >>>> >>>> I've imported "org.apache.poi" % "poi-ooxml" % "3.15-beta2" (only that >>>> dependency). >>>> >>>> I have the following code to test: >>>> >>>> import org.apache.poi.xwpf.usermodel.XWPFDocument >>>> >>>> object XWPFTest { >>>> def main(args: Array[String]) = { >>>> val is = getClass.getResourceAsStream("Word2007.docx") >>>> val doc = new XWPFDocument(is) >>>> println(doc) >>>> } >>>> } >>>> >>>> I run it and I get this exception: >>>> >>>> [error] Exception in thread "main" java.lang.NoSuchFieldError: >>>> RAW_XML_FILE_HEADER >>>> [error] at >>>> org.apache.poi.openxml4j.opc.internal.ZipHelper.verifyZipHeader(ZipHelper.java:179) >>>> [error] at >>>> org.apache.poi.openxml4j.opc.internal.ZipHelper.openZipStream(ZipHelper.java:228) >>>> [error] at >>>> org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:92) >>>> [error] at >>>> org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:292) >>>> [error] at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37) >>>> [error] at >>>> org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:128) >>>> [error] at XWPFTest$.main(XWPFTest.scala:6) >>>> [error] at XWPFTest.main(XWPFTest.scala) >>>> >>>> If I run it with HWPF instead, I get this: >>>> >>>> [error] Exception in thread "main" >>>> org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied >>>> data appears to be in the Office 2007+ XML. You are calling the part >>>> of POI that deals with OLE2 Office Documents. You need to call a >>>> different part of POI to process this data (eg XSSF instead of HSSF) >>>> [error] at >>>> org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:128) >>>> [error] at >>>> org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:112) >>>> [error] at >>>> org.apache.poi.poifs.filesystem.NPOIFSFileSystem.<init>(NPOIFSFileSystem.java:300) >>>> [error] at >>>> org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:86) >>>> [error] at >>>> org.apache.poi.hwpf.HWPFDocumentCore.verifyAndBuildPOIFS(HWPFDocumentCore.java:108) >>>> [error] at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:174) >>>> [error] at XWPFTest$.main(XWPFTest.scala:7) >>>> [error] at XWPFTest.main(XWPFTest.scala) >>>> >>>> Which is fair enough. When I open that file up in Microsoft Word it >>>> seems fine. I've attached the file here in case it's relevant, but >>>> this feels more like a coding issue. >>>> >>>> Any advice is greatly appreciated. >>>> >>>> Cheers, >>>> Branden >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscr...@poi.apache.org >>> For additional commands, e-mail: user-h...@poi.apache.org >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@poi.apache.org >> For additional commands, e-mail: user-h...@poi.apache.org >> --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@poi.apache.org For additional commands, e-mail: user-h...@poi.apache.org