ooxml

Hex Artifact Content
Login

Hex Artifact Content

Artifact b4c372acfe53d92a3a9245e35cc43a064b30fdf1a0617a24b0be2293a9b46f48:


0000: 23 21 2f 62 69 6e 2f 73 68 0a 23 5c 0a 65 78 65  #!/bin/sh.#\.exe
0010: 63 20 74 63 6c 73 68 38 2e 36 20 22 24 30 22 20  c tclsh8.6 "$0" 
0020: 22 24 40 22 0a 0a 23 70 61 63 6b 61 67 65 20 72  "$@"..#package r
0030: 65 71 75 69 72 65 20 6f 6f 78 6d 6c 0a 73 6f 75  equire ooxml.sou
0040: 72 63 65 20 2e 2e 2f 6f 6f 78 6d 6c 2e 74 63 6c  rce ../ooxml.tcl
0050: 0a 0a 73 6f 75 72 63 65 20 61 72 72 61 79 2e 74  ..source array.t
0060: 63 6c 0a 0a 73 65 74 20 73 70 72 65 61 64 73 68  cl..set spreadsh
0070: 65 65 74 20 5b 3a 3a 6f 6f 78 6d 6c 3a 3a 78 6c  eet [::ooxml::xl
0080: 5f 77 72 69 74 65 20 6e 65 77 20 2d 63 72 65 61  _write new -crea
0090: 74 6f 72 20 7b 41 6c 65 78 61 6e 64 65 72 20 53  tor {Alexander S
00a0: 63 68 c3 b6 70 65 7d 5d 0a 69 66 20 7b 5b 73 65  chöpe}].if {[se
00b0: 74 20 73 68 65 65 74 20 5b 24 73 70 72 65 61 64  t sheet [$spread
00c0: 73 68 65 65 74 20 77 6f 72 6b 73 68 65 65 74 20  sheet worksheet 
00d0: 7b 54 61 62 65 6c 6c 65 20 31 7d 5d 5d 20 3e 20  {Tabelle 1}]] > 
00e0: 2d 31 7d 20 7b 0a 20 20 73 65 74 20 63 65 6e 74  -1} {.  set cent
00f0: 65 72 20 5b 24 73 70 72 65 61 64 73 68 65 65 74  er [$spreadsheet
0100: 20 73 74 79 6c 65 20 2d 68 6f 72 69 7a 6f 6e 74   style -horizont
0110: 61 6c 20 63 65 6e 74 65 72 5d 0a 20 20 73 65 74  al center].  set
0120: 20 64 61 74 65 20 5b 24 73 70 72 65 61 64 73 68   date [$spreadsh
0130: 65 65 74 20 73 74 79 6c 65 20 2d 6e 75 6d 66 6d  eet style -numfm
0140: 74 20 5b 24 73 70 72 65 61 64 73 68 65 65 74 20  t [$spreadsheet 
0150: 6e 75 6d 62 65 72 66 6f 72 6d 61 74 20 2d 64 61  numberformat -da
0160: 74 65 74 69 6d 65 5d 5d 0a 20 20 73 65 74 20 64  tetime]].  set d
0170: 65 63 69 6d 61 6c 20 5b 24 73 70 72 65 61 64 73  ecimal [$spreads
0180: 68 65 65 74 20 73 74 79 6c 65 20 2d 6e 75 6d 66  heet style -numf
0190: 6d 74 20 5b 24 73 70 72 65 61 64 73 68 65 65 74  mt [$spreadsheet
01a0: 20 6e 75 6d 62 65 72 66 6f 72 6d 61 74 20 2d 64   numberformat -d
01b0: 65 63 69 6d 61 6c 20 2d 72 65 64 5d 5d 0a 20 20  ecimal -red]].  
01c0: 73 65 74 20 74 65 78 74 20 5b 24 73 70 72 65 61  set text [$sprea
01d0: 64 73 68 65 65 74 20 73 74 79 6c 65 20 2d 6e 75  dsheet style -nu
01e0: 6d 66 6d 74 20 5b 24 73 70 72 65 61 64 73 68 65  mfmt [$spreadshe
01f0: 65 74 20 6e 75 6d 62 65 72 66 6f 72 6d 61 74 20  et numberformat 
0200: 2d 73 74 72 69 6e 67 5d 5d 0a 0a 20 20 24 73 70  -string]]..  $sp
0210: 72 65 61 64 73 68 65 65 74 20 63 6f 6c 75 6d 6e  readsheet column
0220: 20 24 73 68 65 65 74 20 2d 77 69 64 74 68 20 33   $sheet -width 3
0230: 30 20 2d 69 6e 64 65 78 20 31 0a 20 20 24 73 70  0 -index 1.  $sp
0240: 72 65 61 64 73 68 65 65 74 20 63 6f 6c 75 6d 6e  readsheet column
0250: 20 24 73 68 65 65 74 20 2d 73 74 79 6c 65 20 24   $sheet -style $
0260: 64 65 63 69 6d 61 6c 20 2d 69 6e 64 65 78 20 31  decimal -index 1
0270: 31 0a 20 20 24 73 70 72 65 61 64 73 68 65 65 74  1.  $spreadsheet
0280: 20 63 6f 6c 75 6d 6e 20 24 73 68 65 65 74 20 2d   column $sheet -
0290: 73 74 79 6c 65 20 24 64 61 74 65 20 2d 77 69 64  style $date -wid
02a0: 74 68 20 5b 3a 3a 6f 6f 78 6d 6c 3a 3a 43 61 6c  th [::ooxml::Cal
02b0: 63 43 6f 6c 75 6d 6e 57 69 64 74 68 20 31 36 5d  cColumnWidth 16]
02c0: 20 2d 69 6e 64 65 78 20 35 0a 0a 20 20 24 73 70   -index 5..  $sp
02d0: 72 65 61 64 73 68 65 65 74 20 61 75 74 6f 66 69  readsheet autofi
02e0: 6c 74 65 72 20 24 73 68 65 65 74 20 30 2c 30 20  lter $sheet 0,0 
02f0: 30 2c 36 0a 20 20 24 73 70 72 65 61 64 73 68 65  0,6.  $spreadshe
0300: 65 74 20 66 72 65 65 7a 65 20 24 73 68 65 65 74  et freeze $sheet
0310: 20 43 32 0a 0a 20 20 73 65 74 20 6c 61 73 74 52   C2..  set lastR
0320: 6f 77 20 2d 31 0a 20 20 66 6f 72 65 61 63 68 20  ow -1.  foreach 
0330: 6e 61 6d 65 20 5b 6c 73 6f 72 74 20 2d 64 69 63  name [lsort -dic
0340: 74 69 6f 6e 61 72 79 20 5b 61 72 72 61 79 20 6e  tionary [array n
0350: 61 6d 65 73 20 64 61 74 61 5d 5d 20 7b 0a 20 20  ames data]] {.  
0360: 20 20 6c 61 73 73 69 67 6e 20 5b 73 70 6c 69 74    lassign [split
0370: 20 24 6e 61 6d 65 20 2c 5d 20 72 6f 77 20 63 6f   $name ,] row co
0380: 6c 0a 20 20 20 20 69 66 20 7b 24 72 6f 77 20 21  l.    if {$row !
0390: 3d 20 24 6c 61 73 74 52 6f 77 7d 20 7b 0a 20 20  = $lastRow} {.  
03a0: 20 20 20 20 73 65 74 20 6c 61 73 74 52 6f 77 20      set lastRow 
03b0: 24 72 6f 77 0a 20 20 20 20 20 20 24 73 70 72 65  $row.      $spre
03c0: 61 64 73 68 65 65 74 20 72 6f 77 20 24 73 68 65  adsheet row $she
03d0: 65 74 0a 20 20 20 20 7d 0a 20 20 20 20 73 77 69  et.    }.    swi
03e0: 74 63 68 20 2d 2d 20 24 63 6f 6c 20 7b 0a 20 20  tch -- $col {.  
03f0: 20 20 20 20 32 20 7b 0a 09 24 73 70 72 65 61 64      2 {..$spread
0400: 73 68 65 65 74 20 63 65 6c 6c 20 24 73 68 65 65  sheet cell $shee
0410: 74 20 24 64 61 74 61 28 24 6e 61 6d 65 29 20 2d  t $data($name) -
0420: 69 6e 64 65 78 20 24 63 6f 6c 20 2d 73 74 72 69  index $col -stri
0430: 6e 67 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 20  ng.      }.     
0440: 20 64 65 66 61 75 6c 74 20 7b 0a 09 24 73 70 72   default {..$spr
0450: 65 61 64 73 68 65 65 74 20 63 65 6c 6c 20 24 73  eadsheet cell $s
0460: 68 65 65 74 20 24 64 61 74 61 28 24 6e 61 6d 65  heet $data($name
0470: 29 20 2d 69 6e 64 65 78 20 24 63 6f 6c 0a 20 20  ) -index $col.  
0480: 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20 7d 0a      }.    }.  }.
0490: 0a 20 20 24 73 70 72 65 61 64 73 68 65 65 74 20  .  $spreadsheet 
04a0: 77 72 69 74 65 20 65 78 70 6f 72 74 32 2e 78 6c  write export2.xl
04b0: 73 78 0a 7d 0a                                   sx.}.