Create OpenDocument invoices and other documents with Rexx

After my talk about ODF scripting at OOoCon 2010 I got,by another OOoCon speaker, Rony G. Flatscher another script for automatic generation of OpenDocument invoices, or any other ODF text with a fixed structure.

Roni’s script opens an OpenDocument text template as the one shown in the picture above and replaces all the MF_ placeholders strings with values loaded by a plain text file, creating the filled form shown here:

This is the format of the plain text file containing the data that must be inserted in the form (of course, you could either generate this entry file manually, but the real advantage of doing things this way is when the data come from some database, spreadsheet or other similar source:

; empty lines or ones starting with a ; are considered comments
; field separator is the string /;

the first argument after the invocation of the Rexx interpreter is the actual script (which is barely over 100 lines, and half of them are comments! You can read the full source at the bottom of this page), the second is the template file (the one in the left picture above) and the last one is the data file. You can download the Rexx script, the sample data file, the OpenDocument template and the resulting document here. I haven’t been able to test the script myself yet (I’ve messed a bit too much with my system lately and will have to clean it up…) but it looks fine to me and of course I’ll update this page with any bug fix or missing info that should be needed. Here is Roni’s explanation of what his script does:

Rony: following up our little conversation at OOoCon I researched today the Java-odftoolkit and tried to come up with a simple solution that mimickries your approach to changing the content of ODF files. This ooRexx program does basically the same as your bash/Perl scripts, but takes advantage of the Java-odftoolkit without using Java’s strong typing (blessfully). I have added in the comments at the top of the script the instructions to install the required libraries on Linux and Windows in case they aren’t on your system yet. If you’re unfamiliar with the language, just remember that the tilde is ooRexx explicit message operator (left of the tilde is the receiving object, right of it is the name of the message, which may be followed by round parenthesis which contains arguments). Last but not least, should you experience problems, please do not hesitate to contact me (but remember to remove all the anti-spam digits from the email address!!!).

Isn’t OpenDocument wonderful?

I’m very happy to host here Roni’s script and explanation, because he’s proving what I thought when I started the ODF scripting section of this website and explained in my OOoCon talk: the OpenDocument format is not only really open, it’s also so simple that everybody can save lots of tedious, manual office work thanks to it, no matter which language he or she prefers! If you have other examples of OpenDocument scripting, please let me know, I’ll be glad to host them here or link to them!