Tutorial

Please download the attached zip file tutorial.zip and unzip it to a temporary directory. It contains two files:

tutorial.rb
tutorial.odt

tutorial.rb is a Ruby script that contains some sample data. It makes a Ruport Table then renders it using the template tutorial.odt.

You will want to read tutorial.rb first, to see how it works.

Then open tutorial.odt in OpenOffice.org and see how the template is structured. You will notice that the file is basically an OpenDocument file with bits of coloured code throughout. Those bits of code are marked up with special character styles that Documatic recognises and turns into embedded Ruby. The character style "Ruby Code" is used for code that controls the program flow (i.e. looping over each record in the data source) just like embedded Ruby's <% %>, while the character style "Ruby Value" contains code that is rendered and visible in the output, just like <%= %>. (For a full discussion see HowItWorks.)

Then run the script:

  % ruby tutorial.rb

You will find that a directory called output/ is created, containing the finished product. Open it and have a look.

Then you might want to go back and tweak the files: experiment a bit to see what's possible with Documatic.

OpenDocument Spreadsheet Tutorial

Along similar lines, please also find attached calc_tutorial.zip. This tutorial is very similar to the text one, but using a spreadsheet template.

Attachments