Guest User

Load POI 3.8 jars with JavaLoader

a guest
Sep 9th, 2012
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <!--- omit the DOM4J jar --->
  2. <cfset paths = []>
  3. <cfset arrayAppend(paths, "c:/path/to/poi38/poi-3.8-20120326.jar")>
  4. <cfset arrayAppend(paths, "c:/path/to/poi38/poi-ooxml-3.8-20120326.jar")>
  5. <cfset arrayAppend(paths, "c:/path/to/poi38/poi-ooxml-schemas-3.8-20120326.jar")>
  6. <cfset arrayAppend(paths, "c:/path/to/poi38/poi-scratchpad-3.8-20120326.jar")>
  7. <cfset arrayAppend(paths, "c:/path/to/poi38/ooxml-lib/stax-api-1.0.1.jar")>
  8. <cfset arrayAppend(paths, "c:/path/to/poi38/ooxml-lib/xmlbeans-2.3.0.jar")>
  9. <!--- set loadColdFusionClassPath=true so we can use CF's version of DOM4J --->
  10. <cfset javaloader = createObject("component", "javaloader.JavaLoader").init(loadPaths=paths, loadColdFusionClassPath=true)>
  11.  
  12. <!--- load DOCX file --->
  13. <cfset pathToFile = "c:/path/to/someFile.docx">
  14. <cfset fis = createObject("java","java.io.FileInputStream").init( pathToFile )>
  15. <cfset XWPFDocument = javaloader.create("org.apache.poi.xwpf.usermodel.XWPFDocument")>
  16. <cfset poiFile = XWPFDocument.init( fis )>
  17. <cfdump var="#poiFile#" label="It worked!">
Advertisement
Add Comment
Please, Sign In to add comment