Java mail merge with csv data source

The Application Programming Interface and the OASIS Open Document Format

Java mail merge with csv data source

Postby hcday » Tue Jun 14, 2011 12:56 pm

Hi, I'm struggling to get a working example of a Java mail merge using a CSV data source. Has anyone else managed to achieve this and is willing share a snippet or show me where I'm going wrong? The API for this feature is given here:

And a mail merge example is given here but this is old code (2004 vintage) and assumes OpenOffice 1.x and .stw file format:

I've played with this for a while without success. The example is also incomplete in that it does not provide the template file (.stw). Does anyone have a more recent example that would run against OpenOffice 3.x?

A related question: opening a .docx document in the OpenOffice desktop app and saving it in .odt format, the existing mail merge fields in the Word document are not converted to OO mail merge fields. Is this what you'd expect? i.e. OO uses a proprietary mail merge syntax and doesn't understand mail merge fields from Word documents? I'm an OpenOffice newbie so sorry if these are basic questions.

Thanks for any tips,

Henry Day
OpenOffice 3.3 / Windows 7
Posts: 1
Joined: Tue Jun 14, 2011 10:40 am

Re: Java mail merge with csv data source

Postby rudolfo » Tue Jun 14, 2011 2:19 pm

Please read the survival guide for this forum before posting. Right, both your questions are related to Mail-Merge but they depend on different techniques: external macros with Java and import filters of OOo Writers.

In other words, your chances to get an answer for your .docx import issue are higher if you ask this in Writer Forum.
If you want to indicate that your question is related to another one you can always use the bb-code markup (available in the Full Editor, not in Quick Reply) to include a hyperlink to the other thread in your post.

I am not familiar with Java, but usually programming with OpenOffice means to create UNO objects and call methods of these objects. That's the same for all extension languages Python, Java, Basic, ... So don't limit your search to Java. If you find an example for Python it shouldn't be to difficult to convert it to Java.
Actually there is the MRI extension, a object inspection tool, that can create code for all these languages while you are navigating through the object hierachy. Take this as an illustration that the programming language is secondary and the main focus is on the UNO objects.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest