hugh
08/01/2024, 11:15 PMpoi_library = createObject("java","java.io.FileOutputStream")
//WPF_document = createObject("java", "org.apache.poi.xwpf.usermodel.XWPFDocument")
dump( poi_library )
The dump of the poi_library is the only thing that works at this point. When I uncomment the WPF_document variable and try to dump that I get an error. The error message reads:
org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream
Interestingly, if I don't try and dump the variable, no error happens.
I've been at this for about a day and the list of errors grows as I try to add more java classes. My hope is that someone out there has worked with the POI library successfully and can steer me in the right direction, or can post a link where someone explains the proper procedure to use the library with Lucee.denny
08/01/2024, 11:41 PMbkbk
08/02/2024, 11:07 AMcfsimplicity
08/02/2024, 4:19 PMcfsimplicity
08/02/2024, 4:21 PMhugh
08/02/2024, 9:06 PMhugh
08/02/2024, 9:17 PMhugh
08/02/2024, 9:19 PMdenny
08/02/2024, 9:19 PM#!/bin/sh
find "$1" -name "*.jar" -exec sh -c 'unzip -l {} 2>/dev/null |grep -H --label {} '$2'' \;
so if you saved that as findclass
you would use it like ./findclass ./libs UnsynchronizedByteArrayOutputStream
(assuming the libs are in ./libs from where you are calling it, otherwise you'd put in the path) this should work on unix-like systems (mac, linux)denny
08/02/2024, 9:20 PMdenny
08/02/2024, 9:22 PMhugh
08/02/2024, 9:25 PMhugh
08/02/2024, 9:26 PMdenny
08/02/2024, 9:28 PMdenny
08/02/2024, 9:28 PMhugh
08/02/2024, 9:28 PMFOS = createObject("java","java.io.FileOutputStream")
WPF_document = createObject("java", "org.apache.poi.xwpf.usermodel.XWPFDocument")
// WPF_paragraph = createObject("java", "org.apache.poi.xwpf.usermodel.XWPFParagraph")
// WPF_run = createObject("java", "org.apache.poi.xwpf.usermodel.XWPFRun
dump( WPF_document )
hugh
08/02/2024, 9:29 PMdenny
08/02/2024, 9:30 PMdenny
08/02/2024, 9:31 PMdenny
08/02/2024, 9:32 PMhugh
08/02/2024, 9:32 PMdenny
08/02/2024, 9:33 PMhugh
08/02/2024, 9:33 PMdenny
08/02/2024, 9:41 PMdenny
08/02/2024, 9:41 PMcfsimplicity
08/03/2024, 9:35 AMlib-osgi.jar
) rather than from the /lib
dir, which makes it harder to add jars. But you can easily configure the library to use JavaLoader which does load from /lib
and also provides good isolation (this is what happens by default with ACF).
I've only worked with the spreadsheet side of POI, but I suspect much of the other functionality should work with what's already bundled, which includes commons-io
.
Do make sure you use the CreateJavaObject()
method I mentioned though. That will ensure the classes are invoked from the right place.cfsimplicity
08/03/2024, 11:50 AM//Instantiate the library
spreadsheet = new spreadsheet.Spreadsheet() //adapt to where you have put the library
// Create a Word docx object
document = spreadsheet.createJavaObject( "org.apache.poi.xwpf.usermodel.XWPFDocument" )
// Add some text
para = document.createParagraph()
textRun = para.createRun()
textRun.setText( "A programmatically written Word doc!" )
// Save to a Word file
filepath = "c:/temp/word.docx" //adapt to where you want to save the file
try{
outputStream = CreateObject( "java", "java.io.FileOutputStream" ).init( filepath )
document.write( outputStream )
}
finally{
outputStream.close()
document.close()
}
cfsimplicity
08/03/2024, 11:53 AMdenny
08/03/2024, 8:53 PMdenny
08/09/2024, 11:06 PM