Drive OpenOffice Calc with itcluno

This example was created to show the use of tcluno for an article in the German computer magazine http://www.LinuxMagazin.de/ . Variables are therefore in German, but I hope the example is useful for non german speakers as well.

It shows the usage of the itcluno extension found at http://tcluno.sourceforge.net/ using the pure scripting solution tclurtp.

The example creates a spreadsheet with the water level at Hamburg-Harburg, Germany including a simple chart.

Besides installing itcluno, it requires that you start OpenOffice with network support. This could be done by starting OpenOffice using

ooffice \"-accept=socket,host=localhost,port=2002;urp;

Many thanks to the author of tcluno Arnulf Wiedemann and Wolfgang Großer who supported me when writing the article.

Author Carsten Zerbst

 #!/bin/sh
 #
 # Beispiel für TclUno
 # \
 exec tclsh "$0" "$@"

 # damit wird die Skriptlösung angefordert
 # setting the argv to -urtp will require a pure scripted 
 # solution of the network interface
 set ::argv "-urtp"

 package require itcluno

 # Dokument erzeugen 
 # Create empty spreadsheet
 set spreadsheet [::itcluno::SpreadSheet #auto]

 # and rename first sheet to "Werte". This will only work
 # in german version, as the first sheet will not be called
 # Tabelle1 in an non german version
 $spreadsheet renameSheet Tabelle1 Werte

 # Werte Setzen 
 # Set the table headers
 $spreadsheet setCellValue Werte [list 0 0] {{"" Tag Uhrzeit Wochentag Wasserstand}}

 # Wasserstand Harburg Schleuese (www.bsh.de)
 # The values calculated for Harburg (the part of Hamburg were I live) sluice 
 set daten [ list \
     [ list HW 01.01.2006 05:05 So  2.4 ] \
     [ list NW 01.01.2006 12:38 So  -1.5 ] \
     [ list HW 01.01.2006 17:40 So  2.3 ] \
     [ list HW 02.01.2006 00:53 Mo  -1.4 ] \
     [ list HW 02.01.2006 05:55 Mo  2.5 ] \
     [ list NW 02.01.2006 13:32 Mo  -1.5 ] \
     [ list HW 02.01.2006 18:33 Mo  2.3 ] \
     [ list NW 03.01.2006 01:44 Di  -1.4 ] \
     [ list HW 03.01.2006 06:44 Di  2.5 ] \
     [ list NW 03.01.2006 14:26 Di  -1.5 ] \
     [ list HW 03.01.2006 19:24 Di  2.2 ] \
     [ list NW 04.01.2006 02:30 Mi  -1.4 ] \
     [ list HW 04.01.2006 07:30 Mi  2.5 ] \
     [ list NW 04.01.2006 15:13 Mi  -1.6 ] \
     [ list HW 04.01.2006 20:09 Mi  2.1 ] \
     [ list NW 05.01.2006 03:12 Do  -1.5 ] \
     [ list HW 05.01.2006 08:14 Do  2.5 ] \
     [ list NW 05.01.2006 15:58 Do  -1.6 ] \
     [ list HW 05.01.2006 20:54 Do  2.0 ] \
     [ list NW 06.01.2006 03:55 Fr  -1.5 ] \
     [ list HW 06.01.2006 09:01 Fr  2.5 ] \
     [ list NW 06.01.2006 16:43 Fr  -1.5 ] \
     [ list HW 06.01.2006 21:42 Fr  2.0 ] \
     [ list NW 07.01.2006 04:44 Sa  -1.4 ] \
     [ list HW 07.01.2006 09:52 Sa  2.4 ] \
     [ list NW 07.01.2006 17:32 Sa  -1.5 ] \
     [ list HW 07.01.2006 22:32 Sa  1.9 ]  ]

 $spreadsheet setCellValue Werte [list 0 1] $daten

 # Graphik erzeugen 
 # create a chart
 #set sourceRange  
 $spreadsheet createChart Werte [list 12 1 12 12 cm] \
        [list hasRowHeader 1 hasColumnHeader 1 title "Harburg Schleuse" type LineDiagram] \
        Werte [list 3 1 4 28]

 # set the title of OpenOffice
 tcluno_soffice::windowTitle [$spreadsheet cget -desktop] "Wasserstand: Harburg Schleuse"

 # and export as PDF
 $spreadsheet exportToPdf wasserstand.pdf

Category Application Category Example Category Interprocess Communication