ooxml

Check-in [96bb2a2b4e]
Login

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

Overview
Comment:merged from bookview
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 96bb2a2b4e85ff2a1cd9b05f08173d2542d7a7f5a1d73eb8828e6116544ba653
User & Date: alex 2019-12-09 16:19:56
Context
2019-12-09
16:40
renumber some tests check-in: b330c7df2e user: alex tags: trunk
16:19
merged from bookview check-in: 96bb2a2b4e user: alex tags: trunk
16:13
view -x, -y, -height and/or -width; FR [7c58a9aac7]; Units are TWIPS: twentieths of a point = 36 points = 0.5 inches Closed-Leaf check-in: 442d25a964 user: alex tags: bookview
2019-12-06
22:05
fixed an error when using more than one sheet; reported by Steve Landers [c59ca15507] check-in: 9d6b3a0149 user: alex tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ooxml.tcl.

148
149
150
151
152
153
154



155
156
157
158
159
160
161
...
906
907
908
909
910
911
912

















913
914
915
916
917
918
919
....
1485
1486
1487
1488
1489
1490
1491

1492
1493
1494
1495
1496
1497
1498
....
1577
1578
1579
1580
1581
1582
1583


1584
1585
1586
1587
1588
1589
1590
....
2498
2499
2500
2501
2502
2503
2504













































2505
2506
2507
2508
2509
2510
2511
....
2519
2520
2521
2522
2523
2524
2525

2526
2527
2528
2529
2530
2531
2532
....
3283
3284
3285
3286
3287
3288
3289

























3290
3291
3292
3293
3294
3295
3296
3297
# 
#   method freeze sheet index
# 
#   method presetstyles
#
#   method presetsheets
#



#   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
................................................................................
	  set rid [$node getAttributeNS $xmlns(r) id]
	  foreach node [$relsRoot selectNodes {/PR:Relationships/PR:Relationship[@Id=$rid]}] {
	    if {[$node hasAttribute Target]} {
	      lappend sheets [incr idx] $sheetId $name $rid [$node @Target]
	    }
	  }
	}

















      }
      $doc delete
    }
    close $fd
  }

  if {$rels} {
................................................................................
    my variable sharedStrings
    my variable fonts
    my variable numFmts
    my variable styles
    my variable fills
    my variable borders
    my variable cols


    array set opts {
      creator {unknown}
      created {}
      modifiedby {}
      modified {}
      application {}
................................................................................
    array set cols {}

    set obj(calcChain) 0

    set obj(defaultdatestyle) 0

    array set cells {}



    return 0
  }

  destructor {
    return 0
  }
................................................................................
	    foreach item $a($sheet,merge) {
	      my merge $currentSheet {*}[split $item :]
	    }
	  }
	}
      }
    }













































  }

  method debug { args } {
    foreach item $args {
      catch {
	my variable $item
	parray $item
................................................................................
    my variable sharedStrings
    my variable fonts
    my variable numFmts
    my variable styles
    my variable fills
    my variable borders
    my variable cols


    upvar #0 ::ooxml::xmlns xmlns

    ooxml::InitNodeCommands
    namespace import ::ooxml::Tag_* ::ooxml::Text

    # Initialize zip file
................................................................................
    $root setAttribute xmlns $xmlns(M)
    $root setAttribute xmlns:r $xmlns(r)

    $root appendFromScript {
      Tag_fileVersion appName xl lastEdited 5 lowestEdited 5 rupBuild 5000 {}
      Tag_workbookPr showInkAnnotation 0 autoCompressPictures 0 {}
      Tag_bookViews {

























	Tag_workbookView activeTab 1 {}
      }
      Tag_sheets {
	for {set ws 1} {$ws <= $obj(sheets)} {incr ws} {
	  Tag_sheet name $obj(sheet,$ws) sheetId $ws r:id rId$ws {}
	}
      }
      if {0} {







>
>
>







 







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







 







>







 







>
>







 







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







 







>







 







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







148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
...
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
....
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
....
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
....
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
....
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
....
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
# 
#   method freeze sheet index
# 
#   method presetstyles
#
#   method presetsheets
#
#   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
................................................................................
	  set rid [$node getAttributeNS $xmlns(r) id]
	  foreach node [$relsRoot selectNodes {/PR:Relationships/PR:Relationship[@Id=$rid]}] {
	    if {[$node hasAttribute Target]} {
	      lappend sheets [incr idx] $sheetId $name $rid [$node @Target]
	    }
	  }
	}
      }
      foreach node [$root selectNodes /M:workbook/M:bookViews/M:workbookView] {
        if {[$node hasAttribute activeTab]} {
	  lappend wb(view) activetab [$node @activeTab]
	}
        if {[$node hasAttribute xWindow]} {
	  lappend wb(view) x [$node @xWindow]
	}
        if {[$node hasAttribute yWindow]} {
	  lappend wb(view) y [$node @yWindow]
	}
        if {[$node hasAttribute windowHeight]} {
	  lappend wb(view) height [$node @windowHeight]
	}
        if {[$node hasAttribute windowWidth]} {
	  lappend wb(view) width [$node @windowWidth]
	}
      }
      $doc delete
    }
    close $fd
  }

  if {$rels} {
................................................................................
    my variable sharedStrings
    my variable fonts
    my variable numFmts
    my variable styles
    my variable fills
    my variable borders
    my variable cols
    my variable view

    array set opts {
      creator {unknown}
      created {}
      modifiedby {}
      modified {}
      application {}
................................................................................
    array set cols {}

    set obj(calcChain) 0

    set obj(defaultdatestyle) 0

    array set cells {}

    array set view {activetab 0}

    return 0
  }

  destructor {
    return 0
  }
................................................................................
	    foreach item $a($sheet,merge) {
	      my merge $currentSheet {*}[split $item :]
	    }
	  }
	}
      }
    }

    if {[info exists a(view)]} {
      foreach item {activetab} {
        if {[dict exists $a(view) $item]} {
	  my view -$item [dict get $a(view) $item]
	}
      }
    }
  }

  method view { args } {
    my variable view

    array set opts {
      list 0
    }

    set len [llength $args]
    set idx 0
    for {set idx 0} {$idx < $len} {incr idx} {
      switch -- [set opt [lindex $args $idx]] {
        -activetab - -x - -y - -height - -width {
	  incr idx
          if {$idx < $len} {
	    if {[string is integer -strict [lindex $args $idx]] && [lindex $args $idx] > -1} {
	      set view([string range $opt 1 end]) [lindex $args $idx]
	    } else {
	      error "option '$opt': must be a positive integer"
	    }
          } else {
            error "option '$opt': missing argument"
          }            
        }
        -list {
	  set opts([string range $opt 1 end]) 1
        }
        default {
          error "unknown option \"$opt\", should be: -activetab, -x, -y, -height, -width or -list"
        }
      }
    }

    if {$opts(list)} {
      return [array get view]
    }
  }

  method debug { args } {
    foreach item $args {
      catch {
	my variable $item
	parray $item
................................................................................
    my variable sharedStrings
    my variable fonts
    my variable numFmts
    my variable styles
    my variable fills
    my variable borders
    my variable cols
    my variable view

    upvar #0 ::ooxml::xmlns xmlns

    ooxml::InitNodeCommands
    namespace import ::ooxml::Tag_* ::ooxml::Text

    # Initialize zip file
................................................................................
    $root setAttribute xmlns $xmlns(M)
    $root setAttribute xmlns:r $xmlns(r)

    $root appendFromScript {
      Tag_fileVersion appName xl lastEdited 5 lowestEdited 5 rupBuild 5000 {}
      Tag_workbookPr showInkAnnotation 0 autoCompressPictures 0 {}
      Tag_bookViews {
	set attr {}
	foreach {n v} [array get view] {
	  switch -- $n {
	    activetab {
	      if {$v ni $obj(sheets)} {
	        set v 0
	      }
	      lappend attr activeTab $v
	    }
	    x {
	      lappend attr xWindow $v
	    }
	    y {
	      lappend attr yWindow $v
	    }
	    height {
	      lappend attr windowHeight $v
	    }
	    width {
	      lappend attr windowWidth $v
	    }
	    default {
	    }
	  }
	}
	Tag_workbookView {*}$attr {}
      }
      Tag_sheets {
	for {set ws 1} {$ws <= $obj(sheets)} {incr ws} {
	  Tag_sheet name $obj(sheet,$ws) sheetId $ws r:id rId$ws {}
	}
      }
      if {0} {

Changes to tests/formatcell.test.

22
23
24
25
26
27
28




29
30
31
32
33
34
35
...
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
....
1023
1024
1025
1026
1027
1028
1029
1030
1031















1032
1033
1034
1035
1036
test FormatCellNewSpreatsheet-1.1 {Create New Spreadsheet} -body {
  set spreadsheet [::ooxml::xl_write new -creator {Alexander Schöpe}]
} -result {::oo::Obj*} -match glob

test FormatCellNewWorksheet-1.2 {Create New Worksheet} {
  set sheet [$spreadsheet worksheet {Blatt 1}]
} 1





test FormatCellNewStyle-2.1 {New Style} {
  set bold [$spreadsheet style -font [$spreadsheet font -bold]]
} 1

test FormatCellNewStyle-2.2 {New Style} {
  set italic [$spreadsheet style -font [$spreadsheet font -italic]]
................................................................................
} 0

test FormatCellMerge-7.1 {Merge} {
  $spreadsheet merge $sheet 39,3 42,5
} 0


foreach item {obj cells fonts numFmts styles fills borders cols} {
  array set w_$item [array get ${spreadsheet}::$item]
}


test FormatCellWriteSpreatsheet-8.1 {Write Spreatsheet} {
  $spreadsheet write formatcell.xlsx
} 0
................................................................................
      }
    }
    unset -nocomplain w r
  }
  return $rc
} 1

file delete -force formatcell.xlsx

















# cleanup
::tcltest::cleanupTests
return








>
>
>
>







 







|







 







<

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





22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
...
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
....
1027
1028
1029
1030
1031
1032
1033

1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
test FormatCellNewSpreatsheet-1.1 {Create New Spreadsheet} -body {
  set spreadsheet [::ooxml::xl_write new -creator {Alexander Schöpe}]
} -result {::oo::Obj*} -match glob

test FormatCellNewWorksheet-1.2 {Create New Worksheet} {
  set sheet [$spreadsheet worksheet {Blatt 1}]
} 1

test FormatCellView-1.3 {Set View} {
  $spreadsheet view -activetab 0 -x 2200 -y 2760 -height 8140 -width 15140
} {}

test FormatCellNewStyle-2.1 {New Style} {
  set bold [$spreadsheet style -font [$spreadsheet font -bold]]
} 1

test FormatCellNewStyle-2.2 {New Style} {
  set italic [$spreadsheet style -font [$spreadsheet font -italic]]
................................................................................
} 0

test FormatCellMerge-7.1 {Merge} {
  $spreadsheet merge $sheet 39,3 42,5
} 0


foreach item {obj cells fonts numFmts styles fills borders cols view} {
  array set w_$item [array get ${spreadsheet}::$item]
}


test FormatCellWriteSpreatsheet-8.1 {Write Spreatsheet} {
  $spreadsheet write formatcell.xlsx
} 0
................................................................................
      }
    }
    unset -nocomplain w r
  }
  return $rc
} 1



test FormatCellCheckView-11.1 {Check View} {
  set rc 1
  array set w [array get w_view]
  array set r $workbook(view)
  foreach {n v} [array get w] {
    if {![info exists r($n)] || $r($n) ne $v} {
      set rc 0
    }
  }
  unset -nocomplain w r
  return $rc
} 1


file delete -force formatcell.xlsx

# cleanup
::tcltest::cleanupTests
return