This examples were created to show the use of tcluno for in an article for the german computer magazin http://www.LinuxMagazin.de. Variables are therefore in german, but I hope the example is usefull for non german speakers as well. It show the usage of the tcluno extension found at http://tcluno.sourceforge.net using the pure scripting solution tclurtp. The example creates a spreadsheet with some random numbers and a formula and save the sheet in XLS format. Besides installing tcluno 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" "$@" lappend auto_path [ file join [ pwd ] tclurtp ] lappend auto_path [ file join [ pwd ] tcluno ] # damit wird die Skriptlösung angefordert # setting the argv to -urtp will require a pure scripted # solution of the network interface set ::argv "-urtp" # Erweiterung laden # load extension package require tcluno_scalc # Kontakt mit OpenOffice herstellen # contact OpenOffice and print error message if {[catch {::tcluno_soffice::initDesktop } desktop]} { puts stderr "Verbindung mit OpenOffice fehlgeschlagen !" puts stderr "Fehler war:" puts stderr $desktop puts stderr "" puts stderr "Bitte OpenOffice mit Netzwerkunterstützung starten:" puts stderr "ooffice \"-accept=socket,host=localhost,port=2002;urp;\"" exit 1 } # Schnittstellen anzeigen # Show interfaces of the desktop object puts "desktop hat folgende Schnittstellen:" puts [ join [$desktop getTypes] "\n" ] # show services of desktop object puts "\ndesktop ist folgender Service:" puts [$desktop getSupportedServiceNames] # leere Liste erstellen # create empty list of Any type set filterSequence [$desktop tcluno::createUnoSequence Any] # neues Dokument in Tabellenkalkulation # create new document in OO Calc set spreadsheet [$desktop loadComponentFromURL "private:factory/scalc" \ "_blank" 0 $filterSequence ] # erste Seite finden # find the first page set sheets [$spreadsheet getSheets] set sheet [$sheets getByIndex 0] # and set the name to Zufallszahlen (random numbers) puts "\nTabellenname ist: [$sheet getName]" $sheet setName "Zufallszahlen" # Tabelle mit Zufallszahlen füllen # fill the page with random numbers for { set col 0} { $col < 10} {incr col} { for { set row 0} { $row < 10} {incr row} { set cell [$sheet getCellByPosition $col $row] set value [expr rand() * 100] $cell setValue $value } } # Zellenadresse # show the addresse of a cell set cell [ $sheet getCellRangeByName "A12" ] puts "\nKomplette Adresse: [ $cell getCellAddress ]" # Formeln und Texte # enter some text and formula set cell [ $sheet getCellRangeByName "A12" ] $cell setFormula "Summe:" set cell [ $sheet getCellRangeByName "B12" ] $cell setFormula "=sum(B1:B10)" set cell [ $sheet getCellRangeByName "A13" ] $cell setFormula "Mittelwert:" set cell [ $sheet getCellRangeByName "B13" ] $cell setFormula "=median(B1:B10)" # Als Excell speichern # and save as excell set filterSequence [$::desktop tcluno::createUnoSequence Any] set msExcelFilter [$::desktop tcluno::createUnoStructHelper \ com.sun.star.beans.PropertyValue \ {FilterName -1 {MS Excel 97} 0} ] $::desktop tcluno::appendUnoSequence $filterSequence $msExcelFilter $spreadsheet storeAsURL file:/tmp/test.xls $filterSequence ---- [Category Application]