Artifact
309b44ca85ca0f175dc2e3d6edfbc73784eaedca32bb74378805d42aff81a89e:
- Executable file
examples/sample4.tcl
— part of check-in
[49baf5b8b6]
at
2021-04-02 11:27:05
on branch trunk
— Version-1.6
(user:
alex
size: 1480)
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 73 65 74 20 61 75 74 6f 5f 70 "$@"..set auto_p
0030: 61 74 68 20 5b 6c 69 6e 73 65 72 74 20 24 61 75 ath [linsert $au
0040: 74 6f 5f 70 61 74 68 20 30 20 2e 2e 5d 0a 69 66 to_path 0 ..].if
0050: 20 7b 5b 63 61 74 63 68 20 7b 70 61 63 6b 61 67 {[catch {packag
0060: 65 20 72 65 71 75 69 72 65 20 6f 6f 78 6d 6c 7d e require ooxml}
0070: 5d 7d 20 7b 0a 20 20 73 6f 75 72 63 65 20 2e 2e ]} {. source ..
0080: 2f 6f 6f 78 6d 6c 2e 74 63 6c 0a 7d 0a 0a 73 6f /ooxml.tcl.}..so
0090: 75 72 63 65 20 61 72 72 61 79 2e 74 63 6c 0a 0a urce array.tcl..
00a0: 73 65 74 20 73 70 72 65 61 64 73 68 65 65 74 20 set spreadsheet
00b0: 5b 3a 3a 6f 6f 78 6d 6c 3a 3a 78 6c 5f 77 72 69 [::ooxml::xl_wri
00c0: 74 65 20 6e 65 77 20 2d 63 72 65 61 74 6f 72 20 te new -creator
00d0: 7b 41 6c 65 78 61 6e 64 65 72 20 53 63 68 c3 b6 {Alexander Schö
00e0: 70 65 7d 5d 0a 69 66 20 7b 5b 73 65 74 20 73 68 pe}].if {[set sh
00f0: 65 65 74 20 5b 24 73 70 72 65 61 64 73 68 65 65 eet [$spreadshee
0100: 74 20 77 6f 72 6b 73 68 65 65 74 20 7b 54 61 62 t worksheet {Tab
0110: 65 6c 6c 65 20 31 7d 5d 5d 20 3e 20 2d 31 7d 20 elle 1}]] > -1}
0120: 7b 0a 20 20 23 20 73 69 6e 67 6c 65 20 66 6f 72 {. # single for
0130: 6d 75 6c 61 20 61 75 74 6f 69 6e 63 72 65 6d 65 mula autoincreme
0140: 6e 74 20 63 6f 6c 75 6d 6e 20 69 6e 64 65 78 0a nt column index.
0150: 0a 20 20 24 73 70 72 65 61 64 73 68 65 65 74 20 . $spreadsheet
0160: 72 6f 77 20 24 73 68 65 65 74 0a 20 20 24 73 70 row $sheet. $sp
0170: 72 65 61 64 73 68 65 65 74 20 63 65 6c 6c 20 24 readsheet cell $
0180: 73 68 65 65 74 20 33 0a 20 20 24 73 70 72 65 61 sheet 3. $sprea
0190: 64 73 68 65 65 74 20 63 65 6c 6c 20 24 73 68 65 dsheet cell $she
01a0: 65 74 20 35 0a 20 20 24 73 70 72 65 61 64 73 68 et 5. $spreadsh
01b0: 65 65 74 20 63 65 6c 6c 20 24 73 68 65 65 74 20 eet cell $sheet
01c0: 7b 7d 20 2d 66 6f 72 6d 75 6c 61 20 41 31 2b 42 {} -formula A1+B
01d0: 31 0a 0a 20 20 23 20 76 65 72 74 69 63 61 6c 20 1.. # vertical
01e0: 73 68 61 72 65 64 20 66 6f 72 6d 75 6c 61 20 43 shared formula C
01f0: 33 20 74 6f 20 43 35 0a 0a 20 20 24 73 70 72 65 3 to C5.. $spre
0200: 61 64 73 68 65 65 74 20 63 65 6c 6c 20 24 73 68 adsheet cell $sh
0210: 65 65 74 20 31 20 2d 69 6e 64 65 78 20 32 2c 30 eet 1 -index 2,0
0220: 0a 20 20 24 73 70 72 65 61 64 73 68 65 65 74 20 . $spreadsheet
0230: 63 65 6c 6c 20 24 73 68 65 65 74 20 32 20 2d 69 cell $sheet 2 -i
0240: 6e 64 65 78 20 32 2c 31 0a 20 20 24 73 70 72 65 ndex 2,1. $spre
0250: 61 64 73 68 65 65 74 20 63 65 6c 6c 20 24 73 68 adsheet cell $sh
0260: 65 65 74 20 7b 7d 20 2d 69 6e 64 65 78 20 32 2c eet {} -index 2,
0270: 32 20 2d 66 6f 72 6d 75 6c 61 20 7b 41 33 2b 42 2 -formula {A3+B
0280: 33 7d 20 2d 66 6f 72 6d 75 6c 61 72 65 66 20 43 3} -formularef C
0290: 33 3a 43 35 20 2d 66 6f 72 6d 75 6c 61 69 64 78 3:C5 -formulaidx
02a0: 20 30 0a 0a 20 20 24 73 70 72 65 61 64 73 68 65 0.. $spreadshe
02b0: 65 74 20 63 65 6c 6c 20 24 73 68 65 65 74 20 32 et cell $sheet 2
02c0: 20 2d 69 6e 64 65 78 20 33 2c 30 0a 20 20 24 73 -index 3,0. $s
02d0: 70 72 65 61 64 73 68 65 65 74 20 63 65 6c 6c 20 preadsheet cell
02e0: 24 73 68 65 65 74 20 33 20 2d 69 6e 64 65 78 20 $sheet 3 -index
02f0: 33 2c 31 0a 20 20 24 73 70 72 65 61 64 73 68 65 3,1. $spreadshe
0300: 65 74 20 63 65 6c 6c 20 24 73 68 65 65 74 20 7b et cell $sheet {
0310: 7d 20 2d 69 6e 64 65 78 20 33 2c 32 20 2d 66 6f } -index 3,2 -fo
0320: 72 6d 75 6c 61 69 64 78 20 30 0a 0a 20 20 24 73 rmulaidx 0.. $s
0330: 70 72 65 61 64 73 68 65 65 74 20 63 65 6c 6c 20 preadsheet cell
0340: 24 73 68 65 65 74 20 33 20 2d 69 6e 64 65 78 20 $sheet 3 -index
0350: 41 35 0a 20 20 24 73 70 72 65 61 64 73 68 65 65 A5. $spreadshee
0360: 74 20 63 65 6c 6c 20 24 73 68 65 65 74 20 34 20 t cell $sheet 4
0370: 2d 69 6e 64 65 78 20 42 35 0a 20 20 24 73 70 72 -index B5. $spr
0380: 65 61 64 73 68 65 65 74 20 63 65 6c 6c 20 24 73 eadsheet cell $s
0390: 68 65 65 74 20 7b 7d 20 2d 69 6e 64 65 78 20 43 heet {} -index C
03a0: 35 20 2d 66 6f 72 6d 75 6c 61 69 64 78 20 30 0a 5 -formulaidx 0.
03b0: 0a 20 20 23 20 68 6f 72 69 7a 6f 6e 74 61 6c 20 . # horizontal
03c0: 73 68 61 72 65 64 20 66 6f 72 6d 75 6c 61 20 41 shared formula A
03d0: 39 20 74 6f 20 43 39 0a 0a 20 20 24 73 70 72 65 9 to C9.. $spre
03e0: 61 64 73 68 65 65 74 20 63 65 6c 6c 20 24 73 68 adsheet cell $sh
03f0: 65 65 74 20 31 20 2d 69 6e 64 65 78 20 36 2c 30 eet 1 -index 6,0
0400: 0a 20 20 24 73 70 72 65 61 64 73 68 65 65 74 20 . $spreadsheet
0410: 63 65 6c 6c 20 24 73 68 65 65 74 20 32 20 2d 69 cell $sheet 2 -i
0420: 6e 64 65 78 20 37 2c 30 0a 20 20 24 73 70 72 65 ndex 7,0. $spre
0430: 61 64 73 68 65 65 74 20 63 65 6c 6c 20 24 73 68 adsheet cell $sh
0440: 65 65 74 20 7b 7d 20 2d 69 6e 64 65 78 20 41 39 eet {} -index A9
0450: 20 2d 66 6f 72 6d 75 6c 61 20 7b 41 37 2b 41 38 -formula {A7+A8
0460: 7d 20 2d 66 6f 72 6d 75 6c 61 72 65 66 20 38 2c } -formularef 8,
0470: 30 3a 38 2c 32 20 2d 66 6f 72 6d 75 6c 61 69 64 0:8,2 -formulaid
0480: 78 20 31 0a 0a 20 20 24 73 70 72 65 61 64 73 68 x 1.. $spreadsh
0490: 65 65 74 20 63 65 6c 6c 20 24 73 68 65 65 74 20 eet cell $sheet
04a0: 32 20 2d 69 6e 64 65 78 20 36 2c 31 0a 20 20 24 2 -index 6,1. $
04b0: 73 70 72 65 61 64 73 68 65 65 74 20 63 65 6c 6c spreadsheet cell
04c0: 20 24 73 68 65 65 74 20 33 20 2d 69 6e 64 65 78 $sheet 3 -index
04d0: 20 37 2c 31 0a 20 20 24 73 70 72 65 61 64 73 68 7,1. $spreadsh
04e0: 65 65 74 20 63 65 6c 6c 20 24 73 68 65 65 74 20 eet cell $sheet
04f0: 7b 7d 20 2d 69 6e 64 65 78 20 38 2c 31 20 2d 66 {} -index 8,1 -f
0500: 6f 72 6d 75 6c 61 69 64 78 20 31 0a 0a 20 20 24 ormulaidx 1.. $
0510: 73 70 72 65 61 64 73 68 65 65 74 20 63 65 6c 6c spreadsheet cell
0520: 20 24 73 68 65 65 74 20 33 20 2d 69 6e 64 65 78 $sheet 3 -index
0530: 20 43 37 0a 20 20 24 73 70 72 65 61 64 73 68 65 C7. $spreadshe
0540: 65 74 20 63 65 6c 6c 20 24 73 68 65 65 74 20 34 et cell $sheet 4
0550: 20 2d 69 6e 64 65 78 20 43 38 0a 20 20 24 73 70 -index C8. $sp
0560: 72 65 61 64 73 68 65 65 74 20 63 65 6c 6c 20 24 readsheet cell $
0570: 73 68 65 65 74 20 7b 7d 20 2d 69 6e 64 65 78 20 sheet {} -index
0580: 43 39 20 2d 66 6f 72 6d 75 6c 61 69 64 78 20 31 C9 -formulaidx 1
0590: 0a 7d 0a 24 73 70 72 65 61 64 73 68 65 65 74 20 .}.$spreadsheet
05a0: 77 72 69 74 65 20 65 78 70 6f 72 74 34 2e 78 6c write export4.xl
05b0: 73 78 0a 24 73 70 72 65 61 64 73 68 65 65 74 20 sx.$spreadsheet
05c0: 64 65 73 74 72 6f 79 0a destroy.