ooxml

Check-in [1780af15a2]
Login

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

Overview
Comment:Modified writing: hold only just one DOM tree of the xml files to generate in memory and drop that immediately after done with it, to reduce maxium mem peek (at bit).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | populationspeed
Files: files | file ages | folders
SHA3-256: 1780af15a258ca2092b81e7653c20273a4f779e693e6fad9eb1384d29299d421
User & Date: rolf 2019-08-16 09:54:26
Context
2019-08-16
19:23
fixed a problem with -style option (from check-in [6c6aa2f98f]) check-in: 27bb35e6a6 user: alex tags: populationspeed
09:54
Modified writing: hold only just one DOM tree of the xml files to generate in memory and drop that immediately after done with it, to reduce maxium mem peek (at bit). check-in: 1780af15a2 user: rolf tags: populationspeed
03:33
minimum version Tcl 8.6.7 required check-in: 32eaa74737 user: alex tags: populationspeed
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ooxml.tcl.

1392
1393
1394
1395
1396
1397
1398









1399
1400
1401
1402
1403
1404
1405
....
2259
2260
2261
2262
2263
2264
2265


















2266
2267
2268
2269
2270
2271
2272
....
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297


2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
....
2321
2322
2323
2324
2325
2326
2327


2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
....
2365
2366
2367
2368
2369
2370
2371


2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
....
2388
2389
2390
2391
2392
2393
2394


2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
....
2412
2413
2414
2415
2416
2417
2418


2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
....
2435
2436
2437
2438
2439
2440
2441


2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457


2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
....
2593
2594
2595
2596
2597
2598
2599


2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
....
2932
2933
2934
2935
2936
2937
2938


2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
....
2965
2966
2967
2968
2969
2970
2971


2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
....
3073
3074
3075
3076
3077
3078
3079


3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
    if {$column > $wb($sheet,max_column)} {
      set wb($sheet,max_column) $column
    }
  }
  return [array get wb]
}











#
# ooxml::xl_write
#


oo::class create ooxml::xl_write {
................................................................................
    my variable borders
    my variable cols

    if {[::ooxml::Getopt opts {holdcontainerdirectory} $args]} {
      error $opts(-errmsg)
    }



















    foreach {n v} [array get cells] {
      if {[dict exists $v t] && [dict get $v t] eq {s} && [dict exists $v v] && [dict get $v v] ne {}} {
        set thisv [dict get $v v]
        if {[info exists lookup($thisv)]} {
          set pos $lookup($thisv)
        } else {
          set pos [llength $sharedStrings]
................................................................................
	dict set cells($n) v $pos
      }
    }
    unset -nocomplain n v
    array unset lookup
    
    # _rels/.rels
    set doc [set obj(doc,_rels/.rels) [dom createDocument Relationships]]
    set root [$doc documentElement]

    set rId 0

    dom createNodeCmd -tagName Relationship elementNode Tag_Relationship

    $root setAttribute xmlns http://schemas.openxmlformats.org/package/2006/relationships

    $root appendFromScript {
      Tag_Relationship Id rId1 Type http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument Target xl/workbook.xml {}
      Tag_Relationship Id rId2 Type http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties Target docProps/app.xml {}
      Tag_Relationship Id rId3 Type http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties Target docProps/core.xml {}
    }




    # [Content_Types].xml
    set doc [set obj(doc,\[Content_Types\].xml) [dom createDocument Types]]
    set root [$doc documentElement]

    foreach tag {Default Override} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }

    $root setAttribute xmlns http://schemas.openxmlformats.org/package/2006/content-types
................................................................................
      }
      if {$obj(calcChain)} {
	Tag_Override PartName /xl/calcChain.xml ContentType application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml {}
      }
      Tag_Override PartName /docProps/core.xml ContentType application/vnd.openxmlformats-package.core-properties+xml {}
      Tag_Override PartName /docProps/app.xml ContentType application/vnd.openxmlformats-officedocument.extended-properties+xml {}
    }




    # docProps/app.xml
    set doc [set obj(doc,docProps/app.xml) [dom createDocument Properties]]
    set root [$doc documentElement]

    dom createNodeCmd textNode Text
    foreach tag {AppVersion Application Company DocSecurity HeadingPairs HyperlinksChanged LinksUpToDate ScaleCrop SharedDoc TitlesOfParts
                 vt:i4 vt:lpstrvt:lpstr vt:lpstr vt:variant vt:vector} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }
................................................................................
      }
      Tag_Company {}
      Tag_LinksUpToDate { Text false }
      Tag_SharedDoc { Text false }
      Tag_HyperlinksChanged { Text false }
      Tag_AppVersion { Text 1.0 }
    }




    # docProps/core.xml
    set doc [set obj(doc,docProps/core.xml) [dom createDocument cp:coreProperties]]
    set root [$doc documentElement]

    dom createNodeCmd textNode Text
    foreach tag {cp:lastModifiedBy dc:creator dcterms:created dcterms:modified} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }

................................................................................

    $root appendFromScript {
      Tag_dc:creator { Text $obj(creator) }
      Tag_cp:lastModifiedBy { Text $obj(lastModifiedBy) }
      Tag_dcterms:created xsi:type dcterms:W3CDTF { Text $obj(created) }
      Tag_dcterms:modified xsi:type dcterms:W3CDTF { Text $obj(modified) }
    }




    # xl/_rels/workbook.xml.rels
    set doc [set obj(doc,xl/_rels/workbook.xml.rels) [dom createDocument Relationships]]
    set root [$doc documentElement]

    dom createNodeCmd -tagName Relationship elementNode Tag_Relationship

    $root setAttribute xmlns http://schemas.openxmlformats.org/package/2006/relationships

    $root appendFromScript {
................................................................................
      if {$obj(sharedStrings) > 0} {
	Tag_Relationship Id rId[incr rId] Type http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings Target sharedStrings.xml {}
      }
      if {$obj(calcChain)} {
	Tag_Relationship Id rId[incr rId] Type http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain Target calcChain.xml {}
      }
    }




    # xl/sharedStrings.xml
    if {$obj(sharedStrings) > 0} {
      set doc [set obj(doc,xl/sharedStrings.xml) [dom createDocument sst]]
      set root [$doc documentElement]

      dom createNodeCmd textNode Text
      foreach tag {si t} {
	dom createNodeCmd -tagName $tag elementNode Tag_$tag
      }

................................................................................
      $root appendFromScript {
	foreach string $sharedStrings {
	  Tag_si {
	    Tag_t { Text $string }
	  }
	}
      }


    }


    # xl/calcChain.xml
    if {$obj(calcChain)} {
      set doc [set obj(doc,xl/calcChain.xml) [dom createDocument calcChain]]
      set root [$doc documentElement]

      dom createNodeCmd -tagName c elementNode Tag_c

      $root setAttribute xmlns http://schemas.openxmlformats.org/spreadsheetml/2006/main

      $root appendFromScript {
	Tag_c r C1 i 3 l 1 {}
	Tag_c r A3 i 2 {}
      }


    }


    # xl/styles.xml
    set doc [set obj(doc,xl/styles.xml) [dom createDocument styleSheet]]
    set root [$doc documentElement]

    foreach tag {alignment b bgColor border borders bottom cellStyle cellStyleXfs cellStyles cellXfs color diagonal dxfs family
                 fgColor fill fills font fonts i left name numFmt numFmts patternFill right scheme sz tableStyles top u xf} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }

................................................................................
      }
      Tag_cellStyles count 1 {
	Tag_cellStyle name Standard xfId 0 builtinId 0 {}
      }
      Tag_dxfs count 0 {}
      Tag_tableStyles count 0 {}
    }




    # xl/theme/theme1.xml
    set doc [set obj(doc,xl/theme/theme1.xml) [dom createDocument a:theme]]
    set root [$doc documentElement]

    foreach tag {a:accent1 a:accent2 a:accent3 a:accent4 a:accent5 a:accent6 a:alpha a:bevelT a:bgFillStyleLst a:bodyPr a:camera
		 a:clrScheme a:cs a:dk1 a:dk2 a:ea a:effectLst a:effectRef a:effectStyle a:effectStyleLst a:extraClrSchemeLst
		 a:fillRef a:fillStyleLst a:fillToRect a:fmtScheme a:folHlink a:font a:fontRef a:fontScheme a:gradFill a:gs a:gsLst
		 a:hlink a:latin a:lightRig a:lin a:ln a:lnDef a:lnRef a:lnStyleLst a:lstStyle a:lt1 a:lt2 a:majorFont a:minorFont
		 a:objectDefaults a:outerShdw a:path a:prstDash a:rot a:satMod a:scene3d a:schemeClr a:shade a:solidFill a:sp3d
................................................................................
	      Tag_a:schemeClr val tx1 {}
	    }
	  }
	}
      }
      Tag_a:extraClrSchemeLst {}
    }




    # xl/workbook.xml
    set doc [set obj(doc,xl/workbook.xml) [dom createDocument workbook]]
    set root [$doc documentElement]

    dom createNodeCmd textNode Text
    foreach tag {bookViews calcPr definedName definedNames fileVersion sheet sheets workbookPr workbookView} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }

................................................................................
	Tag_definedNames {
	  Tag_definedName name _xlnm._FilterDatabase localSheetId 0 hidden 1 { Text Blatt1!$A$1:$C$1 }
	}
      }
      Tag_calcPr calcId 140000 concurrentCalc 0 {}
      # fullCalcOnLoad 1
    }




    # xl/worksheets/sheet1.xml SHEET
    dom createNodeCmd textNode Text
    foreach tag {autoFilter c col cols dimension f mergeCell mergeCells pageMargins pane row sheetData sheetFormatPr sheetView sheetViews v} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }

    for {set ws 1} {$ws <= $obj(sheets)} {incr ws} {
      set doc [set obj(doc,xl/worksheets/sheet$ws.xml) [dom createDocument worksheet]]
      set root [$doc documentElement]
      $root setAttribute xmlns http://schemas.openxmlformats.org/spreadsheetml/2006/main
      $root setAttribute xmlns:r http://schemas.openxmlformats.org/officeDocument/2006/relationships
      $root setAttribute xmlns:mc http://schemas.openxmlformats.org/markup-compatibility/2006
      $root setAttribute xmlns:x14ac http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac
      $root setAttribute mc:Ignorable x14ac

................................................................................
		lappend attr customWidth [dict get $cols($idx) customwidth]
	      }
	      Tag_col {*}$attr {}
	    }
	  }
	}
      }


    }

    # Content-Type application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    set file [string trim $file]
    if {$file eq {}} {
      set file {spreadsheetml.xlsx}
    }
    if {[file extension $file] ne {.xlsx}} {
      append file {.xlsx}
    }
    if {[catch {set zf [open $file w]}]} {
      error "Unable to write $file"
    }
    fconfigure $zf \
        -encoding    binary \
        -translation binary \
        -eofchar     {}
    set count 0
    set cd ""
    foreach {tag doc} [array get obj doc,*] {
      append cd [::ooxml::add_str_to_archive $zf \
                     [lindex [split $tag ,] 1] \
                     [[$doc documentElement] asXML \
                          -indent $obj(indent) -xmlDeclaration 1 \
                          -encString [string toupper $obj(encoding)]]]
      incr count
      $doc delete
    }
    set cdoffset [tell $zf]
    set endrec [binary format a4ssssiis PK\05\06 0 0 \
                    $count $count [string length $cd] $cdoffset 0]
    puts -nonewline $zf $cd
    puts -nonewline $zf $endrec
    close $zf
    return 0







>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|













>
>

<

|







 







>
>

<

|







 







>
>

<

|







 







>
>

<

|







 







>
>




|







 







>
>





|










>
>




|







 







>
>



|







 







>
>



|







 







>
>









|







 







>
>


<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
....
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
....
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327

2328
2329
2330
2331
2332
2333
2334
2335
2336
....
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358

2359
2360
2361
2362
2363
2364
2365
2366
2367
....
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403

2404
2405
2406
2407
2408
2409
2410
2411
2412
....
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427

2428
2429
2430
2431
2432
2433
2434
2435
2436
....
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
....
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
....
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
....
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
....
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
....
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126


3127























3128
3129
3130
3131
3132
3133
3134
    if {$column > $wb($sheet,max_column)} {
      set wb($sheet,max_column) $column
    }
  }
  return [array get wb]
}

# Internal helper
proc ooxml::Dom2zip {zf node path cd count} {
  upvar $cd mycd
  upvar $count mycount
  append mycd [::ooxml::add_str_to_archive $zf $path \
                   [$node asXML -indent none -xmlDeclaration 1 \
                        -encString "UTF-8"]]
  incr mycount
}

#
# ooxml::xl_write
#


oo::class create ooxml::xl_write {
................................................................................
    my variable borders
    my variable cols

    if {[::ooxml::Getopt opts {holdcontainerdirectory} $args]} {
      error $opts(-errmsg)
    }

    # Initialize zip file
    set file [string trim $file]
    if {$file eq {}} {
      set file {spreadsheetml.xlsx}
    }
    if {[file extension $file] ne {.xlsx}} {
      append file {.xlsx}
    }
    if {[catch {set zf [open $file w]}]} {
      error "Unable to write $file"
    }
    fconfigure $zf \
        -encoding    binary \
        -translation binary \
        -eofchar     {}
    set count 0
    set cd ""
    
    foreach {n v} [array get cells] {
      if {[dict exists $v t] && [dict get $v t] eq {s} && [dict exists $v v] && [dict get $v v] ne {}} {
        set thisv [dict get $v v]
        if {[info exists lookup($thisv)]} {
          set pos $lookup($thisv)
        } else {
          set pos [llength $sharedStrings]
................................................................................
	dict set cells($n) v $pos
      }
    }
    unset -nocomplain n v
    array unset lookup
    
    # _rels/.rels
    set doc [dom createDocument Relationships]
    set root [$doc documentElement]

    set rId 0

    dom createNodeCmd -tagName Relationship elementNode Tag_Relationship

    $root setAttribute xmlns http://schemas.openxmlformats.org/package/2006/relationships

    $root appendFromScript {
      Tag_Relationship Id rId1 Type http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument Target xl/workbook.xml {}
      Tag_Relationship Id rId2 Type http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties Target docProps/app.xml {}
      Tag_Relationship Id rId3 Type http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties Target docProps/core.xml {}
    }
    ::ooxml::Dom2zip $zf $root "_rels/.rels" cd count
    $doc delete


    # [Content_Types].xml
    set doc [dom createDocument Types]
    set root [$doc documentElement]

    foreach tag {Default Override} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }

    $root setAttribute xmlns http://schemas.openxmlformats.org/package/2006/content-types
................................................................................
      }
      if {$obj(calcChain)} {
	Tag_Override PartName /xl/calcChain.xml ContentType application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml {}
      }
      Tag_Override PartName /docProps/core.xml ContentType application/vnd.openxmlformats-package.core-properties+xml {}
      Tag_Override PartName /docProps/app.xml ContentType application/vnd.openxmlformats-officedocument.extended-properties+xml {}
    }
    ::ooxml::Dom2zip $zf $root "\[Content_Types\].xml" cd count
    $doc delete


    # docProps/app.xml
    set doc [set obj(doc,) [dom createDocument Properties]]
    set root [$doc documentElement]

    dom createNodeCmd textNode Text
    foreach tag {AppVersion Application Company DocSecurity HeadingPairs HyperlinksChanged LinksUpToDate ScaleCrop SharedDoc TitlesOfParts
                 vt:i4 vt:lpstrvt:lpstr vt:lpstr vt:variant vt:vector} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }
................................................................................
      }
      Tag_Company {}
      Tag_LinksUpToDate { Text false }
      Tag_SharedDoc { Text false }
      Tag_HyperlinksChanged { Text false }
      Tag_AppVersion { Text 1.0 }
    }
    ::ooxml::Dom2zip $zf $root "docProps/app.xml" cd count
    $doc delete


    # docProps/core.xml
    set doc [dom createDocument cp:coreProperties]
    set root [$doc documentElement]

    dom createNodeCmd textNode Text
    foreach tag {cp:lastModifiedBy dc:creator dcterms:created dcterms:modified} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }

................................................................................

    $root appendFromScript {
      Tag_dc:creator { Text $obj(creator) }
      Tag_cp:lastModifiedBy { Text $obj(lastModifiedBy) }
      Tag_dcterms:created xsi:type dcterms:W3CDTF { Text $obj(created) }
      Tag_dcterms:modified xsi:type dcterms:W3CDTF { Text $obj(modified) }
    }
    ::ooxml::Dom2zip $zf $root "docProps/core.xml" cd count
    $doc delete


    # xl/_rels/workbook.xml.rels
    set doc [dom createDocument Relationships]
    set root [$doc documentElement]

    dom createNodeCmd -tagName Relationship elementNode Tag_Relationship

    $root setAttribute xmlns http://schemas.openxmlformats.org/package/2006/relationships

    $root appendFromScript {
................................................................................
      if {$obj(sharedStrings) > 0} {
	Tag_Relationship Id rId[incr rId] Type http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings Target sharedStrings.xml {}
      }
      if {$obj(calcChain)} {
	Tag_Relationship Id rId[incr rId] Type http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain Target calcChain.xml {}
      }
    }
    ::ooxml::Dom2zip $zf $root "xl/_rels/workbook.xml.rels" cd count
    $doc delete


    # xl/sharedStrings.xml
    if {$obj(sharedStrings) > 0} {
      set doc [dom createDocument sst]
      set root [$doc documentElement]

      dom createNodeCmd textNode Text
      foreach tag {si t} {
	dom createNodeCmd -tagName $tag elementNode Tag_$tag
      }

................................................................................
      $root appendFromScript {
	foreach string $sharedStrings {
	  Tag_si {
	    Tag_t { Text $string }
	  }
	}
      }
      ::ooxml::Dom2zip $zf $root "xl/sharedStrings.xml" cd count
      $doc delete
    }


    # xl/calcChain.xml
    if {$obj(calcChain)} {
      set doc [dom createDocument calcChain]
      set root [$doc documentElement]

      dom createNodeCmd -tagName c elementNode Tag_c

      $root setAttribute xmlns http://schemas.openxmlformats.org/spreadsheetml/2006/main

      $root appendFromScript {
	Tag_c r C1 i 3 l 1 {}
	Tag_c r A3 i 2 {}
      }
      ::ooxml::Dom2zip $zf $root "xl/calcChain.xml" cd count
      $doc delete
    }


    # xl/styles.xml
    set doc [dom createDocument styleSheet]
    set root [$doc documentElement]

    foreach tag {alignment b bgColor border borders bottom cellStyle cellStyleXfs cellStyles cellXfs color diagonal dxfs family
                 fgColor fill fills font fonts i left name numFmt numFmts patternFill right scheme sz tableStyles top u xf} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }

................................................................................
      }
      Tag_cellStyles count 1 {
	Tag_cellStyle name Standard xfId 0 builtinId 0 {}
      }
      Tag_dxfs count 0 {}
      Tag_tableStyles count 0 {}
    }
    ::ooxml::Dom2zip $zf $root "xl/styles.xml" cd count
    $doc delete


    # xl/theme/theme1.xml
    set doc [dom createDocument a:theme]
    set root [$doc documentElement]

    foreach tag {a:accent1 a:accent2 a:accent3 a:accent4 a:accent5 a:accent6 a:alpha a:bevelT a:bgFillStyleLst a:bodyPr a:camera
		 a:clrScheme a:cs a:dk1 a:dk2 a:ea a:effectLst a:effectRef a:effectStyle a:effectStyleLst a:extraClrSchemeLst
		 a:fillRef a:fillStyleLst a:fillToRect a:fmtScheme a:folHlink a:font a:fontRef a:fontScheme a:gradFill a:gs a:gsLst
		 a:hlink a:latin a:lightRig a:lin a:ln a:lnDef a:lnRef a:lnStyleLst a:lstStyle a:lt1 a:lt2 a:majorFont a:minorFont
		 a:objectDefaults a:outerShdw a:path a:prstDash a:rot a:satMod a:scene3d a:schemeClr a:shade a:solidFill a:sp3d
................................................................................
	      Tag_a:schemeClr val tx1 {}
	    }
	  }
	}
      }
      Tag_a:extraClrSchemeLst {}
    }
    ::ooxml::Dom2zip $zf $root "xl/theme/theme1.xml" cd count
    $doc delete


    # xl/workbook.xml
    set doc [dom createDocument workbook]
    set root [$doc documentElement]

    dom createNodeCmd textNode Text
    foreach tag {bookViews calcPr definedName definedNames fileVersion sheet sheets workbookPr workbookView} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }

................................................................................
	Tag_definedNames {
	  Tag_definedName name _xlnm._FilterDatabase localSheetId 0 hidden 1 { Text Blatt1!$A$1:$C$1 }
	}
      }
      Tag_calcPr calcId 140000 concurrentCalc 0 {}
      # fullCalcOnLoad 1
    }
    ::ooxml::Dom2zip $zf $root "xl/workbook.xml" cd count
    $doc delete


    # xl/worksheets/sheet1.xml SHEET
    dom createNodeCmd textNode Text
    foreach tag {autoFilter c col cols dimension f mergeCell mergeCells pageMargins pane row sheetData sheetFormatPr sheetView sheetViews v} {
      dom createNodeCmd -tagName $tag elementNode Tag_$tag
    }

    for {set ws 1} {$ws <= $obj(sheets)} {incr ws} {
      set doc [dom createDocument worksheet]
      set root [$doc documentElement]
      $root setAttribute xmlns http://schemas.openxmlformats.org/spreadsheetml/2006/main
      $root setAttribute xmlns:r http://schemas.openxmlformats.org/officeDocument/2006/relationships
      $root setAttribute xmlns:mc http://schemas.openxmlformats.org/markup-compatibility/2006
      $root setAttribute xmlns:x14ac http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac
      $root setAttribute mc:Ignorable x14ac

................................................................................
		lappend attr customWidth [dict get $cols($idx) customwidth]
	      }
	      Tag_col {*}$attr {}
	    }
	  }
	}
      }
      ::ooxml::Dom2zip $zf $root "xl/worksheets/sheet$ws.xml" cd count
      $doc delete
    }



    # Finalize zip.























    set cdoffset [tell $zf]
    set endrec [binary format a4ssssiis PK\05\06 0 0 \
                    $count $count [string length $cd] $cdoffset 0]
    puts -nonewline $zf $cd
    puts -nonewline $zf $endrec
    close $zf
    return 0