I'm trying to use the libre office mail merge functionality automatically from an java application.
I have tried to install the libreoffice sdk but without success because they require software that is not available anymore (e.g. zip-tools). Anyway I was able to get the jar files (jurtl-3.2.1.jar, ridl-3.2.1.jar, unoil-3.2.1.jar and juh-3.2.1.jar) from the maven repository.
With this jar files I was able to reproduce a lot of examples which are provided here http://api.libreoffice.org/examples/examples.html#Java_examples
Also in the LibreOffice API documentation a service named 'MailMerge' is listed (see here http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1text_1_1MailMerge.html)
But in none of the jar's this service class is available, the only instance available for me is MailMergeType.
I'm able to open an *.odt templatefile within my javacode and the next step would be to create an instance of the mail merge service and pass a *.csv datasourcefile to the mail merge service.
At the API documentation some functions are listed which could help me but as I said before I'm not able to get access to this service class because its simply not exist in the provided jar files.
Do anybody know how I can get access to the mail merge service for libreoffice?
If you need more information about my environment just ask.
Sincerly
Looking at this code from 2004, apparently you can simply use Java's Object
class. Here are a few snippets from that code:
Object mmservice = null;
try {
// Create an instance of the MailMerge service
mmservice = mxMCF.createInstanceWithContext(
"com.sun.star.text.MailMerge", mxComponentContext);
}
// Get the XPropertySet interface of the mmservice object
XPropertySet oObjProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, mmservice);
try {
// Set up the properties for the MailMerge command
oObjProps.setPropertyValue("DataSourceName", mDataSourceName);
}
// Get XJob interface from MailMerge service and call execute on it
XJob job = (XJob) UnoRuntime.queryInterface(XJob.class, mmservice);
try {
job.execute(new NamedValue[0]);
}
See also How to do a simple mail merge in OpenOffice.
Regarding a source for the old zip tools, try zip.exe
from http://www.willus.com/archive/zip64/.