ooxml

Check-in [9fc2848c8f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:ignore "-globalstyle" in versions > 1.5; styles are from now on predefined via method "column" and can be overwritten in method "cell"
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9fc2848c8fa9499bd843dab01d12ecebc04bcad79a6297dfa1e982a475d2b8c6
User & Date: alex 2020-03-05 19:35:42
Context
2020-03-07
21:37
new feature "named formats" for numberformats, fonts, fills, borders and styles check-in: ea03e767f5 user: alex tags: trunk
2020-03-05
21:33
added "-tag" to the method "styles". with this you can give a style a name. in the methods "defaultdatestyle", "column" and "cell" as STYLEID you can also pass the given name. check-in: bcad321da9 user: alex tags: namedfmts
19:35
ignore "-globalstyle" in versions > 1.5; styles are from now on predefined via method "column" and can be overwritten in method "cell" check-in: 9fc2848c8f user: alex tags: trunk
19:28
added "-zero" and "-nostring" to reset globally set options "-nozero" and "-string" with method "column" for a single cell with method "cell" Closed-Leaf check-in: 5c65034ad7 user: alex tags: coldefs
2020-02-04
13:18
bug fix: docProps/app.xml sheet count was wrong check-in: 32d3627499 user: alex tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ooxml.tcl.

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
....
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278


2279
2280
2281
2282
2283
2284
2285
2286
2287
....
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303







2304
2305
2306
2307
2308
2309
2310
....
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327


2328
2329

2330
2331


2332


2333
2334



2335
2336
2337
2338
2339
2340
2341
# 
#   method row sheet args
#     -index INDEX -height HEIGHT
#     autoincrement of row if INDEX not applied
#     return row
# 
#   method cell sheet {data {}} args
#     -index INDEX -style STYLEID -formula FORMULA -string -nozero -globalstyle -height HEIGHT
#     autoincrement of column if INDEX not applied
#     return row,column
# 
#   method autofilter sheet indexFrom indexTo
# 
#   method freeze sheet index
# 
................................................................................
#   method view args
#     -avtivetab TAB -x TWIPS -y TWIPS -height TWIPS -width TWIPS -list
#
#   method write filename
# 
#
# ::ooxml::tablelist_to_xl lb args
#   -callback CALLBACK -path PATH -file FILENAME -creator CREATOR -name NAME -rootonly -addtimestamp -globalstyle
#   Callback arguments
#     spreadsheet sheet maxcol column title width align sortmode hide
#


package require Tcl 8.6.7-
package require tdom 0.9.0-
................................................................................
  method cell { sheet {data {}} args } {
    my variable obj
    my variable cells
    my variable cols

    array set opts {
      index {}
      style 0
      formula {}
      string 0


      nozero 0
      globalstyle 0
      height {}
    }

    set len [llength $args]
    set idx 0
    for {set idx 0} {$idx < $len} {incr idx} {
      switch -- [set opt [lindex $args $idx]] {
................................................................................
	  incr idx
          if {$idx < $len} {
            set opts([string range $opt 1 end]) [lindex $args $idx]
          } else {
            error "option '$opt': missing argument"
          }            
        }
        -string - -nozero - -globalstyle {
	  set opts([string range $opt 1 end]) 1
        }
        default {
          error "unknown option \"$opt\", should be: -index, -style, -formula, -height, -string, -nozero or -globalstyle"
        }
      }
    }








    if {!$obj(callRow,$obj(sheets))} {
      set obj(callRow,$obj(sheets)) 1
      incr obj(row,$sheet)
    }

    if {[regexp {^\d+$} $opts(index)] && $opts(index) > -1} {
................................................................................
    } elseif {[string trim $opts(index)] eq {}} {
      incr obj(col,$sheet)
    }
    if {$obj(row,$sheet) < 0 || $obj(col,$sheet) < 0} {
      return -1
    }

    if {$opts(globalstyle) && [string is integer -strict $opts(style)] && $opts(style) < 1} {
      if {[info exists cols($sheet,$obj(col,$sheet))] && [dict get $cols($sheet,$obj(col,$sheet)) style] >= 0} {
        set opts(style) [dict get $cols($sheet,$obj(col,$sheet)) style]


      }
    }

    if {$opts(string) == 0 && [info exists cols($sheet,$obj(col,$sheet))] && [dict get $cols($sheet,$obj(col,$sheet)) string] == 1} {
      set opts(string) 1


    }


    if {$opts(nozero) == 0 && [info exists cols($sheet,$obj(col,$sheet))] && [dict get $cols($sheet,$obj(col,$sheet)) nozero] == 1} {
      set opts(nozero) 1



    }

    set cell ${sheet},$obj(row,$sheet),$obj(col,$sheet)
    set cells($cell) {}

    if {[string is integer -strict $opts(height)] && $opts(height) > 0 && $opts(height) < 1024} {
      dict set obj(rowHeight,$sheet) $obj(row,$sheet) $opts(height)







|







 







|







 







|

|
>
>
|
|







 







|



|



>
>
>
>
>
>
>







 







|


>
>


>
|
|
>
>
|
>
>
|
|
>
>
>







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
....
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
....
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
....
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
# 
#   method row sheet args
#     -index INDEX -height HEIGHT
#     autoincrement of row if INDEX not applied
#     return row
# 
#   method cell sheet {data {}} args
#     -index INDEX -style STYLEID -formula FORMULA -string -nozero -height HEIGHT
#     autoincrement of column if INDEX not applied
#     return row,column
# 
#   method autofilter sheet indexFrom indexTo
# 
#   method freeze sheet index
# 
................................................................................
#   method view args
#     -avtivetab TAB -x TWIPS -y TWIPS -height TWIPS -width TWIPS -list
#
#   method write filename
# 
#
# ::ooxml::tablelist_to_xl lb args
#   -callback CALLBACK -path PATH -file FILENAME -creator CREATOR -name NAME -rootonly -addtimestamp
#   Callback arguments
#     spreadsheet sheet maxcol column title width align sortmode hide
#


package require Tcl 8.6.7-
package require tdom 0.9.0-
................................................................................
  method cell { sheet {data {}} args } {
    my variable obj
    my variable cells
    my variable cols

    array set opts {
      index {}
      style -1
      formula {}
      string -1
      nostring -1
      zero -1
      nozero -1
      globalstyle {}
      height {}
    }

    set len [llength $args]
    set idx 0
    for {set idx 0} {$idx < $len} {incr idx} {
      switch -- [set opt [lindex $args $idx]] {
................................................................................
	  incr idx
          if {$idx < $len} {
            set opts([string range $opt 1 end]) [lindex $args $idx]
          } else {
            error "option '$opt': missing argument"
          }            
        }
        -string - -nostring - -zero - -nozero - -globalstyle {
	  set opts([string range $opt 1 end]) 1
        }
        default {
          error "unknown option \"$opt\", should be: -index, -style, -formula, -height, -string, nostring, -zero or -nozero"
        }
      }
    }

    if {$opts(nostring) == 1} {
      set opts(string) 0
    }
    if {$opts(zero) == 1} {
      set opts(nozero) 0
    }

    if {!$obj(callRow,$obj(sheets))} {
      set obj(callRow,$obj(sheets)) 1
      incr obj(row,$sheet)
    }

    if {[regexp {^\d+$} $opts(index)] && $opts(index) > -1} {
................................................................................
    } elseif {[string trim $opts(index)] eq {}} {
      incr obj(col,$sheet)
    }
    if {$obj(row,$sheet) < 0 || $obj(col,$sheet) < 0} {
      return -1
    }

    if {[string is integer -strict $opts(style)] && $opts(style) == -1} {
      if {[info exists cols($sheet,$obj(col,$sheet))] && [dict get $cols($sheet,$obj(col,$sheet)) style] >= 0} {
        set opts(style) [dict get $cols($sheet,$obj(col,$sheet)) style]
      } elseif {$opts(style) == -1} {
	set opts(style) 0
      }
    }
    if {[string is integer -strict $opts(string)] && $opts(string) == -1} {
      if {[info exists cols($sheet,$obj(col,$sheet))] && [dict get $cols($sheet,$obj(col,$sheet)) string] == 1} {
	set opts(string) 1
      } elseif {$opts(string) == -1} {
	set opts(string) 0
      }
    }
    if {[string is integer -strict $opts(nozero)] && $opts(nozero) == -1} {
      if {[info exists cols($sheet,$obj(col,$sheet))] && [dict get $cols($sheet,$obj(col,$sheet)) nozero] == 1} {
	set opts(nozero) 1
      } elseif {$opts(nozero) == -1} {
	set opts(nozero) 0
      }
    }

    set cell ${sheet},$obj(row,$sheet),$obj(col,$sheet)
    set cells($cell) {}

    if {[string is integer -strict $opts(height)] && $opts(height) > 0 && $opts(height) < 1024} {
      dict set obj(rowHeight,$sheet) $obj(row,$sheet) $opts(height)