@office-open/xlsx 0.8.0 → 0.8.1
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/index.d.mts +146 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +348 -62
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -259,7 +259,10 @@ function buildRPrXml(pr) {
|
|
|
259
259
|
if (pr.shadow) parts.push("<shadow/>");
|
|
260
260
|
if (pr.condense) parts.push("<condense/>");
|
|
261
261
|
if (pr.extend) parts.push("<extend/>");
|
|
262
|
-
if (pr.color)
|
|
262
|
+
if (pr.color) {
|
|
263
|
+
const rgb = pr.color.length === 6 ? `FF${pr.color}` : pr.color;
|
|
264
|
+
parts.push(`<color rgb="${escapeXml(rgb)}"/>`);
|
|
265
|
+
}
|
|
263
266
|
if (pr.size !== void 0) parts.push(`<sz val="${pr.size}"/>`);
|
|
264
267
|
if (pr.underline) if (pr.underline === "none") parts.push("<u/>");
|
|
265
268
|
else parts.push(`<u val="${pr.underline}"/>`);
|
|
@@ -339,7 +342,7 @@ function fillKey(f) {
|
|
|
339
342
|
}
|
|
340
343
|
function borderKey(b) {
|
|
341
344
|
const sk = (o) => `${o?.style ?? ""}_${o?.color ?? ""}`;
|
|
342
|
-
return `t${sk(b.top)}b${sk(b.bottom)}l${sk(b.left)}r${sk(b.right)}d${sk(b.diagonal)}st${sk(b.start)}en${sk(b.end)}v${sk(b.vertical)}h${sk(b.horizontal)}`;
|
|
345
|
+
return `t${sk(b.top)}b${sk(b.bottom)}l${sk(b.left)}r${sk(b.right)}d${sk(b.diagonal)}du${b.diagonalUp ? 1 : 0}dd${b.diagonalDown ? 1 : 0}st${sk(b.start)}en${sk(b.end)}v${sk(b.vertical)}h${sk(b.horizontal)}`;
|
|
343
346
|
}
|
|
344
347
|
const BUILTIN_NUMFMTS = {
|
|
345
348
|
General: 0,
|
|
@@ -391,6 +394,8 @@ var Styles = class extends BaseXmlComponent {
|
|
|
391
394
|
dxfs = [];
|
|
392
395
|
colors;
|
|
393
396
|
tableStyles;
|
|
397
|
+
/** Custom cell styles (CT_CellStyles) */
|
|
398
|
+
customCellStyles;
|
|
394
399
|
/** Style sheet extensions (CT_ExtensionList) */
|
|
395
400
|
styleExtensions;
|
|
396
401
|
constructor() {
|
|
@@ -414,6 +419,7 @@ var Styles = class extends BaseXmlComponent {
|
|
|
414
419
|
alignment: opts.alignment,
|
|
415
420
|
quotePrefix: opts.quotePrefix,
|
|
416
421
|
pivotButton: opts.pivotButton,
|
|
422
|
+
applyProtection: opts.applyProtection,
|
|
417
423
|
protection: opts.protection
|
|
418
424
|
};
|
|
419
425
|
const key = this.cellXfKey(xf);
|
|
@@ -445,6 +451,9 @@ var Styles = class extends BaseXmlComponent {
|
|
|
445
451
|
setExtensions(extensions) {
|
|
446
452
|
this.styleExtensions = extensions;
|
|
447
453
|
}
|
|
454
|
+
setCustomCellStyles(styles) {
|
|
455
|
+
this.customCellStyles = styles;
|
|
456
|
+
}
|
|
448
457
|
registerFont(opts) {
|
|
449
458
|
if (!opts) return 0;
|
|
450
459
|
const key = fontKey(opts);
|
|
@@ -519,12 +528,18 @@ var Styles = class extends BaseXmlComponent {
|
|
|
519
528
|
p.push(`<fill><gradientFill${attrs(gfAttrs)}>${stopParts}</gradientFill></fill>`);
|
|
520
529
|
} else {
|
|
521
530
|
const patternAttrs = attrs({ patternType: f.patternType ?? "solid" });
|
|
522
|
-
const colorContent = (f.color ? `<fgColor rgb="FF${f.color}"/>` : "") + (f.bgColor ? `<bgColor rgb="FF${f.bgColor}"/>` : "");
|
|
531
|
+
const colorContent = (f.color ? `<fgColor rgb="FF${f.color}"/>` : f.colorIndexed !== void 0 ? `<fgColor indexed="${f.colorIndexed}"/>` : "") + (f.bgColor ? `<bgColor rgb="FF${f.bgColor}"/>` : "");
|
|
523
532
|
p.push(colorContent ? `<fill><patternFill${patternAttrs}>${colorContent}</patternFill></fill>` : `<fill><patternFill${patternAttrs}/></fill>`);
|
|
524
533
|
}
|
|
525
534
|
p.push("</fills>");
|
|
526
535
|
p.push(`<borders count="${this.borders.length}">`);
|
|
527
|
-
for (const b of this.borders)
|
|
536
|
+
for (const b of this.borders) {
|
|
537
|
+
const bAttrs = [];
|
|
538
|
+
if (b.diagonalUp) bAttrs.push("diagonalUp=\"1\"");
|
|
539
|
+
if (b.diagonalDown) bAttrs.push("diagonalDown=\"1\"");
|
|
540
|
+
const bAttr = bAttrs.length ? ` ${bAttrs.join(" ")}` : "";
|
|
541
|
+
p.push(`<border${bAttr}>${this.borderXmlStr(b)}</border>`);
|
|
542
|
+
}
|
|
528
543
|
p.push("</borders>");
|
|
529
544
|
p.push("<cellStyleXfs count=\"1\"><xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\"/></cellStyleXfs>");
|
|
530
545
|
p.push(`<cellXfs count="${this.cellXfs.length}">`);
|
|
@@ -543,11 +558,26 @@ var Styles = class extends BaseXmlComponent {
|
|
|
543
558
|
if (xf.numFmtId > 0) xAttrs.applyNumberFormat = 1;
|
|
544
559
|
if (xf.quotePrefix) xAttrs.quotePrefix = 1;
|
|
545
560
|
if (xf.pivotButton) xAttrs.pivotButton = 1;
|
|
561
|
+
if (xf.applyProtection) xAttrs.applyProtection = 1;
|
|
562
|
+
if (xf.protection) xAttrs.applyProtection = xAttrs.applyProtection ?? 1;
|
|
546
563
|
const inner = (xf.alignment ? this.alignmentXmlStr(xf.alignment) : "") + (xf.protection ? this.protectionXmlStr(xf.protection) : "");
|
|
547
564
|
p.push(inner ? `<xf${attrs(xAttrs)}>${inner}</xf>` : `<xf${attrs(xAttrs)}/>`);
|
|
548
565
|
}
|
|
549
566
|
p.push("</cellXfs>");
|
|
550
|
-
|
|
567
|
+
if (this.customCellStyles && this.customCellStyles.length > 0) {
|
|
568
|
+
const csParts = [`<cellStyles ${[`count="${this.customCellStyles.length + 1}"`].join(" ")}>`];
|
|
569
|
+
csParts.push("<cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/>");
|
|
570
|
+
for (const cs of this.customCellStyles) {
|
|
571
|
+
const attrs = [`name="${escapeXml(cs.name)}"`, `xfId="${cs.xfId}"`];
|
|
572
|
+
if (cs.builtinId !== void 0) attrs.push(`builtinId="${cs.builtinId}"`);
|
|
573
|
+
if (cs.customBuiltin) attrs.push("customBuiltin=\"1\"");
|
|
574
|
+
if (cs.iLevel !== void 0) attrs.push(`iLevel="${cs.iLevel}"`);
|
|
575
|
+
if (cs.hidden) attrs.push("hidden=\"1\"");
|
|
576
|
+
csParts.push(`<cellStyle ${attrs.join(" ")}/>`);
|
|
577
|
+
}
|
|
578
|
+
csParts.push("</cellStyles>");
|
|
579
|
+
p.push(csParts.join(""));
|
|
580
|
+
} else p.push("<cellStyles count=\"1\"><cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/></cellStyles>");
|
|
551
581
|
if (this.dxfs.length > 0) {
|
|
552
582
|
p.push(`<dxfs count="${this.dxfs.length}">`);
|
|
553
583
|
for (const dxf of this.dxfs) {
|
|
@@ -559,6 +589,7 @@ var Styles = class extends BaseXmlComponent {
|
|
|
559
589
|
dParts.push(`<fill><patternFill${patAttrs}>${bgColor}</patternFill></fill>`);
|
|
560
590
|
}
|
|
561
591
|
if (dxf.numFmt) dParts.push(`<numFmt formatCode="${escapeXml(dxf.numFmt)}"/>`);
|
|
592
|
+
if (dxf.border) dParts.push(`<border>${this.borderXmlStr(dxf.border)}</border>`);
|
|
562
593
|
if (dParts.length > 0) p.push(`<dxf>${dParts.join("")}</dxf>`);
|
|
563
594
|
else p.push("<dxf/>");
|
|
564
595
|
}
|
|
@@ -690,7 +721,8 @@ var WorkbookXml = class extends BaseXmlComponent {
|
|
|
690
721
|
bookView;
|
|
691
722
|
volTypes;
|
|
692
723
|
webPublishObjects;
|
|
693
|
-
|
|
724
|
+
conformance;
|
|
725
|
+
constructor(sheets, pivotCaches, protection, customViews, fileRecoveryPr, functionGroups, webPublishing, fileSharing, workbookPr, calcPr, bookView, volTypes, webPublishObjects, conformance) {
|
|
694
726
|
super("workbook");
|
|
695
727
|
this.sheets = sheets;
|
|
696
728
|
this.pivotCaches = pivotCaches ?? [];
|
|
@@ -705,9 +737,10 @@ var WorkbookXml = class extends BaseXmlComponent {
|
|
|
705
737
|
this.bookView = bookView;
|
|
706
738
|
this.volTypes = volTypes;
|
|
707
739
|
this.webPublishObjects = webPublishObjects;
|
|
740
|
+
this.conformance = conformance;
|
|
708
741
|
}
|
|
709
742
|
toXml(_context) {
|
|
710
|
-
const parts = [
|
|
743
|
+
const parts = [`<workbook 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="x15 xr xr6 xr10 xr2" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main" xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision" xmlns:xr6="http://schemas.microsoft.com/office/spreadsheetml/2016/revision6" xmlns:xr10="http://schemas.microsoft.com/office/spreadsheetml/2016/revision10" xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"${this.conformance ? ` conformance="${this.conformance}"` : ""}>`, "<fileVersion appName=\"xl\" lastEdited=\"7\" lowestEdited=\"6\" rupBuild=\"29929\"/>"];
|
|
711
744
|
if (this.fileSharing) {
|
|
712
745
|
const fileSharing = this.fileSharing;
|
|
713
746
|
const fsAttrs = [];
|
|
@@ -786,6 +819,8 @@ var WorkbookXml = class extends BaseXmlComponent {
|
|
|
786
819
|
if (prot.revisionsHashValue) protAttrs.push(`revisionsHashValue="${escapeXml(prot.revisionsHashValue)}"`);
|
|
787
820
|
if (prot.revisionsSaltValue) protAttrs.push(`revisionsSaltValue="${escapeXml(prot.revisionsSaltValue)}"`);
|
|
788
821
|
if (prot.revisionsSpinCount !== void 0) protAttrs.push(`revisionsSpinCount="${prot.revisionsSpinCount}"`);
|
|
822
|
+
if (prot.workbookPasswordCharacterSet) protAttrs.push(`workbookPasswordCharacterSet="${escapeXml(prot.workbookPasswordCharacterSet)}"`);
|
|
823
|
+
if (prot.revisionsPasswordCharacterSet) protAttrs.push(`revisionsPasswordCharacterSet="${escapeXml(prot.revisionsPasswordCharacterSet)}"`);
|
|
789
824
|
if (protAttrs.length > 0) parts.push(`<workbookProtection ${protAttrs.join(" ")}/>`);
|
|
790
825
|
}
|
|
791
826
|
if (this.bookView) {
|
|
@@ -1001,6 +1036,7 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
|
|
|
1001
1036
|
images;
|
|
1002
1037
|
chartOptions;
|
|
1003
1038
|
dataValidations;
|
|
1039
|
+
dataValidationsDisablePrompts;
|
|
1004
1040
|
conditionalFormats;
|
|
1005
1041
|
hyperlinks;
|
|
1006
1042
|
comments;
|
|
@@ -1044,6 +1080,7 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
|
|
|
1044
1080
|
this.images = options.images ?? [];
|
|
1045
1081
|
this.chartOptions = options.charts ?? [];
|
|
1046
1082
|
this.dataValidations = options.dataValidations ?? [];
|
|
1083
|
+
this.dataValidationsDisablePrompts = options.dataValidationsDisablePrompts;
|
|
1047
1084
|
this.conditionalFormats = options.conditionalFormats ?? [];
|
|
1048
1085
|
this.hyperlinks = options.hyperlinks ?? [];
|
|
1049
1086
|
this.comments = options.comments ?? [];
|
|
@@ -1129,6 +1166,7 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
|
|
|
1129
1166
|
if (tc.rgb) tcAttrs.rgb = tc.rgb;
|
|
1130
1167
|
if (tc.theme !== void 0) tcAttrs.theme = tc.theme;
|
|
1131
1168
|
if (tc.tint !== void 0) tcAttrs.tint = tc.tint;
|
|
1169
|
+
if (tc.indexed !== void 0) tcAttrs.indexed = tc.indexed;
|
|
1132
1170
|
prParts.push(`<tabColor${attrs(tcAttrs)}/>`);
|
|
1133
1171
|
}
|
|
1134
1172
|
if (hasOutline) {
|
|
@@ -1140,7 +1178,12 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
|
|
|
1140
1178
|
if (sp?.outlineShowSymbols === false) outAttrs.showOutlineSymbols = 0;
|
|
1141
1179
|
prParts.push(`<outlinePr${attrs(outAttrs)}/>`);
|
|
1142
1180
|
}
|
|
1143
|
-
if (this.pageSetup?.fitToWidth || this.pageSetup?.fitToHeight
|
|
1181
|
+
if (this.pageSetup?.fitToWidth || this.pageSetup?.fitToHeight || this.pageSetup?.autoPageBreaks) {
|
|
1182
|
+
const psupAttrs = {};
|
|
1183
|
+
if (this.pageSetup?.fitToWidth || this.pageSetup?.fitToHeight) psupAttrs.fitToPage = 1;
|
|
1184
|
+
if (this.pageSetup?.autoPageBreaks) psupAttrs.autoPageBreaks = 1;
|
|
1185
|
+
prParts.push(`<pageSetUpPr${attrs(psupAttrs)}/>`);
|
|
1186
|
+
}
|
|
1144
1187
|
const prAttrStr = Object.keys(prAttrs).length > 0 ? attrs(prAttrs) : "";
|
|
1145
1188
|
p.push(`<sheetPr${prAttrStr}>${prParts.join("")}</sheetPr>`);
|
|
1146
1189
|
}
|
|
@@ -1373,6 +1416,7 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
|
|
|
1373
1416
|
val: String(cell.val)
|
|
1374
1417
|
};
|
|
1375
1418
|
if (cell.deleted) icAttrs.deleted = true;
|
|
1419
|
+
if (cell.undone) icAttrs.undone = true;
|
|
1376
1420
|
sParts.push(`<inputCells${attrs(icAttrs)}/>`);
|
|
1377
1421
|
}
|
|
1378
1422
|
sParts.push("</scenario>");
|
|
@@ -1386,12 +1430,19 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
|
|
|
1386
1430
|
const af = this.autoFilter;
|
|
1387
1431
|
const inner = [];
|
|
1388
1432
|
for (const t10 of af.top10 ?? []) {
|
|
1433
|
+
const fcAttrs = { colId: t10.colId };
|
|
1434
|
+
if (t10.hiddenButton) fcAttrs.hiddenButton = 1;
|
|
1435
|
+
if (t10.showButton === false) fcAttrs.showButton = 0;
|
|
1389
1436
|
const t10Attrs = { val: t10.val };
|
|
1390
1437
|
if (t10.top === false) t10Attrs.top = 0;
|
|
1391
1438
|
if (t10.percent) t10Attrs.percent = 1;
|
|
1392
|
-
|
|
1439
|
+
if (t10.filterVal !== void 0) t10Attrs.filterVal = t10.filterVal;
|
|
1440
|
+
inner.push(`<filterColumn${attrs(fcAttrs)}><top10${attrs(t10Attrs)}/></filterColumn>`);
|
|
1393
1441
|
}
|
|
1394
1442
|
for (const cf of af.customFilters ?? []) {
|
|
1443
|
+
const fcAttrs = { colId: cf.colId };
|
|
1444
|
+
if (cf.hiddenButton) fcAttrs.hiddenButton = 1;
|
|
1445
|
+
if (cf.showButton === false) fcAttrs.showButton = 0;
|
|
1395
1446
|
const cfAttrs = {};
|
|
1396
1447
|
if (cf.and) cfAttrs.and = 1;
|
|
1397
1448
|
const filters = [];
|
|
@@ -1401,7 +1452,15 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
|
|
|
1401
1452
|
filters.push(selfCloseElement("customFilter", attrs(fAttrs)));
|
|
1402
1453
|
}
|
|
1403
1454
|
if (cf.val2 !== void 0) filters.push(selfCloseElement("customFilter", attrs({ val: cf.val2 })));
|
|
1404
|
-
if (filters.length > 0) inner.push(`<filterColumn
|
|
1455
|
+
if (filters.length > 0) inner.push(`<filterColumn${attrs(fcAttrs)}><customFilters${attrs(cfAttrs)}>${filters.join("")}</customFilters></filterColumn>`);
|
|
1456
|
+
}
|
|
1457
|
+
for (const fi of af.filters ?? []) {
|
|
1458
|
+
const fcAttrs = { colId: fi.colId };
|
|
1459
|
+
const filtersAttrs = {};
|
|
1460
|
+
if (fi.blank) filtersAttrs.blank = 1;
|
|
1461
|
+
if (fi.calendarType) filtersAttrs.calendarType = fi.calendarType;
|
|
1462
|
+
const valParts = (fi.values ?? []).map((v) => `<filter val="${escapeXml(v)}"/>`);
|
|
1463
|
+
inner.push(`<filterColumn${attrs(fcAttrs)}><filters${attrs(filtersAttrs)}>${valParts.join("")}</filters></filterColumn>`);
|
|
1405
1464
|
}
|
|
1406
1465
|
if (af.sort && af.sort.length > 0) {
|
|
1407
1466
|
const sortParts = [];
|
|
@@ -1434,6 +1493,8 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
|
|
|
1434
1493
|
const dfAttrs = { type: df.type };
|
|
1435
1494
|
if (df.val !== void 0) dfAttrs.val = df.val;
|
|
1436
1495
|
if (df.maxVal !== void 0) dfAttrs.maxVal = df.maxVal;
|
|
1496
|
+
if (df.valIso !== void 0) dfAttrs.valIso = df.valIso;
|
|
1497
|
+
if (df.maxValIso !== void 0) dfAttrs.maxValIso = df.maxValIso;
|
|
1437
1498
|
inner.push(`<filterColumn colId="${df.colId}"><dynamicFilter${attrs(dfAttrs)}/></filterColumn>`);
|
|
1438
1499
|
}
|
|
1439
1500
|
for (const dg of af.dateGroupItems ?? []) {
|
|
@@ -1515,7 +1576,9 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
|
|
|
1515
1576
|
p.push("</conditionalFormatting>");
|
|
1516
1577
|
}
|
|
1517
1578
|
if (this.dataValidations.length > 0) {
|
|
1518
|
-
|
|
1579
|
+
const dvContainerAttrs = { count: this.dataValidations.length };
|
|
1580
|
+
if (this.dataValidationsDisablePrompts) dvContainerAttrs.disablePrompts = 1;
|
|
1581
|
+
p.push(`<dataValidations${attrs(dvContainerAttrs)}>`);
|
|
1519
1582
|
for (const dv of this.dataValidations) {
|
|
1520
1583
|
const dvAttrs = { sqref: dv.sqref };
|
|
1521
1584
|
if (dv.type && dv.type !== "none") dvAttrs.type = dv.type;
|
|
@@ -1683,6 +1746,10 @@ var Worksheet = class extends IgnoreIfEmptyXmlComponent {
|
|
|
1683
1746
|
const prAttrs = [];
|
|
1684
1747
|
if (c.locked === false) prAttrs.push("locked=\"0\"");
|
|
1685
1748
|
if (c.uiObject) prAttrs.push("uiObject=\"1\"");
|
|
1749
|
+
if (c.recalcAlways) prAttrs.push("recalcAlways=\"1\"");
|
|
1750
|
+
if (c.linkedCell) prAttrs.push(`linkedCell="${escapeXml(c.linkedCell)}"`);
|
|
1751
|
+
if (c.listFillRange) prAttrs.push(`listFillRange="${escapeXml(c.listFillRange)}"`);
|
|
1752
|
+
if (c.cf) prAttrs.push(`cf="${escapeXml(c.cf)}"`);
|
|
1686
1753
|
if (prAttrs.length > 0) ctrlParts.push(`<control ${cAttrs.join(" ")}><controlPr${prAttrs.length ? " " + prAttrs.join(" ") : ""}/></control>`);
|
|
1687
1754
|
else ctrlParts.push(`<control ${cAttrs.join(" ")}/>`);
|
|
1688
1755
|
}
|
|
@@ -2268,7 +2335,24 @@ var PivotCacheDefinitionXml = class extends BaseXmlComponent {
|
|
|
2268
2335
|
max = 0;
|
|
2269
2336
|
}
|
|
2270
2337
|
const allInteger = this.sourceData.records.every((row) => typeof row[i] === "number" && Number.isInteger(row[i]));
|
|
2271
|
-
|
|
2338
|
+
const cfOverride = this.cacheDefOpts?.cacheFieldOverrides?.get(i);
|
|
2339
|
+
const cfExtraAttrs = [];
|
|
2340
|
+
const siExtraAttrs = [];
|
|
2341
|
+
if (cfOverride) {
|
|
2342
|
+
if (cfOverride.databaseField) cfExtraAttrs.push("databaseField=\"1\"");
|
|
2343
|
+
if (cfOverride.level !== void 0) cfExtraAttrs.push(`level="${cfOverride.level}"`);
|
|
2344
|
+
if (cfOverride.mappingCount !== void 0) cfExtraAttrs.push(`mappingCount="${cfOverride.mappingCount}"`);
|
|
2345
|
+
if (cfOverride.memberPropertyField !== void 0) cfExtraAttrs.push(`memberPropertyField="${cfOverride.memberPropertyField}"`);
|
|
2346
|
+
if (cfOverride.propertyName) cfExtraAttrs.push(`propertyName="${escapeXml(cfOverride.propertyName)}"`);
|
|
2347
|
+
if (cfOverride.serverField) cfExtraAttrs.push("serverField=\"1\"");
|
|
2348
|
+
if (cfOverride.uniqueList) cfExtraAttrs.push("uniqueList=\"1\"");
|
|
2349
|
+
if (cfOverride.containsMixedTypes) siExtraAttrs.push("containsMixedTypes=\"1\"");
|
|
2350
|
+
if (cfOverride.containsNonDate) siExtraAttrs.push("containsNonDate=\"1\"");
|
|
2351
|
+
if (cfOverride.longText) siExtraAttrs.push("longText=\"1\"");
|
|
2352
|
+
if (cfOverride.maxDate) siExtraAttrs.push(`maxDate="${escapeXml(cfOverride.maxDate)}"`);
|
|
2353
|
+
if (cfOverride.minDate) siExtraAttrs.push(`minDate="${escapeXml(cfOverride.minDate)}"`);
|
|
2354
|
+
}
|
|
2355
|
+
p.push(`<cacheField name="${escapeXml(fieldName)}" ${cfExtraAttrs.length ? cfExtraAttrs.join(" ") + " " : ""}numFmtId="0"><sharedItems containsSemiMixedTypes="0" containsString="0" containsNumber="1" containsInteger="${allInteger ? "1" : "0"}" minValue="${min}" maxValue="${max}" count="${uniqueVals.length}"${siExtraAttrs.length ? " " + siExtraAttrs.join(" ") : ""}/></cacheField>`);
|
|
2272
2356
|
} else {
|
|
2273
2357
|
let hasDate = false;
|
|
2274
2358
|
let hasMissing = false;
|
|
@@ -2279,7 +2363,23 @@ var PivotCacheDefinitionXml = class extends BaseXmlComponent {
|
|
|
2279
2363
|
const siAttrs = [`count="${uniqueVals.length}"`];
|
|
2280
2364
|
if (hasDate) siAttrs.push("containsDate=\"1\"");
|
|
2281
2365
|
if (hasMissing) siAttrs.push("containsBlank=\"1\"");
|
|
2282
|
-
|
|
2366
|
+
const cfOverride = this.cacheDefOpts?.cacheFieldOverrides?.get(i);
|
|
2367
|
+
const cfExtraAttrs = [];
|
|
2368
|
+
if (cfOverride) {
|
|
2369
|
+
if (cfOverride.databaseField) cfExtraAttrs.push("databaseField=\"1\"");
|
|
2370
|
+
if (cfOverride.level !== void 0) cfExtraAttrs.push(`level="${cfOverride.level}"`);
|
|
2371
|
+
if (cfOverride.mappingCount !== void 0) cfExtraAttrs.push(`mappingCount="${cfOverride.mappingCount}"`);
|
|
2372
|
+
if (cfOverride.memberPropertyField !== void 0) cfExtraAttrs.push(`memberPropertyField="${cfOverride.memberPropertyField}"`);
|
|
2373
|
+
if (cfOverride.propertyName) cfExtraAttrs.push(`propertyName="${escapeXml(cfOverride.propertyName)}"`);
|
|
2374
|
+
if (cfOverride.serverField) cfExtraAttrs.push("serverField=\"1\"");
|
|
2375
|
+
if (cfOverride.uniqueList) cfExtraAttrs.push("uniqueList=\"1\"");
|
|
2376
|
+
if (cfOverride.containsMixedTypes) siAttrs.push("containsMixedTypes=\"1\"");
|
|
2377
|
+
if (cfOverride.containsNonDate) siAttrs.push("containsNonDate=\"1\"");
|
|
2378
|
+
if (cfOverride.longText) siAttrs.push("longText=\"1\"");
|
|
2379
|
+
if (cfOverride.maxDate) siAttrs.push(`maxDate="${escapeXml(cfOverride.maxDate)}"`);
|
|
2380
|
+
if (cfOverride.minDate) siAttrs.push(`minDate="${escapeXml(cfOverride.minDate)}"`);
|
|
2381
|
+
}
|
|
2382
|
+
p.push(`<cacheField name="${escapeXml(fieldName)}" ${cfExtraAttrs.length ? cfExtraAttrs.join(" ") + " " : ""}numFmtId="0"><sharedItems ${siAttrs.join(" ")}>`);
|
|
2283
2383
|
for (const v of uniqueVals) if (v === null) p.push("<m/>");
|
|
2284
2384
|
else if (v instanceof Date) p.push(`<d v="${v.toISOString().replace(/\.\d{3}Z$/, "Z")}"/>`);
|
|
2285
2385
|
else p.push(`<s v="${escapeXml(String(v))}"/>`);
|
|
@@ -2357,6 +2457,9 @@ var PivotCacheDefinitionXml = class extends BaseXmlComponent {
|
|
|
2357
2457
|
if (ch.measures) chAttrs.push("measures=\"1\"");
|
|
2358
2458
|
if (ch.oneField) chAttrs.push("oneField=\"1\"");
|
|
2359
2459
|
if (ch.hidden) chAttrs.push("hidden=\"1\"");
|
|
2460
|
+
if (ch.memberValueDatatype) chAttrs.push(`memberValueDatatype="${ch.memberValueDatatype}"`);
|
|
2461
|
+
if (ch.unbalanced) chAttrs.push("unbalanced=\"1\"");
|
|
2462
|
+
if (ch.unbalancedGroup) chAttrs.push("unbalancedGroup=\"1\"");
|
|
2360
2463
|
const hasGroupLevels = ch.groupLevels && ch.groupLevels.length > 0;
|
|
2361
2464
|
const hasFieldsUsage = ch.fieldsUsage && ch.fieldsUsage.length > 0;
|
|
2362
2465
|
if (hasGroupLevels || hasFieldsUsage) {
|
|
@@ -2663,8 +2766,20 @@ var PivotTableXml = class extends BaseXmlComponent {
|
|
|
2663
2766
|
if (o.fieldListSortAscending) defAttrs.push("fieldListSortAscending=\"1\"");
|
|
2664
2767
|
if (o.mdxSubqueries) defAttrs.push("mdxSubqueries=\"1\"");
|
|
2665
2768
|
if (o.customListSort === false) defAttrs.push("customListSort=\"0\"");
|
|
2769
|
+
if (o.asteriskTotals) defAttrs.push("asteriskTotals=\"1\"");
|
|
2770
|
+
if (o.dataPosition !== void 0) defAttrs.push(`dataPosition="${o.dataPosition}"`);
|
|
2771
|
+
if (o.immersive) defAttrs.push("immersive=\"1\"");
|
|
2772
|
+
if (o.vacatedStyle) defAttrs.push(`vacatedStyle="${escapeXml(o.vacatedStyle)}"`);
|
|
2666
2773
|
p.push(`<pivotTableDefinition xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" ${defAttrs.join(" ")}>`);
|
|
2667
|
-
|
|
2774
|
+
const locAttrs = [
|
|
2775
|
+
`ref="${escapeXml(locationRef)}"`,
|
|
2776
|
+
`firstHeaderRow="1"`,
|
|
2777
|
+
`firstDataRow="${colFieldIndices.length + 1}"`,
|
|
2778
|
+
`firstDataCol="${rowFieldIndices.length}"`
|
|
2779
|
+
];
|
|
2780
|
+
if (o.locationColPageCount !== void 0) locAttrs.push(`colPageCount="${o.locationColPageCount}"`);
|
|
2781
|
+
if (o.locationRowPageCount !== void 0) locAttrs.push(`rowPageCount="${o.locationRowPageCount}"`);
|
|
2782
|
+
p.push(`<location ${locAttrs.join(" ")}/>`);
|
|
2668
2783
|
p.push(pivotFieldsXml);
|
|
2669
2784
|
if (o.pivotHierarchies && o.pivotHierarchies.length > 0) p.push(this.buildPivotHierarchies(o.pivotHierarchies));
|
|
2670
2785
|
if (pageFieldIndices.length > 0) p.push(pageFieldsXml);
|
|
@@ -2701,6 +2816,36 @@ var PivotTableXml = class extends BaseXmlComponent {
|
|
|
2701
2816
|
p.push("</pivotTableDefinition>");
|
|
2702
2817
|
return p.join("");
|
|
2703
2818
|
}
|
|
2819
|
+
buildFieldOverrideAttrs(fo) {
|
|
2820
|
+
const a = [];
|
|
2821
|
+
if (fo.allDrilled) a.push("allDrilled=\"1\"");
|
|
2822
|
+
if (fo.autoShow) a.push("autoShow=\"1\"");
|
|
2823
|
+
if (fo.countSubtotal) a.push("countSubtotal=\"1\"");
|
|
2824
|
+
if (fo.dataSourceSort) a.push("dataSourceSort=\"1\"");
|
|
2825
|
+
if (fo.defaultAttributeDrillState) a.push("defaultAttributeDrillState=\"1\"");
|
|
2826
|
+
if (fo.hiddenLevel) a.push("hiddenLevel=\"1\"");
|
|
2827
|
+
if (fo.hideNewItems) a.push("hideNewItems=\"1\"");
|
|
2828
|
+
if (fo.insertBlankRow) a.push("insertBlankRow=\"1\"");
|
|
2829
|
+
if (fo.insertPageBreak) a.push("insertPageBreak=\"1\"");
|
|
2830
|
+
if (fo.itemPageCount) a.push("itemPageCount=\"1\"");
|
|
2831
|
+
if (fo.measureFilter) a.push("measureFilter=\"1\"");
|
|
2832
|
+
if (fo.nonAutoSortDefault) a.push("nonAutoSortDefault=\"1\"");
|
|
2833
|
+
if (fo.productSubtotal) a.push("productSubtotal=\"1\"");
|
|
2834
|
+
if (fo.rankBy !== void 0) a.push(`rankBy="${fo.rankBy}"`);
|
|
2835
|
+
if (fo.serverField) a.push("serverField=\"1\"");
|
|
2836
|
+
if (fo.showDropDowns) a.push("showDropDowns=\"1\"");
|
|
2837
|
+
if (fo.showPropAsCaption) a.push("showPropAsCaption=\"1\"");
|
|
2838
|
+
if (fo.showPropCell) a.push("showPropCell=\"1\"");
|
|
2839
|
+
if (fo.showPropTip) a.push("showPropTip=\"1\"");
|
|
2840
|
+
if (fo.stdDevPSubtotal) a.push("stdDevPSubtotal=\"1\"");
|
|
2841
|
+
if (fo.stdDevSubtotal) a.push("stdDevSubtotal=\"1\"");
|
|
2842
|
+
if (fo.subtotalCaption) a.push(`subtotalCaption="${escapeXml(fo.subtotalCaption)}"`);
|
|
2843
|
+
if (fo.topAutoShow) a.push("topAutoShow=\"1\"");
|
|
2844
|
+
if (fo.uniqueMemberProperty) a.push("uniqueMemberProperty=\"1\"");
|
|
2845
|
+
if (fo.varPSubtotal) a.push("varPSubtotal=\"1\"");
|
|
2846
|
+
if (fo.varSubtotal) a.push("varSubtotal=\"1\"");
|
|
2847
|
+
return a.join(" ");
|
|
2848
|
+
}
|
|
2704
2849
|
buildPivotFields(rowIndices, colIndices, dataIndices, pageIndices) {
|
|
2705
2850
|
const fields = this.sourceData.fieldNames;
|
|
2706
2851
|
const o = this.options;
|
|
@@ -2710,10 +2855,13 @@ var PivotTableXml = class extends BaseXmlComponent {
|
|
|
2710
2855
|
const isCol = colIndices.includes(i);
|
|
2711
2856
|
const isData = dataIndices.includes(i);
|
|
2712
2857
|
const isPage = pageIndices.includes(i);
|
|
2858
|
+
const override = o.fieldOverrides?.find((fo) => fo.field === fields[i]);
|
|
2859
|
+
const extraAttrs = override ? this.buildFieldOverrideAttrs(override) : "";
|
|
2713
2860
|
if (isData) {
|
|
2714
2861
|
const dataFieldIdx = dataIndices.indexOf(i);
|
|
2715
2862
|
const df = o.data[dataFieldIdx];
|
|
2716
2863
|
const dfAttrs = ["dataField=\"1\"", "showAll=\"0\""];
|
|
2864
|
+
if (extraAttrs) dfAttrs.push(extraAttrs);
|
|
2717
2865
|
if (df?.showDataAs) dfAttrs.push(`showDataAs="${df.showDataAs}"`);
|
|
2718
2866
|
if (df?.baseField !== void 0) dfAttrs.push(`baseField="${df.baseField}"`);
|
|
2719
2867
|
if (df?.baseItem !== void 0) dfAttrs.push(`baseItem="${df.baseItem}"`);
|
|
@@ -2728,34 +2876,45 @@ var PivotTableXml = class extends BaseXmlComponent {
|
|
|
2728
2876
|
} else parts.push(`<pivotField ${dfAttrs.join(" ")}/>`);
|
|
2729
2877
|
} else if (isRow) {
|
|
2730
2878
|
const uniqueVals = collectUniqueValues(this.sourceData.records, i);
|
|
2731
|
-
|
|
2879
|
+
const rAttrs = extraAttrs ? ` axis="axisRow" showAll="0" ${extraAttrs}` : " axis=\"axisRow\" showAll=\"0\"";
|
|
2880
|
+
parts.push(`<pivotField${rAttrs}>`);
|
|
2732
2881
|
parts.push(`<items count="${uniqueVals.length + 1}">`);
|
|
2733
2882
|
for (let j = 0; j < uniqueVals.length; j++) parts.push(`<item x="${j}"/>`);
|
|
2734
|
-
parts.push(`<item t="default"/>`);
|
|
2883
|
+
parts.push(`<item t="default"${override?.defaultItemSd === false ? " sd=\"0\"" : ""}/>`);
|
|
2735
2884
|
parts.push("</items></pivotField>");
|
|
2736
2885
|
} else if (isCol) {
|
|
2737
2886
|
const uniqueVals = collectUniqueValues(this.sourceData.records, i);
|
|
2738
|
-
|
|
2887
|
+
const cAttrs = extraAttrs ? ` axis="axisCol" showAll="0" ${extraAttrs}` : " axis=\"axisCol\" showAll=\"0\"";
|
|
2888
|
+
parts.push(`<pivotField${cAttrs}>`);
|
|
2739
2889
|
parts.push(`<items count="${uniqueVals.length + 1}">`);
|
|
2740
2890
|
for (let j = 0; j < uniqueVals.length; j++) parts.push(`<item x="${j}"/>`);
|
|
2741
|
-
parts.push(`<item t="default"/>`);
|
|
2891
|
+
parts.push(`<item t="default"${override?.defaultItemSd === false ? " sd=\"0\"" : ""}/>`);
|
|
2742
2892
|
parts.push("</items></pivotField>");
|
|
2743
2893
|
} else if (isPage) {
|
|
2744
2894
|
const uniqueVals = collectUniqueValues(this.sourceData.records, i);
|
|
2745
|
-
|
|
2895
|
+
const pAttrs = extraAttrs ? ` axis="axisPage" showAll="0" ${extraAttrs}` : " axis=\"axisPage\" showAll=\"0\"";
|
|
2896
|
+
parts.push(`<pivotField${pAttrs}>`);
|
|
2746
2897
|
parts.push(`<items count="${uniqueVals.length + 1}">`);
|
|
2747
2898
|
for (let j = 0; j < uniqueVals.length; j++) parts.push(`<item x="${j}"/>`);
|
|
2748
|
-
parts.push(`<item t="default"/>`);
|
|
2899
|
+
parts.push(`<item t="default"${override?.defaultItemSd === false ? " sd=\"0\"" : ""}/>`);
|
|
2749
2900
|
parts.push("</items></pivotField>");
|
|
2750
|
-
} else
|
|
2901
|
+
} else {
|
|
2902
|
+
const nAttrs = extraAttrs ? ` showAll="0" ${extraAttrs}` : " showAll=\"0\"";
|
|
2903
|
+
parts.push(`<pivotField${nAttrs}/>`);
|
|
2904
|
+
}
|
|
2751
2905
|
}
|
|
2752
2906
|
parts.push("</pivotFields>");
|
|
2753
2907
|
return parts.join("");
|
|
2754
2908
|
}
|
|
2755
2909
|
buildPageFields(pageIndices) {
|
|
2756
2910
|
if (pageIndices.length === 0) return "";
|
|
2911
|
+
const o = this.options;
|
|
2757
2912
|
const parts = [`<pageFields count="${pageIndices.length}">`];
|
|
2758
|
-
for (let i = 0; i < pageIndices.length; i++)
|
|
2913
|
+
for (let i = 0; i < pageIndices.length; i++) {
|
|
2914
|
+
const cap = o.pageCaptions?.[i];
|
|
2915
|
+
const capAttr = cap ? ` cap="${escapeXml(cap)}"` : "";
|
|
2916
|
+
parts.push(`<pageField fld="${pageIndices[i]}" hier="${i}"${capAttr}/>`);
|
|
2917
|
+
}
|
|
2759
2918
|
parts.push("</pageFields>");
|
|
2760
2919
|
return parts.join("");
|
|
2761
2920
|
}
|
|
@@ -2893,8 +3052,15 @@ var PivotTableXml = class extends BaseXmlComponent {
|
|
|
2893
3052
|
if (mp.name !== void 0) mpAttrs.push(`name="${escapeXml(mp.name)}"`);
|
|
2894
3053
|
if (mp.showCell) mpAttrs.push("showCell=\"1\"");
|
|
2895
3054
|
if (mp.showTip) mpAttrs.push("showTip=\"1\"");
|
|
3055
|
+
if (mp.showAsCaption) mpAttrs.push("showAsCaption=\"1\"");
|
|
3056
|
+
if (mp.nameLen !== void 0) mpAttrs.push(`nameLen="${mp.nameLen}"`);
|
|
3057
|
+
if (mp.pPos !== void 0) mpAttrs.push(`pPos="${mp.pPos}"`);
|
|
3058
|
+
if (mp.pLen !== void 0) mpAttrs.push(`pLen="${mp.pLen}"`);
|
|
2896
3059
|
return `<mp ${mpAttrs.join(" ")}/>`;
|
|
2897
|
-
}).join("")}</mps>` : "") + (h.members ? `<members count="${h.members.length}">${h.members.map((m) =>
|
|
3060
|
+
}).join("")}</mps>` : "") + (h.members ? `<members count="${h.members.length}">${h.members.map((m) => {
|
|
3061
|
+
const levelAttr = m.level !== void 0 ? ` level="${m.level}"` : "";
|
|
3062
|
+
return `<member name="${escapeXml(m.name)}"${levelAttr}/>`;
|
|
3063
|
+
}).join("")}</members>` : "");
|
|
2898
3064
|
if (inner) parts.push(`<pivotHierarchy ${hAttrs.join(" ")}>${inner}</pivotHierarchy>`);
|
|
2899
3065
|
else parts.push(`<pivotHierarchy ${hAttrs.join(" ")}/>`);
|
|
2900
3066
|
}
|
|
@@ -2986,6 +3152,12 @@ var PivotTableXml = class extends BaseXmlComponent {
|
|
|
2986
3152
|
if (ref.avgSubtotal) rAttrs.push("avgSubtotal=\"1\"");
|
|
2987
3153
|
if (ref.maxSubtotal) rAttrs.push("maxSubtotal=\"1\"");
|
|
2988
3154
|
if (ref.minSubtotal) rAttrs.push("minSubtotal=\"1\"");
|
|
3155
|
+
if (ref.countSubtotal) rAttrs.push("countSubtotal=\"1\"");
|
|
3156
|
+
if (ref.productSubtotal) rAttrs.push("productSubtotal=\"1\"");
|
|
3157
|
+
if (ref.stdDevPSubtotal) rAttrs.push("stdDevPSubtotal=\"1\"");
|
|
3158
|
+
if (ref.stdDevSubtotal) rAttrs.push("stdDevSubtotal=\"1\"");
|
|
3159
|
+
if (ref.varPSubtotal) rAttrs.push("varPSubtotal=\"1\"");
|
|
3160
|
+
if (ref.varSubtotal) rAttrs.push("varSubtotal=\"1\"");
|
|
2989
3161
|
const xXml = ref.x ? ref.x.map((v) => `<x v="${v}"/>`).join("") : "";
|
|
2990
3162
|
if (xXml) parts.push(`<reference ${rAttrs.join(" ")}>${xXml}</reference>`);
|
|
2991
3163
|
else parts.push(`<reference ${rAttrs.join(" ")}/>`);
|
|
@@ -3100,7 +3272,6 @@ var TableXml = class extends BaseXmlComponent {
|
|
|
3100
3272
|
const fAttrs = col.totalsRowFormulaArray ? " array=\"1\"" : "";
|
|
3101
3273
|
inner.push(`<totalsRowFormula${fAttrs}>${escapeXml(col.totalsRowFormula)}</totalsRowFormula>`);
|
|
3102
3274
|
}
|
|
3103
|
-
if (col.totalsRowFunction === TotalsRowFunction.CUSTOM && col.totalsRowLabel) {}
|
|
3104
3275
|
if (col.totalsRowFunction !== void 0 && col.totalsRowFunction !== TotalsRowFunction.NONE) colAttrs.totalsRowFunction = col.totalsRowFunction;
|
|
3105
3276
|
if (col.totalsRowLabel !== void 0) colAttrs.totalsRowLabel = col.totalsRowLabel;
|
|
3106
3277
|
if (col.uniqueName) colAttrs.uniqueName = col.uniqueName;
|
|
@@ -3202,6 +3373,7 @@ var Dialogsheet = class extends BaseXmlComponent {
|
|
|
3202
3373
|
*
|
|
3203
3374
|
* @module
|
|
3204
3375
|
*/
|
|
3376
|
+
/** Preserve sort/filter layout (CT_QueryTableRefresh @preserveSortFilterLayout) */
|
|
3205
3377
|
var QueryTableXml = class extends BaseXmlComponent {
|
|
3206
3378
|
opts;
|
|
3207
3379
|
constructor(options) {
|
|
@@ -3242,6 +3414,11 @@ function buildQueryTableRefresh(opts) {
|
|
|
3242
3414
|
if (opts.refreshOnLoad) a.refreshOnLoad = 1;
|
|
3243
3415
|
if (opts.backgroundRefresh) a.backgroundRefresh = 1;
|
|
3244
3416
|
if (opts.rowCount !== void 0) a.rowCount = opts.rowCount;
|
|
3417
|
+
if (opts.fieldIdWrapped) a.fieldIdWrapped = 1;
|
|
3418
|
+
if (opts.headersInLastRefresh) a.headersInLastRefresh = 1;
|
|
3419
|
+
if (opts.preserveSortFilterLayout) a.preserveSortFilterLayout = 1;
|
|
3420
|
+
if (opts.unboundColumnsLeft !== void 0) a.unboundColumnsLeft = opts.unboundColumnsLeft;
|
|
3421
|
+
if (opts.unboundColumnsRight !== void 0) a.unboundColumnsRight = opts.unboundColumnsRight;
|
|
3245
3422
|
const children = [];
|
|
3246
3423
|
if (opts.deletedFields && opts.deletedFields.length > 0) {
|
|
3247
3424
|
const dfParts = opts.deletedFields.map((df) => `<deletedField name="${escapeXml(df.name)}"/>`);
|
|
@@ -3260,6 +3437,7 @@ function buildQueryTableRefresh(opts) {
|
|
|
3260
3437
|
if (f.borderFormatting) fAttrs.borderFormatting = 1;
|
|
3261
3438
|
if (f.width !== void 0) fAttrs.width = f.width;
|
|
3262
3439
|
if (f.clipped) fAttrs.clipped = 1;
|
|
3440
|
+
if (f.dataBound !== void 0) fAttrs.dataBound = f.dataBound ? 1 : 0;
|
|
3263
3441
|
fParts.push(`<queryTableField${attrs(fAttrs)}/>`);
|
|
3264
3442
|
}
|
|
3265
3443
|
fParts.push("</queryTableFields>");
|
|
@@ -3411,7 +3589,9 @@ var RevisionHeadersXml = class extends BaseXmlComponent {
|
|
|
3411
3589
|
version: this.opts.version,
|
|
3412
3590
|
keepChangeHistory: this.opts.keepChangeHistory,
|
|
3413
3591
|
protected: this.opts.protected,
|
|
3414
|
-
preserveHistory: this.opts.preserveHistory
|
|
3592
|
+
preserveHistory: this.opts.preserveHistory,
|
|
3593
|
+
diskRevisions: this.opts.diskRevisions,
|
|
3594
|
+
exclusive: this.opts.exclusive
|
|
3415
3595
|
};
|
|
3416
3596
|
p.push(`${attrs(rootAttrs)}>`);
|
|
3417
3597
|
for (const h of this.opts.headers) {
|
|
@@ -3469,7 +3649,10 @@ function buildRowColumn(opts) {
|
|
|
3469
3649
|
deleteCol: "dc"
|
|
3470
3650
|
}[opts.action],
|
|
3471
3651
|
sId: opts.sheetIndex,
|
|
3472
|
-
edge: opts.edge ? 1 : void 0
|
|
3652
|
+
edge: opts.edge ? 1 : void 0,
|
|
3653
|
+
ra: opts.ra,
|
|
3654
|
+
ua: opts.ua,
|
|
3655
|
+
eol: opts.eol ? 1 : void 0
|
|
3473
3656
|
};
|
|
3474
3657
|
if (opts.action.includes("Row")) a.row = opts.row;
|
|
3475
3658
|
else a.col = opts.col;
|
|
@@ -3482,20 +3665,25 @@ function buildCellChange(opts) {
|
|
|
3482
3665
|
quotePrefix: opts.quotePrefix ? 1 : void 0,
|
|
3483
3666
|
oldQuotePrefix: opts.oldQuotePrefix ? 1 : void 0,
|
|
3484
3667
|
ph: opts.ph ? 1 : void 0,
|
|
3485
|
-
oldPh: opts.oldPh ? 1 : void 0
|
|
3668
|
+
oldPh: opts.oldPh ? 1 : void 0,
|
|
3669
|
+
ra: opts.ra,
|
|
3670
|
+
ua: opts.ua
|
|
3486
3671
|
};
|
|
3487
3672
|
const children = [];
|
|
3488
3673
|
if (opts.oldValue !== void 0) {
|
|
3489
3674
|
const oldType = opts.oldType ?? (typeof opts.oldValue === "number" ? "n" : "s");
|
|
3490
3675
|
if (opts.formula) children.push(`<f>${escapeXml(opts.formula)}</f>`);
|
|
3491
|
-
|
|
3676
|
+
const ocAttrs = {
|
|
3492
3677
|
t: oldType,
|
|
3493
3678
|
vm: opts.numFmtId
|
|
3494
|
-
}
|
|
3679
|
+
};
|
|
3680
|
+
if (opts.oldCellMeta !== void 0) ocAttrs.cm = opts.oldCellMeta;
|
|
3681
|
+
children.push(`<oc${attrs(ocAttrs)}><v>${escapeXml(String(opts.oldValue))}</v></oc>`);
|
|
3495
3682
|
}
|
|
3496
3683
|
if (opts.newValue !== void 0) {
|
|
3497
|
-
const
|
|
3498
|
-
|
|
3684
|
+
const ncAttrs = { t: opts.newType ?? (typeof opts.newValue === "number" ? "n" : "s") };
|
|
3685
|
+
if (opts.newCellMeta !== void 0) ncAttrs.cm = opts.newCellMeta;
|
|
3686
|
+
children.push(`<nc${attrs(ncAttrs)}><v>${escapeXml(String(opts.newValue))}</v></nc>`);
|
|
3499
3687
|
}
|
|
3500
3688
|
if (opts.xfDxf !== void 0) {
|
|
3501
3689
|
children.push(`<ndxf><font/><numFmt/><fill/><border/><protection/></ndxf>`);
|
|
@@ -3512,7 +3700,9 @@ function buildMove(opts) {
|
|
|
3512
3700
|
sId: opts.sheetIndex,
|
|
3513
3701
|
source: opts.source,
|
|
3514
3702
|
destination: opts.destination,
|
|
3515
|
-
sourceSheetId: opts.sourceSheetId
|
|
3703
|
+
sourceSheetId: opts.sourceSheetId,
|
|
3704
|
+
ra: opts.ra,
|
|
3705
|
+
ua: opts.ua
|
|
3516
3706
|
})}/>`;
|
|
3517
3707
|
}
|
|
3518
3708
|
function buildFormatting(opts) {
|
|
@@ -3529,7 +3719,9 @@ function buildInsertSheet(opts) {
|
|
|
3529
3719
|
rId: opts.rId,
|
|
3530
3720
|
sId: opts.sheetIndex,
|
|
3531
3721
|
name: opts.name,
|
|
3532
|
-
sheetPosition: opts.sheetPosition
|
|
3722
|
+
sheetPosition: opts.sheetPosition,
|
|
3723
|
+
ra: opts.ra,
|
|
3724
|
+
ua: opts.ua
|
|
3533
3725
|
})}/>`;
|
|
3534
3726
|
}
|
|
3535
3727
|
function buildComment(opts) {
|
|
@@ -3569,7 +3761,9 @@ function buildDefinedName(opts) {
|
|
|
3569
3761
|
help: opts.help,
|
|
3570
3762
|
oldHelp: opts.oldHelp,
|
|
3571
3763
|
statusBar: opts.statusBar,
|
|
3572
|
-
oldStatusBar: opts.oldStatusBar
|
|
3764
|
+
oldStatusBar: opts.oldStatusBar,
|
|
3765
|
+
ra: opts.ra,
|
|
3766
|
+
ua: opts.ua
|
|
3573
3767
|
};
|
|
3574
3768
|
const children = [];
|
|
3575
3769
|
if (opts.value) children.push(`<formula>${escapeXml(opts.value)}</formula>`);
|
|
@@ -3594,20 +3788,26 @@ function buildSheetRename(opts) {
|
|
|
3594
3788
|
rId: opts.rId,
|
|
3595
3789
|
sId: opts.sheetIndex,
|
|
3596
3790
|
oldName: opts.oldName,
|
|
3597
|
-
newName: opts.newName
|
|
3791
|
+
newName: opts.newName,
|
|
3792
|
+
ra: opts.ra,
|
|
3793
|
+
ua: opts.ua
|
|
3598
3794
|
})}/>`;
|
|
3599
3795
|
}
|
|
3600
3796
|
function buildQueryTableField(opts) {
|
|
3601
3797
|
return `<rqt${attrs({
|
|
3602
3798
|
rId: opts.rId,
|
|
3603
3799
|
sId: opts.sheetIndex,
|
|
3604
|
-
fieldId: opts.fieldId
|
|
3800
|
+
fieldId: opts.fieldId,
|
|
3801
|
+
ra: opts.ra,
|
|
3802
|
+
ua: opts.ua
|
|
3605
3803
|
})}/>`;
|
|
3606
3804
|
}
|
|
3607
3805
|
function buildConflict(opts) {
|
|
3608
3806
|
return `<rcft${attrs({
|
|
3609
3807
|
rId: opts.rId,
|
|
3610
|
-
sId: opts.sheetIndex
|
|
3808
|
+
sId: opts.sheetIndex,
|
|
3809
|
+
ra: opts.ra,
|
|
3810
|
+
ua: opts.ua
|
|
3611
3811
|
})}/>`;
|
|
3612
3812
|
}
|
|
3613
3813
|
var RevisionLogXml = class extends BaseXmlComponent {
|
|
@@ -3645,9 +3845,62 @@ var RevisionLogXml = class extends BaseXmlComponent {
|
|
|
3645
3845
|
localReviewedList.push(`<reviewed rId="${entry.data.rId}"/>`);
|
|
3646
3846
|
p.push(`<reviewed rId="${entry.data.rId}"/>`);
|
|
3647
3847
|
break;
|
|
3648
|
-
case "undo":
|
|
3649
|
-
|
|
3848
|
+
case "undo": {
|
|
3849
|
+
const undoAttrs = {
|
|
3850
|
+
rId: entry.data.rId,
|
|
3851
|
+
cs: entry.data.cs ? 1 : void 0,
|
|
3852
|
+
dn: entry.data.dn ? 1 : void 0,
|
|
3853
|
+
exp: entry.data.exp ? 1 : void 0,
|
|
3854
|
+
nf: entry.data.nf ? 1 : void 0,
|
|
3855
|
+
ref3D: entry.data.ref3D ? 1 : void 0
|
|
3856
|
+
};
|
|
3857
|
+
if (entry.data.revisions && entry.data.revisions.length > 0) {
|
|
3858
|
+
const innerParts = [];
|
|
3859
|
+
for (const inner of entry.data.revisions) switch (inner.type) {
|
|
3860
|
+
case "rowColumn":
|
|
3861
|
+
innerParts.push(buildRowColumn(inner.data));
|
|
3862
|
+
break;
|
|
3863
|
+
case "cellChange":
|
|
3864
|
+
innerParts.push(buildCellChange(inner.data));
|
|
3865
|
+
break;
|
|
3866
|
+
case "move":
|
|
3867
|
+
innerParts.push(buildMove(inner.data));
|
|
3868
|
+
break;
|
|
3869
|
+
case "formatting":
|
|
3870
|
+
innerParts.push(buildFormatting(inner.data));
|
|
3871
|
+
break;
|
|
3872
|
+
case "insertSheet":
|
|
3873
|
+
innerParts.push(buildInsertSheet(inner.data));
|
|
3874
|
+
break;
|
|
3875
|
+
case "comment":
|
|
3876
|
+
innerParts.push(buildComment(inner.data));
|
|
3877
|
+
break;
|
|
3878
|
+
case "definedName":
|
|
3879
|
+
innerParts.push(buildDefinedName(inner.data));
|
|
3880
|
+
break;
|
|
3881
|
+
case "reviewed":
|
|
3882
|
+
innerParts.push(`<reviewed rId="${inner.data.rId}"/>`);
|
|
3883
|
+
break;
|
|
3884
|
+
case "autoFormatting":
|
|
3885
|
+
innerParts.push(buildAutoFormatting(inner.data));
|
|
3886
|
+
break;
|
|
3887
|
+
case "customView":
|
|
3888
|
+
innerParts.push(buildCustomView(inner.data));
|
|
3889
|
+
break;
|
|
3890
|
+
case "sheetRename":
|
|
3891
|
+
innerParts.push(buildSheetRename(inner.data));
|
|
3892
|
+
break;
|
|
3893
|
+
case "queryTableField":
|
|
3894
|
+
innerParts.push(buildQueryTableField(inner.data));
|
|
3895
|
+
break;
|
|
3896
|
+
case "conflict":
|
|
3897
|
+
innerParts.push(buildConflict(inner.data));
|
|
3898
|
+
break;
|
|
3899
|
+
}
|
|
3900
|
+
p.push(`<undo${attrs(undoAttrs)}>${innerParts.join("")}</undo>`);
|
|
3901
|
+
} else p.push(`<undo${attrs(undoAttrs)}/>`);
|
|
3650
3902
|
break;
|
|
3903
|
+
}
|
|
3651
3904
|
case "autoFormatting":
|
|
3652
3905
|
p.push(buildAutoFormatting(entry.data));
|
|
3653
3906
|
break;
|
|
@@ -3698,6 +3951,13 @@ var ConnectionsXml = class extends BaseXmlComponent {
|
|
|
3698
3951
|
if (c.savePassword) cAttrs.savePassword = 1;
|
|
3699
3952
|
if (c.description !== void 0) cAttrs.description = c.description;
|
|
3700
3953
|
if (c.credentials !== void 0) cAttrs.credentials = c.credentials;
|
|
3954
|
+
if (c.interval !== void 0) cAttrs.interval = c.interval;
|
|
3955
|
+
if (c.keepAlive) cAttrs.keepAlive = 1;
|
|
3956
|
+
if (c.new) cAttrs.new = 1;
|
|
3957
|
+
if (c.odcFile !== void 0) cAttrs.odcFile = c.odcFile;
|
|
3958
|
+
if (c.onlyUseConnectionFile) cAttrs.onlyUseConnectionFile = 1;
|
|
3959
|
+
if (c.reconnectionMethod !== void 0) cAttrs.reconnectionMethod = c.reconnectionMethod;
|
|
3960
|
+
if (c.singleSignOnId !== void 0) cAttrs.singleSignOnId = c.singleSignOnId;
|
|
3701
3961
|
const children = [];
|
|
3702
3962
|
if (c.dbPr) {
|
|
3703
3963
|
const dbAttrs = { connection: c.dbPr.connection };
|
|
@@ -3714,6 +3974,11 @@ var ConnectionsXml = class extends BaseXmlComponent {
|
|
|
3714
3974
|
if (c.webPr.firstRowHeader) wpAttrs.firstRowHeader = 1;
|
|
3715
3975
|
if (c.webPr.parsePre) wpAttrs.parsePre = 1;
|
|
3716
3976
|
if (c.webPr.xl2000) wpAttrs.xl2000 = 1;
|
|
3977
|
+
if (c.webPr.editPage !== void 0) wpAttrs.editPage = c.webPr.editPage;
|
|
3978
|
+
if (c.webPr.firstRow) wpAttrs.firstRow = 1;
|
|
3979
|
+
if (c.webPr.post) wpAttrs.post = 1;
|
|
3980
|
+
if (c.webPr.textDates) wpAttrs.textDates = 1;
|
|
3981
|
+
if (c.webPr.xl97) wpAttrs.xl97 = 1;
|
|
3717
3982
|
const wpChildren = [];
|
|
3718
3983
|
if (c.webPr.htmlTables && c.webPr.htmlTables.length > 0) wpChildren.push(`<tables>${c.webPr.htmlTables.map((t) => `<x v="${escapeXml(t)}"/>`).join("")}</tables>`);
|
|
3719
3984
|
if (c.webPr.textFields && c.webPr.textFields.length > 0) wpChildren.push(buildTextFields(c.webPr.textFields));
|
|
@@ -3734,6 +3999,10 @@ var ConnectionsXml = class extends BaseXmlComponent {
|
|
|
3734
3999
|
if (c.textPr.decimal !== void 0) tpAttrs.decimal = c.textPr.decimal;
|
|
3735
4000
|
if (c.textPr.thousands !== void 0) tpAttrs.thousands = c.textPr.thousands;
|
|
3736
4001
|
if (c.textPr.trailingMinus !== void 0) tpAttrs.trailingMinus = c.textPr.trailingMinus ? 1 : 0;
|
|
4002
|
+
if (c.textPr.delimiter !== void 0) tpAttrs.delimiter = c.textPr.delimiter;
|
|
4003
|
+
if (c.textPr.fileType !== void 0) tpAttrs.fileType = c.textPr.fileType;
|
|
4004
|
+
if (c.textPr.firstRow) tpAttrs.firstRow = 1;
|
|
4005
|
+
if (c.textPr.qualifier !== void 0) tpAttrs.qualifier = c.textPr.qualifier;
|
|
3737
4006
|
const tpChildren = [];
|
|
3738
4007
|
if (c.textPr.textFields && c.textPr.textFields.length > 0) tpChildren.push(buildTextFields(c.textPr.textFields));
|
|
3739
4008
|
if (tpChildren.length > 0) children.push(`<textPr${attrs(tpAttrs)}>${tpChildren.join("")}</textPr>`);
|
|
@@ -3750,6 +4019,7 @@ var ConnectionsXml = class extends BaseXmlComponent {
|
|
|
3750
4019
|
if (param.booleanValue !== void 0) paramAttrs.booleanValue = param.booleanValue ? 1 : 0;
|
|
3751
4020
|
if (param.refreshOnChange) paramAttrs.refreshOnChange = 1;
|
|
3752
4021
|
if (param.prompt) paramAttrs.prompt = 1;
|
|
4022
|
+
if (param.integer) paramAttrs.integer = 1;
|
|
3753
4023
|
if (param.reference !== void 0) paramAttrs.reference = param.reference;
|
|
3754
4024
|
if (param.parameterType !== void 0) paramAttrs.parameterType = param.parameterType;
|
|
3755
4025
|
paramParts.push(`<parameter${attrs(paramAttrs)}/>`);
|
|
@@ -3883,7 +4153,8 @@ var XmlColumnPrXml = class extends BaseXmlComponent {
|
|
|
3883
4153
|
return `<xmlColumnPr${attrs({
|
|
3884
4154
|
xpath: this.options.xpath,
|
|
3885
4155
|
xmlDataType: this.options.xmlDataType,
|
|
3886
|
-
mapId: this.options.mapId
|
|
4156
|
+
mapId: this.options.mapId,
|
|
4157
|
+
denormalized: this.options.denormalized ? 1 : void 0
|
|
3887
4158
|
})}/>`;
|
|
3888
4159
|
}
|
|
3889
4160
|
};
|
|
@@ -4014,38 +4285,49 @@ var Comments = class extends BaseXmlComponent {
|
|
|
4014
4285
|
}
|
|
4015
4286
|
toXml(_context) {
|
|
4016
4287
|
const authors = this.collectAuthors();
|
|
4017
|
-
const p = [
|
|
4288
|
+
const p = [`<comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"${this.entries.some((e) => e.commentPr) ? " xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\"" : ""}>`, `<authors>`];
|
|
4018
4289
|
for (const author of authors) p.push(`<author>${escapeXml(author)}</author>`);
|
|
4019
4290
|
p.push("</authors><commentList>");
|
|
4020
4291
|
for (const entry of this.entries) {
|
|
4021
4292
|
const authorId = authors.indexOf(entry.author);
|
|
4022
4293
|
const textXml = typeof entry.text === "string" ? `<t>${escapeXml(entry.text)}</t>` : buildRstXml(entry.text);
|
|
4023
|
-
|
|
4024
|
-
if (entry.commentPr) {
|
|
4025
|
-
const cp = entry.commentPr;
|
|
4026
|
-
const cpAttrs = [];
|
|
4027
|
-
if (cp.locked === false) cpAttrs.push("locked=\"0\"");
|
|
4028
|
-
if (cp.defaultSize === false) cpAttrs.push("defaultSize=\"0\"");
|
|
4029
|
-
if (cp.print === false) cpAttrs.push("print=\"0\"");
|
|
4030
|
-
if (cp.disabled) cpAttrs.push("disabled=\"1\"");
|
|
4031
|
-
if (cp.autoFill === false) cpAttrs.push("autoFill=\"0\"");
|
|
4032
|
-
if (cp.autoLine === false) cpAttrs.push("autoLine=\"0\"");
|
|
4033
|
-
if (cp.altText) cpAttrs.push(`altText="${escapeXml(cp.altText)}"`);
|
|
4034
|
-
if (cp.textHAlign && cp.textHAlign !== "left") cpAttrs.push(`textHAlign="${cp.textHAlign}"`);
|
|
4035
|
-
if (cp.textVAlign && cp.textVAlign !== "top") cpAttrs.push(`textVAlign="${cp.textVAlign}"`);
|
|
4036
|
-
if (cp.lockText === false) cpAttrs.push("lockText=\"0\"");
|
|
4037
|
-
if (cp.justLastX) cpAttrs.push("justLastX=\"1\"");
|
|
4038
|
-
if (cp.autoScale) cpAttrs.push("autoScale=\"1\"");
|
|
4039
|
-
const anchorAttrs = [];
|
|
4040
|
-
if (cp.anchor?.moveWithCells) anchorAttrs.push("moveWithCells=\"1\"");
|
|
4041
|
-
if (cp.anchor?.sizeWithCells) anchorAttrs.push("sizeWithCells=\"1\"");
|
|
4042
|
-
commentPrXml = `<commentPr${cpAttrs.length ? " " + cpAttrs.join(" ") : ""}><anchor${anchorAttrs.length ? " " + anchorAttrs.join(" ") : ""}/></commentPr>`;
|
|
4043
|
-
}
|
|
4294
|
+
const commentPrXml = this.buildCommentPrXml(entry);
|
|
4044
4295
|
p.push(`<comment ref="${entry.cell}" authorId="${authorId}"><text>${textXml}</text>${commentPrXml}</comment>`);
|
|
4045
4296
|
}
|
|
4046
4297
|
p.push("</commentList></comments>");
|
|
4047
4298
|
return p.join("");
|
|
4048
4299
|
}
|
|
4300
|
+
/** Build CT_CommentPr XML. Returns empty string if commentPr is not set. */
|
|
4301
|
+
buildCommentPrXml(entry) {
|
|
4302
|
+
const cp = entry.commentPr;
|
|
4303
|
+
if (!cp) return "";
|
|
4304
|
+
const attrs = [];
|
|
4305
|
+
if (cp.locked === false) attrs.push("locked=\"0\"");
|
|
4306
|
+
if (cp.defaultSize === false) attrs.push("defaultSize=\"0\"");
|
|
4307
|
+
if (cp.print === false) attrs.push("print=\"0\"");
|
|
4308
|
+
if (cp.disabled) attrs.push("disabled=\"1\"");
|
|
4309
|
+
if (cp.autoFill === false) attrs.push("autoFill=\"0\"");
|
|
4310
|
+
if (cp.autoLine === false) attrs.push("autoLine=\"0\"");
|
|
4311
|
+
if (cp.altText) attrs.push(`altText="${escapeXml(cp.altText)}"`);
|
|
4312
|
+
if (cp.textHAlign && cp.textHAlign !== "left") attrs.push(`textHAlign="${cp.textHAlign}"`);
|
|
4313
|
+
if (cp.textVAlign && cp.textVAlign !== "top") attrs.push(`textVAlign="${cp.textVAlign}"`);
|
|
4314
|
+
if (cp.lockText === false) attrs.push("lockText=\"0\"");
|
|
4315
|
+
if (cp.justLastX) attrs.push("justLastX=\"1\"");
|
|
4316
|
+
if (cp.autoScale) attrs.push("autoScale=\"1\"");
|
|
4317
|
+
const anchorXml = this.buildAnchorXml(entry.cell, cp.anchor);
|
|
4318
|
+
return `<commentPr${attrs.length ? ` ${attrs.join(" ")}` : ""}>${anchorXml}</commentPr>`;
|
|
4319
|
+
}
|
|
4320
|
+
/** Build CT_ObjectAnchor with required xdr:from/xdr:to markers. */
|
|
4321
|
+
buildAnchorXml(cell, anchor) {
|
|
4322
|
+
const col = cell.charCodeAt(0) - 65;
|
|
4323
|
+
const row = parseInt(cell.slice(1), 10) - 1;
|
|
4324
|
+
const toCol = col + 2;
|
|
4325
|
+
const toRow = row + 2;
|
|
4326
|
+
const anchorAttrs = [];
|
|
4327
|
+
if (anchor?.moveWithCells) anchorAttrs.push(" moveWithCells=\"1\"");
|
|
4328
|
+
if (anchor?.sizeWithCells) anchorAttrs.push(" sizeWithCells=\"1\"");
|
|
4329
|
+
return `<anchor${anchorAttrs.join("")}><xdr:from><xdr:col>${col}</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>${row}</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:to><xdr:col>${toCol}</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>${toRow}</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:to></anchor>`;
|
|
4330
|
+
}
|
|
4049
4331
|
collectAuthors() {
|
|
4050
4332
|
const seen = /* @__PURE__ */ new Set();
|
|
4051
4333
|
const result = [];
|
|
@@ -4124,6 +4406,10 @@ var ExternalLinkXml = class extends BaseXmlComponent {
|
|
|
4124
4406
|
const dnAttrs = { name: dn.name };
|
|
4125
4407
|
if (dn.refersTo !== void 0) dnAttrs.refersTo = dn.refersTo;
|
|
4126
4408
|
if (dn.sheetId !== void 0) dnAttrs.sheetId = dn.sheetId;
|
|
4409
|
+
if (dn.publishToServer) dnAttrs.publishToServer = 1;
|
|
4410
|
+
if (dn.vbProcedure) dnAttrs.vbProcedure = 1;
|
|
4411
|
+
if (dn.workbookParameter) dnAttrs.workbookParameter = 1;
|
|
4412
|
+
if (dn.xlm) dnAttrs.xlm = 1;
|
|
4127
4413
|
bookParts.push(`<definedName${attrs(dnAttrs)}/>`);
|
|
4128
4414
|
}
|
|
4129
4415
|
bookParts.push("</definedNames>");
|