ooxml

Artifact Content
Login

Artifact b4c372acfe53d92a3a9245e35cc43a064b30fdf1a0617a24b0be2293a9b46f48:


#!/bin/sh
#\
exec tclsh8.6 "$0" "$@"

#package require ooxml
source ../ooxml.tcl

source array.tcl

set spreadsheet [::ooxml::xl_write new -creator {Alexander Schöpe}]
if {[set sheet [$spreadsheet worksheet {Tabelle 1}]] > -1} {
  set center [$spreadsheet style -horizontal center]
  set date [$spreadsheet style -numfmt [$spreadsheet numberformat -datetime]]
  set decimal [$spreadsheet style -numfmt [$spreadsheet numberformat -decimal -red]]
  set text [$spreadsheet style -numfmt [$spreadsheet numberformat -string]]

  $spreadsheet column $sheet -width 30 -index 1
  $spreadsheet column $sheet -style $decimal -index 11
  $spreadsheet column $sheet -style $date -width [::ooxml::CalcColumnWidth 16] -index 5

  $spreadsheet autofilter $sheet 0,0 0,6
  $spreadsheet freeze $sheet C2

  set lastRow -1
  foreach name [lsort -dictionary [array names data]] {
    lassign [split $name ,] row col
    if {$row != $lastRow} {
      set lastRow $row
      $spreadsheet row $sheet
    }
    switch -- $col {
      2 {
	$spreadsheet cell $sheet $data($name) -index $col -string
      }
      default {
	$spreadsheet cell $sheet $data($name) -index $col
      }
    }
  }

  $spreadsheet write export2.xlsx
}