970
971
972
973
974
975
976
977
978
979
980
981
982
983
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
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
|
972
973
974
975
976
977
978
979
980
981
982
983
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
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
|
+
+
-
+
-
-
-
-
+
+
+
+
-
+
+
-
+
-
+
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
set rels 0
if {![catch {open xlsx/xl/_rels/workbook.xml.rels r} fd]} {
fconfigure $fd -encoding utf-8
if {![catch {dom parse [read $fd]} rdoc]} {
set rels 1
set relsroot [$rdoc documentElement]
$rdoc selectNodesNamespaces [list X [$relsroot namespaceURI]]
}
close $fd
}
if {![catch {open xlsx/xl/workbook.xml r} fd]} {
fconfigure $fd -encoding utf-8
if {![catch {dom parse [read $fd]} doc]} {
set root [$doc documentElement]
$doc selectNodesNamespaces [list X [$root namespaceURI]]
set idx -1
foreach node [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:workbook/X:sheets/X:sheet}] {
foreach node [$root selectNodes /X:workbook/X:sheets/X:sheet] {
if {[$node hasAttribute sheetId] && [$node hasAttribute name]} {
set sheetId [$node getAttribute sheetId]
set name [$node getAttribute name]
set rid [$node getAttribute r:id]
foreach node [$relsroot selectNodes -namespaces [list X [$relsroot namespaceURI]] [subst -nobackslashes -nocommands {/X:Relationships/X:Relationship[@Id="$rid"]}]] {
set sheetId [$node @sheetId]
set name [$node @name]
set rid [$node @r:id]
foreach node [$relsroot selectNodes {/X:Relationships/X:Relationship[@Id=$rid]}] {
if {[$node hasAttribute Target]} {
lappend sheets [incr idx] $sheetId $name $rid [$node getAttribute Target]
lappend sheets [incr idx] $sheetId $name $rid [$node @Target]
}
}
}
}
$doc delete
}
close $fd
}
if {$rels} {
$rdoc delete
}
if {![catch {open xlsx/xl/sharedStrings.xml r} fd]} {
fconfigure $fd -encoding utf-8
if {![catch {dom parse [read $fd]} doc]} {
set root [$doc documentElement]
$doc selectNodesNamespaces [list X [$root namespaceURI]]
set idx -1
foreach shared [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:sst/X:si}] {
foreach shared [$root selectNodes /X:sst/X:si] {
incr idx
foreach node [$shared selectNodes -namespaces [list X [$shared namespaceURI]] {X:t/text()}] {
foreach node [$shared selectNodes X:t/text()] {
append sharedStrings($idx) [$node nodeValue]
}
foreach node [$shared selectNodes -namespaces [list X [$shared namespaceURI]] {*/X:t/text()}] {
foreach node [$shared selectNodes */X:t/text()] {
append sharedStrings($idx) [$node nodeValue]
}
}
$doc delete
}
close $fd
}
if {![catch {open xlsx/xl/styles.xml r} fd]} {
fconfigure $fd -encoding utf-8
if {![catch {dom parse [read $fd]} doc]} {
set root [$doc documentElement]
$doc selectNodesNamespaces [list X [$root namespaceURI]]
set idx -1
foreach node [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:styleSheet/X:numFmts/X:numFmt}] {
foreach node [$root selectNodes /X:styleSheet/X:numFmts/X:numFmt] {
incr idx
if {[$node hasAttribute numFmtId] && [$node hasAttribute formatCode]} {
set numFmtId [$node getAttribute numFmtId]
set formatCode [$node getAttribute formatCode]
set numFmtId [$node @numFmtId]
set formatCode [$node @formatCode]
set datetime 0
foreach tag {*y* *m* *d* *h* *s*} {
if {[string match -nocase $tag [string map {Black {} Blue {} Cyan {} Green {} Magenta {} Red {} White {} Yellow {}} $formatCode]]} {
set datetime 1
break
}
}
set numFmts($numFmtId) [list dt $datetime fmt $formatCode]
}
}
set idx -1
foreach node [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:styleSheet/X:cellXfs/X:xf}] {
foreach node [$root selectNodes /X:styleSheet/X:cellXfs/X:xf] {
incr idx
if {[$node hasAttribute numFmtId]} {
set numFmtId [$node getAttribute numFmtId]
set numFmtId [$node @numFmtId]
if {[$node hasAttribute applyNumberFormat]} {
set applyNumberFormat [$node getAttribute applyNumberFormat]
set applyNumberFormat [$node @applyNumberFormat]
} else {
set applyNumberFormat 0
}
set cellXfs($idx) [list nfi $numFmtId anf $applyNumberFormat]
}
}
### READING KNOWN FORMATS AND STYLES ###
set wb(s,@) {}
array unset a *
set a(max) 0
set wb(s,numFmtsIds) {}
foreach node [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:styleSheet/X:numFmts/X:numFmt}] {
foreach node [$root selectNodes /X:styleSheet/X:numFmts/X:numFmt] {
if {[$node hasAttribute numFmtId] && [$node hasAttribute formatCode]} {
set wb(s,numFmts,[set idx [$node getAttribute numFmtId]]) [$node getAttribute formatCode]
set wb(s,numFmts,[set idx [$node @numFmtId]]) [$node @formatCode]
lappend wb(s,numFmtsIds) $idx
if {$idx > $a(max)} {
set a(max) $idx
}
}
}
if {$a(max) < $::ooxml::defaults(numFmts,start)} {
set a(max) $::ooxml::defaults(numFmts,start)
}
lappend wb(s,@) numFmtId [incr a(max)]
set idx -1
array unset a *
foreach node [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:styleSheet/X:fonts/X:font}] {
foreach node [$root selectNodes /X:styleSheet/X:fonts/X:font] {
incr idx
array set a {name {} family {} size {} color {} scheme {} bold 0 italic 0 underline 0 color {}}
foreach node1 [$node childNodes] {
switch -- [$node1 nodeName] {
b {
set a(bold) 1
}
i {
set a(italic) 1
}
u {
set a(underline) 1
}
sz {
if {[$node1 hasAttribute val]} {
set a(size) [$node1 getAttribute val]
set a(size) [$node1 @val]
}
}
color {
if {[$node1 hasAttribute auto]} {
set a(color) [list auto [$node1 getAttribute auto]]
set a(color) [list auto [$node1 @auto]]
} elseif {[$node1 hasAttribute rgb]} {
set a(color) [list rgb [$node1 getAttribute rgb]]
set a(color) [list rgb [$node1 @rgb]]
} elseif {[$node1 hasAttribute indexed]} {
set a(color) [list indexed [$node1 getAttribute indexed]]
set a(color) [list indexed [$node1 @indexed]]
} elseif {[$node1 hasAttribute theme]} {
set a(color) [list theme [$node1 getAttribute theme]]
set a(color) [list theme [$node1 @theme]]
}
}
name {
if {[$node1 hasAttribute val]} {
set a(name) [$node1 getAttribute val]
set a(name) [$node1 @val]
}
}
family {
if {[$node1 hasAttribute val]} {
set a(family) [$node1 getAttribute val]
set a(family) [$node1 @val]
}
}
scheme {
if {[$node1 hasAttribute val]} {
set a(scheme) [$node1 getAttribute val]
set a(scheme) [$node1 @val]
}
}
}
}
set wb(s,fonts,$idx) [array get a]
}
lappend wb(s,@) fonts [incr idx]
set idx -1
array unset a *
foreach node [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:styleSheet/X:fills/X:fill}] {
foreach node [$root selectNodes /X:styleSheet/X:fills/X:fill] {
incr idx
array set a {patterntype {} fgcolor {} bgcolor {}}
foreach node1 [$node childNodes] {
switch -- [$node1 nodeName] {
patternFill {
if {[$node1 hasAttribute patternType]} {
set a(patterntype) [$node1 getAttribute patternType]
set a(patterntype) [$node1 @patternType]
}
foreach node2 [$node1 childNodes] {
if {[$node2 nodeName] in { fgColor bgColor}} {
if {[$node2 hasAttribute auto]} {
set a([string tolower [$node2 nodeName]]) [list auto [$node2 getAttribute auto]]
set a([string tolower [$node2 nodeName]]) [list auto [$node2 @auto]]
} elseif {[$node2 hasAttribute rgb]} {
set a([string tolower [$node2 nodeName]]) [list rgb [$node2 getAttribute rgb]]
set a([string tolower [$node2 nodeName]]) [list rgb [$node2 @rgb]]
} elseif {[$node2 hasAttribute indexed]} {
set a([string tolower [$node2 nodeName]]) [list indexed [$node2 getAttribute indexed]]
set a([string tolower [$node2 nodeName]]) [list indexed [$node2 @indexed]]
} elseif {[$node2 hasAttribute theme]} {
set a([string tolower [$node2 nodeName]]) [list theme [$node2 getAttribute theme]]
set a([string tolower [$node2 nodeName]]) [list theme [$node2 @theme]]
}
}
}
}
}
}
set wb(s,fills,$idx) [array get a]
}
lappend wb(s,@) fills [incr idx]
set idx -1
unset -nocomplain d
foreach node [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:styleSheet/X:borders/X:border}] {
foreach node [$root selectNodes /X:styleSheet/X:borders/X:border] {
incr idx
set d {left {style {} color {}} right {style {} color {}} top {style {} color {}} bottom {style {} color {}} diagonal {style {} color {} direction {}}}
foreach node1 [$node childNodes] {
if {[$node1 hasAttribute style]} {
set style [$node1 getAttribute style]
set style [$node1 @style]
} else {
set style {}
}
set color {}
foreach node2 [$node1 childNodes] {
if {[$node2 nodeName] eq {color}} {
if {[$node2 hasAttribute auto]} {
set color [list auto [$node2 getAttribute auto]]
set color [list auto [$node2 @auto]]
} elseif {[$node2 hasAttribute rgb]} {
set color [list rgb [$node2 getAttribute rgb]]
set color [list rgb [$node2 @rgb]]
} elseif {[$node2 hasAttribute indexed]} {
set color [list indexed [$node2 getAttribute indexed]]
set color [list indexed [$node2 @indexed]]
} elseif {[$node2 hasAttribute theme]} {
set color [list theme [$node2 getAttribute theme]]
set color [list theme [$node2 @theme]]
}
}
}
if {[$node1 nodeName] in {left right top bottom diagonal}} {
if {$style ne {}} {
dict set d [$node1 nodeName] style $style
}
|
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
|
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
set wb(s,borders,$idx) $d
}
lappend wb(s,@) borders [incr idx]
set idx -1
array unset a *
foreach node [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:styleSheet/X:cellXfs/X:xf}] {
foreach node [$root selectNodes /X:styleSheet/X:cellXfs/X:xf] {
incr idx
array set a {numfmt 0 font 0 fill 0 border 0 xf 0 horizontal {} vertical {} rotate {} wrap {}}
if {[$node hasAttribute numFmtId]} {
set a(numfmt) [$node getAttribute numFmtId]
set a(numfmt) [$node @numFmtId]
}
if {[$node hasAttribute fontId]} {
set a(font) [$node getAttribute fontId]
set a(font) [$node @fontId]
}
if {[$node hasAttribute fillId]} {
set a(fill) [$node getAttribute fillId]
set a(fill) [$node @fillId]
}
if {[$node hasAttribute borderId]} {
set a(border) [$node getAttribute borderId]
set a(border) [$node @borderId]
}
if {[$node hasAttribute xfId]} {
set a(xf) [$node getAttribute xfId]
set a(xf) [$node @xfId]
}
foreach node1 [$node childNodes] {
switch -- [$node1 nodeName] {
alignment {
if {[$node1 hasAttribute horizontal]} {
set a(horizontal) [$node1 getAttribute horizontal]
set a(horizontal) [$node1 @horizontal]
}
if {[$node1 hasAttribute vertical]} {
set a(vertical) [$node1 getAttribute vertical]
set a(vertical) [$node1 @vertical]
}
if {[$node1 hasAttribute textRotation]} {
set a(rotate) [$node1 getAttribute textRotation]
set a(rotate) [$node1 @textRotation]
}
if {[$node1 hasAttribute wrapText]} {
set a(wrap) [$node1 getAttribute wrapText]
set a(wrap) [$node1 @wrapText]
}
}
}
}
set wb(s,styles,$idx) [array get a]
}
lappend wb(s,@) styles [incr idx]
|
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
|
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
|
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
|
set wb($sheet,max_row) -1
set wb($sheet,max_column) -1
if {![catch {open [file join xlsx/xl $target] r} fd]} {
fconfigure $fd -encoding utf-8
if {![catch {dom parse [read $fd]} doc]} {
set root [$doc documentElement]
$doc selectNodesNamespaces [list X [$root namespaceURI]]
set idx -1
foreach col [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:worksheet/X:cols/X:col}] {
foreach col [$root selectNodes /X:worksheet/X:cols/X:col] {
incr idx
foreach item {min max width style bestFit customWidth} {
if {[$col hasAttribute $item]} {
switch -- $item {
min - max {
lappend wb($sheet,col,$idx) [string tolower $item] [expr {[$col getAttribute $item] - 1}]
lappend wb($sheet,col,$idx) [string tolower $item] [expr {[$col @$item] - 1}]
}
default {
lappend wb($sheet,col,$idx) [string tolower $item] [$col getAttribute $item]
lappend wb($sheet,col,$idx) [string tolower $item] [$col @$item]
}
}
} else {
lappend wb($sheet,col,$idx) [string tolower $item] 0
}
}
lappend wb($sheet,col,$idx) string 0 nozero 0 calcfit 0
}
set wb($sheet,cols) [incr idx]
foreach cell [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:worksheet/X:sheetData/X:row/X:c}] {
foreach cell [$root selectNodes /X:worksheet/X:sheetData/X:row/X:c] {
if {[$cell hasAttribute t]} {
set type [$cell getAttribute 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 -namespaces [list X [$cell namespaceURI]] X:v/text()]] ne {}} {
if {[set node [$cell selectNodes X:v/text()]] ne {}} {
set value [$node nodeValue]
if {$type eq {n} && [$cell hasAttribute s] && [string is double -strict $value]} {
set idx [$cell getAttribute s]
set idx [$cell @s]
if {[dict exists $cellXfs($idx) nfi]} {
set numFmtId [dict get $cellXfs($idx) nfi]
if {[info exists numFmts($numFmtId)] && [dict exists $numFmts($numFmtId) dt] && [dict get $numFmts($numFmtId) dt]} {
set datetime $value
catch {clock format [expr {int(($value - 25569) * 86400.0)}] -format $opts(datefmt) -gmt 1} value
}
}
}
} else {
if {![$cell hasAttribute s]} continue
}
}
s {
# shared string
if {[set node [$cell selectNodes -namespaces [list X [$cell namespaceURI]] X:v/text()]] ne {}} {
if {[set node [$cell selectNodes X:v/text()]] ne {}} {
set index [$node nodeValue]
if {[info exists sharedStrings($index)]} {
set value $sharedStrings($index)
}
} else {
if {![$cell hasAttribute s]} continue
}
}
inlineStr {
# inline string
if {[set string [$cell selectNodes -namespaces [list X [$cell namespaceURI]] X:is]] ne {}} {
foreach node [$string selectNodes -namespaces [list X [$string namespaceURI]] {X:t/text()}] {
if {[set string [$cell selectNodes X:is]] ne {}} {
foreach node [$string selectNodes X:t/text()] {
append value [$node nodeValue]
}
foreach node [$string selectNodes -namespaces [list X [$string namespaceURI]] {*/X:t/text()}] {
foreach node [$string selectNodes */X:t/text()] {
append value [$node nodeValue]
}
} else {
if {![$cell hasAttribute s]} continue
}
}
e {
# error
}
}
if {[$cell hasAttribute r]} {
if {!$opts(valuesonly)} {
set wb($sheet,c,[StringToRowColumn [$cell getAttribute r]]) [$cell getAttribute r]
set wb($sheet,c,[StringToRowColumn [$cell @r]]) [$cell @r]
}
if {!$opts(valuesonly)} {
if {[$cell hasAttribute s]} {
set wb($sheet,s,[StringToRowColumn [$cell getAttribute r]]) [$cell getAttribute s]
set wb($sheet,s,[StringToRowColumn [$cell @r]]) [$cell @s]
}
}
if {!$opts(valuesonly)} {
if {[$cell hasAttribute t]} {
set wb($sheet,t,[StringToRowColumn [$cell getAttribute r]]) [$cell getAttribute t]
set wb($sheet,t,[StringToRowColumn [$cell @r]]) [$cell @t]
}
}
set wb($sheet,v,[StringToRowColumn [$cell getAttribute r]]) $value
set wb($sheet,v,[StringToRowColumn [$cell @r]]) $value
if {!$opts(valuesonly) && $datetime ne {}} {
set wb($sheet,d,[StringToRowColumn [$cell getAttribute r]]) $datetime
set wb($sheet,d,[StringToRowColumn [$cell @r]]) $datetime
}
if {!$opts(valuesonly) && [set node [$cell selectNodes -namespaces [list X [$cell namespaceURI]] X:f/text()]] ne {}} {
set wb($sheet,f,[StringToRowColumn [$cell getAttribute r]]) [$node nodeValue]
if {!$opts(valuesonly) && [set node [$cell selectNodes X:f/text()]] ne {}} {
set wb($sheet,f,[StringToRowColumn [$cell @r]]) [$node nodeValue]
}
}
}
if {!$opts(valuesonly)} {
foreach row [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:worksheet/X:sheetData/X:row}] {
if {[$row hasAttribute r] && [$row hasAttribute ht] && [$row hasAttribute customHeight] && [$row getAttribute customHeight] == 1} {
dict set wb($sheet,rowheight) [expr {[$row getAttribute r] - 1}] [$row getAttribute ht]
foreach row [$root selectNodes /X:worksheet/X:sheetData/X: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]
}
}
}
if {!$opts(valuesonly)} {
foreach freeze [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:worksheet/X:sheetViews/X:sheetView/X:pane}] {
if {[$freeze hasAttribute topLeftCell] && [$freeze hasAttribute state] && [$freeze getAttribute state] eq {frozen}} {
set wb($sheet,freeze) [$freeze getAttribute topLeftCell]
foreach freeze [$root selectNodes /X:worksheet/X:sheetViews/X:sheetView/X:pane] {
if {[$freeze hasAttribute topLeftCell] && [$freeze hasAttribute state] && [$freeze @state] eq {frozen}} {
set wb($sheet,freeze) [$freeze @topLeftCell]
}
}
}
if {!$opts(valuesonly)} {
foreach filter [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:worksheet/X:autoFilter}] {
foreach filter [$root selectNodes /X:worksheet/X:autoFilter] {
if {[$filter hasAttribute ref]} {
lappend wb($sheet,filter) [$filter getAttribute ref]
lappend wb($sheet,filter) [$filter @ref]
}
}
}
if {!$opts(valuesonly)} {
foreach merge [$root selectNodes -namespaces [list X [$root namespaceURI]] {/X:worksheet/X:mergeCells/X:mergeCell}] {
foreach merge [$root selectNodes /X:worksheet/X:mergeCells/X:mergeCell] {
if {[$merge hasAttribute ref]} {
lappend wb($sheet,merge) [$merge getAttribute ref]
lappend wb($sheet,merge) [$merge @ref]
}
}
}
$doc delete
}
close $fd
}
|