@office-open/xlsx 0.9.7 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/comments-DxU57iWZ.mjs +1723 -0
- package/dist/comments-DxU57iWZ.mjs.map +1 -0
- package/dist/{context-D-5KiTi9.mjs → context-e2jg7QPd.mjs} +532 -1661
- package/dist/context-e2jg7QPd.mjs.map +1 -0
- package/dist/file-DRUArxbd.d.mts +515 -0
- package/dist/file-DRUArxbd.d.mts.map +1 -0
- package/dist/{generate-DWMr3rAE.mjs → generate-ByinSGdN.mjs} +54 -10
- package/dist/generate-ByinSGdN.mjs.map +1 -0
- package/dist/generate.d.mts +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.d.mts +19 -228
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -4
- package/dist/index.mjs.map +1 -1
- package/dist/parse.d.mts +2 -1
- package/dist/parse.d.mts.map +1 -1
- package/dist/parse.mjs +65 -4
- package/dist/parse.mjs.map +1 -1
- package/dist/patch.d.mts +20 -22
- package/dist/patch.d.mts.map +1 -1
- package/dist/patch.mjs +398 -23
- package/dist/patch.mjs.map +1 -1
- package/dist/{file-CgICvJzI.d.mts → worksheet-Dnj8Ou-w.d.mts} +52 -328
- package/dist/worksheet-Dnj8Ou-w.d.mts.map +1 -0
- package/package.json +3 -3
- package/dist/context-D-5KiTi9.mjs.map +0 -1
- package/dist/file-CgICvJzI.d.mts.map +0 -1
- package/dist/generate-DWMr3rAE.mjs.map +0 -1
|
@@ -1,206 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SharedStrings } from "./comments-DxU57iWZ.mjs";
|
|
2
|
+
import { attr, attrNum, attrs, children, escapeXml, findChild, stringify, textOf } from "@office-open/xml";
|
|
2
3
|
import { ChartCollection, Relationships, derivePasswordHash } from "@office-open/core";
|
|
3
|
-
//#region src/parts/shared-strings.ts
|
|
4
|
-
/**
|
|
5
|
-
* Build rich text run properties XML (CT_RPrElt).
|
|
6
|
-
* Exported for reuse by Comments and other components.
|
|
7
|
-
*/
|
|
8
|
-
function buildRPrXml(pr) {
|
|
9
|
-
if (!pr) return "";
|
|
10
|
-
const parts = [];
|
|
11
|
-
if (pr.font) parts.push(`<rFont val="${escapeXml(pr.font)}"/>`);
|
|
12
|
-
if (pr.charset !== void 0) parts.push(`<charset val="${pr.charset}"/>`);
|
|
13
|
-
if (pr.family !== void 0) parts.push(`<family val="${pr.family}"/>`);
|
|
14
|
-
if (pr.bold) parts.push("<b/>");
|
|
15
|
-
if (pr.italic) parts.push("<i/>");
|
|
16
|
-
if (pr.strike) parts.push("<strike/>");
|
|
17
|
-
if (pr.outline) parts.push("<outline/>");
|
|
18
|
-
if (pr.shadow) parts.push("<shadow/>");
|
|
19
|
-
if (pr.condense) parts.push("<condense/>");
|
|
20
|
-
if (pr.extend) parts.push("<extend/>");
|
|
21
|
-
if (pr.color) {
|
|
22
|
-
const rgb = pr.color.length === 6 ? `FF${pr.color}` : pr.color;
|
|
23
|
-
parts.push(`<color rgb="${escapeXml(rgb)}"/>`);
|
|
24
|
-
}
|
|
25
|
-
if (pr.size !== void 0) parts.push(`<sz val="${pr.size}"/>`);
|
|
26
|
-
if (pr.underline) if (pr.underline === "none") parts.push("<u/>");
|
|
27
|
-
else parts.push(`<u val="${pr.underline}"/>`);
|
|
28
|
-
if (pr.vertAlign) parts.push(`<vertAlign val="${pr.vertAlign}"/>`);
|
|
29
|
-
if (pr.scheme) parts.push(`<scheme val="${pr.scheme}"/>`);
|
|
30
|
-
return parts.length > 0 ? `<rPr>${parts.join("")}</rPr>` : "";
|
|
31
|
-
}
|
|
32
|
-
/** Build a CT_Rst XML string from RichTextOptions. */
|
|
33
|
-
function buildRstXml$1(rst) {
|
|
34
|
-
const parts = [];
|
|
35
|
-
if (rst.runs && rst.runs.length > 0) for (const run of rst.runs) {
|
|
36
|
-
const rPr = buildRPrXml(run.properties);
|
|
37
|
-
parts.push(`<r>${rPr}<t>${escapeXml(run.text)}</t></r>`);
|
|
38
|
-
}
|
|
39
|
-
else if (rst.text !== void 0) parts.push(`<t>${escapeXml(rst.text)}</t>`);
|
|
40
|
-
if (rst.phonetics) for (const ph of rst.phonetics) parts.push(`<rPh sb="${ph.sb}" eb="${ph.eb}"><t>${escapeXml(ph.text)}</t></rPh>`);
|
|
41
|
-
return parts.join("");
|
|
42
|
-
}
|
|
43
|
-
var SharedStrings = class {
|
|
44
|
-
entries = [];
|
|
45
|
-
/** Dedup map for plain strings only. Rich text is not deduped. */
|
|
46
|
-
indexMap = /* @__PURE__ */ new Map();
|
|
47
|
-
/**
|
|
48
|
-
* Register a plain string and return its index.
|
|
49
|
-
* Returns existing index if the string is already registered.
|
|
50
|
-
*/
|
|
51
|
-
register(s) {
|
|
52
|
-
const existing = this.indexMap.get(s);
|
|
53
|
-
if (existing !== void 0) return existing;
|
|
54
|
-
const idx = this.entries.length;
|
|
55
|
-
this.entries.push(s);
|
|
56
|
-
this.indexMap.set(s, idx);
|
|
57
|
-
return idx;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Register a rich text entry and return its index.
|
|
61
|
-
* Rich text is not deduped (each call creates a new entry).
|
|
62
|
-
*/
|
|
63
|
-
registerRich(rst) {
|
|
64
|
-
const idx = this.entries.length;
|
|
65
|
-
this.entries.push(rst);
|
|
66
|
-
return idx;
|
|
67
|
-
}
|
|
68
|
-
get count() {
|
|
69
|
-
return this.entries.length;
|
|
70
|
-
}
|
|
71
|
-
/** Return a serializable snapshot for the descriptor. */
|
|
72
|
-
toDescriptorOptions() {
|
|
73
|
-
return {
|
|
74
|
-
entries: this.entries,
|
|
75
|
-
uniqueCount: this.indexMap.size
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
/** Serialize to xl/sharedStrings.xml content (without XML declaration). */
|
|
79
|
-
serialize() {
|
|
80
|
-
const p = ["<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"", ` count="${this.entries.length}" uniqueCount="${this.indexMap.size}">`];
|
|
81
|
-
for (const entry of this.entries) if (typeof entry === "string") p.push(`<si><t>${escapeXml(entry)}</t></si>`);
|
|
82
|
-
else p.push(`<si>${buildRstXml$1(entry)}</si>`);
|
|
83
|
-
p.push("</sst>");
|
|
84
|
-
return p.join("");
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const sharedStringsDesc = {
|
|
88
|
-
kind: "custom",
|
|
89
|
-
stringify(opts, _ctx) {
|
|
90
|
-
if (opts.entries.length === 0) return void 0;
|
|
91
|
-
const p = ["<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"", ` count="${opts.entries.length}" uniqueCount="${opts.uniqueCount}">`];
|
|
92
|
-
for (const entry of opts.entries) if (typeof entry === "string") p.push(`<si><t>${escapeXml(entry)}</t></si>`);
|
|
93
|
-
else p.push(`<si>${buildRstXml$1(entry)}</si>`);
|
|
94
|
-
p.push("</sst>");
|
|
95
|
-
return p.join("");
|
|
96
|
-
},
|
|
97
|
-
parse(el, _ctx) {
|
|
98
|
-
const entries = [];
|
|
99
|
-
for (const si of el.elements ?? []) {
|
|
100
|
-
if (si.name !== "si") continue;
|
|
101
|
-
const t = findChild(si, "t");
|
|
102
|
-
if (t) {
|
|
103
|
-
entries.push(textOf(t) ?? "");
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
const runs = [];
|
|
107
|
-
for (const r of si.elements ?? []) {
|
|
108
|
-
if (r.name !== "r") continue;
|
|
109
|
-
const rt = findChild(r, "t");
|
|
110
|
-
if (rt) {
|
|
111
|
-
const rPrEl = findChild(r, "rPr");
|
|
112
|
-
const run = { text: textOf(rt) ?? "" };
|
|
113
|
-
if (rPrEl) run.properties = parseRPr(rPrEl);
|
|
114
|
-
runs.push(run);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const phonetics = [];
|
|
118
|
-
for (const rPh of si.elements ?? []) {
|
|
119
|
-
if (rPh.name !== "rPh") continue;
|
|
120
|
-
const sb = attrNum(rPh, "sb") ?? 0;
|
|
121
|
-
const eb = attrNum(rPh, "eb") ?? 0;
|
|
122
|
-
const rPhT = findChild(rPh, "t");
|
|
123
|
-
phonetics.push({
|
|
124
|
-
sb,
|
|
125
|
-
eb,
|
|
126
|
-
text: rPhT ? textOf(rPhT) ?? "" : ""
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
if (runs.length > 0) {
|
|
130
|
-
const entry = { runs };
|
|
131
|
-
if (phonetics.length > 0) entry.phonetics = phonetics;
|
|
132
|
-
entries.push(entry);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return {
|
|
136
|
-
entries,
|
|
137
|
-
uniqueCount: entries.length
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
/** Parse CT_RPrElt (run properties inside shared strings r element). */
|
|
142
|
-
function parseRPr(el) {
|
|
143
|
-
const result = {};
|
|
144
|
-
for (const child of el.elements ?? []) switch (child.name) {
|
|
145
|
-
case "rFont":
|
|
146
|
-
result.font = attr(child, "val") ?? void 0;
|
|
147
|
-
break;
|
|
148
|
-
case "charset":
|
|
149
|
-
result.charset = attrNum(child, "val");
|
|
150
|
-
break;
|
|
151
|
-
case "family":
|
|
152
|
-
result.family = attrNum(child, "val");
|
|
153
|
-
break;
|
|
154
|
-
case "b":
|
|
155
|
-
result.bold = attr(child, "val") !== "0";
|
|
156
|
-
break;
|
|
157
|
-
case "i":
|
|
158
|
-
result.italic = attr(child, "val") !== "0";
|
|
159
|
-
break;
|
|
160
|
-
case "strike":
|
|
161
|
-
result.strike = true;
|
|
162
|
-
break;
|
|
163
|
-
case "outline":
|
|
164
|
-
result.outline = true;
|
|
165
|
-
break;
|
|
166
|
-
case "shadow":
|
|
167
|
-
result.shadow = true;
|
|
168
|
-
break;
|
|
169
|
-
case "condense":
|
|
170
|
-
result.condense = true;
|
|
171
|
-
break;
|
|
172
|
-
case "extend":
|
|
173
|
-
result.extend = true;
|
|
174
|
-
break;
|
|
175
|
-
case "color": {
|
|
176
|
-
const rgb = attr(child, "rgb");
|
|
177
|
-
if (rgb) result.color = rgb.length === 8 ? rgb.slice(2) : rgb;
|
|
178
|
-
else {
|
|
179
|
-
const indexed = attrNum(child, "indexed");
|
|
180
|
-
if (indexed !== void 0) result.color = String(indexed);
|
|
181
|
-
else {
|
|
182
|
-
const theme = attr(child, "theme");
|
|
183
|
-
if (theme !== void 0) result.color = `theme:${theme}`;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
case "sz":
|
|
189
|
-
result.size = attrNum(child, "val");
|
|
190
|
-
break;
|
|
191
|
-
case "u":
|
|
192
|
-
result.underline = attr(child, "val") ?? true;
|
|
193
|
-
break;
|
|
194
|
-
case "vertAlign":
|
|
195
|
-
result.vertAlign = attr(child, "val") ?? void 0;
|
|
196
|
-
break;
|
|
197
|
-
case "scheme":
|
|
198
|
-
result.scheme = attr(child, "val") ?? void 0;
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
return result;
|
|
202
|
-
}
|
|
203
|
-
//#endregion
|
|
204
4
|
//#region src/parts/styles.ts
|
|
205
5
|
function fontKey(f) {
|
|
206
6
|
return `b${f.bold ? 1 : 0}i${f.italic ? 1 : 0}u${f.underline ? 1 : 0}s${f.strike ? 1 : 0}z${f.size ?? 0}c${f.color ?? ""}n${f.font ?? ""}cs${f.charset ?? ""}fm${f.family ?? ""}co${f.condense ? 1 : 0}ex${f.extend ? 1 : 0}va${f.vertAlign ?? ""}sc${f.scheme ?? ""}sh${f.shadow ? 1 : 0}ol${f.outline ? 1 : 0}`;
|
|
@@ -642,10 +442,10 @@ const stylesDesc = {
|
|
|
642
442
|
const fillId = attrNum(xf, "fillId");
|
|
643
443
|
const borderId = attrNum(xf, "borderId");
|
|
644
444
|
const numFmtId = attrNum(xf, "numFmtId");
|
|
645
|
-
if (fontId !== void 0) style.
|
|
646
|
-
if (fillId !== void 0) style.
|
|
647
|
-
if (borderId !== void 0) style.
|
|
648
|
-
if (numFmtId !== void 0) style.
|
|
445
|
+
if (fontId !== void 0) style.fontId = fontId;
|
|
446
|
+
if (fillId !== void 0) style.fillId = fillId;
|
|
447
|
+
if (borderId !== void 0) style.borderId = borderId;
|
|
448
|
+
if (numFmtId !== void 0) style.numFmtId = numFmtId;
|
|
649
449
|
xfs.push(style);
|
|
650
450
|
}
|
|
651
451
|
result.cellStyleXfs = xfs;
|
|
@@ -664,10 +464,10 @@ const stylesDesc = {
|
|
|
664
464
|
const protectionEl = findChild(xf, "protection");
|
|
665
465
|
const protection = protectionEl ? parseProtection(protectionEl) : void 0;
|
|
666
466
|
const style = {};
|
|
667
|
-
if (fontId > 0) style.
|
|
668
|
-
if (fillId > 0) style.
|
|
669
|
-
if (borderId > 0) style.
|
|
670
|
-
if (numFmtId > 0) style.
|
|
467
|
+
if (fontId > 0) style.fontId = fontId;
|
|
468
|
+
if (fillId > 0) style.fillId = fillId;
|
|
469
|
+
if (borderId > 0) style.borderId = borderId;
|
|
470
|
+
if (numFmtId > 0) style.numFmtId = numFmtId;
|
|
671
471
|
if (alignment) style.alignment = alignment;
|
|
672
472
|
if (protection) style.protection = protection;
|
|
673
473
|
if (attr(xf, "quotePrefix") === "1") style.quotePrefix = true;
|
|
@@ -934,1305 +734,6 @@ function parseColorHex(el) {
|
|
|
934
734
|
if (rgb) return rgb.length === 8 ? rgb.slice(2) : rgb;
|
|
935
735
|
}
|
|
936
736
|
//#endregion
|
|
937
|
-
//#region src/parts/worksheet.ts
|
|
938
|
-
/**
|
|
939
|
-
* Worksheet XML generation — pure functions for xl/worksheets/sheet{n}.xml.
|
|
940
|
-
*
|
|
941
|
-
* All interfaces and the zero-allocation string concatenation fast path
|
|
942
|
-
* are preserved. The `Worksheet` class has been replaced by `buildWorksheetXml()`.
|
|
943
|
-
*
|
|
944
|
-
* @module
|
|
945
|
-
*/
|
|
946
|
-
/** Cell formula type (maps to ST_CellFormulaType). */
|
|
947
|
-
const FormulaType = {
|
|
948
|
-
NORMAL: "normal",
|
|
949
|
-
ARRAY: "array",
|
|
950
|
-
SHARED: "shared"
|
|
951
|
-
};
|
|
952
|
-
const worksheetDesc = {
|
|
953
|
-
kind: "custom",
|
|
954
|
-
/**
|
|
955
|
-
* NOT intended for direct use by the compiler.
|
|
956
|
-
* The compiler calls `stringifyWorksheet(opts, ctx)` instead, which has
|
|
957
|
-
* access to the SharedStrings and Styles accumulators.
|
|
958
|
-
* This method exists to satisfy the CustomDescriptor interface for the read path.
|
|
959
|
-
*/
|
|
960
|
-
stringify(_opts, _ctx) {
|
|
961
|
-
throw new Error("Use stringifyWorksheet(opts, ctx) for the write path. worksheetDesc.stringify() is not supported.");
|
|
962
|
-
},
|
|
963
|
-
parse(el, ctx) {
|
|
964
|
-
const result = {};
|
|
965
|
-
let pageSetUpPrCache;
|
|
966
|
-
const strings = ctx && "sharedStrings" in ctx ? ctx.sharedStrings : [];
|
|
967
|
-
const sheetPrEl = findChild(el, "sheetPr");
|
|
968
|
-
if (sheetPrEl) {
|
|
969
|
-
const sp = {};
|
|
970
|
-
if (attr(sheetPrEl, "syncHorizontal") === "1") sp.syncHorizontal = true;
|
|
971
|
-
if (attr(sheetPrEl, "syncVertical") === "1") sp.syncVertical = true;
|
|
972
|
-
if (attr(sheetPrEl, "syncRef")) sp.syncRef = attr(sheetPrEl, "syncRef");
|
|
973
|
-
if (attr(sheetPrEl, "transitionEvaluation") === "1") sp.transitionEvaluation = true;
|
|
974
|
-
if (attr(sheetPrEl, "transitionEntry") === "1") sp.transitionEntry = true;
|
|
975
|
-
if (attr(sheetPrEl, "published") === "1") sp.published = true;
|
|
976
|
-
if (attr(sheetPrEl, "filterMode") === "1") sp.filterMode = true;
|
|
977
|
-
if (attr(sheetPrEl, "enableFormatConditionsCalculation") === "1") sp.enableFormatConditionsCalculation = true;
|
|
978
|
-
const outlinePr = findChild(sheetPrEl, "outlinePr");
|
|
979
|
-
if (outlinePr) {
|
|
980
|
-
if (attr(outlinePr, "applyStyles") === "1") sp.outlineApplyStyles = true;
|
|
981
|
-
if (attr(outlinePr, "showOutlineSymbols") === "0") sp.outlineShowSymbols = false;
|
|
982
|
-
if (attr(outlinePr, "summaryBelow") === "0") sp.outlineSummaryBelow = false;
|
|
983
|
-
if (attr(outlinePr, "summaryRight") === "0") sp.outlineSummaryRight = false;
|
|
984
|
-
}
|
|
985
|
-
const pageSetUpPr = findChild(sheetPrEl, "pageSetUpPr");
|
|
986
|
-
if (pageSetUpPr) {
|
|
987
|
-
const psup = {};
|
|
988
|
-
if (attr(pageSetUpPr, "fitToPage") === "1") psup.fitToPage = true;
|
|
989
|
-
if (attr(pageSetUpPr, "autoPageBreaks") === "1") psup.autoPageBreaks = true;
|
|
990
|
-
if (Object.keys(psup).length > 0) pageSetUpPrCache = psup;
|
|
991
|
-
}
|
|
992
|
-
if (Object.keys(sp).length > 0) result.sheetPr = sp;
|
|
993
|
-
const tabColorEl = findChild(sheetPrEl, "tabColor");
|
|
994
|
-
if (tabColorEl) {
|
|
995
|
-
const tc = {};
|
|
996
|
-
if (attr(tabColorEl, "rgb")) tc.rgb = attr(tabColorEl, "rgb");
|
|
997
|
-
if (attrNum(tabColorEl, "theme") !== void 0) tc.theme = attrNum(tabColorEl, "theme");
|
|
998
|
-
if (attrNum(tabColorEl, "tint") !== void 0) tc.tint = attrNum(tabColorEl, "tint");
|
|
999
|
-
if (attrNum(tabColorEl, "indexed") !== void 0) tc.indexed = attrNum(tabColorEl, "indexed");
|
|
1000
|
-
result.tabColor = tc;
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
const sheetViewsEl = findChild(el, "sheetViews");
|
|
1004
|
-
if (sheetViewsEl) {
|
|
1005
|
-
const svEl = findChild(sheetViewsEl, "sheetView");
|
|
1006
|
-
if (svEl) {
|
|
1007
|
-
const sv = {};
|
|
1008
|
-
if (attr(svEl, "showGridLines") === "0") sv.showGridLines = false;
|
|
1009
|
-
if (attr(svEl, "showRowColHeaders") === "0") sv.showRowColHeaders = false;
|
|
1010
|
-
if (attr(svEl, "showZeros") === "0") sv.showZeros = false;
|
|
1011
|
-
const zs = attrNum(svEl, "zoomScale");
|
|
1012
|
-
if (zs !== void 0) sv.zoomScale = zs;
|
|
1013
|
-
if (attr(svEl, "tabSelected") !== void 0) sv.tabSelected = attr(svEl, "tabSelected") !== "0";
|
|
1014
|
-
if (attr(svEl, "rightToLeft") === "1") sv.rightToLeft = true;
|
|
1015
|
-
if (attr(svEl, "windowProtection") === "1") sv.windowProtection = true;
|
|
1016
|
-
if (attr(svEl, "showFormulas") === "1") sv.showFormulas = true;
|
|
1017
|
-
if (attr(svEl, "showRuler") === "0") sv.showRuler = false;
|
|
1018
|
-
if (attr(svEl, "showOutlineSymbols") === "0") sv.showOutlineSymbols = false;
|
|
1019
|
-
if (attr(svEl, "defaultGridColor") === "0") sv.defaultGridColor = false;
|
|
1020
|
-
if (attr(svEl, "showWhiteSpace") === "0") sv.showWhiteSpace = false;
|
|
1021
|
-
if (attr(svEl, "view")) sv.view = attr(svEl, "view");
|
|
1022
|
-
const colorId = attrNum(svEl, "colorId");
|
|
1023
|
-
if (colorId !== void 0) sv.colorId = colorId;
|
|
1024
|
-
const zsn = attrNum(svEl, "zoomScaleNormal");
|
|
1025
|
-
if (zsn !== void 0) sv.zoomScaleNormal = zsn;
|
|
1026
|
-
const zssl = attrNum(svEl, "zoomScaleSheetLayoutView");
|
|
1027
|
-
if (zssl !== void 0) sv.zoomScaleSheetLayoutView = zssl;
|
|
1028
|
-
const zspl = attrNum(svEl, "zoomScalePageLayoutView");
|
|
1029
|
-
if (zspl !== void 0) sv.zoomScalePageLayoutView = zspl;
|
|
1030
|
-
result.sheetView = sv;
|
|
1031
|
-
const paneEl = findChild(svEl, "pane");
|
|
1032
|
-
if (paneEl && attr(paneEl, "state") === "frozen") {
|
|
1033
|
-
const fp = {};
|
|
1034
|
-
const ys = attrNum(paneEl, "ySplit");
|
|
1035
|
-
if (ys && ys > 0) fp.row = ys;
|
|
1036
|
-
const xs = attrNum(paneEl, "xSplit");
|
|
1037
|
-
if (xs && xs > 0) fp.col = xs;
|
|
1038
|
-
if (Object.keys(fp).length > 0) result.freezePanes = fp;
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
const sfpEl = findChild(el, "sheetFormatPr");
|
|
1043
|
-
if (sfpEl) {
|
|
1044
|
-
const sfp = {};
|
|
1045
|
-
const bcw = attrNum(sfpEl, "baseColWidth");
|
|
1046
|
-
if (bcw !== void 0) sfp.baseColWidth = bcw;
|
|
1047
|
-
const dcw = attrNum(sfpEl, "defaultColWidth");
|
|
1048
|
-
if (dcw !== void 0) sfp.defaultColWidth = dcw;
|
|
1049
|
-
const drh = attrNum(sfpEl, "defaultRowHeight");
|
|
1050
|
-
if (drh !== void 0) sfp.defaultRowHeight = drh;
|
|
1051
|
-
if (attr(sfpEl, "zeroHeight") === "1") sfp.zeroHeight = true;
|
|
1052
|
-
if (attr(sfpEl, "thickTop") === "1") sfp.thickTop = true;
|
|
1053
|
-
if (attr(sfpEl, "thickBottom") === "1") sfp.thickBottom = true;
|
|
1054
|
-
const olr = attrNum(sfpEl, "outlineLevelRow");
|
|
1055
|
-
if (olr !== void 0) sfp.outlineLevelRow = olr;
|
|
1056
|
-
const olc = attrNum(sfpEl, "outlineLevelCol");
|
|
1057
|
-
if (olc !== void 0) sfp.outlineLevelCol = olc;
|
|
1058
|
-
result.sheetFormatPr = sfp;
|
|
1059
|
-
}
|
|
1060
|
-
const colsEl = findChild(el, "cols");
|
|
1061
|
-
if (colsEl) {
|
|
1062
|
-
const columns = [];
|
|
1063
|
-
for (const colEl of colsEl.elements ?? []) {
|
|
1064
|
-
if (colEl.name !== "col") continue;
|
|
1065
|
-
const col = {};
|
|
1066
|
-
col.min = attrNum(colEl, "min") ?? 0;
|
|
1067
|
-
col.max = attrNum(colEl, "max") ?? 0;
|
|
1068
|
-
const w = attrNum(colEl, "width");
|
|
1069
|
-
if (w !== void 0) col.width = w;
|
|
1070
|
-
if (attr(colEl, "hidden") === "1") col.hidden = true;
|
|
1071
|
-
if (attr(colEl, "customWidth") === "1") col.customWidth = true;
|
|
1072
|
-
const ol = attrNum(colEl, "outlineLevel");
|
|
1073
|
-
if (ol !== void 0) col.outlineLevel = ol;
|
|
1074
|
-
if (attr(colEl, "collapsed") === "1") col.collapsed = true;
|
|
1075
|
-
if (attr(colEl, "bestFit") === "1") col.bestFit = true;
|
|
1076
|
-
if (attr(colEl, "phonetic") === "1") col.phonetic = true;
|
|
1077
|
-
columns.push(col);
|
|
1078
|
-
}
|
|
1079
|
-
if (columns.length > 0) result.columns = columns;
|
|
1080
|
-
}
|
|
1081
|
-
const protEl = findChild(el, "sheetProtection");
|
|
1082
|
-
if (protEl?.attributes) {
|
|
1083
|
-
const prot = {};
|
|
1084
|
-
if (attr(protEl, "password")) prot.password = attr(protEl, "password");
|
|
1085
|
-
if (attr(protEl, "algorithmName")) prot.algorithmName = attr(protEl, "algorithmName");
|
|
1086
|
-
if (attr(protEl, "hashValue")) prot.hashValue = attr(protEl, "hashValue");
|
|
1087
|
-
if (attr(protEl, "saltValue")) prot.saltValue = attr(protEl, "saltValue");
|
|
1088
|
-
if (attrNum(protEl, "spinCount") !== void 0) prot.spinCount = attrNum(protEl, "spinCount");
|
|
1089
|
-
if (attr(protEl, "sheet") === "1") prot.sheet = true;
|
|
1090
|
-
if (attr(protEl, "objects") === "1") prot.objects = true;
|
|
1091
|
-
if (attr(protEl, "scenarios") === "1") prot.scenarios = true;
|
|
1092
|
-
if (attr(protEl, "formatCells") === "0") prot.formatCells = false;
|
|
1093
|
-
if (attr(protEl, "formatColumns") === "0") prot.formatColumns = false;
|
|
1094
|
-
if (attr(protEl, "formatRows") === "0") prot.formatRows = false;
|
|
1095
|
-
if (attr(protEl, "insertColumns") === "0") prot.insertColumns = false;
|
|
1096
|
-
if (attr(protEl, "insertRows") === "0") prot.insertRows = false;
|
|
1097
|
-
if (attr(protEl, "insertHyperlinks") === "0") prot.insertHyperlinks = false;
|
|
1098
|
-
if (attr(protEl, "deleteColumns") === "0") prot.deleteColumns = false;
|
|
1099
|
-
if (attr(protEl, "deleteRows") === "0") prot.deleteRows = false;
|
|
1100
|
-
if (attr(protEl, "selectLockedCells") === "1") prot.selectLockedCells = true;
|
|
1101
|
-
if (attr(protEl, "sort") === "0") prot.sort = false;
|
|
1102
|
-
if (attr(protEl, "autoFilter") === "0") prot.autoFilter = false;
|
|
1103
|
-
if (attr(protEl, "pivotTables") === "0") prot.pivotTables = false;
|
|
1104
|
-
if (attr(protEl, "selectUnlockedCells") === "1") prot.selectUnlockedCells = true;
|
|
1105
|
-
result.protection = prot;
|
|
1106
|
-
}
|
|
1107
|
-
const prEl = findChild(el, "protectedRanges");
|
|
1108
|
-
if (prEl) {
|
|
1109
|
-
const ranges = [];
|
|
1110
|
-
for (const rEl of prEl.elements ?? []) {
|
|
1111
|
-
if (rEl.name !== "protectedRange") continue;
|
|
1112
|
-
const r = {};
|
|
1113
|
-
r.sqref = attr(rEl, "sqref") ?? "";
|
|
1114
|
-
r.name = attr(rEl, "name") ?? "";
|
|
1115
|
-
if (attr(rEl, "password")) r.password = attr(rEl, "password");
|
|
1116
|
-
if (attr(rEl, "algorithmName")) r.algorithmName = attr(rEl, "algorithmName");
|
|
1117
|
-
if (attr(rEl, "hashValue")) r.hashValue = attr(rEl, "hashValue");
|
|
1118
|
-
if (attr(rEl, "saltValue")) r.saltValue = attr(rEl, "saltValue");
|
|
1119
|
-
if (attrNum(rEl, "spinCount") !== void 0) r.spinCount = attrNum(rEl, "spinCount");
|
|
1120
|
-
const sdEl = findChild(rEl, "securityDescriptor");
|
|
1121
|
-
if (sdEl) r.securityDescriptor = textOf(sdEl);
|
|
1122
|
-
ranges.push(r);
|
|
1123
|
-
}
|
|
1124
|
-
if (ranges.length > 0) result.protectedRanges = ranges;
|
|
1125
|
-
}
|
|
1126
|
-
const afEl = findChild(el, "autoFilter");
|
|
1127
|
-
if (afEl) result.autoFilter = attr(afEl, "ref") ?? "";
|
|
1128
|
-
const mcEl = findChild(el, "mergeCells");
|
|
1129
|
-
if (mcEl) {
|
|
1130
|
-
const merges = [];
|
|
1131
|
-
for (const mEl of mcEl.elements ?? []) {
|
|
1132
|
-
if (mEl.name !== "mergeCell") continue;
|
|
1133
|
-
const parts = (attr(mEl, "ref") ?? "").split(":");
|
|
1134
|
-
if (parts.length === 2) {
|
|
1135
|
-
const from = parseCellRef(parts[0]);
|
|
1136
|
-
const to = parseCellRef(parts[1]);
|
|
1137
|
-
if (from && to) merges.push({
|
|
1138
|
-
from,
|
|
1139
|
-
to
|
|
1140
|
-
});
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
if (merges.length > 0) result.mergeCells = merges;
|
|
1144
|
-
}
|
|
1145
|
-
const cfEls = el.elements?.filter((e) => e.name === "conditionalFormatting") ?? [];
|
|
1146
|
-
if (cfEls.length > 0) {
|
|
1147
|
-
const cfs = [];
|
|
1148
|
-
for (const cfEl of cfEls) {
|
|
1149
|
-
const sqref = attr(cfEl, "sqref") ?? "";
|
|
1150
|
-
const rules = [];
|
|
1151
|
-
for (const ruleEl of cfEl.elements ?? []) {
|
|
1152
|
-
if (ruleEl.name !== "cfRule") continue;
|
|
1153
|
-
const rule = {};
|
|
1154
|
-
rule.type = attr(ruleEl, "type");
|
|
1155
|
-
rule.priority = attrNum(ruleEl, "priority") ?? 1;
|
|
1156
|
-
if (attr(ruleEl, "operator")) rule.operator = attr(ruleEl, "operator");
|
|
1157
|
-
const dxfId = attrNum(ruleEl, "dxfId");
|
|
1158
|
-
if (dxfId !== void 0) rule.dxfId = dxfId;
|
|
1159
|
-
if (attr(ruleEl, "stopIfTrue") === "1") rule.stopIfTrue = true;
|
|
1160
|
-
if (attr(ruleEl, "timePeriod")) rule.timePeriod = attr(ruleEl, "timePeriod");
|
|
1161
|
-
const rank = attrNum(ruleEl, "rank");
|
|
1162
|
-
if (rank !== void 0) rule.rank = rank;
|
|
1163
|
-
if (attr(ruleEl, "equalAverage") === "1") rule.equalAverage = true;
|
|
1164
|
-
const csEl = findChild(ruleEl, "colorScale");
|
|
1165
|
-
if (csEl) {
|
|
1166
|
-
const cfvo = [];
|
|
1167
|
-
const colors = [];
|
|
1168
|
-
for (const child of csEl.elements ?? []) {
|
|
1169
|
-
if (child.name === "cfvo") cfvo.push(parseCfvo(child));
|
|
1170
|
-
if (child.name === "color") {
|
|
1171
|
-
const rgb = attr(child, "rgb");
|
|
1172
|
-
if (rgb) colors.push(rgb.length === 8 ? rgb.slice(2) : rgb);
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
rule.colorScale = {
|
|
1176
|
-
cfvo,
|
|
1177
|
-
colors
|
|
1178
|
-
};
|
|
1179
|
-
}
|
|
1180
|
-
const dbEl = findChild(ruleEl, "dataBar");
|
|
1181
|
-
if (dbEl) {
|
|
1182
|
-
const cfvo = [];
|
|
1183
|
-
let color = "";
|
|
1184
|
-
for (const child of dbEl.elements ?? []) {
|
|
1185
|
-
if (child.name === "cfvo") cfvo.push(parseCfvo(child));
|
|
1186
|
-
if (child.name === "color") {
|
|
1187
|
-
const rgb = attr(child, "rgb");
|
|
1188
|
-
if (rgb) color = rgb.length === 8 ? rgb.slice(2) : rgb;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
rule.dataBar = {
|
|
1192
|
-
cfvo,
|
|
1193
|
-
color
|
|
1194
|
-
};
|
|
1195
|
-
}
|
|
1196
|
-
const isEl = findChild(ruleEl, "iconSet");
|
|
1197
|
-
if (isEl) {
|
|
1198
|
-
const cfvo = [];
|
|
1199
|
-
for (const child of isEl.elements ?? []) if (child.name === "cfvo") cfvo.push(parseCfvo(child));
|
|
1200
|
-
const iconSet = { cfvo };
|
|
1201
|
-
if (attr(isEl, "iconSet")) iconSet.iconSet = attr(isEl, "iconSet");
|
|
1202
|
-
if (attr(isEl, "showValue") === "0") iconSet.showValue = false;
|
|
1203
|
-
if (attr(isEl, "percent") === "0") iconSet.percent = false;
|
|
1204
|
-
if (attr(isEl, "reverse") === "1") iconSet.reverse = true;
|
|
1205
|
-
rule.iconSet = iconSet;
|
|
1206
|
-
}
|
|
1207
|
-
const formulas = [];
|
|
1208
|
-
for (const child of ruleEl.elements ?? []) if (child.name === "formula") formulas.push(textOf(child) ?? "");
|
|
1209
|
-
if (formulas.length > 0) rule.formulas = formulas;
|
|
1210
|
-
rules.push(rule);
|
|
1211
|
-
}
|
|
1212
|
-
cfs.push({
|
|
1213
|
-
sqref,
|
|
1214
|
-
rules
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
result.conditionalFormats = cfs;
|
|
1218
|
-
}
|
|
1219
|
-
const dvEl = findChild(el, "dataValidations");
|
|
1220
|
-
if (dvEl) {
|
|
1221
|
-
const dvs = [];
|
|
1222
|
-
for (const dEl of dvEl.elements ?? []) {
|
|
1223
|
-
if (dEl.name !== "dataValidation") continue;
|
|
1224
|
-
const dv = {};
|
|
1225
|
-
dv.sqref = attr(dEl, "sqref") ?? "";
|
|
1226
|
-
if (attr(dEl, "type")) dv.type = attr(dEl, "type");
|
|
1227
|
-
if (attr(dEl, "operator")) dv.operator = attr(dEl, "operator");
|
|
1228
|
-
if (attr(dEl, "allowBlank") === "1") dv.allowBlank = true;
|
|
1229
|
-
if (attr(dEl, "showErrorMessage") === "1") dv.showErrorMessage = true;
|
|
1230
|
-
if (attr(dEl, "showInputMessage") === "1") dv.showInputMessage = true;
|
|
1231
|
-
if (attr(dEl, "errorTitle")) dv.errorTitle = attr(dEl, "errorTitle");
|
|
1232
|
-
if (attr(dEl, "error")) dv.error = attr(dEl, "error");
|
|
1233
|
-
if (attr(dEl, "promptTitle")) dv.promptTitle = attr(dEl, "promptTitle");
|
|
1234
|
-
if (attr(dEl, "prompt")) dv.prompt = attr(dEl, "prompt");
|
|
1235
|
-
if (attr(dEl, "errorStyle")) dv.errorStyle = attr(dEl, "errorStyle");
|
|
1236
|
-
if (attr(dEl, "imeMode")) dv.imeMode = attr(dEl, "imeMode");
|
|
1237
|
-
if (attr(dEl, "showDropDown") === "1") dv.showDropDown = true;
|
|
1238
|
-
const f1El = findChild(dEl, "formula1");
|
|
1239
|
-
if (f1El) dv.formula1 = textOf(f1El);
|
|
1240
|
-
const f2El = findChild(dEl, "formula2");
|
|
1241
|
-
if (f2El) dv.formula2 = textOf(f2El);
|
|
1242
|
-
dvs.push(dv);
|
|
1243
|
-
}
|
|
1244
|
-
result.dataValidations = dvs;
|
|
1245
|
-
}
|
|
1246
|
-
const hlEl = findChild(el, "hyperlinks");
|
|
1247
|
-
if (hlEl) {
|
|
1248
|
-
const hyperlinks = [];
|
|
1249
|
-
for (const hEl of hlEl.elements ?? []) {
|
|
1250
|
-
if (hEl.name !== "hyperlink") continue;
|
|
1251
|
-
const hl = {};
|
|
1252
|
-
hl.cell = attr(hEl, "ref") ?? "";
|
|
1253
|
-
const rId = hEl.attributes?.["r:id"];
|
|
1254
|
-
const location = attr(hEl, "location");
|
|
1255
|
-
if (rId) hl.target = {
|
|
1256
|
-
type: "external",
|
|
1257
|
-
url: rId
|
|
1258
|
-
};
|
|
1259
|
-
else if (location) hl.target = {
|
|
1260
|
-
type: "internal",
|
|
1261
|
-
location
|
|
1262
|
-
};
|
|
1263
|
-
if (attr(hEl, "tooltip")) hl.tooltip = attr(hEl, "tooltip");
|
|
1264
|
-
if (attr(hEl, "display")) hl.display = attr(hEl, "display");
|
|
1265
|
-
hyperlinks.push(hl);
|
|
1266
|
-
}
|
|
1267
|
-
result.hyperlinks = hyperlinks;
|
|
1268
|
-
}
|
|
1269
|
-
const poEl = findChild(el, "printOptions");
|
|
1270
|
-
if (poEl) {
|
|
1271
|
-
const po = {};
|
|
1272
|
-
if (attr(poEl, "horizontalCentered") === "1") po.horizontalCentered = true;
|
|
1273
|
-
if (attr(poEl, "verticalCentered") === "1") po.verticalCentered = true;
|
|
1274
|
-
if (attr(poEl, "headings") === "1") po.headings = true;
|
|
1275
|
-
if (attr(poEl, "gridLines") === "1") po.gridLines = true;
|
|
1276
|
-
if (attr(poEl, "gridLinesSet") === "0") po.gridLinesSet = false;
|
|
1277
|
-
result.printOptions = po;
|
|
1278
|
-
}
|
|
1279
|
-
const psEl = findChild(el, "pageSetup");
|
|
1280
|
-
if (psEl) {
|
|
1281
|
-
const ps = {};
|
|
1282
|
-
const pz = attrNum(psEl, "paperSize");
|
|
1283
|
-
if (pz !== void 0) ps.paperSize = pz;
|
|
1284
|
-
if (attr(psEl, "orientation")) ps.orientation = attr(psEl, "orientation");
|
|
1285
|
-
const sc = attrNum(psEl, "scale");
|
|
1286
|
-
if (sc !== void 0) ps.scale = sc;
|
|
1287
|
-
const ftw = attrNum(psEl, "fitToWidth");
|
|
1288
|
-
if (ftw !== void 0) ps.fitToWidth = ftw;
|
|
1289
|
-
const fth = attrNum(psEl, "fitToHeight");
|
|
1290
|
-
if (fth !== void 0) ps.fitToHeight = fth;
|
|
1291
|
-
if (attr(psEl, "pageOrder")) ps.pageOrder = attr(psEl, "pageOrder");
|
|
1292
|
-
if (attr(psEl, "useFirstPageNumber") === "1") ps.useFirstPageNumber = true;
|
|
1293
|
-
const fpn = attrNum(psEl, "firstPageNumber");
|
|
1294
|
-
if (fpn !== void 0) ps.firstPageNumber = fpn;
|
|
1295
|
-
if (pageSetUpPrCache) Object.assign(ps, pageSetUpPrCache);
|
|
1296
|
-
result.pageSetup = ps;
|
|
1297
|
-
} else if (pageSetUpPrCache) result.pageSetup = pageSetUpPrCache;
|
|
1298
|
-
const hfEl = findChild(el, "headerFooter");
|
|
1299
|
-
if (hfEl) {
|
|
1300
|
-
const hf = {};
|
|
1301
|
-
if (attr(hfEl, "differentOddEven") === "1") hf.differentOddEven = true;
|
|
1302
|
-
if (attr(hfEl, "differentFirst") === "1") hf.differentFirst = true;
|
|
1303
|
-
if (attr(hfEl, "scaleWithDoc") === "0") hf.scaleWithDoc = false;
|
|
1304
|
-
if (attr(hfEl, "alignWithMargins") === "0") hf.alignWithMargins = false;
|
|
1305
|
-
const oh = findChild(hfEl, "oddHeader");
|
|
1306
|
-
if (oh) hf.oddHeader = textOf(oh);
|
|
1307
|
-
const of2 = findChild(hfEl, "oddFooter");
|
|
1308
|
-
if (of2) hf.oddFooter = textOf(of2);
|
|
1309
|
-
const eh = findChild(hfEl, "evenHeader");
|
|
1310
|
-
if (eh) hf.evenHeader = textOf(eh);
|
|
1311
|
-
const ef = findChild(hfEl, "evenFooter");
|
|
1312
|
-
if (ef) hf.evenFooter = textOf(ef);
|
|
1313
|
-
const fh = findChild(hfEl, "firstHeader");
|
|
1314
|
-
if (fh) hf.firstHeader = textOf(fh);
|
|
1315
|
-
const ff = findChild(hfEl, "firstFooter");
|
|
1316
|
-
if (ff) hf.firstFooter = textOf(ff);
|
|
1317
|
-
result.headerFooter = hf;
|
|
1318
|
-
}
|
|
1319
|
-
const ieEl = findChild(el, "ignoredErrors");
|
|
1320
|
-
if (ieEl) {
|
|
1321
|
-
const errors = [];
|
|
1322
|
-
for (const eEl of ieEl.elements ?? []) {
|
|
1323
|
-
if (eEl.name !== "ignoredError") continue;
|
|
1324
|
-
const ie = {};
|
|
1325
|
-
ie.sqref = attr(eEl, "sqref") ?? "";
|
|
1326
|
-
if (attr(eEl, "evalError") === "1") ie.evalError = true;
|
|
1327
|
-
if (attr(eEl, "twoDigitTextYear") === "1") ie.twoDigitTextYear = true;
|
|
1328
|
-
if (attr(eEl, "numberStoredAsText") === "1") ie.numberStoredAsText = true;
|
|
1329
|
-
if (attr(eEl, "formula") === "1") ie.formula = true;
|
|
1330
|
-
if (attr(eEl, "formulaRange") === "1") ie.formulaRange = true;
|
|
1331
|
-
if (attr(eEl, "unlockedFormula") === "1") ie.unlockedFormula = true;
|
|
1332
|
-
if (attr(eEl, "emptyCellReference") === "1") ie.emptyCellReference = true;
|
|
1333
|
-
if (attr(eEl, "listDataValidation") === "1") ie.listDataValidation = true;
|
|
1334
|
-
if (attr(eEl, "calculatedColumn") === "1") ie.calculatedColumn = true;
|
|
1335
|
-
errors.push(ie);
|
|
1336
|
-
}
|
|
1337
|
-
result.ignoredErrors = errors;
|
|
1338
|
-
}
|
|
1339
|
-
const ppEl = findChild(el, "phoneticPr");
|
|
1340
|
-
if (ppEl) {
|
|
1341
|
-
const pp = {};
|
|
1342
|
-
pp.fontId = attrNum(ppEl, "fontId") ?? 0;
|
|
1343
|
-
if (attr(ppEl, "type")) pp.type = attr(ppEl, "type");
|
|
1344
|
-
if (attr(ppEl, "alignment")) pp.alignment = attr(ppEl, "alignment");
|
|
1345
|
-
result.phoneticPr = pp;
|
|
1346
|
-
}
|
|
1347
|
-
const scEl = findChild(el, "sheetCalcPr");
|
|
1348
|
-
if (scEl) {
|
|
1349
|
-
const sc = {};
|
|
1350
|
-
if (attr(scEl, "fullCalcOnLoad") === "1") sc.fullCalcOnLoad = true;
|
|
1351
|
-
result.sheetCalcPr = sc;
|
|
1352
|
-
}
|
|
1353
|
-
const sheetDataEl = findChild(el, "sheetData");
|
|
1354
|
-
if (sheetDataEl) {
|
|
1355
|
-
const rows = [];
|
|
1356
|
-
for (const rowEl of sheetDataEl.elements ?? []) {
|
|
1357
|
-
if (rowEl.name !== "row") continue;
|
|
1358
|
-
const row = {};
|
|
1359
|
-
const rowNumber = attrNum(rowEl, "r");
|
|
1360
|
-
if (rowNumber !== void 0) row.rowNumber = rowNumber;
|
|
1361
|
-
const ht = attrNum(rowEl, "ht");
|
|
1362
|
-
if (ht !== void 0) row.height = ht;
|
|
1363
|
-
if (attr(rowEl, "hidden") === "1") row.hidden = true;
|
|
1364
|
-
if (attr(rowEl, "spans")) row.spans = attr(rowEl, "spans");
|
|
1365
|
-
if (attr(rowEl, "customFormat") === "1") row.customFormat = true;
|
|
1366
|
-
if (attr(rowEl, "thickTop") === "1") row.thickTop = true;
|
|
1367
|
-
if (attr(rowEl, "thickBot") === "1") row.thickBot = true;
|
|
1368
|
-
if (attr(rowEl, "ph") === "1") row.ph = true;
|
|
1369
|
-
const cells = [];
|
|
1370
|
-
for (const cellEl of rowEl.elements ?? []) {
|
|
1371
|
-
if (cellEl.name !== "c") continue;
|
|
1372
|
-
const cell = {};
|
|
1373
|
-
const ref = attr(cellEl, "r");
|
|
1374
|
-
if (ref) cell.reference = ref;
|
|
1375
|
-
const type = attr(cellEl, "t");
|
|
1376
|
-
const styleIdx = attrNum(cellEl, "s");
|
|
1377
|
-
if (styleIdx !== void 0) {
|
|
1378
|
-
const resolved = ctx && "resolveStyle" in ctx ? ctx.resolveStyle(styleIdx) : void 0;
|
|
1379
|
-
if (resolved) cell.style = resolved;
|
|
1380
|
-
else cell.styleIndex = styleIdx;
|
|
1381
|
-
}
|
|
1382
|
-
const vEl = findChild(cellEl, "v");
|
|
1383
|
-
const isEl = findChild(cellEl, "is");
|
|
1384
|
-
if (type === "s" && vEl) cell.value = strings[parseInt(textOf(vEl) ?? "", 10)] ?? "";
|
|
1385
|
-
else if (type === "b" && vEl) cell.value = textOf(vEl) === "1";
|
|
1386
|
-
else if (type === "inlineStr" && isEl) cell.value = textOf(findChild(isEl, "t")) ?? "";
|
|
1387
|
-
else if (vEl) {
|
|
1388
|
-
const raw = textOf(vEl) ?? "";
|
|
1389
|
-
const num = Number(raw);
|
|
1390
|
-
cell.value = isNaN(num) ? raw : num;
|
|
1391
|
-
}
|
|
1392
|
-
const fEl = findChild(cellEl, "f");
|
|
1393
|
-
if (fEl) {
|
|
1394
|
-
const formula = { formula: textOf(fEl) ?? "" };
|
|
1395
|
-
const ft = attr(fEl, "t");
|
|
1396
|
-
if (ft && ft !== "normal") formula.type = ft;
|
|
1397
|
-
const fRef = attr(fEl, "ref");
|
|
1398
|
-
if (fRef) formula.reference = fRef;
|
|
1399
|
-
const fSi = attrNum(fEl, "si");
|
|
1400
|
-
if (fSi !== void 0) formula.sharedIndex = fSi;
|
|
1401
|
-
if (attr(fEl, "aca") === "1") formula.aca = true;
|
|
1402
|
-
if (attr(fEl, "ca") === "1") formula.ca = true;
|
|
1403
|
-
if (attr(fEl, "bx") === "1") formula.bx = true;
|
|
1404
|
-
cell.formula = formula;
|
|
1405
|
-
}
|
|
1406
|
-
cells.push(cell);
|
|
1407
|
-
}
|
|
1408
|
-
row.cells = cells;
|
|
1409
|
-
rows.push(row);
|
|
1410
|
-
}
|
|
1411
|
-
if (rows.length > 0) result.rows = rows;
|
|
1412
|
-
}
|
|
1413
|
-
return result;
|
|
1414
|
-
}
|
|
1415
|
-
};
|
|
1416
|
-
/**
|
|
1417
|
-
* Build the complete worksheet XML string.
|
|
1418
|
-
*
|
|
1419
|
-
* Zero-allocation fast path: directly concatenates XML string,
|
|
1420
|
-
* bypassing the IXmlableObject intermediate tree entirely.
|
|
1421
|
-
*/
|
|
1422
|
-
function stringifyWorksheet(opts, ctx) {
|
|
1423
|
-
const sharedStrings = ctx.sharedStrings;
|
|
1424
|
-
const styles = ctx.styles;
|
|
1425
|
-
const rows = opts.rows ?? [];
|
|
1426
|
-
const columns = opts.columns ?? [];
|
|
1427
|
-
const mergeCells = opts.mergeCells ?? [];
|
|
1428
|
-
const protectedRanges = opts.protectedRanges ?? [];
|
|
1429
|
-
const ignoredErrors = opts.ignoredErrors ?? [];
|
|
1430
|
-
const rowBreaks = opts.rowBreaks ?? [];
|
|
1431
|
-
const colBreaks = opts.colBreaks ?? [];
|
|
1432
|
-
const customSheetViews = opts.customSheetViews ?? [];
|
|
1433
|
-
const cellWatches = opts.cellWatches ?? [];
|
|
1434
|
-
const controls = opts.controls ?? [];
|
|
1435
|
-
const customProperties = opts.customProperties ?? [];
|
|
1436
|
-
const oleObjects = opts.oleObjects ?? [];
|
|
1437
|
-
const webPublishItems = opts.webPublishItems ?? [];
|
|
1438
|
-
const p = ["<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" mc:Ignorable=\"x14ac xr xr2 xr3\" xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\" xmlns:xr=\"http://schemas.microsoft.com/office/spreadsheetml/2014/revision\" xmlns:xr2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2\" xmlns:xr3=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3\">"];
|
|
1439
|
-
const hasTabColor = !!opts.tabColor;
|
|
1440
|
-
const hasOutline = columns.some((c) => c.outlineLevel !== void 0);
|
|
1441
|
-
const sp = opts.sheetPr;
|
|
1442
|
-
const hasSheetPrAttrs = sp && (sp.syncHorizontal || sp.syncVertical || sp.syncRef || sp.transitionEvaluation || sp.transitionEntry || sp.published || sp.filterMode || sp.enableFormatConditionsCalculation);
|
|
1443
|
-
const hasPageSetUpPr = !!opts.pageSetup?.fitToWidth || !!opts.pageSetup?.fitToHeight || !!opts.pageSetup?.autoPageBreaks;
|
|
1444
|
-
if (hasTabColor || hasOutline || hasSheetPrAttrs || hasPageSetUpPr) {
|
|
1445
|
-
const prParts = [];
|
|
1446
|
-
const prAttrs = {};
|
|
1447
|
-
if (sp?.syncHorizontal) prAttrs.syncHorizontal = 1;
|
|
1448
|
-
if (sp?.syncVertical) prAttrs.syncVertical = 1;
|
|
1449
|
-
if (sp?.syncRef) prAttrs.syncRef = sp.syncRef;
|
|
1450
|
-
if (sp?.transitionEvaluation) prAttrs.transitionEvaluation = 1;
|
|
1451
|
-
if (sp?.transitionEntry) prAttrs.transitionEntry = 1;
|
|
1452
|
-
if (sp?.published) prAttrs.published = 1;
|
|
1453
|
-
if (sp?.filterMode) prAttrs.filterMode = 1;
|
|
1454
|
-
if (sp?.enableFormatConditionsCalculation) prAttrs.enableFormatConditionsCalculation = 1;
|
|
1455
|
-
if (opts.tabColor) {
|
|
1456
|
-
const tc = opts.tabColor;
|
|
1457
|
-
const tcAttrs = {};
|
|
1458
|
-
if (tc.rgb) tcAttrs.rgb = tc.rgb;
|
|
1459
|
-
if (tc.theme !== void 0) tcAttrs.theme = tc.theme;
|
|
1460
|
-
if (tc.tint !== void 0) tcAttrs.tint = tc.tint;
|
|
1461
|
-
if (tc.indexed !== void 0) tcAttrs.indexed = tc.indexed;
|
|
1462
|
-
prParts.push(`<tabColor${attrs(tcAttrs)}/>`);
|
|
1463
|
-
}
|
|
1464
|
-
if (hasOutline) {
|
|
1465
|
-
const outAttrs = {
|
|
1466
|
-
summaryBelow: 1,
|
|
1467
|
-
summaryRight: 1
|
|
1468
|
-
};
|
|
1469
|
-
if (sp?.outlineSummaryBelow === false) outAttrs.summaryBelow = 0;
|
|
1470
|
-
if (sp?.outlineSummaryRight === false) outAttrs.summaryRight = 0;
|
|
1471
|
-
if (sp?.outlineApplyStyles) outAttrs.applyStyles = 1;
|
|
1472
|
-
if (sp?.outlineShowSymbols === false) outAttrs.showOutlineSymbols = 0;
|
|
1473
|
-
prParts.push(`<outlinePr${attrs(outAttrs)}/>`);
|
|
1474
|
-
}
|
|
1475
|
-
if (opts.pageSetup?.fitToWidth || opts.pageSetup?.fitToHeight || opts.pageSetup?.autoPageBreaks) {
|
|
1476
|
-
const psupAttrs = {};
|
|
1477
|
-
if (opts.pageSetup?.fitToWidth || opts.pageSetup?.fitToHeight) psupAttrs.fitToPage = 1;
|
|
1478
|
-
if (opts.pageSetup?.autoPageBreaks) psupAttrs.autoPageBreaks = 1;
|
|
1479
|
-
prParts.push(`<pageSetUpPr${attrs(psupAttrs)}/>`);
|
|
1480
|
-
}
|
|
1481
|
-
const prAttrStr = Object.keys(prAttrs).length > 0 ? attrs(prAttrs) : "";
|
|
1482
|
-
p.push(`<sheetPr${prAttrStr}>${prParts.join("")}</sheetPr>`);
|
|
1483
|
-
}
|
|
1484
|
-
const maxRow = rows.length;
|
|
1485
|
-
let maxCol = 0;
|
|
1486
|
-
for (const row of rows) if (row.cells && row.cells.length > maxCol) maxCol = row.cells.length;
|
|
1487
|
-
if (maxRow > 0 && maxCol > 0) {
|
|
1488
|
-
const dimRef = `A1:${defaultCellRef(maxRow, maxCol)}`;
|
|
1489
|
-
p.push(`<dimension ref="${dimRef}"/>`);
|
|
1490
|
-
}
|
|
1491
|
-
const pivotSelXml = opts.sheetView?.pivotSelections ? opts.sheetView.pivotSelections.map((ps) => buildPivotSelectionXml(ps)).join("") : "";
|
|
1492
|
-
if (opts.freezePanes) {
|
|
1493
|
-
const fp = opts.freezePanes;
|
|
1494
|
-
const ySplit = fp.row ? fp.row : 0;
|
|
1495
|
-
const xSplit = fp.col ? fp.col : 0;
|
|
1496
|
-
const topLeftCell = defaultCellRef(fp.row ? fp.row + 1 : 1, fp.col ? fp.col + 1 : 1);
|
|
1497
|
-
const activePane = ySplit > 0 && xSplit > 0 ? "bottomRight" : ySplit > 0 ? "bottomLeft" : "topRight";
|
|
1498
|
-
const svAttrs = buildSheetViewAttrs(opts.sheetView);
|
|
1499
|
-
p.push(`<sheetViews><sheetView${svAttrs}>`, `<pane ySplit="${ySplit}" xSplit="${xSplit}" topLeftCell="${topLeftCell}" activePane="${activePane}" state="frozen"/>`, opts.selection ? buildSelectionXml(opts.selection) : "", pivotSelXml, "</sheetView></sheetViews>");
|
|
1500
|
-
} else {
|
|
1501
|
-
const svAttrs = buildSheetViewAttrs(opts.sheetView);
|
|
1502
|
-
const innerXml = (opts.selection ? buildSelectionXml(opts.selection) : "") + pivotSelXml;
|
|
1503
|
-
if (innerXml) p.push(`<sheetViews><sheetView${svAttrs}>${innerXml}</sheetView></sheetViews>`);
|
|
1504
|
-
else p.push(`<sheetViews><sheetView${svAttrs}/></sheetViews>`);
|
|
1505
|
-
}
|
|
1506
|
-
if (opts.sheetFormatPr) {
|
|
1507
|
-
const sfp = opts.sheetFormatPr;
|
|
1508
|
-
const sfpAttrs = {};
|
|
1509
|
-
if (sfp.baseColWidth !== void 0) sfpAttrs.baseColWidth = sfp.baseColWidth;
|
|
1510
|
-
if (sfp.defaultColWidth !== void 0) sfpAttrs.defaultColWidth = sfp.defaultColWidth;
|
|
1511
|
-
sfpAttrs.defaultRowHeight = sfp.defaultRowHeight ?? 15;
|
|
1512
|
-
if (sfp.zeroHeight) sfpAttrs.zeroHeight = 1;
|
|
1513
|
-
if (sfp.thickTop) sfpAttrs.thickTop = 1;
|
|
1514
|
-
if (sfp.thickBottom) sfpAttrs.thickBottom = 1;
|
|
1515
|
-
if (sfp.outlineLevelRow !== void 0) sfpAttrs.outlineLevelRow = sfp.outlineLevelRow;
|
|
1516
|
-
if (sfp.outlineLevelCol !== void 0) sfpAttrs.outlineLevelCol = sfp.outlineLevelCol;
|
|
1517
|
-
p.push(`<sheetFormatPr${attrs(sfpAttrs)}/>`);
|
|
1518
|
-
} else p.push("<sheetFormatPr defaultRowHeight=\"15\"/>");
|
|
1519
|
-
if (columns.length > 0) {
|
|
1520
|
-
p.push("<cols>");
|
|
1521
|
-
for (const col of columns) {
|
|
1522
|
-
const colAttrs = {
|
|
1523
|
-
min: col.min,
|
|
1524
|
-
max: col.max
|
|
1525
|
-
};
|
|
1526
|
-
if (col.width !== void 0) {
|
|
1527
|
-
colAttrs.width = col.width;
|
|
1528
|
-
colAttrs.customWidth = 1;
|
|
1529
|
-
}
|
|
1530
|
-
if (col.hidden) colAttrs.hidden = 1;
|
|
1531
|
-
if (col.outlineLevel !== void 0) colAttrs.outlineLevel = col.outlineLevel;
|
|
1532
|
-
if (col.collapsed) colAttrs.collapsed = 1;
|
|
1533
|
-
if (col.bestFit) colAttrs.bestFit = 1;
|
|
1534
|
-
if (col.phonetic) colAttrs.phonetic = 1;
|
|
1535
|
-
p.push(selfCloseElement("col", attrs(colAttrs)));
|
|
1536
|
-
}
|
|
1537
|
-
p.push("</cols>");
|
|
1538
|
-
}
|
|
1539
|
-
p.push("<sheetData>");
|
|
1540
|
-
for (let i = 0; i < rows.length; i++) {
|
|
1541
|
-
const rowOpts = rows[i];
|
|
1542
|
-
const rowNumber = rowOpts.rowNumber ?? i + 1;
|
|
1543
|
-
const rowAttrs = { r: rowNumber };
|
|
1544
|
-
if (rowOpts.height !== void 0) {
|
|
1545
|
-
rowAttrs.ht = rowOpts.height;
|
|
1546
|
-
rowAttrs.customHeight = 1;
|
|
1547
|
-
}
|
|
1548
|
-
if (rowOpts.hidden) rowAttrs.hidden = 1;
|
|
1549
|
-
if (rowOpts.spans) rowAttrs.spans = rowOpts.spans;
|
|
1550
|
-
if (rowOpts.customFormat) rowAttrs.customFormat = 1;
|
|
1551
|
-
if (rowOpts.thickTop) rowAttrs.thickTop = 1;
|
|
1552
|
-
if (rowOpts.thickBot) rowAttrs.thickBot = 1;
|
|
1553
|
-
if (rowOpts.ph) rowAttrs.ph = 1;
|
|
1554
|
-
if (rowOpts.cells) {
|
|
1555
|
-
p.push(`<row${attrsRaw(rowAttrs)}>`);
|
|
1556
|
-
for (let j = 0; j < rowOpts.cells.length; j++) {
|
|
1557
|
-
const cell = rowOpts.cells[j];
|
|
1558
|
-
const cellStr = buildCellString(cell.reference ?? defaultCellRef(rowNumber, j + 1), cell, sharedStrings, styles);
|
|
1559
|
-
if (cellStr) p.push(cellStr);
|
|
1560
|
-
}
|
|
1561
|
-
p.push("</row>");
|
|
1562
|
-
} else p.push(`<row${attrsRaw(rowAttrs)}/>`);
|
|
1563
|
-
}
|
|
1564
|
-
p.push("</sheetData>");
|
|
1565
|
-
if (opts.sheetCalcPr) {
|
|
1566
|
-
const scAttrs = [];
|
|
1567
|
-
if (opts.sheetCalcPr.fullCalcOnLoad) scAttrs.push("fullCalcOnLoad=\"1\"");
|
|
1568
|
-
p.push(`<sheetCalcPr${scAttrs.length ? " " + scAttrs.join(" ") : ""}/>`);
|
|
1569
|
-
}
|
|
1570
|
-
if (rowBreaks.length > 0) {
|
|
1571
|
-
const brkParts = rowBreaks.map((b) => {
|
|
1572
|
-
const bAttrs = { id: b.id };
|
|
1573
|
-
if (b.min !== void 0) bAttrs.min = b.min;
|
|
1574
|
-
if (b.max !== void 0) bAttrs.max = b.max;
|
|
1575
|
-
if (b.manual) bAttrs.man = 1;
|
|
1576
|
-
if (b.pivot) bAttrs.pt = 1;
|
|
1577
|
-
return `<brk${attrs(bAttrs)}/>`;
|
|
1578
|
-
});
|
|
1579
|
-
p.push(`<rowBreaks count="${rowBreaks.length}" manualBreakCount="${rowBreaks.filter((b) => b.manual).length}">${brkParts.join("")}</rowBreaks>`);
|
|
1580
|
-
}
|
|
1581
|
-
if (colBreaks.length > 0) {
|
|
1582
|
-
const brkParts = colBreaks.map((b) => {
|
|
1583
|
-
const bAttrs = { id: b.id };
|
|
1584
|
-
if (b.min !== void 0) bAttrs.min = b.min;
|
|
1585
|
-
if (b.max !== void 0) bAttrs.max = b.max;
|
|
1586
|
-
if (b.manual) bAttrs.man = 1;
|
|
1587
|
-
if (b.pivot) bAttrs.pt = 1;
|
|
1588
|
-
return `<brk${attrs(bAttrs)}/>`;
|
|
1589
|
-
});
|
|
1590
|
-
p.push(`<colBreaks count="${colBreaks.length}" manualBreakCount="${colBreaks.filter((b) => b.manual).length}">${brkParts.join("")}</colBreaks>`);
|
|
1591
|
-
}
|
|
1592
|
-
if (customProperties.length > 0) {
|
|
1593
|
-
const cpParts = ["<customProperties>"];
|
|
1594
|
-
for (const cp of customProperties) cpParts.push(`<customPr name="${escapeXml(cp.name)}" r:id="${escapeXml(cp.rId)}"/>`);
|
|
1595
|
-
cpParts.push("</customProperties>");
|
|
1596
|
-
p.push(cpParts.join(""));
|
|
1597
|
-
}
|
|
1598
|
-
if (opts.oleSize) p.push(`<oleSize ref="${escapeXml(opts.oleSize)}"/>`);
|
|
1599
|
-
if (customSheetViews.length > 0) {
|
|
1600
|
-
p.push("<customSheetViews>");
|
|
1601
|
-
for (const csv of customSheetViews) {
|
|
1602
|
-
const csvAttrs = { guid: csv.guid };
|
|
1603
|
-
if (csv.scale !== void 0) csvAttrs.scale = csv.scale;
|
|
1604
|
-
if (csv.showPageBreaks) csvAttrs.showPageBreaks = 1;
|
|
1605
|
-
if (csv.showFormulas) csvAttrs.showFormulas = 1;
|
|
1606
|
-
if (csv.showGridLines === false) csvAttrs.showGridLines = 0;
|
|
1607
|
-
if (csv.showRowColHeaders === false) csvAttrs.showRowCol = 0;
|
|
1608
|
-
if (csv.outlineSymbols === false) csvAttrs.outlineSymbols = 0;
|
|
1609
|
-
if (csv.zeroValues === false) csvAttrs.zeroValues = 0;
|
|
1610
|
-
if (csv.fitToPage) csvAttrs.fitToPage = 1;
|
|
1611
|
-
if (csv.printArea) csvAttrs.printArea = 1;
|
|
1612
|
-
if (csv.filter) csvAttrs.filter = 1;
|
|
1613
|
-
if (csv.showAutoFilter) csvAttrs.showAutoFilter = 1;
|
|
1614
|
-
if (csv.hiddenRows) csvAttrs.hiddenRows = 1;
|
|
1615
|
-
if (csv.hiddenColumns) csvAttrs.hiddenColumns = 1;
|
|
1616
|
-
if (csv.state && csv.state !== "visible") csvAttrs.state = csv.state;
|
|
1617
|
-
if (csv.filterUnique) csvAttrs.filterUnique = 1;
|
|
1618
|
-
if (csv.view && csv.view !== "normal") csvAttrs.view = csv.view;
|
|
1619
|
-
p.push(`<customSheetView${attrs(csvAttrs)}/>`);
|
|
1620
|
-
}
|
|
1621
|
-
p.push("</customSheetViews>");
|
|
1622
|
-
}
|
|
1623
|
-
if (cellWatches.length > 0) {
|
|
1624
|
-
p.push("<cellWatches>");
|
|
1625
|
-
for (const cw of cellWatches) p.push(`<cellWatch r="${escapeXml(cw.r)}"/>`);
|
|
1626
|
-
p.push("</cellWatches>");
|
|
1627
|
-
}
|
|
1628
|
-
if (opts.dataConsolidate) {
|
|
1629
|
-
const dc = opts.dataConsolidate;
|
|
1630
|
-
const dcAttrs = {};
|
|
1631
|
-
if (dc.function && dc.function !== "sum") dcAttrs.function = dc.function;
|
|
1632
|
-
if (dc.topLabels) dcAttrs.topLabels = 1;
|
|
1633
|
-
if (dc.leftLabels) dcAttrs.leftLabels = 1;
|
|
1634
|
-
if (dc.startLabels) dcAttrs.startLabels = 1;
|
|
1635
|
-
if (dc.link) dcAttrs.link = 1;
|
|
1636
|
-
const refsInner = dc.refs?.map((r) => `<dataRef ref="${escapeXml(r)}"/>`).join("") ?? "";
|
|
1637
|
-
const refsXml = refsInner ? `<dataRefs>${refsInner}</dataRefs>` : "";
|
|
1638
|
-
if (refsXml || Object.keys(dcAttrs).length > 0) p.push(`<dataConsolidate${attrs(dcAttrs)}>${refsXml}</dataConsolidate>`);
|
|
1639
|
-
}
|
|
1640
|
-
if (opts.protection) {
|
|
1641
|
-
const prot = opts.protection;
|
|
1642
|
-
const protAttrs = {};
|
|
1643
|
-
if (prot.password) protAttrs.password = hashPassword$1(prot.password);
|
|
1644
|
-
let derived;
|
|
1645
|
-
if (prot.password !== void 0 && prot.hashValue === void 0) derived = derivePasswordHash(prot.password);
|
|
1646
|
-
protAttrs.algorithmName = prot.algorithmName ?? derived?.algorithmName;
|
|
1647
|
-
protAttrs.hashValue = prot.hashValue ?? derived?.hashValue;
|
|
1648
|
-
protAttrs.saltValue = prot.saltValue ?? derived?.saltValue;
|
|
1649
|
-
if (prot.spinCount !== void 0) protAttrs.spinCount = prot.spinCount;
|
|
1650
|
-
else if (derived) protAttrs.spinCount = derived.spinCount;
|
|
1651
|
-
if (prot.sheet) protAttrs.sheet = 1;
|
|
1652
|
-
if (prot.objects) protAttrs.objects = 1;
|
|
1653
|
-
if (prot.scenarios) protAttrs.scenarios = 1;
|
|
1654
|
-
if (prot.formatCells === false) protAttrs.formatCells = 0;
|
|
1655
|
-
if (prot.formatColumns === false) protAttrs.formatColumns = 0;
|
|
1656
|
-
if (prot.formatRows === false) protAttrs.formatRows = 0;
|
|
1657
|
-
if (prot.insertColumns === false) protAttrs.insertColumns = 0;
|
|
1658
|
-
if (prot.insertRows === false) protAttrs.insertRows = 0;
|
|
1659
|
-
if (prot.insertHyperlinks === false) protAttrs.insertHyperlinks = 0;
|
|
1660
|
-
if (prot.deleteColumns === false) protAttrs.deleteColumns = 0;
|
|
1661
|
-
if (prot.deleteRows === false) protAttrs.deleteRows = 0;
|
|
1662
|
-
if (prot.selectLockedCells) protAttrs.selectLockedCells = 1;
|
|
1663
|
-
if (prot.sort === false) protAttrs.sort = 0;
|
|
1664
|
-
if (prot.autoFilter === false) protAttrs.autoFilter = 0;
|
|
1665
|
-
if (prot.pivotTables === false) protAttrs.pivotTables = 0;
|
|
1666
|
-
if (prot.selectUnlockedCells) protAttrs.selectUnlockedCells = 1;
|
|
1667
|
-
p.push(selfCloseElement("sheetProtection", attrs(protAttrs)));
|
|
1668
|
-
}
|
|
1669
|
-
if (protectedRanges.length > 0) {
|
|
1670
|
-
const prParts = ["<protectedRanges>"];
|
|
1671
|
-
for (const pr of protectedRanges) {
|
|
1672
|
-
const prAttrs = {
|
|
1673
|
-
name: pr.name,
|
|
1674
|
-
sqref: pr.sqref
|
|
1675
|
-
};
|
|
1676
|
-
if (pr.password) prAttrs.password = hashPassword$1(pr.password);
|
|
1677
|
-
let prDerived;
|
|
1678
|
-
if (pr.password !== void 0 && pr.hashValue === void 0) prDerived = derivePasswordHash(pr.password);
|
|
1679
|
-
prAttrs.algorithmName = pr.algorithmName ?? prDerived?.algorithmName;
|
|
1680
|
-
prAttrs.hashValue = pr.hashValue ?? prDerived?.hashValue;
|
|
1681
|
-
prAttrs.saltValue = pr.saltValue ?? prDerived?.saltValue;
|
|
1682
|
-
if (pr.spinCount !== void 0) prAttrs.spinCount = pr.spinCount;
|
|
1683
|
-
else if (prDerived) prAttrs.spinCount = prDerived.spinCount;
|
|
1684
|
-
if (!!pr.securityDescriptor) prParts.push(`<protectedRange${attrs(prAttrs)}><securityDescriptor>${escapeXml(pr.securityDescriptor)}</securityDescriptor></protectedRange>`);
|
|
1685
|
-
else prParts.push(selfCloseElement("protectedRange", attrs(prAttrs)));
|
|
1686
|
-
}
|
|
1687
|
-
prParts.push("</protectedRanges>");
|
|
1688
|
-
p.push(prParts.join(""));
|
|
1689
|
-
}
|
|
1690
|
-
if (opts.scenarios) {
|
|
1691
|
-
const scParts = ["<scenarios"];
|
|
1692
|
-
const scAttrs = {};
|
|
1693
|
-
if (opts.scenarios.current !== void 0) scAttrs.current = opts.scenarios.current;
|
|
1694
|
-
if (opts.scenarios.show !== void 0) scAttrs.show = opts.scenarios.show;
|
|
1695
|
-
scParts[0] = `<scenarios${attrs(scAttrs)}>`;
|
|
1696
|
-
for (const scenario of opts.scenarios.scenarios) {
|
|
1697
|
-
const sAttrs = { name: scenario.name };
|
|
1698
|
-
if (scenario.count !== void 0) sAttrs.count = scenario.count;
|
|
1699
|
-
if (scenario.user) sAttrs.user = scenario.user;
|
|
1700
|
-
if (scenario.comment) sAttrs.comment = scenario.comment;
|
|
1701
|
-
if (scenario.hidden) sAttrs.hidden = true;
|
|
1702
|
-
if (scenario.locked) sAttrs.locked = true;
|
|
1703
|
-
const sParts = [`<scenario${attrs(sAttrs)}>`];
|
|
1704
|
-
for (const cell of scenario.inputCells) {
|
|
1705
|
-
const icAttrs = {
|
|
1706
|
-
r: cell.r,
|
|
1707
|
-
val: String(cell.val)
|
|
1708
|
-
};
|
|
1709
|
-
if (cell.deleted) icAttrs.deleted = true;
|
|
1710
|
-
if (cell.undone) icAttrs.undone = true;
|
|
1711
|
-
sParts.push(`<inputCells${attrs(icAttrs)}/>`);
|
|
1712
|
-
}
|
|
1713
|
-
sParts.push("</scenario>");
|
|
1714
|
-
scParts.push(sParts.join(""));
|
|
1715
|
-
}
|
|
1716
|
-
scParts.push("</scenarios>");
|
|
1717
|
-
p.push(scParts.join(""));
|
|
1718
|
-
}
|
|
1719
|
-
if (opts.autoFilter) if (typeof opts.autoFilter === "string") p.push(selfCloseElement("autoFilter", attrs({ ref: opts.autoFilter })));
|
|
1720
|
-
else {
|
|
1721
|
-
const af = opts.autoFilter;
|
|
1722
|
-
const inner = [];
|
|
1723
|
-
for (const t10 of af.top10 ?? []) {
|
|
1724
|
-
const fcAttrs = { colId: t10.colId };
|
|
1725
|
-
if (t10.hiddenButton) fcAttrs.hiddenButton = 1;
|
|
1726
|
-
if (t10.showButton === false) fcAttrs.showButton = 0;
|
|
1727
|
-
const t10Attrs = { val: t10.val };
|
|
1728
|
-
if (t10.top === false) t10Attrs.top = 0;
|
|
1729
|
-
if (t10.percent) t10Attrs.percent = 1;
|
|
1730
|
-
if (t10.filterVal !== void 0) t10Attrs.filterVal = t10.filterVal;
|
|
1731
|
-
inner.push(`<filterColumn${attrs(fcAttrs)}><top10${attrs(t10Attrs)}/></filterColumn>`);
|
|
1732
|
-
}
|
|
1733
|
-
for (const cf of af.customFilters ?? []) {
|
|
1734
|
-
const fcAttrs = { colId: cf.colId };
|
|
1735
|
-
if (cf.hiddenButton) fcAttrs.hiddenButton = 1;
|
|
1736
|
-
if (cf.showButton === false) fcAttrs.showButton = 0;
|
|
1737
|
-
const cfAttrs = {};
|
|
1738
|
-
if (cf.and) cfAttrs.and = 1;
|
|
1739
|
-
const filters = [];
|
|
1740
|
-
if (cf.val !== void 0) {
|
|
1741
|
-
const fAttrs = { val: cf.val };
|
|
1742
|
-
if (cf.operator) fAttrs.operator = cf.operator;
|
|
1743
|
-
filters.push(selfCloseElement("customFilter", attrs(fAttrs)));
|
|
1744
|
-
}
|
|
1745
|
-
if (cf.val2 !== void 0) filters.push(selfCloseElement("customFilter", attrs({ val: cf.val2 })));
|
|
1746
|
-
if (filters.length > 0) inner.push(`<filterColumn${attrs(fcAttrs)}><customFilters${attrs(cfAttrs)}>${filters.join("")}</customFilters></filterColumn>`);
|
|
1747
|
-
}
|
|
1748
|
-
for (const fi of af.filters ?? []) {
|
|
1749
|
-
const fcAttrs = { colId: fi.colId };
|
|
1750
|
-
const filtersAttrs = {};
|
|
1751
|
-
if (fi.blank) filtersAttrs.blank = 1;
|
|
1752
|
-
if (fi.calendarType) filtersAttrs.calendarType = fi.calendarType;
|
|
1753
|
-
const valParts = (fi.values ?? []).map((v) => `<filter val="${escapeXml(v)}"/>`);
|
|
1754
|
-
inner.push(`<filterColumn${attrs(fcAttrs)}><filters${attrs(filtersAttrs)}>${valParts.join("")}</filters></filterColumn>`);
|
|
1755
|
-
}
|
|
1756
|
-
if (af.sort && af.sort.length > 0) {
|
|
1757
|
-
const sortParts = [];
|
|
1758
|
-
for (const sc of af.sort) {
|
|
1759
|
-
const scAttrs = { ref: sc.ref };
|
|
1760
|
-
if (sc.descending) scAttrs.descending = 1;
|
|
1761
|
-
if (sc.sortBy) scAttrs.sortBy = sc.sortBy;
|
|
1762
|
-
if (sc.customList) scAttrs.customList = sc.customList;
|
|
1763
|
-
if (sc.iconId !== void 0) scAttrs.iconId = sc.iconId;
|
|
1764
|
-
sortParts.push(selfCloseElement("sortCondition", attrs(scAttrs)));
|
|
1765
|
-
}
|
|
1766
|
-
const ssAttrs = { ref: af.ref };
|
|
1767
|
-
if (af.sortState?.columnSort) ssAttrs.columnSort = 1;
|
|
1768
|
-
if (af.sortState?.caseSensitive) ssAttrs.caseSensitive = 1;
|
|
1769
|
-
if (af.sortState?.sortMethod) ssAttrs.sortMethod = af.sortState.sortMethod;
|
|
1770
|
-
inner.push(`<sortState${attrs(ssAttrs)}>${sortParts.join("")}</sortState>`);
|
|
1771
|
-
}
|
|
1772
|
-
for (const cf of af.colorFilters ?? []) {
|
|
1773
|
-
const cfAttrs = {};
|
|
1774
|
-
if (cf.dxfId !== void 0) cfAttrs.dxfId = cf.dxfId;
|
|
1775
|
-
if (cf.cellColor === false) cfAttrs.cellColor = 0;
|
|
1776
|
-
inner.push(`<filterColumn colId="${cf.colId}"><colorFilter${attrs(cfAttrs)}/></filterColumn>`);
|
|
1777
|
-
}
|
|
1778
|
-
for (const if_ of af.iconFilters ?? []) {
|
|
1779
|
-
const ifAttrs = { iconSet: if_.iconSet };
|
|
1780
|
-
if (if_.iconId !== void 0) ifAttrs.iconId = if_.iconId;
|
|
1781
|
-
inner.push(`<filterColumn colId="${if_.colId}"><iconFilter${attrs(ifAttrs)}/></filterColumn>`);
|
|
1782
|
-
}
|
|
1783
|
-
for (const df of af.dynamicFilters ?? []) {
|
|
1784
|
-
const dfAttrs = { type: df.type };
|
|
1785
|
-
if (df.val !== void 0) dfAttrs.val = df.val;
|
|
1786
|
-
if (df.maxVal !== void 0) dfAttrs.maxVal = df.maxVal;
|
|
1787
|
-
if (df.valIso !== void 0) dfAttrs.valIso = df.valIso;
|
|
1788
|
-
if (df.maxValIso !== void 0) dfAttrs.maxValIso = df.maxValIso;
|
|
1789
|
-
inner.push(`<filterColumn colId="${df.colId}"><dynamicFilter${attrs(dfAttrs)}/></filterColumn>`);
|
|
1790
|
-
}
|
|
1791
|
-
for (const dg of af.dateGroupItems ?? []) {
|
|
1792
|
-
const dgAttrs = { dateTimeGrouping: dg.dateTimeGrouping };
|
|
1793
|
-
if (dg.year !== void 0) dgAttrs.year = dg.year;
|
|
1794
|
-
if (dg.month !== void 0) dgAttrs.month = dg.month;
|
|
1795
|
-
if (dg.day !== void 0) dgAttrs.day = dg.day;
|
|
1796
|
-
if (dg.hour !== void 0) dgAttrs.hour = dg.hour;
|
|
1797
|
-
if (dg.minute !== void 0) dgAttrs.minute = dg.minute;
|
|
1798
|
-
if (dg.second !== void 0) dgAttrs.second = dg.second;
|
|
1799
|
-
inner.push(`<filterColumn colId="${dg.colId}"><dateGroupItem${attrs(dgAttrs)}/></filterColumn>`);
|
|
1800
|
-
}
|
|
1801
|
-
if (inner.length > 0) p.push(`<autoFilter ref="${af.ref}">`, ...inner, "</autoFilter>");
|
|
1802
|
-
else p.push(selfCloseElement("autoFilter", attrs({ ref: af.ref })));
|
|
1803
|
-
}
|
|
1804
|
-
if (mergeCells.length > 0) {
|
|
1805
|
-
p.push(`<mergeCells count="${mergeCells.length}">`);
|
|
1806
|
-
for (const mc of mergeCells) {
|
|
1807
|
-
const fromRef = defaultCellRef(mc.from.row, mc.from.col);
|
|
1808
|
-
const toRef = defaultCellRef(mc.to.row, mc.to.col);
|
|
1809
|
-
p.push(selfCloseElement("mergeCell", attrs({ ref: `${fromRef}:${toRef}` })));
|
|
1810
|
-
}
|
|
1811
|
-
p.push("</mergeCells>");
|
|
1812
|
-
}
|
|
1813
|
-
if (opts.phoneticPr) {
|
|
1814
|
-
const pp = opts.phoneticPr;
|
|
1815
|
-
const ppAttrs = { fontId: pp.fontId };
|
|
1816
|
-
if (pp.type && pp.type !== "fullwidthKatakana") ppAttrs.type = pp.type;
|
|
1817
|
-
if (pp.alignment && pp.alignment !== "left") ppAttrs.alignment = pp.alignment;
|
|
1818
|
-
p.push(selfCloseElement("phoneticPr", attrs(ppAttrs)));
|
|
1819
|
-
}
|
|
1820
|
-
const conditionalFormats = opts.conditionalFormats ?? [];
|
|
1821
|
-
if (conditionalFormats.length > 0) for (const cf of conditionalFormats) {
|
|
1822
|
-
p.push(`<conditionalFormatting sqref="${cf.sqref}">`);
|
|
1823
|
-
for (let ri = 0; ri < cf.rules.length; ri++) {
|
|
1824
|
-
const rule = cf.rules[ri];
|
|
1825
|
-
const ruleAttrs = {
|
|
1826
|
-
type: rule.type,
|
|
1827
|
-
priority: rule.priority ?? ri + 1
|
|
1828
|
-
};
|
|
1829
|
-
if (rule.operator) ruleAttrs.operator = rule.operator;
|
|
1830
|
-
if (rule.dxfId !== void 0) ruleAttrs.dxfId = rule.dxfId;
|
|
1831
|
-
if (rule.stopIfTrue) ruleAttrs.stopIfTrue = 1;
|
|
1832
|
-
if (rule.timePeriod) ruleAttrs.timePeriod = rule.timePeriod;
|
|
1833
|
-
if (rule.rank !== void 0) ruleAttrs.rank = rule.rank;
|
|
1834
|
-
if (rule.equalAverage) ruleAttrs.equalAverage = 1;
|
|
1835
|
-
if (rule.type === "colorScale" && rule.colorScale) {
|
|
1836
|
-
const cs = rule.colorScale;
|
|
1837
|
-
const inner = [];
|
|
1838
|
-
for (const v of cs.cfvo) inner.push(buildCfvoXml(v));
|
|
1839
|
-
for (const c of cs.colors) inner.push(`<color rgb="FF${c}"/>`);
|
|
1840
|
-
p.push(`<cfRule${attrs(ruleAttrs)}><colorScale>${inner.join("")}</colorScale></cfRule>`);
|
|
1841
|
-
} else if (rule.type === "dataBar" && rule.dataBar) {
|
|
1842
|
-
const db = rule.dataBar;
|
|
1843
|
-
const inner = [];
|
|
1844
|
-
for (const v of db.cfvo) inner.push(buildCfvoXml(v));
|
|
1845
|
-
inner.push(`<color rgb="FF${db.color}"/>`);
|
|
1846
|
-
const dbAttrs = {};
|
|
1847
|
-
if (db.minLength !== void 0 && db.minLength !== 10) dbAttrs.minLength = db.minLength;
|
|
1848
|
-
if (db.maxLength !== void 0 && db.maxLength !== 90) dbAttrs.maxLength = db.maxLength;
|
|
1849
|
-
if (db.showValue === false) dbAttrs.showValue = 0;
|
|
1850
|
-
const attrStr = Object.keys(dbAttrs).length > 0 ? attrs(dbAttrs) : "";
|
|
1851
|
-
p.push(`<cfRule${attrs(ruleAttrs)}><dataBar${attrStr}>${inner.join("")}</dataBar></cfRule>`);
|
|
1852
|
-
} else if (rule.type === "iconSet" && rule.iconSet) {
|
|
1853
|
-
const is = rule.iconSet;
|
|
1854
|
-
const inner = [];
|
|
1855
|
-
for (const v of is.cfvo) inner.push(buildCfvoXml(v));
|
|
1856
|
-
const isAttrs = {};
|
|
1857
|
-
if (is.iconSet !== void 0 && is.iconSet !== "3TrafficLights1") isAttrs.iconSet = is.iconSet;
|
|
1858
|
-
if (is.showValue === false) isAttrs.showValue = 0;
|
|
1859
|
-
if (is.percent === false) isAttrs.percent = 0;
|
|
1860
|
-
if (is.reverse) isAttrs.reverse = 1;
|
|
1861
|
-
const attrStr = Object.keys(isAttrs).length > 0 ? attrs(isAttrs) : "";
|
|
1862
|
-
p.push(`<cfRule${attrs(ruleAttrs)}><iconSet${attrStr}>${inner.join("")}</iconSet></cfRule>`);
|
|
1863
|
-
} else if (rule.formulas && rule.formulas.length > 0) {
|
|
1864
|
-
const formulaParts = rule.formulas.map((f) => `<formula>${escapeXml(f)}</formula>`);
|
|
1865
|
-
p.push(`<cfRule${attrs(ruleAttrs)}>`, ...formulaParts, "</cfRule>");
|
|
1866
|
-
} else p.push(selfCloseElement("cfRule", attrs(ruleAttrs)));
|
|
1867
|
-
}
|
|
1868
|
-
p.push("</conditionalFormatting>");
|
|
1869
|
-
}
|
|
1870
|
-
const dataValidations = opts.dataValidations ?? [];
|
|
1871
|
-
if (dataValidations.length > 0) {
|
|
1872
|
-
const dvContainerAttrs = { count: dataValidations.length };
|
|
1873
|
-
if (opts.dataValidationsDisablePrompts) dvContainerAttrs.disablePrompts = 1;
|
|
1874
|
-
p.push(`<dataValidations${attrs(dvContainerAttrs)}>`);
|
|
1875
|
-
for (const dv of dataValidations) {
|
|
1876
|
-
const dvAttrs = { sqref: dv.sqref };
|
|
1877
|
-
if (dv.type && dv.type !== "none") dvAttrs.type = dv.type;
|
|
1878
|
-
if (dv.operator) dvAttrs.operator = dv.operator;
|
|
1879
|
-
if (dv.allowBlank) dvAttrs.allowBlank = 1;
|
|
1880
|
-
if (dv.showErrorMessage) dvAttrs.showErrorMessage = 1;
|
|
1881
|
-
if (dv.showInputMessage) dvAttrs.showInputMessage = 1;
|
|
1882
|
-
if (dv.errorTitle) dvAttrs.errorTitle = dv.errorTitle;
|
|
1883
|
-
if (dv.error) dvAttrs.error = dv.error;
|
|
1884
|
-
if (dv.promptTitle) dvAttrs.promptTitle = dv.promptTitle;
|
|
1885
|
-
if (dv.prompt) dvAttrs.prompt = dv.prompt;
|
|
1886
|
-
if (dv.errorStyle) dvAttrs.errorStyle = dv.errorStyle;
|
|
1887
|
-
if (dv.imeMode) dvAttrs.imeMode = dv.imeMode;
|
|
1888
|
-
if (dv.showDropDown) dvAttrs.showDropDown = 1;
|
|
1889
|
-
const inner = [];
|
|
1890
|
-
if (dv.formula1 !== void 0) inner.push(`<formula1>${escapeXml(dv.formula1)}</formula1>`);
|
|
1891
|
-
if (dv.formula2 !== void 0) inner.push(`<formula2>${escapeXml(dv.formula2)}</formula2>`);
|
|
1892
|
-
if (inner.length > 0) p.push(`<dataValidation${attrs(dvAttrs)}>`, ...inner, "</dataValidation>");
|
|
1893
|
-
else p.push(selfCloseElement("dataValidation", attrs(dvAttrs)));
|
|
1894
|
-
}
|
|
1895
|
-
p.push("</dataValidations>");
|
|
1896
|
-
}
|
|
1897
|
-
const hyperlinks = opts.hyperlinks ?? [];
|
|
1898
|
-
if (hyperlinks.length > 0) {
|
|
1899
|
-
p.push("<hyperlinks>");
|
|
1900
|
-
let hlIdx = 0;
|
|
1901
|
-
for (const hl of hyperlinks) {
|
|
1902
|
-
const hlAttrs = { ref: hl.cell };
|
|
1903
|
-
if (hl.target.type === "external") {
|
|
1904
|
-
hlIdx++;
|
|
1905
|
-
hlAttrs["r:id"] = `rId${hlIdx}`;
|
|
1906
|
-
} else hlAttrs.location = hl.target.location;
|
|
1907
|
-
if (hl.tooltip) hlAttrs.tooltip = hl.tooltip;
|
|
1908
|
-
if (hl.display) hlAttrs.display = hl.display;
|
|
1909
|
-
p.push(selfCloseElement("hyperlink", attrs(hlAttrs)));
|
|
1910
|
-
}
|
|
1911
|
-
p.push("</hyperlinks>");
|
|
1912
|
-
}
|
|
1913
|
-
if (opts.printOptions) {
|
|
1914
|
-
const po = opts.printOptions;
|
|
1915
|
-
const poAttrs = {};
|
|
1916
|
-
if (po.horizontalCentered) poAttrs.horizontalCentered = 1;
|
|
1917
|
-
if (po.verticalCentered) poAttrs.verticalCentered = 1;
|
|
1918
|
-
if (po.headings) poAttrs.headings = 1;
|
|
1919
|
-
if (po.gridLines) poAttrs.gridLines = 1;
|
|
1920
|
-
if (po.gridLinesSet === false) poAttrs.gridLinesSet = 0;
|
|
1921
|
-
p.push(selfCloseElement("printOptions", attrs(poAttrs)));
|
|
1922
|
-
}
|
|
1923
|
-
p.push("<pageMargins left=\"0.75\" right=\"0.75\" top=\"1\" bottom=\"1\" header=\"0.5\" footer=\"0.5\"/>");
|
|
1924
|
-
if (opts.pageSetup) {
|
|
1925
|
-
const ps = opts.pageSetup;
|
|
1926
|
-
const psAttrs = {};
|
|
1927
|
-
if (ps.paperSize !== void 0) psAttrs.paperSize = ps.paperSize;
|
|
1928
|
-
if (ps.orientation && ps.orientation !== "default") psAttrs.orientation = ps.orientation;
|
|
1929
|
-
if (ps.scale !== void 0) psAttrs.scale = ps.scale;
|
|
1930
|
-
if (ps.fitToWidth !== void 0) psAttrs.fitToWidth = ps.fitToWidth;
|
|
1931
|
-
if (ps.fitToHeight !== void 0) psAttrs.fitToHeight = ps.fitToHeight;
|
|
1932
|
-
if (ps.pageOrder && ps.pageOrder !== "downThenOver") psAttrs.pageOrder = ps.pageOrder;
|
|
1933
|
-
if (ps.useFirstPageNumber) psAttrs.useFirstPageNumber = 1;
|
|
1934
|
-
if (ps.firstPageNumber !== void 0) psAttrs.firstPageNumber = ps.firstPageNumber;
|
|
1935
|
-
if (ps.paperHeight !== void 0) psAttrs.paperHeight = ps.paperHeight;
|
|
1936
|
-
if (ps.paperWidth !== void 0) psAttrs.paperWidth = ps.paperWidth;
|
|
1937
|
-
if (ps.usePrinterDefaults) psAttrs.usePrinterDefaults = 1;
|
|
1938
|
-
if (ps.blackAndWhite) psAttrs.blackAndWhite = 1;
|
|
1939
|
-
if (ps.draft) psAttrs.draft = 1;
|
|
1940
|
-
if (ps.cellComments && ps.cellComments !== "none") psAttrs.cellComments = ps.cellComments;
|
|
1941
|
-
if (ps.errors && ps.errors !== "displayed") psAttrs.errors = ps.errors;
|
|
1942
|
-
p.push(selfCloseElement("pageSetup", attrs(psAttrs)));
|
|
1943
|
-
}
|
|
1944
|
-
if (opts.headerFooter) {
|
|
1945
|
-
const hf = opts.headerFooter;
|
|
1946
|
-
const hfAttrs = {};
|
|
1947
|
-
if (hf.differentOddEven) hfAttrs.differentOddEven = 1;
|
|
1948
|
-
if (hf.differentFirst) hfAttrs.differentFirst = 1;
|
|
1949
|
-
if (hf.scaleWithDoc === false) hfAttrs.scaleWithDoc = 0;
|
|
1950
|
-
if (hf.alignWithMargins === false) hfAttrs.alignWithMargins = 0;
|
|
1951
|
-
const inner = [];
|
|
1952
|
-
if (hf.oddHeader) inner.push(`<oddHeader>${escapeXml(hf.oddHeader)}</oddHeader>`);
|
|
1953
|
-
if (hf.oddFooter) inner.push(`<oddFooter>${escapeXml(hf.oddFooter)}</oddFooter>`);
|
|
1954
|
-
if (hf.evenHeader) inner.push(`<evenHeader>${escapeXml(hf.evenHeader)}</evenHeader>`);
|
|
1955
|
-
if (hf.evenFooter) inner.push(`<evenFooter>${escapeXml(hf.evenFooter)}</evenFooter>`);
|
|
1956
|
-
if (hf.firstHeader) inner.push(`<firstHeader>${escapeXml(hf.firstHeader)}</firstHeader>`);
|
|
1957
|
-
if (hf.firstFooter) inner.push(`<firstFooter>${escapeXml(hf.firstFooter)}</firstFooter>`);
|
|
1958
|
-
if (inner.length > 0) p.push(`<headerFooter${attrs(hfAttrs)}>`, ...inner, "</headerFooter>");
|
|
1959
|
-
else if (hfAttrs.differentOddEven || hfAttrs.differentFirst) p.push(selfCloseElement("headerFooter", attrs(hfAttrs)));
|
|
1960
|
-
}
|
|
1961
|
-
if (opts.drawingHF) {
|
|
1962
|
-
const dhf = opts.drawingHF;
|
|
1963
|
-
const dhfAttrs = { "r:id": dhf.rId };
|
|
1964
|
-
if (dhf.lho !== void 0) dhfAttrs.lho = dhf.lho;
|
|
1965
|
-
if (dhf.lhe !== void 0) dhfAttrs.lhe = dhf.lhe;
|
|
1966
|
-
if (dhf.lhf !== void 0) dhfAttrs.lhf = dhf.lhf;
|
|
1967
|
-
if (dhf.cho !== void 0) dhfAttrs.cho = dhf.cho;
|
|
1968
|
-
if (dhf.che !== void 0) dhfAttrs.che = dhf.che;
|
|
1969
|
-
if (dhf.chf !== void 0) dhfAttrs.chf = dhf.chf;
|
|
1970
|
-
if (dhf.rho !== void 0) dhfAttrs.rho = dhf.rho;
|
|
1971
|
-
if (dhf.rhe !== void 0) dhfAttrs.rhe = dhf.rhe;
|
|
1972
|
-
if (dhf.rhf !== void 0) dhfAttrs.rhf = dhf.rhf;
|
|
1973
|
-
if (dhf.lfo !== void 0) dhfAttrs.lfo = dhf.lfo;
|
|
1974
|
-
if (dhf.lfe !== void 0) dhfAttrs.lfe = dhf.lfe;
|
|
1975
|
-
if (dhf.lff !== void 0) dhfAttrs.lff = dhf.lff;
|
|
1976
|
-
if (dhf.cfo !== void 0) dhfAttrs.cfo = dhf.cfo;
|
|
1977
|
-
if (dhf.cfe !== void 0) dhfAttrs.cfe = dhf.cfe;
|
|
1978
|
-
if (dhf.cff !== void 0) dhfAttrs.cff = dhf.cff;
|
|
1979
|
-
if (dhf.rfo !== void 0) dhfAttrs.rfo = dhf.rfo;
|
|
1980
|
-
if (dhf.rfe !== void 0) dhfAttrs.rfe = dhf.rfe;
|
|
1981
|
-
if (dhf.rff !== void 0) dhfAttrs.rff = dhf.rff;
|
|
1982
|
-
p.push(selfCloseElement("drawingHF", attrs(dhfAttrs)));
|
|
1983
|
-
}
|
|
1984
|
-
if (opts.legacyDrawingHF) p.push(`<legacyDrawingHF r:id="${escapeXml(opts.legacyDrawingHF)}"/>`);
|
|
1985
|
-
if (ignoredErrors.length > 0) {
|
|
1986
|
-
const ieParts = ["<ignoredErrors>"];
|
|
1987
|
-
for (const ie of ignoredErrors) {
|
|
1988
|
-
const ieAttrs = { sqref: ie.sqref };
|
|
1989
|
-
if (ie.evalError) ieAttrs.evalError = 1;
|
|
1990
|
-
if (ie.twoDigitTextYear) ieAttrs.twoDigitTextYear = 1;
|
|
1991
|
-
if (ie.numberStoredAsText) ieAttrs.numberStoredAsText = 1;
|
|
1992
|
-
if (ie.formula) ieAttrs.formula = 1;
|
|
1993
|
-
if (ie.formulaRange) ieAttrs.formulaRange = 1;
|
|
1994
|
-
if (ie.unlockedFormula) ieAttrs.unlockedFormula = 1;
|
|
1995
|
-
if (ie.emptyCellReference) ieAttrs.emptyCellReference = 1;
|
|
1996
|
-
if (ie.listDataValidation) ieAttrs.listDataValidation = 1;
|
|
1997
|
-
if (ie.calculatedColumn) ieAttrs.calculatedColumn = 1;
|
|
1998
|
-
ieParts.push(selfCloseElement("ignoredError", attrs(ieAttrs)));
|
|
1999
|
-
}
|
|
2000
|
-
ieParts.push("</ignoredErrors>");
|
|
2001
|
-
p.push(ieParts.join(""));
|
|
2002
|
-
}
|
|
2003
|
-
if (opts.backgroundImage) p.push("<!--BACKGROUND_PICTURE-->");
|
|
2004
|
-
if (oleObjects.length > 0) {
|
|
2005
|
-
const oleParts = ["<oleObjects>"];
|
|
2006
|
-
for (const ole of oleObjects) {
|
|
2007
|
-
const oleAttrs = [`shapeId="${ole.shapeId}"`];
|
|
2008
|
-
if (ole.progId) oleAttrs.push(`progId="${escapeXml(ole.progId)}"`);
|
|
2009
|
-
if (ole.dvAspect && ole.dvAspect !== "DVASPECT_CONTENT") oleAttrs.push(`dvAspect="${ole.dvAspect}"`);
|
|
2010
|
-
if (ole.link) oleAttrs.push(`link="${escapeXml(ole.link)}"`);
|
|
2011
|
-
if (ole.oleUpdate) oleAttrs.push(`oleUpdate="${ole.oleUpdate}"`);
|
|
2012
|
-
if (ole.autoLoad) oleAttrs.push("autoLoad=\"1\"");
|
|
2013
|
-
if (ole.rId) oleAttrs.push(`r:id="${escapeXml(ole.rId)}"`);
|
|
2014
|
-
if (ole.objectPr) {
|
|
2015
|
-
const opr = ole.objectPr;
|
|
2016
|
-
const oprAttrs = [];
|
|
2017
|
-
if (opr.locked === false) oprAttrs.push("locked=\"0\"");
|
|
2018
|
-
if (opr.defaultSize === false) oprAttrs.push("defaultSize=\"0\"");
|
|
2019
|
-
if (opr.print === false) oprAttrs.push("print=\"0\"");
|
|
2020
|
-
if (opr.disabled) oprAttrs.push("disabled=\"1\"");
|
|
2021
|
-
if (opr.uiObject) oprAttrs.push("uiObject=\"1\"");
|
|
2022
|
-
if (opr.autoFill === false) oprAttrs.push("autoFill=\"0\"");
|
|
2023
|
-
if (opr.autoLine === false) oprAttrs.push("autoLine=\"0\"");
|
|
2024
|
-
if (opr.autoPict === false) oprAttrs.push("autoPict=\"0\"");
|
|
2025
|
-
if (opr.macro) oprAttrs.push(`macro="${escapeXml(opr.macro)}"`);
|
|
2026
|
-
if (opr.altText) oprAttrs.push(`altText="${escapeXml(opr.altText)}"`);
|
|
2027
|
-
if (opr.dde) oprAttrs.push("dde=\"1\"");
|
|
2028
|
-
if (opr.rId) oprAttrs.push(`r:id="${escapeXml(opr.rId)}"`);
|
|
2029
|
-
oleParts.push(`<oleObject ${oleAttrs.join(" ")}><objectPr${oprAttrs.length ? " " + oprAttrs.join(" ") : ""}/></oleObject>`);
|
|
2030
|
-
} else oleParts.push(`<oleObject ${oleAttrs.join(" ")}/>`);
|
|
2031
|
-
}
|
|
2032
|
-
oleParts.push("</oleObjects>");
|
|
2033
|
-
p.push(oleParts.join(""));
|
|
2034
|
-
}
|
|
2035
|
-
if (controls.length > 0) {
|
|
2036
|
-
const ctrlParts = ["<controls>"];
|
|
2037
|
-
for (const c of controls) {
|
|
2038
|
-
const cAttrs = [`shapeId="${c.shapeId}"`, `r:id="${escapeXml(c.rId)}"`];
|
|
2039
|
-
if (c.name) cAttrs.push(`name="${escapeXml(c.name)}"`);
|
|
2040
|
-
const prAttrs = [];
|
|
2041
|
-
if (c.locked === false) prAttrs.push("locked=\"0\"");
|
|
2042
|
-
if (c.uiObject) prAttrs.push("uiObject=\"1\"");
|
|
2043
|
-
if (c.recalcAlways) prAttrs.push("recalcAlways=\"1\"");
|
|
2044
|
-
if (c.linkedCell) prAttrs.push(`linkedCell="${escapeXml(c.linkedCell)}"`);
|
|
2045
|
-
if (c.listFillRange) prAttrs.push(`listFillRange="${escapeXml(c.listFillRange)}"`);
|
|
2046
|
-
if (c.cf) prAttrs.push(`cf="${escapeXml(c.cf)}"`);
|
|
2047
|
-
if (prAttrs.length > 0) ctrlParts.push(`<control ${cAttrs.join(" ")}><controlPr${prAttrs.length ? " " + prAttrs.join(" ") : ""}/></control>`);
|
|
2048
|
-
else ctrlParts.push(`<control ${cAttrs.join(" ")}/>`);
|
|
2049
|
-
}
|
|
2050
|
-
ctrlParts.push("</controls>");
|
|
2051
|
-
p.push(ctrlParts.join(""));
|
|
2052
|
-
}
|
|
2053
|
-
if (webPublishItems.length > 0) {
|
|
2054
|
-
const wpParts = [`<webPublishItems count="${webPublishItems.length}">`];
|
|
2055
|
-
for (const wpi of webPublishItems) {
|
|
2056
|
-
const wpiAttrs = [
|
|
2057
|
-
`id="${wpi.id}"`,
|
|
2058
|
-
`divId="${escapeXml(wpi.divId)}"`,
|
|
2059
|
-
`sourceType="${wpi.sourceType}"`,
|
|
2060
|
-
`destinationFile="${escapeXml(wpi.destinationFile)}"`
|
|
2061
|
-
];
|
|
2062
|
-
if (wpi.sourceRef) wpiAttrs.push(`sourceRef="${escapeXml(wpi.sourceRef)}"`);
|
|
2063
|
-
if (wpi.sourceObject) wpiAttrs.push(`sourceObject="${escapeXml(wpi.sourceObject)}"`);
|
|
2064
|
-
if (wpi.title) wpiAttrs.push(`title="${escapeXml(wpi.title)}"`);
|
|
2065
|
-
if (wpi.autoRepublish) wpiAttrs.push("autoRepublish=\"1\"");
|
|
2066
|
-
wpParts.push(`<webPublishItem ${wpiAttrs.join(" ")}/>`);
|
|
2067
|
-
}
|
|
2068
|
-
wpParts.push("</webPublishItems>");
|
|
2069
|
-
p.push(wpParts.join(""));
|
|
2070
|
-
}
|
|
2071
|
-
if (opts.ext) p.push(`<extLst>${opts.ext}</extLst>`);
|
|
2072
|
-
p.push("</worksheet>");
|
|
2073
|
-
return p.join("");
|
|
2074
|
-
}
|
|
2075
|
-
function buildCfvoXml(cfvo) {
|
|
2076
|
-
const a = { type: cfvo.type };
|
|
2077
|
-
if (cfvo.val !== void 0) a.val = cfvo.val;
|
|
2078
|
-
if (cfvo.gte === false) a.gte = 0;
|
|
2079
|
-
return `<cfvo${attrs(a)}/>`;
|
|
2080
|
-
}
|
|
2081
|
-
function buildSheetViewAttrs(sv) {
|
|
2082
|
-
const svMap = { workbookViewId: 0 };
|
|
2083
|
-
if (sv?.tabSelected !== void 0) svMap.tabSelected = sv.tabSelected ? 1 : 0;
|
|
2084
|
-
else svMap.tabSelected = 1;
|
|
2085
|
-
if (sv?.showGridLines === false) svMap.showGridLines = 0;
|
|
2086
|
-
if (sv?.showRowColHeaders === false) svMap.showRowColHeaders = 0;
|
|
2087
|
-
if (sv?.showZeros === false) svMap.showZeros = 0;
|
|
2088
|
-
if (sv?.zoomScale !== void 0) svMap.zoomScale = sv.zoomScale;
|
|
2089
|
-
if (sv?.rightToLeft) svMap.rightToLeft = 1;
|
|
2090
|
-
if (sv?.windowProtection) svMap.windowProtection = 1;
|
|
2091
|
-
if (sv?.showFormulas) svMap.showFormulas = 1;
|
|
2092
|
-
if (sv?.showRuler === false) svMap.showRuler = 0;
|
|
2093
|
-
if (sv?.showOutlineSymbols === false) svMap.showOutlineSymbols = 0;
|
|
2094
|
-
if (sv?.defaultGridColor === false) svMap.defaultGridColor = 0;
|
|
2095
|
-
if (sv?.showWhiteSpace === false) svMap.showWhiteSpace = 0;
|
|
2096
|
-
if (sv?.view) svMap.view = sv.view;
|
|
2097
|
-
if (sv?.colorId !== void 0) svMap.colorId = sv.colorId;
|
|
2098
|
-
if (sv?.zoomScaleNormal !== void 0) svMap.zoomScaleNormal = sv.zoomScaleNormal;
|
|
2099
|
-
if (sv?.zoomScaleSheetLayoutView !== void 0) svMap.zoomScaleSheetLayoutView = sv.zoomScaleSheetLayoutView;
|
|
2100
|
-
if (sv?.zoomScalePageLayoutView !== void 0) svMap.zoomScalePageLayoutView = sv.zoomScalePageLayoutView;
|
|
2101
|
-
return attrs(svMap);
|
|
2102
|
-
}
|
|
2103
|
-
function buildSelectionXml(sel) {
|
|
2104
|
-
const selAttrs = {};
|
|
2105
|
-
if (sel.pane) selAttrs.pane = sel.pane;
|
|
2106
|
-
if (sel.activeCell) selAttrs.activeCell = sel.activeCell;
|
|
2107
|
-
if (sel.activeCellId !== void 0) selAttrs.activeCellId = sel.activeCellId;
|
|
2108
|
-
if (sel.sqref) selAttrs.sqref = sel.sqref;
|
|
2109
|
-
return `<selection${attrs(selAttrs)}/>`;
|
|
2110
|
-
}
|
|
2111
|
-
function buildPivotSelectionXml(_ps) {
|
|
2112
|
-
return "";
|
|
2113
|
-
}
|
|
2114
|
-
function hashPassword$1(password) {
|
|
2115
|
-
let hash = 0;
|
|
2116
|
-
for (let i = 0; i < password.length; i++) {
|
|
2117
|
-
const c = password.charCodeAt(i);
|
|
2118
|
-
hash = (hash >> 14 & 1) + (hash << 1 & 32767);
|
|
2119
|
-
hash ^= c;
|
|
2120
|
-
hash = hash & 16384 ? hash ^ 1 : hash;
|
|
2121
|
-
}
|
|
2122
|
-
hash = (hash >> 14 & 1) + (hash << 1 & 32767);
|
|
2123
|
-
hash = (hash >> 14 & 1) + (hash << 1 & 32767);
|
|
2124
|
-
hash ^= password.length;
|
|
2125
|
-
return hash.toString(16).toUpperCase().padStart(4, "0");
|
|
2126
|
-
}
|
|
2127
|
-
function buildFormulaString(fOpts) {
|
|
2128
|
-
const fAttrs = {};
|
|
2129
|
-
if (fOpts.type && fOpts.type !== FormulaType.NORMAL) fAttrs.t = fOpts.type;
|
|
2130
|
-
if (fOpts.reference) fAttrs.ref = fOpts.reference;
|
|
2131
|
-
if (fOpts.sharedIndex !== void 0) fAttrs.si = fOpts.sharedIndex;
|
|
2132
|
-
if (fOpts.aca) fAttrs.aca = 1;
|
|
2133
|
-
if (fOpts.dt2D) fAttrs.dt2D = 1;
|
|
2134
|
-
if (fOpts.dtr) fAttrs.dtr = 1;
|
|
2135
|
-
if (fOpts.del1) fAttrs.del1 = 1;
|
|
2136
|
-
if (fOpts.del2) fAttrs.del2 = 1;
|
|
2137
|
-
if (fOpts.r1) fAttrs.r1 = fOpts.r1;
|
|
2138
|
-
if (fOpts.r2) fAttrs.r2 = fOpts.r2;
|
|
2139
|
-
if (fOpts.ca) fAttrs.ca = 1;
|
|
2140
|
-
if (fOpts.bx) fAttrs.bx = 1;
|
|
2141
|
-
if (fOpts.formula !== void 0 && fOpts.formula !== "") return `<f${attrs(fAttrs)}>${escapeXml(fOpts.formula)}</f>`;
|
|
2142
|
-
if (Object.keys(fAttrs).length > 0) return selfCloseElement("f", attrs(fAttrs));
|
|
2143
|
-
return "";
|
|
2144
|
-
}
|
|
2145
|
-
function buildCellString(ref, cell, sharedStrings, styles) {
|
|
2146
|
-
const cellAttrs = { r: ref };
|
|
2147
|
-
if (cell.style !== void 0 && styles) cellAttrs.s = styles.register(cell.style);
|
|
2148
|
-
else if (cell.styleIndex !== void 0) cellAttrs.s = cell.styleIndex;
|
|
2149
|
-
const value = cell.value;
|
|
2150
|
-
if (cell.formula) {
|
|
2151
|
-
const fStr = buildFormulaString(cell.formula);
|
|
2152
|
-
let vStr = "";
|
|
2153
|
-
if (value === null || value === void 0) return `<c${attrsRaw(cellAttrs)}>${fStr}</c>`;
|
|
2154
|
-
if (typeof value === "number") vStr = `<v>${value}</v>`;
|
|
2155
|
-
else if (typeof value === "boolean") {
|
|
2156
|
-
cellAttrs.t = "b";
|
|
2157
|
-
vStr = `<v>${value ? 1 : 0}</v>`;
|
|
2158
|
-
} else if (typeof value === "string") {
|
|
2159
|
-
cellAttrs.t = "str";
|
|
2160
|
-
vStr = `<v>${escapeXml(value)}</v>`;
|
|
2161
|
-
} else if (value instanceof Date) vStr = `<v>${dateToSerialNumber(value)}</v>`;
|
|
2162
|
-
if (vStr) return `<c${attrsRaw(cellAttrs)}>${fStr}${vStr}</c>`;
|
|
2163
|
-
return `<c${attrsRaw(cellAttrs)}>${fStr}</c>`;
|
|
2164
|
-
}
|
|
2165
|
-
if (value === null || value === void 0) {
|
|
2166
|
-
if (cell.styleIndex !== void 0) return selfCloseElement("c", attrsRaw(cellAttrs));
|
|
2167
|
-
return "";
|
|
2168
|
-
}
|
|
2169
|
-
if (typeof value === "object" && !(value instanceof Date)) {
|
|
2170
|
-
if (sharedStrings) {
|
|
2171
|
-
cellAttrs.t = "s";
|
|
2172
|
-
const idx = sharedStrings.registerRich(value);
|
|
2173
|
-
return `<c${attrsRaw(cellAttrs)}><v>${idx}</v></c>`;
|
|
2174
|
-
}
|
|
2175
|
-
cellAttrs.t = "inlineStr";
|
|
2176
|
-
return `<c${attrsRaw(cellAttrs)}><is>${buildRstXml$1(value)}</is></c>`;
|
|
2177
|
-
}
|
|
2178
|
-
if (typeof value === "string") {
|
|
2179
|
-
if (sharedStrings) {
|
|
2180
|
-
cellAttrs.t = "s";
|
|
2181
|
-
const idx = sharedStrings.register(value);
|
|
2182
|
-
return `<c${attrsRaw(cellAttrs)}><v>${idx}</v></c>`;
|
|
2183
|
-
}
|
|
2184
|
-
cellAttrs.t = "inlineStr";
|
|
2185
|
-
return `<c${attrsRaw(cellAttrs)}><is><t>${escapeXml(value)}</t></is></c>`;
|
|
2186
|
-
}
|
|
2187
|
-
if (typeof value === "number") return `<c${attrsRaw(cellAttrs)}><v>${value}</v></c>`;
|
|
2188
|
-
if (typeof value === "boolean") {
|
|
2189
|
-
cellAttrs.t = "b";
|
|
2190
|
-
return `<c${attrsRaw(cellAttrs)}><v>${value ? 1 : 0}</v></c>`;
|
|
2191
|
-
}
|
|
2192
|
-
if (value instanceof Date) {
|
|
2193
|
-
const serial = dateToSerialNumber(value);
|
|
2194
|
-
return `<c${attrsRaw(cellAttrs)}><v>${serial}</v></c>`;
|
|
2195
|
-
}
|
|
2196
|
-
return "";
|
|
2197
|
-
}
|
|
2198
|
-
function defaultCellRef(row, col) {
|
|
2199
|
-
return columnToLetter(col) + row;
|
|
2200
|
-
}
|
|
2201
|
-
function columnToLetter(col) {
|
|
2202
|
-
let result = "";
|
|
2203
|
-
let n = col;
|
|
2204
|
-
while (n > 0) {
|
|
2205
|
-
const remainder = (n - 1) % 26;
|
|
2206
|
-
result = String.fromCharCode(65 + remainder) + result;
|
|
2207
|
-
n = Math.floor((n - 1) / 26);
|
|
2208
|
-
}
|
|
2209
|
-
return result;
|
|
2210
|
-
}
|
|
2211
|
-
function dateToSerialNumber(date) {
|
|
2212
|
-
const epoch = new Date(1899, 11, 30);
|
|
2213
|
-
return (date.getTime() - epoch.getTime()) / 864e5;
|
|
2214
|
-
}
|
|
2215
|
-
function parseCfvo(el) {
|
|
2216
|
-
const result = {};
|
|
2217
|
-
result.type = attr(el, "type") ?? "num";
|
|
2218
|
-
const val = attr(el, "val");
|
|
2219
|
-
if (val !== void 0) result.val = isNaN(Number(val)) ? val : Number(val);
|
|
2220
|
-
if (attr(el, "gte") === "0") result.gte = false;
|
|
2221
|
-
return result;
|
|
2222
|
-
}
|
|
2223
|
-
function parseCellRef(ref) {
|
|
2224
|
-
const match = ref.match(/^([A-Z]+)(\d+)$/);
|
|
2225
|
-
if (!match) return void 0;
|
|
2226
|
-
const colStr = match[1];
|
|
2227
|
-
const row = parseInt(match[2], 10);
|
|
2228
|
-
let col = 0;
|
|
2229
|
-
for (let i = 0; i < colStr.length; i++) col = col * 26 + (colStr.charCodeAt(i) - 64);
|
|
2230
|
-
return {
|
|
2231
|
-
row,
|
|
2232
|
-
col
|
|
2233
|
-
};
|
|
2234
|
-
}
|
|
2235
|
-
//#endregion
|
|
2236
737
|
//#region src/parts/calc-chain.ts
|
|
2237
738
|
const calcChainDesc = {
|
|
2238
739
|
kind: "custom",
|
|
@@ -2342,143 +843,10 @@ const chartsheetDesc = {
|
|
|
2342
843
|
}
|
|
2343
844
|
};
|
|
2344
845
|
//#endregion
|
|
2345
|
-
//#region src/parts/comments.ts
|
|
2346
|
-
const commentsDesc = {
|
|
2347
|
-
kind: "custom",
|
|
2348
|
-
stringify(opts, _ctx) {
|
|
2349
|
-
if (opts.comments.length === 0) return void 0;
|
|
2350
|
-
const authors = collectAuthors(opts.comments);
|
|
2351
|
-
const p = [`<comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`, `<authors>`];
|
|
2352
|
-
for (const author of authors) p.push(`<author>${escapeXml(author)}</author>`);
|
|
2353
|
-
p.push("</authors><commentList>");
|
|
2354
|
-
for (const entry of opts.comments) {
|
|
2355
|
-
const authorId = authors.indexOf(entry.author);
|
|
2356
|
-
const textXml = typeof entry.text === "string" ? `<t>${escapeXml(entry.text)}</t>` : buildRstXml(entry.text);
|
|
2357
|
-
p.push(`<comment ref="${entry.cell}" authorId="${authorId}"><text>${textXml}</text></comment>`);
|
|
2358
|
-
}
|
|
2359
|
-
p.push("</commentList></comments>");
|
|
2360
|
-
return p.join("");
|
|
2361
|
-
},
|
|
2362
|
-
parse(el, _ctx) {
|
|
2363
|
-
const comments = [];
|
|
2364
|
-
const authors = [];
|
|
2365
|
-
const authorsEl = findChild(el, "authors");
|
|
2366
|
-
if (authorsEl) {
|
|
2367
|
-
for (const a of authorsEl.elements ?? []) if (a.name === "author") authors.push(textOf(a) ?? "");
|
|
2368
|
-
}
|
|
2369
|
-
const listEl = findChild(el, "commentList");
|
|
2370
|
-
if (listEl) for (const c of listEl.elements ?? []) {
|
|
2371
|
-
if (c.name !== "comment") continue;
|
|
2372
|
-
const ref = attr(c, "ref") ?? "";
|
|
2373
|
-
const authorId = Number(attr(c, "authorId") ?? 0);
|
|
2374
|
-
const textEl = findChild(c, "text");
|
|
2375
|
-
const text = textEl ? parseRst(textEl) : "";
|
|
2376
|
-
comments.push({
|
|
2377
|
-
cell: ref,
|
|
2378
|
-
author: authors[authorId] ?? "",
|
|
2379
|
-
text
|
|
2380
|
-
});
|
|
2381
|
-
}
|
|
2382
|
-
return { comments };
|
|
2383
|
-
}
|
|
2384
|
-
};
|
|
2385
|
-
const vmlNotesDesc = {
|
|
2386
|
-
kind: "custom",
|
|
2387
|
-
stringify(opts, _ctx) {
|
|
2388
|
-
if (opts.comments.length === 0) return void 0;
|
|
2389
|
-
const p = [
|
|
2390
|
-
"<xml xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\">",
|
|
2391
|
-
"<o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout>",
|
|
2392
|
-
"<v:shapetype id=\"_x0000_t202\" coordsize=\"21600,21600\" o:spt=\"202\" path=\"m,l,21600r21600,l21600,xe\">",
|
|
2393
|
-
"<v:stroke joinstyle=\"miter\"/>",
|
|
2394
|
-
"<v:path gradientshapeok=\"t\" o:connecttype=\"rect\"/>",
|
|
2395
|
-
"</v:shapetype>"
|
|
2396
|
-
];
|
|
2397
|
-
for (let i = 0; i < opts.comments.length; i++) {
|
|
2398
|
-
const c = opts.comments[i];
|
|
2399
|
-
const col = c.cell.charCodeAt(0) - 65;
|
|
2400
|
-
const row = parseInt(c.cell.slice(1), 10) - 1;
|
|
2401
|
-
const anchor = `${col}, 0, ${row}, 0, ${col + 2}, 0, ${row + 2}, 0`;
|
|
2402
|
-
p.push(`<v:shape id="_x0000_s${1025 + i}" type="#_x0000_t202" style="position:absolute;margin-left:59.25pt;margin-top:1.5pt;width:108pt;height:59.25pt;z-index:1;visibility:hidden" fillcolor="infoBackground [80]" strokecolor="none [81]" o:insetmode="auto">`, `<v:fill color2="infoBackground [80]"/>`, `<v:shadow color="none [81]" obscured="t"/>`, `<v:path o:connecttype="none"/>`, `<v:textbox style="mso-direction-alt:auto"><div style="text-align:left"></div></v:textbox>`, `<x:ClientData ObjectType="Note"><x:MoveWithCells/><x:SizeWithCells/>`, `<x:Anchor>${anchor}</x:Anchor>`, `<x:AutoFill>False</x:AutoFill>`, `<x:Row>${row}</x:Row>`, `<x:Column>${col}</x:Column>`, `</x:ClientData>`, `</v:shape>`);
|
|
2403
|
-
}
|
|
2404
|
-
p.push("</xml>");
|
|
2405
|
-
return p.join("");
|
|
2406
|
-
},
|
|
2407
|
-
parse(_el, _ctx) {
|
|
2408
|
-
return { comments: [] };
|
|
2409
|
-
}
|
|
2410
|
-
};
|
|
2411
|
-
function collectAuthors(comments) {
|
|
2412
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2413
|
-
const result = [];
|
|
2414
|
-
for (const entry of comments) if (!seen.has(entry.author)) {
|
|
2415
|
-
seen.add(entry.author);
|
|
2416
|
-
result.push(entry.author);
|
|
2417
|
-
}
|
|
2418
|
-
return result.length > 0 ? result : [""];
|
|
2419
|
-
}
|
|
2420
|
-
/** Build rich text (CT_Rst) XML from runs. */
|
|
2421
|
-
function buildRstXml(rst) {
|
|
2422
|
-
const runs = rst.runs ?? [];
|
|
2423
|
-
const parts = [];
|
|
2424
|
-
for (const run of runs) {
|
|
2425
|
-
const props = run.properties;
|
|
2426
|
-
if (!props) {
|
|
2427
|
-
parts.push(`<r><t>${escapeXml(run.text)}</t></r>`);
|
|
2428
|
-
continue;
|
|
2429
|
-
}
|
|
2430
|
-
const rPr = [];
|
|
2431
|
-
if (props.bold) rPr.push("<b/>");
|
|
2432
|
-
if (props.italic) rPr.push("<i/>");
|
|
2433
|
-
if (props.underline) rPr.push(`<u val="${props.underline}"/>`);
|
|
2434
|
-
if (props.strike) rPr.push("<strike/>");
|
|
2435
|
-
if (props.size) rPr.push(`<sz val="${props.size}"/>`);
|
|
2436
|
-
if (props.color) rPr.push(`<color rgb="${props.color}"/>`);
|
|
2437
|
-
if (props.font) rPr.push(`<rFont val="${props.font}"/>`);
|
|
2438
|
-
const rPrXml = rPr.length ? `<rPr>${rPr.join("")}</rPr>` : "";
|
|
2439
|
-
parts.push(`<r>${rPrXml}<t>${escapeXml(run.text)}</t></r>`);
|
|
2440
|
-
}
|
|
2441
|
-
return parts.join("");
|
|
2442
|
-
}
|
|
2443
|
-
/** Parse rich text element into a plain string or rich runs. */
|
|
2444
|
-
function parseRst(textEl) {
|
|
2445
|
-
const runs = [];
|
|
2446
|
-
const parts = [];
|
|
2447
|
-
let hasRuns = false;
|
|
2448
|
-
for (const child of textEl.elements ?? []) if (child.name === "t") parts.push(textOf(child) ?? "");
|
|
2449
|
-
else if (child.name === "r") {
|
|
2450
|
-
hasRuns = true;
|
|
2451
|
-
const t = findChild(child, "t");
|
|
2452
|
-
const run = { text: t ? textOf(t) ?? "" : "" };
|
|
2453
|
-
const rPr = findChild(child, "rPr");
|
|
2454
|
-
if (rPr) {
|
|
2455
|
-
const props = {};
|
|
2456
|
-
if (findChild(rPr, "b")) props.bold = true;
|
|
2457
|
-
if (findChild(rPr, "i")) props.italic = true;
|
|
2458
|
-
const uEl = findChild(rPr, "u");
|
|
2459
|
-
if (uEl) props.underline = attr(uEl, "val") ?? "single";
|
|
2460
|
-
if (findChild(rPr, "strike")) props.strike = true;
|
|
2461
|
-
const szEl = findChild(rPr, "sz");
|
|
2462
|
-
if (szEl) {
|
|
2463
|
-
const sz = Number(attr(szEl, "val"));
|
|
2464
|
-
if (!Number.isNaN(sz)) props.size = sz;
|
|
2465
|
-
}
|
|
2466
|
-
const colorEl = findChild(rPr, "color");
|
|
2467
|
-
if (colorEl && attr(colorEl, "rgb")) props.color = attr(colorEl, "rgb");
|
|
2468
|
-
const rFontEl = findChild(rPr, "rFont");
|
|
2469
|
-
if (rFontEl && attr(rFontEl, "val")) props.font = attr(rFontEl, "val");
|
|
2470
|
-
run.properties = props;
|
|
2471
|
-
}
|
|
2472
|
-
runs.push(run);
|
|
2473
|
-
}
|
|
2474
|
-
if (hasRuns) return { runs };
|
|
2475
|
-
return parts.join("");
|
|
2476
|
-
}
|
|
2477
|
-
//#endregion
|
|
2478
846
|
//#region src/parts/drawing.ts
|
|
2479
847
|
const XDR_NS = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing";
|
|
2480
848
|
const A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
2481
|
-
const R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
849
|
+
const R_NS$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
2482
850
|
const C_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
|
|
2483
851
|
const drawingDesc = {
|
|
2484
852
|
kind: "custom",
|
|
@@ -2486,14 +854,14 @@ const drawingDesc = {
|
|
|
2486
854
|
const images = opts.images ?? [];
|
|
2487
855
|
const charts = opts.charts ?? [];
|
|
2488
856
|
if (images.length === 0 && charts.length === 0) return void 0;
|
|
2489
|
-
const p = [`<wsDr xmlns="${XDR_NS}" xmlns:a="${A_NS}" xmlns:r="${R_NS}">`];
|
|
857
|
+
const p = [`<wsDr xmlns="${XDR_NS}" xmlns:a="${A_NS}" xmlns:r="${R_NS$1}">`];
|
|
2490
858
|
let id = 1;
|
|
2491
859
|
for (const img of images) {
|
|
2492
860
|
p.push(`<twoCellAnchor editAs="oneCell"><from><col>${img.col - 1}</col><colOff>${img.colOffset ?? 0}</colOff><row>${img.row - 1}</row><rowOff>${img.rowOffset ?? 0}</rowOff></from>`, `<to><col>${img.col}</col><colOff>0</colOff><row>${img.row}</row><rowOff>0</rowOff></to>`, `<pic><nvPicPr><cNvPr id="${id}" name="Picture ${id}"/><cNvPicPr preferRelativeResize="1"/></nvPicPr>`, `<blipFill><a:blip r:embed="${img.rId}"/><a:stretch><a:fillRect/></a:stretch></blipFill>`, `<spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="400000" cy="300000"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></spPr></pic>`, `<clientData fLocksWithSheet="${img.locksWithSheet !== false ? 1 : 0}" fPrintsWithSheet="${img.printsWithSheet !== false ? 1 : 0}"/></twoCellAnchor>`);
|
|
2493
861
|
id++;
|
|
2494
862
|
}
|
|
2495
863
|
for (const chart of charts) {
|
|
2496
|
-
p.push(`<twoCellAnchor editAs="oneCell"><from><col>${chart.col - 1}</col><colOff>${chart.colOffset ?? 0}</colOff><row>${chart.row - 1}</row><rowOff>${chart.rowOffset ?? 0}</rowOff></from>`, `<to><col>${chart.col + 8}</col><colOff>0</colOff><row>${chart.row + 15}</row><rowOff>0</rowOff></to>`, `<graphicFrame><nvGraphicFramePr><cNvPr id="${id}" name="Chart ${id}"/><cNvGraphicFramePr><a:graphicFrameLocks noGrp="1"/></cNvGraphicFramePr></nvGraphicFramePr>`, `<xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/></xfrm>`, `<a:graphic><a:graphicData uri="${C_URI}"><c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:r="${R_NS}" r:id="${chart.rId}"/></a:graphicData></a:graphic></graphicFrame>`, `<clientData fLocksWithSheet="${chart.locksWithSheet !== false ? 1 : 0}" fPrintsWithSheet="${chart.printsWithSheet !== false ? 1 : 0}"/></twoCellAnchor>`);
|
|
864
|
+
p.push(`<twoCellAnchor editAs="oneCell"><from><col>${chart.col - 1}</col><colOff>${chart.colOffset ?? 0}</colOff><row>${chart.row - 1}</row><rowOff>${chart.rowOffset ?? 0}</rowOff></from>`, `<to><col>${chart.col + 8}</col><colOff>0</colOff><row>${chart.row + 15}</row><rowOff>0</rowOff></to>`, `<graphicFrame><nvGraphicFramePr><cNvPr id="${id}" name="Chart ${id}"/><cNvGraphicFramePr><a:graphicFrameLocks noGrp="1"/></cNvGraphicFramePr></nvGraphicFramePr>`, `<xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/></xfrm>`, `<a:graphic><a:graphicData uri="${C_URI}"><c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:r="${R_NS$1}" r:id="${chart.rId}"/></a:graphicData></a:graphic></graphicFrame>`, `<clientData fLocksWithSheet="${chart.locksWithSheet !== false ? 1 : 0}" fPrintsWithSheet="${chart.printsWithSheet !== false ? 1 : 0}"/></twoCellAnchor>`);
|
|
2497
865
|
id++;
|
|
2498
866
|
}
|
|
2499
867
|
p.push("</wsDr>");
|
|
@@ -4753,6 +3121,498 @@ function hashPassword(password) {
|
|
|
4753
3121
|
return hash.toString(16).toUpperCase().padStart(4, "0");
|
|
4754
3122
|
}
|
|
4755
3123
|
//#endregion
|
|
3124
|
+
//#region src/parts/revision-log.ts
|
|
3125
|
+
const S_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
3126
|
+
const R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
3127
|
+
function stringifyHeader(h) {
|
|
3128
|
+
const sheetIds = h.sheetIds.map((id) => `<sheetId val="${id}"/>`).join("");
|
|
3129
|
+
const reviewedXml = h.reviewed && h.reviewed.length > 0 ? `<reviewedList count="${h.reviewed.length}">${h.reviewed.map((r) => `<reviewed rId="${r}"/>`).join("")}</reviewedList>` : "";
|
|
3130
|
+
let attrs = ` guid="${escapeXml(h.guid)}" dateTime="${escapeXml(h.dateTime)}" maxSheetId="${h.maxSheetId}" userName="${escapeXml(h.userName)}" r:id="${escapeXml(h.rId)}"`;
|
|
3131
|
+
if (h.minRId !== void 0) attrs += ` minRId="${h.minRId}"`;
|
|
3132
|
+
if (h.maxRId !== void 0) attrs += ` maxRId="${h.maxRId}"`;
|
|
3133
|
+
return `<header${attrs}><sheetIdMap count="${h.sheetIds.length}">${sheetIds}</sheetIdMap>${reviewedXml}</header>`;
|
|
3134
|
+
}
|
|
3135
|
+
function parseHeader(el) {
|
|
3136
|
+
const result = {
|
|
3137
|
+
guid: attr(el, "guid") ?? "",
|
|
3138
|
+
dateTime: attr(el, "dateTime") ?? "",
|
|
3139
|
+
userName: attr(el, "userName") ?? "",
|
|
3140
|
+
rId: String(el.attributes?.["r:id"] ?? el.attributes?.["id"] ?? ""),
|
|
3141
|
+
maxSheetId: Number(attr(el, "maxSheetId") ?? "0"),
|
|
3142
|
+
sheetIds: children(findChild(el, "sheetIdMap"), "sheetId").map((s) => Number(attr(s, "val") ?? "0"))
|
|
3143
|
+
};
|
|
3144
|
+
const reviewedList = findChild(el, "reviewedList");
|
|
3145
|
+
if (reviewedList) {
|
|
3146
|
+
const reviewed = children(reviewedList, "reviewed").map((r) => Number(attr(r, "rId") ?? "0"));
|
|
3147
|
+
if (reviewed.length > 0) result.reviewed = reviewed;
|
|
3148
|
+
}
|
|
3149
|
+
const minRId = attr(el, "minRId");
|
|
3150
|
+
if (minRId !== void 0) result.minRId = Number(minRId);
|
|
3151
|
+
const maxRId = attr(el, "maxRId");
|
|
3152
|
+
if (maxRId !== void 0) result.maxRId = Number(maxRId);
|
|
3153
|
+
return result;
|
|
3154
|
+
}
|
|
3155
|
+
const revisionHeadersDesc = {
|
|
3156
|
+
kind: "custom",
|
|
3157
|
+
stringify(opts, _ctx) {
|
|
3158
|
+
if (opts.headers.length === 0) return void 0;
|
|
3159
|
+
let attrs = ` xmlns="${S_NS}" xmlns:r="${R_NS}" guid="${escapeXml(opts.guid)}"`;
|
|
3160
|
+
if (opts.lastGuid) attrs += ` lastGuid="${escapeXml(opts.lastGuid)}"`;
|
|
3161
|
+
if (opts.shared !== void 0) attrs += ` shared="${opts.shared ? 1 : 0}"`;
|
|
3162
|
+
if (opts.diskRevisions !== void 0) attrs += ` diskRevisions="${opts.diskRevisions ? 1 : 0}"`;
|
|
3163
|
+
if (opts.history !== void 0) attrs += ` history="${opts.history ? 1 : 0}"`;
|
|
3164
|
+
if (opts.trackRevisions !== void 0) attrs += ` trackRevisions="${opts.trackRevisions ? 1 : 0}"`;
|
|
3165
|
+
if (opts.exclusive !== void 0) attrs += ` exclusive="${opts.exclusive ? 1 : 0}"`;
|
|
3166
|
+
if (opts.revisionId !== void 0) attrs += ` revisionId="${opts.revisionId}"`;
|
|
3167
|
+
if (opts.version !== void 0) attrs += ` version="${opts.version}"`;
|
|
3168
|
+
if (opts.keepChangeHistory !== void 0) attrs += ` keepChangeHistory="${opts.keepChangeHistory ? 1 : 0}"`;
|
|
3169
|
+
if (opts.protected !== void 0) attrs += ` protected="${opts.protected ? 1 : 0}"`;
|
|
3170
|
+
if (opts.preserveHistory !== void 0) attrs += ` preserveHistory="${opts.preserveHistory}"`;
|
|
3171
|
+
return `<headers${attrs}>${opts.headers.map(stringifyHeader).join("")}</headers>`;
|
|
3172
|
+
},
|
|
3173
|
+
parse(el, _ctx) {
|
|
3174
|
+
const result = {
|
|
3175
|
+
guid: attr(el, "guid") ?? "",
|
|
3176
|
+
headers: children(el, "header").map(parseHeader)
|
|
3177
|
+
};
|
|
3178
|
+
const lastGuid = attr(el, "lastGuid");
|
|
3179
|
+
if (lastGuid !== void 0) result.lastGuid = lastGuid;
|
|
3180
|
+
readBool(el, "shared", (v) => result.shared = v);
|
|
3181
|
+
readBool(el, "diskRevisions", (v) => result.diskRevisions = v);
|
|
3182
|
+
readBool(el, "history", (v) => result.history = v);
|
|
3183
|
+
readBool(el, "trackRevisions", (v) => result.trackRevisions = v);
|
|
3184
|
+
readBool(el, "exclusive", (v) => result.exclusive = v);
|
|
3185
|
+
readNum(el, "revisionId", (v) => result.revisionId = v);
|
|
3186
|
+
readNum(el, "version", (v) => result.version = v);
|
|
3187
|
+
readBool(el, "keepChangeHistory", (v) => result.keepChangeHistory = v);
|
|
3188
|
+
readBool(el, "protected", (v) => result.protected = v);
|
|
3189
|
+
readNum(el, "preserveHistory", (v) => result.preserveHistory = v);
|
|
3190
|
+
return result;
|
|
3191
|
+
}
|
|
3192
|
+
};
|
|
3193
|
+
const usersDesc = {
|
|
3194
|
+
kind: "custom",
|
|
3195
|
+
stringify(opts, _ctx) {
|
|
3196
|
+
if (!opts.users || opts.users.length === 0) return void 0;
|
|
3197
|
+
const users = opts.users.map((u) => `<userInfo guid="${escapeXml(u.guid)}" name="${escapeXml(u.name)}" id="${u.id}" dateTime="${escapeXml(u.dateTime)}"/>`).join("");
|
|
3198
|
+
return `<users xmlns="${S_NS}" count="${opts.users.length}">${users}</users>`;
|
|
3199
|
+
},
|
|
3200
|
+
parse(el, _ctx) {
|
|
3201
|
+
const users = children(el, "userInfo").map((u) => ({
|
|
3202
|
+
guid: attr(u, "guid") ?? "",
|
|
3203
|
+
name: attr(u, "name") ?? "",
|
|
3204
|
+
id: Number(attr(u, "id") ?? "0"),
|
|
3205
|
+
dateTime: attr(u, "dateTime") ?? ""
|
|
3206
|
+
}));
|
|
3207
|
+
const result = {};
|
|
3208
|
+
if (users.length > 0) result.users = users;
|
|
3209
|
+
return result;
|
|
3210
|
+
}
|
|
3211
|
+
};
|
|
3212
|
+
function agRevData(data) {
|
|
3213
|
+
let s = ` rId="${data.rId}"`;
|
|
3214
|
+
if (data.undo) s += ` ua="1"`;
|
|
3215
|
+
if (data.rejected) s += ` ra="1"`;
|
|
3216
|
+
return s;
|
|
3217
|
+
}
|
|
3218
|
+
function stringifyEntry(entry) {
|
|
3219
|
+
switch (entry.type) {
|
|
3220
|
+
case "rowColumn": {
|
|
3221
|
+
const d = entry.data;
|
|
3222
|
+
let a = agRevData(d) + ` sId="${d.sheetId}" ref="${escapeXml(d.ref)}" action="${d.action}"`;
|
|
3223
|
+
if (d.endOfList) a += ` eol="1"`;
|
|
3224
|
+
if (d.edge) a += ` edge="1"`;
|
|
3225
|
+
return `<rrc${a}>${d.childrenXml ?? ""}</rrc>`;
|
|
3226
|
+
}
|
|
3227
|
+
case "move": {
|
|
3228
|
+
const d = entry.data;
|
|
3229
|
+
let a = agRevData(d) + ` sheetId="${d.sheetId}" source="${escapeXml(d.source)}" destination="${escapeXml(d.destination)}"`;
|
|
3230
|
+
if (d.sourceSheetId !== void 0) a += ` sourceSheetId="${d.sourceSheetId}"`;
|
|
3231
|
+
return `<rm${a}>${d.childrenXml ?? ""}</rm>`;
|
|
3232
|
+
}
|
|
3233
|
+
case "customView": {
|
|
3234
|
+
const d = entry.data;
|
|
3235
|
+
return `<rcv guid="${escapeXml(d.guid)}" action="${d.action}"/>`;
|
|
3236
|
+
}
|
|
3237
|
+
case "sheetRename": {
|
|
3238
|
+
const d = entry.data;
|
|
3239
|
+
return `<rsnm${agRevData(d)} sheetId="${d.sheetId}" oldName="${escapeXml(d.oldName)}" newName="${escapeXml(d.newName)}"/>`;
|
|
3240
|
+
}
|
|
3241
|
+
case "insertSheet": {
|
|
3242
|
+
const d = entry.data;
|
|
3243
|
+
return `<ris${agRevData(d)} sheetId="${d.sheetId}" name="${escapeXml(d.name)}" sheetPosition="${d.sheetPosition}"/>`;
|
|
3244
|
+
}
|
|
3245
|
+
case "cellChange": {
|
|
3246
|
+
const d = entry.data;
|
|
3247
|
+
let a = agRevData(d) + ` sId="${d.sheetId}"`;
|
|
3248
|
+
if (d.hasOldDxf) a += ` odxf="1"`;
|
|
3249
|
+
if (d.xfDxf) a += ` xfDxf="1"`;
|
|
3250
|
+
if (d.style) a += ` s="1"`;
|
|
3251
|
+
if (d.hasDxf) a += ` dxf="1"`;
|
|
3252
|
+
if (d.numFmtId !== void 0) a += ` numFmtId="${d.numFmtId}"`;
|
|
3253
|
+
if (d.quotePrefix) a += ` quotePrefix="1"`;
|
|
3254
|
+
if (d.oldQuotePrefix) a += ` oldQuotePrefix="1"`;
|
|
3255
|
+
if (d.phonetic) a += ` ph="1"`;
|
|
3256
|
+
if (d.oldPhonetic) a += ` oldPh="1"`;
|
|
3257
|
+
if (d.endOfListFormulaUpdate) a += ` endOfListFormulaUpdate="1"`;
|
|
3258
|
+
const children = [
|
|
3259
|
+
d.oldCellXml ?? "",
|
|
3260
|
+
d.newCellXml,
|
|
3261
|
+
d.oldDxfXml ?? "",
|
|
3262
|
+
d.newDxfXml ?? ""
|
|
3263
|
+
].filter(Boolean).join("");
|
|
3264
|
+
return `<rcc${a}>${children}</rcc>`;
|
|
3265
|
+
}
|
|
3266
|
+
case "formatting": {
|
|
3267
|
+
const d = entry.data;
|
|
3268
|
+
let a = ` sheetId="${d.sheetId}" sqref="${escapeXml(d.sqref)}"`;
|
|
3269
|
+
if (d.xfDxf) a += ` xfDxf="1"`;
|
|
3270
|
+
if (d.style) a += ` s="1"`;
|
|
3271
|
+
if (d.start !== void 0) a += ` start="${d.start}"`;
|
|
3272
|
+
if (d.length !== void 0) a += ` length="${d.length}"`;
|
|
3273
|
+
return `<rfmt${a}>${d.dxfXml ?? ""}</rfmt>`;
|
|
3274
|
+
}
|
|
3275
|
+
case "autoFormatting": {
|
|
3276
|
+
const d = entry.data;
|
|
3277
|
+
return `<raf sheetId="${d.sheetId}" ref="${escapeXml(d.ref)}"${d.autoFormatXml ?? ""}/>`;
|
|
3278
|
+
}
|
|
3279
|
+
case "definedName": {
|
|
3280
|
+
const d = entry.data;
|
|
3281
|
+
let a = agRevData(d) + ` name="${escapeXml(d.name)}"`;
|
|
3282
|
+
if (d.localSheetId !== void 0) a += ` localSheetId="${d.localSheetId}"`;
|
|
3283
|
+
if (d.customView) a += ` customView="1"`;
|
|
3284
|
+
if (d.function) a += ` function="1"`;
|
|
3285
|
+
if (d.oldFunction) a += ` oldFunction="1"`;
|
|
3286
|
+
if (d.functionGroupId !== void 0) a += ` functionGroupId="${d.functionGroupId}"`;
|
|
3287
|
+
if (d.oldFunctionGroupId !== void 0) a += ` oldFunctionGroupId="${d.oldFunctionGroupId}"`;
|
|
3288
|
+
if (d.shortcutKey !== void 0) a += ` shortcutKey="${d.shortcutKey}"`;
|
|
3289
|
+
if (d.oldShortcutKey !== void 0) a += ` oldShortcutKey="${d.oldShortcutKey}"`;
|
|
3290
|
+
if (d.hidden) a += ` hidden="1"`;
|
|
3291
|
+
if (d.oldHidden) a += ` oldHidden="1"`;
|
|
3292
|
+
const xstring = (v, attr) => v !== void 0 ? ` ${attr}="${escapeXml(v)}"` : "";
|
|
3293
|
+
a += xstring(d.customMenu, "customMenu") + xstring(d.oldCustomMenu, "oldCustomMenu");
|
|
3294
|
+
a += xstring(d.description, "description") + xstring(d.oldDescription, "oldDescription");
|
|
3295
|
+
a += xstring(d.help, "help") + xstring(d.oldHelp, "oldHelp");
|
|
3296
|
+
a += xstring(d.statusBar, "statusBar") + xstring(d.oldStatusBar, "oldStatusBar");
|
|
3297
|
+
a += xstring(d.comment, "comment") + xstring(d.oldComment, "oldComment");
|
|
3298
|
+
const children = [d.formula !== void 0 ? `<formula>${escapeXml(d.formula)}</formula>` : "", d.oldFormula !== void 0 ? `<oldFormula>${escapeXml(d.oldFormula)}</oldFormula>` : ""].filter(Boolean).join("");
|
|
3299
|
+
return `<rdn${a}>${children}</rdn>`;
|
|
3300
|
+
}
|
|
3301
|
+
case "comment": {
|
|
3302
|
+
const d = entry.data;
|
|
3303
|
+
let a = ` sheetId="${d.sheetId}" cell="${escapeXml(d.cell)}" guid="${escapeXml(d.guid)}" action="${d.action ?? "add"}" author="${escapeXml(d.author)}"`;
|
|
3304
|
+
if (d.alwaysShow) a += ` alwaysShow="1"`;
|
|
3305
|
+
if (d.old) a += ` old="1"`;
|
|
3306
|
+
if (d.hiddenRow) a += ` hiddenRow="1"`;
|
|
3307
|
+
if (d.hiddenColumn) a += ` hiddenColumn="1"`;
|
|
3308
|
+
if (d.oldLength !== void 0) a += ` oldLength="${d.oldLength}"`;
|
|
3309
|
+
if (d.newLength !== void 0) a += ` newLength="${d.newLength}"`;
|
|
3310
|
+
return `<rcmt${a}/>`;
|
|
3311
|
+
}
|
|
3312
|
+
case "queryTableField": {
|
|
3313
|
+
const d = entry.data;
|
|
3314
|
+
return `<rqt sheetId="${d.sheetId}" ref="${escapeXml(d.ref)}" fieldId="${d.fieldId}"/>`;
|
|
3315
|
+
}
|
|
3316
|
+
case "conflict": {
|
|
3317
|
+
const d = entry.data;
|
|
3318
|
+
let a = agRevData(d);
|
|
3319
|
+
if (d.sheetId !== void 0) a += ` sheetId="${d.sheetId}"`;
|
|
3320
|
+
return `<rcft${a}/>`;
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
/** Serializes an element's children back to a raw XML string (for rawXml passthrough). */
|
|
3325
|
+
function childrenToXml(el) {
|
|
3326
|
+
if (!el || !el.elements) return "";
|
|
3327
|
+
return el.elements.filter((c) => c.type === "element").map((c) => elementToXml(c)).join("");
|
|
3328
|
+
}
|
|
3329
|
+
function elementToXml(el) {
|
|
3330
|
+
const attrStr = Object.entries(el.attributes ?? {}).map(([k, v]) => ` ${k}="${escapeXml(String(v))}"`).join("");
|
|
3331
|
+
const inner = el.elements ? el.elements.map((c) => {
|
|
3332
|
+
if (c.type === "text") return escapeXml(textOf({ elements: [c] }) ?? "");
|
|
3333
|
+
if (c.type === "element") return elementToXml(c);
|
|
3334
|
+
return "";
|
|
3335
|
+
}).join("") : "";
|
|
3336
|
+
return `<${el.name}${attrStr}>${inner}</${el.name}>`;
|
|
3337
|
+
}
|
|
3338
|
+
/** Returns the first element child of a node as raw XML string. */
|
|
3339
|
+
function firstChildXml(el, name) {
|
|
3340
|
+
const child = findChild(el ?? void 0, name);
|
|
3341
|
+
return child ? elementToXml(child) : void 0;
|
|
3342
|
+
}
|
|
3343
|
+
function parseBool(el, name) {
|
|
3344
|
+
const v = attr(el, name);
|
|
3345
|
+
if (v === void 0) return void 0;
|
|
3346
|
+
return v === "1" || v === "true";
|
|
3347
|
+
}
|
|
3348
|
+
function parseEntry(el) {
|
|
3349
|
+
switch (el.name) {
|
|
3350
|
+
case "rrc": {
|
|
3351
|
+
const d = {
|
|
3352
|
+
rId: Number(attr(el, "rId") ?? "0"),
|
|
3353
|
+
sheetId: Number(attr(el, "sId") ?? "0"),
|
|
3354
|
+
ref: attr(el, "ref") ?? "",
|
|
3355
|
+
action: attr(el, "action") ?? "insertRow"
|
|
3356
|
+
};
|
|
3357
|
+
const endOfList = parseBool(el, "eol");
|
|
3358
|
+
if (endOfList) d.endOfList = endOfList;
|
|
3359
|
+
const edge = parseBool(el, "edge");
|
|
3360
|
+
if (edge) d.edge = edge;
|
|
3361
|
+
const undo = parseBool(el, "ua");
|
|
3362
|
+
if (undo) d.undo = undo;
|
|
3363
|
+
const rejected = parseBool(el, "ra");
|
|
3364
|
+
if (rejected) d.rejected = rejected;
|
|
3365
|
+
const childrenXml = childrenToXml(el);
|
|
3366
|
+
if (childrenXml) d.childrenXml = childrenXml;
|
|
3367
|
+
return {
|
|
3368
|
+
type: "rowColumn",
|
|
3369
|
+
data: d
|
|
3370
|
+
};
|
|
3371
|
+
}
|
|
3372
|
+
case "rm": {
|
|
3373
|
+
const d = {
|
|
3374
|
+
rId: Number(attr(el, "rId") ?? "0"),
|
|
3375
|
+
sheetId: Number(attr(el, "sheetId") ?? "0"),
|
|
3376
|
+
source: attr(el, "source") ?? "",
|
|
3377
|
+
destination: attr(el, "destination") ?? ""
|
|
3378
|
+
};
|
|
3379
|
+
const sourceSheetId = attr(el, "sourceSheetId");
|
|
3380
|
+
if (sourceSheetId !== void 0) d.sourceSheetId = Number(sourceSheetId);
|
|
3381
|
+
const undo = parseBool(el, "ua");
|
|
3382
|
+
if (undo) d.undo = undo;
|
|
3383
|
+
const rejected = parseBool(el, "ra");
|
|
3384
|
+
if (rejected) d.rejected = rejected;
|
|
3385
|
+
const childrenXml = childrenToXml(el);
|
|
3386
|
+
if (childrenXml) d.childrenXml = childrenXml;
|
|
3387
|
+
return {
|
|
3388
|
+
type: "move",
|
|
3389
|
+
data: d
|
|
3390
|
+
};
|
|
3391
|
+
}
|
|
3392
|
+
case "rcv": return {
|
|
3393
|
+
type: "customView",
|
|
3394
|
+
data: {
|
|
3395
|
+
guid: attr(el, "guid") ?? "",
|
|
3396
|
+
action: attr(el, "action") ?? "add"
|
|
3397
|
+
}
|
|
3398
|
+
};
|
|
3399
|
+
case "rsnm": {
|
|
3400
|
+
const d = {
|
|
3401
|
+
rId: Number(attr(el, "rId") ?? "0"),
|
|
3402
|
+
sheetId: Number(attr(el, "sheetId") ?? "0"),
|
|
3403
|
+
oldName: attr(el, "oldName") ?? "",
|
|
3404
|
+
newName: attr(el, "newName") ?? ""
|
|
3405
|
+
};
|
|
3406
|
+
const undo = parseBool(el, "ua");
|
|
3407
|
+
if (undo) d.undo = undo;
|
|
3408
|
+
const rejected = parseBool(el, "ra");
|
|
3409
|
+
if (rejected) d.rejected = rejected;
|
|
3410
|
+
return {
|
|
3411
|
+
type: "sheetRename",
|
|
3412
|
+
data: d
|
|
3413
|
+
};
|
|
3414
|
+
}
|
|
3415
|
+
case "ris": {
|
|
3416
|
+
const d = {
|
|
3417
|
+
rId: Number(attr(el, "rId") ?? "0"),
|
|
3418
|
+
sheetId: Number(attr(el, "sheetId") ?? "0"),
|
|
3419
|
+
name: attr(el, "name") ?? "",
|
|
3420
|
+
sheetPosition: Number(attr(el, "sheetPosition") ?? "0")
|
|
3421
|
+
};
|
|
3422
|
+
const undo = parseBool(el, "ua");
|
|
3423
|
+
if (undo) d.undo = undo;
|
|
3424
|
+
const rejected = parseBool(el, "ra");
|
|
3425
|
+
if (rejected) d.rejected = rejected;
|
|
3426
|
+
return {
|
|
3427
|
+
type: "insertSheet",
|
|
3428
|
+
data: d
|
|
3429
|
+
};
|
|
3430
|
+
}
|
|
3431
|
+
case "rcc": {
|
|
3432
|
+
const d = {
|
|
3433
|
+
rId: Number(attr(el, "rId") ?? "0"),
|
|
3434
|
+
sheetId: Number(attr(el, "sId") ?? "0"),
|
|
3435
|
+
newCellXml: firstChildXml(el, "nc") ?? ""
|
|
3436
|
+
};
|
|
3437
|
+
const hasOldDxf = parseBool(el, "odxf");
|
|
3438
|
+
if (hasOldDxf) d.hasOldDxf = hasOldDxf;
|
|
3439
|
+
const xfDxf = parseBool(el, "xfDxf");
|
|
3440
|
+
if (xfDxf) d.xfDxf = xfDxf;
|
|
3441
|
+
const style = parseBool(el, "s");
|
|
3442
|
+
if (style) d.style = style;
|
|
3443
|
+
const hasDxf = parseBool(el, "dxf");
|
|
3444
|
+
if (hasDxf) d.hasDxf = hasDxf;
|
|
3445
|
+
const numFmtId = attr(el, "numFmtId");
|
|
3446
|
+
if (numFmtId !== void 0) d.numFmtId = Number(numFmtId);
|
|
3447
|
+
const quotePrefix = parseBool(el, "quotePrefix");
|
|
3448
|
+
if (quotePrefix) d.quotePrefix = quotePrefix;
|
|
3449
|
+
const oldQuotePrefix = parseBool(el, "oldQuotePrefix");
|
|
3450
|
+
if (oldQuotePrefix) d.oldQuotePrefix = oldQuotePrefix;
|
|
3451
|
+
const phonetic = parseBool(el, "ph");
|
|
3452
|
+
if (phonetic) d.phonetic = phonetic;
|
|
3453
|
+
const oldPhonetic = parseBool(el, "oldPh");
|
|
3454
|
+
if (oldPhonetic) d.oldPhonetic = oldPhonetic;
|
|
3455
|
+
const endOfList = parseBool(el, "endOfListFormulaUpdate");
|
|
3456
|
+
if (endOfList) d.endOfListFormulaUpdate = endOfList;
|
|
3457
|
+
const undo = parseBool(el, "ua");
|
|
3458
|
+
if (undo) d.undo = undo;
|
|
3459
|
+
const rejected = parseBool(el, "ra");
|
|
3460
|
+
if (rejected) d.rejected = rejected;
|
|
3461
|
+
const oc = firstChildXml(el, "oc");
|
|
3462
|
+
if (oc) d.oldCellXml = oc;
|
|
3463
|
+
const odxf = firstChildXml(el, "odxf");
|
|
3464
|
+
if (odxf) d.oldDxfXml = odxf;
|
|
3465
|
+
const ndxf = firstChildXml(el, "ndxf");
|
|
3466
|
+
if (ndxf) d.newDxfXml = ndxf;
|
|
3467
|
+
return {
|
|
3468
|
+
type: "cellChange",
|
|
3469
|
+
data: d
|
|
3470
|
+
};
|
|
3471
|
+
}
|
|
3472
|
+
case "rfmt": {
|
|
3473
|
+
const d = {
|
|
3474
|
+
sheetId: Number(attr(el, "sheetId") ?? "0"),
|
|
3475
|
+
sqref: attr(el, "sqref") ?? ""
|
|
3476
|
+
};
|
|
3477
|
+
const xfDxf = parseBool(el, "xfDxf");
|
|
3478
|
+
if (xfDxf) d.xfDxf = xfDxf;
|
|
3479
|
+
const style = parseBool(el, "s");
|
|
3480
|
+
if (style) d.style = style;
|
|
3481
|
+
const start = attr(el, "start");
|
|
3482
|
+
if (start !== void 0) d.start = Number(start);
|
|
3483
|
+
const length = attr(el, "length");
|
|
3484
|
+
if (length !== void 0) d.length = Number(length);
|
|
3485
|
+
const dxfXml = firstChildXml(el, "dxf");
|
|
3486
|
+
if (dxfXml) d.dxfXml = dxfXml;
|
|
3487
|
+
return {
|
|
3488
|
+
type: "formatting",
|
|
3489
|
+
data: d
|
|
3490
|
+
};
|
|
3491
|
+
}
|
|
3492
|
+
case "raf": {
|
|
3493
|
+
const d = {
|
|
3494
|
+
sheetId: Number(attr(el, "sheetId") ?? "0"),
|
|
3495
|
+
ref: attr(el, "ref") ?? ""
|
|
3496
|
+
};
|
|
3497
|
+
const autoAttrs = Object.entries(el.attributes ?? {}).filter(([k]) => k !== "sheetId" && k !== "ref").map(([k, v]) => ` ${k}="${escapeXml(String(v))}"`).join("");
|
|
3498
|
+
if (autoAttrs) d.autoFormatXml = autoAttrs;
|
|
3499
|
+
return {
|
|
3500
|
+
type: "autoFormatting",
|
|
3501
|
+
data: d
|
|
3502
|
+
};
|
|
3503
|
+
}
|
|
3504
|
+
case "rdn": {
|
|
3505
|
+
const d = {
|
|
3506
|
+
rId: Number(attr(el, "rId") ?? "0"),
|
|
3507
|
+
name: attr(el, "name") ?? ""
|
|
3508
|
+
};
|
|
3509
|
+
const localSheetId = attr(el, "localSheetId");
|
|
3510
|
+
if (localSheetId !== void 0) d.localSheetId = Number(localSheetId);
|
|
3511
|
+
readBool(el, "customView", (v) => d.customView = v);
|
|
3512
|
+
readBool(el, "function", (v) => d.function = v);
|
|
3513
|
+
readBool(el, "oldFunction", (v) => d.oldFunction = v);
|
|
3514
|
+
readNum(el, "functionGroupId", (v) => d.functionGroupId = v);
|
|
3515
|
+
readNum(el, "oldFunctionGroupId", (v) => d.oldFunctionGroupId = v);
|
|
3516
|
+
readNum(el, "shortcutKey", (v) => d.shortcutKey = v);
|
|
3517
|
+
readNum(el, "oldShortcutKey", (v) => d.oldShortcutKey = v);
|
|
3518
|
+
readBool(el, "hidden", (v) => d.hidden = v);
|
|
3519
|
+
readBool(el, "oldHidden", (v) => d.oldHidden = v);
|
|
3520
|
+
readStr(el, "customMenu", (v) => d.customMenu = v);
|
|
3521
|
+
readStr(el, "oldCustomMenu", (v) => d.oldCustomMenu = v);
|
|
3522
|
+
readStr(el, "description", (v) => d.description = v);
|
|
3523
|
+
readStr(el, "oldDescription", (v) => d.oldDescription = v);
|
|
3524
|
+
readStr(el, "help", (v) => d.help = v);
|
|
3525
|
+
readStr(el, "oldHelp", (v) => d.oldHelp = v);
|
|
3526
|
+
readStr(el, "statusBar", (v) => d.statusBar = v);
|
|
3527
|
+
readStr(el, "oldStatusBar", (v) => d.oldStatusBar = v);
|
|
3528
|
+
readStr(el, "comment", (v) => d.comment = v);
|
|
3529
|
+
readStr(el, "oldComment", (v) => d.oldComment = v);
|
|
3530
|
+
const undo = parseBool(el, "ua");
|
|
3531
|
+
if (undo) d.undo = undo;
|
|
3532
|
+
const rejected = parseBool(el, "ra");
|
|
3533
|
+
if (rejected) d.rejected = rejected;
|
|
3534
|
+
const formula = findChild(el, "formula");
|
|
3535
|
+
if (formula) d.formula = textOf(formula) ?? "";
|
|
3536
|
+
const oldFormula = findChild(el, "oldFormula");
|
|
3537
|
+
if (oldFormula) d.oldFormula = textOf(oldFormula) ?? "";
|
|
3538
|
+
return {
|
|
3539
|
+
type: "definedName",
|
|
3540
|
+
data: d
|
|
3541
|
+
};
|
|
3542
|
+
}
|
|
3543
|
+
case "rcmt": {
|
|
3544
|
+
const d = {
|
|
3545
|
+
sheetId: Number(attr(el, "sheetId") ?? "0"),
|
|
3546
|
+
cell: attr(el, "cell") ?? "",
|
|
3547
|
+
guid: attr(el, "guid") ?? "",
|
|
3548
|
+
author: attr(el, "author") ?? ""
|
|
3549
|
+
};
|
|
3550
|
+
const action = attr(el, "action");
|
|
3551
|
+
if (action) d.action = action;
|
|
3552
|
+
readBool(el, "alwaysShow", (v) => d.alwaysShow = v);
|
|
3553
|
+
readBool(el, "old", (v) => d.old = v);
|
|
3554
|
+
readBool(el, "hiddenRow", (v) => d.hiddenRow = v);
|
|
3555
|
+
readBool(el, "hiddenColumn", (v) => d.hiddenColumn = v);
|
|
3556
|
+
readNum(el, "oldLength", (v) => d.oldLength = v);
|
|
3557
|
+
readNum(el, "newLength", (v) => d.newLength = v);
|
|
3558
|
+
return {
|
|
3559
|
+
type: "comment",
|
|
3560
|
+
data: d
|
|
3561
|
+
};
|
|
3562
|
+
}
|
|
3563
|
+
case "rqt": return {
|
|
3564
|
+
type: "queryTableField",
|
|
3565
|
+
data: {
|
|
3566
|
+
sheetId: Number(attr(el, "sheetId") ?? "0"),
|
|
3567
|
+
ref: attr(el, "ref") ?? "",
|
|
3568
|
+
fieldId: Number(attr(el, "fieldId") ?? "0")
|
|
3569
|
+
}
|
|
3570
|
+
};
|
|
3571
|
+
case "rcft": {
|
|
3572
|
+
const d = { rId: Number(attr(el, "rId") ?? "0") };
|
|
3573
|
+
const undo = parseBool(el, "ua");
|
|
3574
|
+
if (undo) d.undo = undo;
|
|
3575
|
+
const rejected = parseBool(el, "ra");
|
|
3576
|
+
if (rejected) d.rejected = rejected;
|
|
3577
|
+
const sheetId = attr(el, "sheetId");
|
|
3578
|
+
if (sheetId !== void 0) d.sheetId = Number(sheetId);
|
|
3579
|
+
return {
|
|
3580
|
+
type: "conflict",
|
|
3581
|
+
data: d
|
|
3582
|
+
};
|
|
3583
|
+
}
|
|
3584
|
+
default: return;
|
|
3585
|
+
}
|
|
3586
|
+
}
|
|
3587
|
+
const revisionLogDesc = {
|
|
3588
|
+
kind: "custom",
|
|
3589
|
+
stringify(opts, _ctx) {
|
|
3590
|
+
if (opts.revisions.length === 0) return void 0;
|
|
3591
|
+
return `<revisions xmlns="${S_NS}">${opts.revisions.map(stringifyEntry).join("")}</revisions>`;
|
|
3592
|
+
},
|
|
3593
|
+
parse(el, _ctx) {
|
|
3594
|
+
const revisions = [];
|
|
3595
|
+
for (const child of el.elements ?? []) {
|
|
3596
|
+
if (child.type !== "element") continue;
|
|
3597
|
+
const entry = parseEntry(child);
|
|
3598
|
+
if (entry) revisions.push(entry);
|
|
3599
|
+
}
|
|
3600
|
+
return { revisions };
|
|
3601
|
+
}
|
|
3602
|
+
};
|
|
3603
|
+
function readBool(el, name, set) {
|
|
3604
|
+
const raw = attr(el, name);
|
|
3605
|
+
if (raw === "1" || raw === "true") set(true);
|
|
3606
|
+
}
|
|
3607
|
+
function readNum(el, name, set) {
|
|
3608
|
+
const raw = attr(el, name);
|
|
3609
|
+
if (raw !== void 0) set(Number(raw));
|
|
3610
|
+
}
|
|
3611
|
+
function readStr(el, name, set) {
|
|
3612
|
+
const raw = attr(el, name);
|
|
3613
|
+
if (raw !== void 0) set(raw);
|
|
3614
|
+
}
|
|
3615
|
+
//#endregion
|
|
4756
3616
|
//#region src/parts/content-types.ts
|
|
4757
3617
|
/**
|
|
4758
3618
|
* Content Types module for XLSX packages.
|
|
@@ -4766,6 +3626,7 @@ const XLSX_STYLES = "application/vnd.openxmlformats-officedocument.spreadsheetml
|
|
|
4766
3626
|
const XLSX_SHARED_STRINGS = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml";
|
|
4767
3627
|
const XLSX_THEME = "application/vnd.openxmlformats-officedocument.theme+xml";
|
|
4768
3628
|
const XLSX_CHART = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
|
|
3629
|
+
const CUSTOM_PROPS = "application/vnd.openxmlformats-officedocument.custom-properties+xml";
|
|
4769
3630
|
const STATIC_XML = [
|
|
4770
3631
|
{
|
|
4771
3632
|
type: "Default",
|
|
@@ -4830,6 +3691,13 @@ var ContentTypes = class {
|
|
|
4830
3691
|
key: `/xl/theme/theme${index}.xml`
|
|
4831
3692
|
});
|
|
4832
3693
|
}
|
|
3694
|
+
addCustomProperties() {
|
|
3695
|
+
this.dynamicEntries.push({
|
|
3696
|
+
type: "Override",
|
|
3697
|
+
contentType: CUSTOM_PROPS,
|
|
3698
|
+
key: "/docProps/custom.xml"
|
|
3699
|
+
});
|
|
3700
|
+
}
|
|
4833
3701
|
addChart(index) {
|
|
4834
3702
|
this.dynamicEntries.push({
|
|
4835
3703
|
type: "Override",
|
|
@@ -4931,6 +3799,13 @@ var ContentTypes = class {
|
|
|
4931
3799
|
key: `/xl/revisions/revision${index}.xml`
|
|
4932
3800
|
});
|
|
4933
3801
|
}
|
|
3802
|
+
addUsers() {
|
|
3803
|
+
this.dynamicEntries.push({
|
|
3804
|
+
type: "Override",
|
|
3805
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.users+xml",
|
|
3806
|
+
key: "/xl/users.xml"
|
|
3807
|
+
});
|
|
3808
|
+
}
|
|
4934
3809
|
addQueryTable(index) {
|
|
4935
3810
|
this.dynamicEntries.push({
|
|
4936
3811
|
type: "Override",
|
|
@@ -5081,23 +3956,19 @@ var XlsxReadContext = class {
|
|
|
5081
3956
|
resolveStyle(styleIndex) {
|
|
5082
3957
|
const ps = this.parsedStyles;
|
|
5083
3958
|
if (!ps) return void 0;
|
|
5084
|
-
const cellXfs = ps
|
|
3959
|
+
const { cellXfs, fonts, fills, borders, customNumFmts } = ps;
|
|
5085
3960
|
if (!cellXfs || styleIndex >= cellXfs.length) return void 0;
|
|
5086
3961
|
const xf = cellXfs[styleIndex];
|
|
5087
3962
|
const result = {};
|
|
5088
|
-
const
|
|
5089
|
-
|
|
5090
|
-
const
|
|
5091
|
-
|
|
5092
|
-
const
|
|
5093
|
-
if (
|
|
5094
|
-
const
|
|
5095
|
-
if (
|
|
5096
|
-
|
|
5097
|
-
if (borderIdx !== void 0 && borders && borderIdx < borders.length) result.border = borders[borderIdx];
|
|
5098
|
-
const numFmtIdx = xf.numFmtIdx;
|
|
5099
|
-
if (numFmtIdx !== void 0 && customNumFmts) {
|
|
5100
|
-
for (const [code, id] of Object.entries(customNumFmts)) if (id === numFmtIdx) {
|
|
3963
|
+
const fontId = xf.fontId;
|
|
3964
|
+
if (fontId !== void 0 && fonts && fontId < fonts.length) result.font = fonts[fontId];
|
|
3965
|
+
const fillId = xf.fillId;
|
|
3966
|
+
if (fillId !== void 0 && fills && fillId < fills.length) result.fill = fills[fillId];
|
|
3967
|
+
const borderId = xf.borderId;
|
|
3968
|
+
if (borderId !== void 0 && borders && borderId < borders.length) result.border = borders[borderId];
|
|
3969
|
+
const numFmtId = xf.numFmtId;
|
|
3970
|
+
if (numFmtId !== void 0 && customNumFmts) {
|
|
3971
|
+
for (const [code, id] of Object.entries(customNumFmts)) if (id === numFmtId) {
|
|
5101
3972
|
result.numFmt = code;
|
|
5102
3973
|
break;
|
|
5103
3974
|
}
|
|
@@ -5125,6 +3996,6 @@ function resolveWsTarget(wsPath, target) {
|
|
|
5125
3996
|
return dirParts.join("/");
|
|
5126
3997
|
}
|
|
5127
3998
|
//#endregion
|
|
5128
|
-
export {
|
|
3999
|
+
export { stylesDesc as C, Styles as S, collectUniqueValues as _, usersDesc as a, chartsheetDesc as b, workbookDesc as c, tableDesc as d, pivotCacheDefDesc as f, aggregate as g, PivotFilterType as h, revisionLogDesc as i, TableType as l, pivotTableDesc as m, XlsxWriteContext as n, buildExternalReferencesXml as o, pivotCacheRecordsDesc as p, revisionHeadersDesc as r, buildTablePartsXml as s, XlsxReadContext as t, TotalsRowFunction as u, externalLinkDesc as v, calcChainDesc as x, drawingDesc as y };
|
|
5129
4000
|
|
|
5130
|
-
//# sourceMappingURL=context-
|
|
4001
|
+
//# sourceMappingURL=context-e2jg7QPd.mjs.map
|