ooxml

Check-in [1c847e5dfb]
Login

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

Overview
Comment:xl_read read formula patch; formatcell.test added cell data check
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tcltest
Files: files | file ages | folders
SHA3-256: 1c847e5dfb3599ebdd049adb880697b26ab0c97d2d750c2924544a722105fe4c
User & Date: alex 2019-11-28 14:20:01
Original Comment: xl_read read formular patch; formatcell.test added cell data check
Context
2019-11-28
14:21
enable benchmark Closed-Leaf check-in: 8fa48338f7 user: alex tags: tcltest
14:20
xl_read read formula patch; formatcell.test added cell data check check-in: 1c847e5dfb user: alex tags: tcltest
09:03
formatcell.test rowheight and merge; patch preset styles after idx change check-in: d330abd2a3 user: alex tags: tcltest
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ooxml.tcl.

1236
1237
1238
1239
1240
1241
1242







1243
1244
1245
1246
1247
1248
1249
....
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
	  if {[$cell hasAttribute t]} {
	    set type [$cell @t]
	  } else {
	    set type n
	  }
	  set value {}
	  set datetime {}







	  switch -- $type {
	    n - b - d - str {
	      # number (default), boolean, iso-date, formula string
	      if {[set node [$cell selectNodes M:v/text()]] ne {}} {
		set value [$node nodeValue]
		if {$type eq {n} && [$cell hasAttribute s] && [string is double -strict $value]} {
		  set idx [$cell @s]
................................................................................
		set wb($sheet,t,[StringToRowColumn [$cell @r]]) [$cell @t]
	      }
	    }
	    set wb($sheet,v,[StringToRowColumn [$cell @r]]) $value
	    if {!$opts(valuesonly) && $datetime ne {}} {
	      set wb($sheet,d,[StringToRowColumn [$cell @r]]) $datetime
	    }
	    if {!$opts(valuesonly) && [set node [$cell selectNodes M:f/text()]] ne {}} {
	      set wb($sheet,f,[StringToRowColumn [$cell @r]]) [$node nodeValue]
	    }
	  }
	}
	if {!$opts(valuesonly)} {
	  foreach row [$root selectNodes /M:worksheet/M:sheetData/M:row] {
	    if {[$row hasAttribute r] && [$row hasAttribute ht] && [$row hasAttribute customHeight] && [$row @customHeight] == 1} {
	      dict set wb($sheet,rowheight) [expr {[$row @r] - 1}] [$row @ht]
	    }
	  }
	}







>
>
>
>
>
>
>







 







<
<
|
|
|







1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
....
1309
1310
1311
1312
1313
1314
1315


1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
	  if {[$cell hasAttribute t]} {
	    set type [$cell @t]
	  } else {
	    set type n
	  }
	  set value {}
	  set datetime {}

	  if {[$cell hasAttribute r]} {
	    if {!$opts(valuesonly) && [set node [$cell selectNodes M:f/text()]] ne {}} {
	      set wb($sheet,f,[StringToRowColumn [$cell @r]]) [$node nodeValue]
	    }
	  }

	  switch -- $type {
	    n - b - d - str {
	      # number (default), boolean, iso-date, formula string
	      if {[set node [$cell selectNodes M:v/text()]] ne {}} {
		set value [$node nodeValue]
		if {$type eq {n} && [$cell hasAttribute s] && [string is double -strict $value]} {
		  set idx [$cell @s]
................................................................................
		set wb($sheet,t,[StringToRowColumn [$cell @r]]) [$cell @t]
	      }
	    }
	    set wb($sheet,v,[StringToRowColumn [$cell @r]]) $value
	    if {!$opts(valuesonly) && $datetime ne {}} {
	      set wb($sheet,d,[StringToRowColumn [$cell @r]]) $datetime
	    }


	  }
	}

	if {!$opts(valuesonly)} {
	  foreach row [$root selectNodes /M:worksheet/M:sheetData/M:row] {
	    if {[$row hasAttribute r] && [$row hasAttribute ht] && [$row hasAttribute customHeight] && [$row @customHeight] == 1} {
	      dict set wb($sheet,rowheight) [expr {[$row @r] - 1}] [$row @ht]
	    }
	  }
	}

Changes to tests/benchmark.test.

34
35
36
37
38
39
40

41
42
43
44
45
46
47
..
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    incr row
  }
  $spreadsheet write "$rows-$cols.xlsx"
  $spreadsheet destroy
}



test Benchmark-1.1 {benchmark cell generating} {
  set rc 1

  set list {msec per cell}
  set first -1
  foreach {rows cols} { 500 10 1000 10 3000 10 5000 10 } {
    set msec [lindex [time {doit $rows $cols}] 0]
................................................................................
      puts $list
      set rc 0
    }
  }

  return $rc
} 1


file delete -force 500-10.xlsx 1000-10.xlsx 3000-10.xlsx 5000-10.xlsx


# cleanup
::tcltest::cleanupTests
return








>







 







|








34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
    incr row
  }
  $spreadsheet write "$rows-$cols.xlsx"
  $spreadsheet destroy
}


if 0 {
test Benchmark-1.1 {benchmark cell generating} {
  set rc 1

  set list {msec per cell}
  set first -1
  foreach {rows cols} { 500 10 1000 10 3000 10 5000 10 } {
    set msec [lindex [time {doit $rows $cols}] 0]
................................................................................
      puts $list
      set rc 0
    }
  }

  return $rc
} 1
}

file delete -force 500-10.xlsx 1000-10.xlsx 3000-10.xlsx 5000-10.xlsx


# cleanup
::tcltest::cleanupTests
return

Changes to tests/formatcell.test.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004

























1005
1006
1007
1008
1009
1010
1011
1012
  package require tcltest 2
  namespace import -force ::tcltest::*
  loadTestedCommands
}


package require ooxml
package require vfs::zip


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} {
................................................................................
  }
  return $rc
} 1

test FormatCellCheckRowHeight-10.5 {Check Worksheet RowHeight} {
  set rc 1
  array set w $w_obj(rowHeight,1)
  array set r $workbook(0,rowHeight)
  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


#catch {vfs::zip::Mount formatcell.xlsx xlsx} mnt
#vfs::zip::Unmount $mnt xlsx


























file delete -force formatcell.xlsx


# cleanup
::tcltest::cleanupTests
return








<







 







|










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








13
14
15
16
17
18
19

20
21
22
23
24
25
26
...
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
  package require tcltest 2
  namespace import -force ::tcltest::*
  loadTestedCommands
}


package require ooxml



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} {
................................................................................
  }
  return $rc
} 1

test FormatCellCheckRowHeight-10.5 {Check Worksheet RowHeight} {
  set rc 1
  array set w $w_obj(rowHeight,1)
  array set r $workbook(0,rowheight)
  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


test FormatCellCheckRowHeight-10.5 {Check Worksheet RowHeight} {
  set rc 1
  foreach item [lsort -dictionary [array names w_cells 1,*,*]] {
    lassign [split $item ,] sheet row col
    incr sheet -1
    array set w $w_cells($item)
    array unset w t
    array set r {}
    foreach tag {f s t v d} {
      if {[info exists workbook($sheet,$tag,$row,$col)]} {
	if {$tag eq {d}} {
	  # overwrite datetime string with ole date
	  array set r [list v $workbook($sheet,$tag,$row,$col)]
	} else {
	  array set r [list $tag $workbook($sheet,$tag,$row,$col)]
	}
      }
    }
    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