I am working on a POC where I need to create a DOCX from some plain text. I was wondering if anybody had any advice on how to do this with Lucee. It appears the CFDOCUMENT won’t do it.
ChatGPT recommended docx4j , has anybody had success with this?
Thanks
Windows Server 2022
IIS 10
Lucee: 6.2.1.122
Tomcat/10.1.36
Java|21.0.6 (Eclipse Adoptium) 64bit
Are you by any chance already using the Spreadsheet CFML library? If so you can also use its underlying POI libraries to write your own Word generation fairly easily. Use the createJavaObject method to work with the classes you need.
My installation is more or less out of the box right now. I’m not familiar with Maven.
I could not get the code to work. I have Grok play with it and ended up with the two attached files, but just can’t get it working. It’s suggesting “Since Lucee is failing to load xmlbeans:5.3.0 (and potentially other dependencies), we’ll download the required JARs and place them in Lucee’s library directory.”
Thanks @Julian_Halliwell I tried it but it threw an error
PoiComponent initialized
Result path: D:\ACS\aspirenet\test\simple.docx
Error creating document: Failed to create document: Cannot load XWPFDocument class: could not find component or class with name [XWPFDocument]
This component java integration is quite new and I’m finding some aspects of it a bit flaky at the moment, so failing that, I would give my first suggestion a go, using Spreadsheet CFML. No installation needed, just copy the required files/folders to your app and call it as above. No need to mess about with the POI jars, it’s all packaged up and loaded for you.
Thanks again. I tried those files, it failed
Lucee 6.2.1.122 Error (expression)
Message Component [PoiComponent] has no function with name [getVersion]
AI (Experimental) For AI-driven exception analysis setup, see AI Setup Guide.
Stacktrace The Error Occurred in D:\ACS\aspirenet\test\createdoc.cfm: line 13
11: }
12: 13: dump( var=poi.getVersion(), label=“POI version” );
14:
15: // Define the result path