@office-open/xlsx 0.9.3 → 0.9.5
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/{context-BXK92u5G.mjs → context-ChKe3x0r.mjs} +89 -14
- package/dist/context-ChKe3x0r.mjs.map +1 -0
- package/dist/{worksheet--3Qbjk4x.d.mts → file-DQTBkYzl.d.mts} +25 -2
- package/dist/file-DQTBkYzl.d.mts.map +1 -0
- package/dist/{generate-BqlKnMiw.mjs → generate-DGqFsuiZ.mjs} +6 -2
- package/dist/generate-DGqFsuiZ.mjs.map +1 -0
- package/dist/generate.d.mts +10 -2
- package/dist/generate.d.mts.map +1 -0
- package/dist/generate.mjs +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/parse.d.mts +26 -2
- package/dist/parse.d.mts.map +1 -0
- package/dist/parse.mjs +32 -2
- package/dist/parse.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/context-BXK92u5G.mjs.map +0 -1
- package/dist/generate-BqlKnMiw.mjs.map +0 -1
- package/dist/generate-DJhsIF31.d.mts +0 -26
- package/dist/generate-DJhsIF31.d.mts.map +0 -1
- package/dist/parse-DvLtpSVC.d.mts +0 -42
- package/dist/parse-DvLtpSVC.d.mts.map +0 -1
- package/dist/worksheet--3Qbjk4x.d.mts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { attr, attrNum, attrs, attrsRaw, escapeXml, findChild, selfCloseElement, textOf } from "@office-open/xml";
|
|
1
|
+
import { attr, attrNum, attrs, attrsRaw, escapeXml, findChild, selfCloseElement, stringify, textOf } from "@office-open/xml";
|
|
2
2
|
import { ChartCollection, Relationships, derivePasswordHash } from "@office-open/core";
|
|
3
3
|
//#region src/parts/shared-strings.ts
|
|
4
4
|
/**
|
|
@@ -451,8 +451,9 @@ var Styles = class {
|
|
|
451
451
|
}
|
|
452
452
|
p.push("</cellXfs>");
|
|
453
453
|
if (this.customCellStyles && this.customCellStyles.length > 0) {
|
|
454
|
-
const
|
|
455
|
-
csParts.
|
|
454
|
+
const hasNormal = this.customCellStyles.some((cs) => cs.builtinId === 0 && cs.name === "Normal");
|
|
455
|
+
const csParts = [`<cellStyles ${[`count="${this.customCellStyles.length + (hasNormal ? 0 : 1)}"`].join(" ")}>`];
|
|
456
|
+
if (!hasNormal) csParts.push("<cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/>");
|
|
456
457
|
for (const cs of this.customCellStyles) {
|
|
457
458
|
const attrs = [`name="${escapeXml(cs.name)}"`, `xfId="${cs.xfId}"`];
|
|
458
459
|
if (cs.builtinId !== void 0) attrs.push(`builtinId="${cs.builtinId}"`);
|
|
@@ -767,9 +768,7 @@ const stylesDesc = {
|
|
|
767
768
|
if (ext.name !== "ext") continue;
|
|
768
769
|
const uri = attr(ext, "uri");
|
|
769
770
|
if (uri) {
|
|
770
|
-
const content = (ext.elements ?? []).map((e) =>
|
|
771
|
-
return JSON.stringify(e);
|
|
772
|
-
}).join("");
|
|
771
|
+
const content = (ext.elements ?? []).map((e) => stringify(e)).join("");
|
|
773
772
|
exts.push({
|
|
774
773
|
uri,
|
|
775
774
|
content: content || void 0
|
|
@@ -836,7 +835,8 @@ function parseFill(el) {
|
|
|
836
835
|
const patternFill = findChild(el, "patternFill");
|
|
837
836
|
if (patternFill) {
|
|
838
837
|
const result = {};
|
|
839
|
-
|
|
838
|
+
const patternType = attr(patternFill, "patternType");
|
|
839
|
+
if (patternType) result.patternType = patternType;
|
|
840
840
|
const fg = findChild(patternFill, "fgColor");
|
|
841
841
|
if (fg) result.color = parseColorHex(fg);
|
|
842
842
|
const bg = findChild(patternFill, "bgColor");
|
|
@@ -852,6 +852,14 @@ function parseFill(el) {
|
|
|
852
852
|
if (gType) result.gradientType = gType;
|
|
853
853
|
const degree = attrNum(gradientFill, "degree");
|
|
854
854
|
if (degree !== void 0) result.gradientDegree = degree;
|
|
855
|
+
const left = attrNum(gradientFill, "left");
|
|
856
|
+
if (left !== void 0) result.gradientLeft = left;
|
|
857
|
+
const right = attrNum(gradientFill, "right");
|
|
858
|
+
if (right !== void 0) result.gradientRight = right;
|
|
859
|
+
const top = attrNum(gradientFill, "top");
|
|
860
|
+
if (top !== void 0) result.gradientTop = top;
|
|
861
|
+
const bottom = attrNum(gradientFill, "bottom");
|
|
862
|
+
if (bottom !== void 0) result.gradientBottom = bottom;
|
|
855
863
|
const stops = [];
|
|
856
864
|
for (const s of gradientFill.elements ?? []) {
|
|
857
865
|
if (s.name !== "stop") continue;
|
|
@@ -905,6 +913,12 @@ function parseAlignment(el) {
|
|
|
905
913
|
if (rotation !== void 0) result.textRotation = rotation;
|
|
906
914
|
const indent = attrNum(el, "indent");
|
|
907
915
|
if (indent !== void 0) result.indent = indent;
|
|
916
|
+
const relativeIndent = attrNum(el, "relativeIndent");
|
|
917
|
+
if (relativeIndent !== void 0) result.relativeIndent = relativeIndent;
|
|
918
|
+
if (attr(el, "justifyLastLine") === "1") result.justifyLastLine = true;
|
|
919
|
+
if (attr(el, "shrinkToFit") === "1") result.shrinkToFit = true;
|
|
920
|
+
const readingOrder = attrNum(el, "readingOrder");
|
|
921
|
+
if (readingOrder !== void 0) result.readingOrder = readingOrder;
|
|
908
922
|
return result;
|
|
909
923
|
}
|
|
910
924
|
function parseProtection(el) {
|
|
@@ -948,6 +962,7 @@ const worksheetDesc = {
|
|
|
948
962
|
},
|
|
949
963
|
parse(el, ctx) {
|
|
950
964
|
const result = {};
|
|
965
|
+
let pageSetUpPrCache;
|
|
951
966
|
const strings = ctx && "sharedStrings" in ctx ? ctx.sharedStrings : [];
|
|
952
967
|
const sheetPrEl = findChild(el, "sheetPr");
|
|
953
968
|
if (sheetPrEl) {
|
|
@@ -964,6 +979,15 @@ const worksheetDesc = {
|
|
|
964
979
|
if (outlinePr) {
|
|
965
980
|
if (attr(outlinePr, "applyStyles") === "1") sp.outlineApplyStyles = true;
|
|
966
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;
|
|
967
991
|
}
|
|
968
992
|
if (Object.keys(sp).length > 0) result.sheetPr = sp;
|
|
969
993
|
const tabColorEl = findChild(sheetPrEl, "tabColor");
|
|
@@ -988,7 +1012,21 @@ const worksheetDesc = {
|
|
|
988
1012
|
if (zs !== void 0) sv.zoomScale = zs;
|
|
989
1013
|
if (attr(svEl, "tabSelected") !== void 0) sv.tabSelected = attr(svEl, "tabSelected") !== "0";
|
|
990
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;
|
|
991
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;
|
|
992
1030
|
result.sheetView = sv;
|
|
993
1031
|
const paneEl = findChild(svEl, "pane");
|
|
994
1032
|
if (paneEl && attr(paneEl, "state") === "frozen") {
|
|
@@ -1254,8 +1292,9 @@ const worksheetDesc = {
|
|
|
1254
1292
|
if (attr(psEl, "useFirstPageNumber") === "1") ps.useFirstPageNumber = true;
|
|
1255
1293
|
const fpn = attrNum(psEl, "firstPageNumber");
|
|
1256
1294
|
if (fpn !== void 0) ps.firstPageNumber = fpn;
|
|
1295
|
+
if (pageSetUpPrCache) Object.assign(ps, pageSetUpPrCache);
|
|
1257
1296
|
result.pageSetup = ps;
|
|
1258
|
-
}
|
|
1297
|
+
} else if (pageSetUpPrCache) result.pageSetup = pageSetUpPrCache;
|
|
1259
1298
|
const hfEl = findChild(el, "headerFooter");
|
|
1260
1299
|
if (hfEl) {
|
|
1261
1300
|
const hf = {};
|
|
@@ -1335,7 +1374,11 @@ const worksheetDesc = {
|
|
|
1335
1374
|
if (ref) cell.reference = ref;
|
|
1336
1375
|
const type = attr(cellEl, "t");
|
|
1337
1376
|
const styleIdx = attrNum(cellEl, "s");
|
|
1338
|
-
if (styleIdx !== void 0)
|
|
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
|
+
}
|
|
1339
1382
|
const vEl = findChild(cellEl, "v");
|
|
1340
1383
|
const isEl = findChild(cellEl, "is");
|
|
1341
1384
|
if (type === "s" && vEl) cell.value = strings[parseInt(textOf(vEl) ?? "", 10)] ?? "";
|
|
@@ -1397,7 +1440,8 @@ function stringifyWorksheet(opts, ctx) {
|
|
|
1397
1440
|
const hasOutline = columns.some((c) => c.outlineLevel !== void 0);
|
|
1398
1441
|
const sp = opts.sheetPr;
|
|
1399
1442
|
const hasSheetPrAttrs = sp && (sp.syncHorizontal || sp.syncVertical || sp.syncRef || sp.transitionEvaluation || sp.transitionEntry || sp.published || sp.filterMode || sp.enableFormatConditionsCalculation);
|
|
1400
|
-
|
|
1443
|
+
const hasPageSetUpPr = !!opts.pageSetup?.fitToWidth || !!opts.pageSetup?.fitToHeight || !!opts.pageSetup?.autoPageBreaks;
|
|
1444
|
+
if (hasTabColor || hasOutline || hasSheetPrAttrs || hasPageSetUpPr) {
|
|
1401
1445
|
const prParts = [];
|
|
1402
1446
|
const prAttrs = {};
|
|
1403
1447
|
if (sp?.syncHorizontal) prAttrs.syncHorizontal = 1;
|
|
@@ -1422,6 +1466,8 @@ function stringifyWorksheet(opts, ctx) {
|
|
|
1422
1466
|
summaryBelow: 1,
|
|
1423
1467
|
summaryRight: 1
|
|
1424
1468
|
};
|
|
1469
|
+
if (sp?.outlineSummaryBelow === false) outAttrs.summaryBelow = 0;
|
|
1470
|
+
if (sp?.outlineSummaryRight === false) outAttrs.summaryRight = 0;
|
|
1425
1471
|
if (sp?.outlineApplyStyles) outAttrs.applyStyles = 1;
|
|
1426
1472
|
if (sp?.outlineShowSymbols === false) outAttrs.showOutlineSymbols = 0;
|
|
1427
1473
|
prParts.push(`<outlinePr${attrs(outAttrs)}/>`);
|
|
@@ -2394,14 +2440,38 @@ function buildRstXml(rst) {
|
|
|
2394
2440
|
}
|
|
2395
2441
|
return parts.join("");
|
|
2396
2442
|
}
|
|
2397
|
-
/** Parse rich text element into a
|
|
2443
|
+
/** Parse rich text element into a plain string or rich runs. */
|
|
2398
2444
|
function parseRst(textEl) {
|
|
2445
|
+
const runs = [];
|
|
2399
2446
|
const parts = [];
|
|
2447
|
+
let hasRuns = false;
|
|
2400
2448
|
for (const child of textEl.elements ?? []) if (child.name === "t") parts.push(textOf(child) ?? "");
|
|
2401
2449
|
else if (child.name === "r") {
|
|
2450
|
+
hasRuns = true;
|
|
2402
2451
|
const t = findChild(child, "t");
|
|
2403
|
-
|
|
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);
|
|
2404
2473
|
}
|
|
2474
|
+
if (hasRuns) return { runs };
|
|
2405
2475
|
return parts.join("");
|
|
2406
2476
|
}
|
|
2407
2477
|
//#endregion
|
|
@@ -4056,7 +4126,7 @@ const tableDesc = {
|
|
|
4056
4126
|
if (s.showRowStripes !== false) styleAttrs.showRowStripes = 1;
|
|
4057
4127
|
if (s.showColumnStripes) styleAttrs.showColumnStripes = 1;
|
|
4058
4128
|
p.push(`<tableStyleInfo${buildAttrs(styleAttrs)}/>`);
|
|
4059
|
-
}
|
|
4129
|
+
}
|
|
4060
4130
|
p.push("</table>");
|
|
4061
4131
|
return p.join("");
|
|
4062
4132
|
},
|
|
@@ -4214,9 +4284,14 @@ const workbookDesc = {
|
|
|
4214
4284
|
if (wh !== void 0) bv.windowHeight = wh;
|
|
4215
4285
|
const at = attrNum(bvEl, "activeTab");
|
|
4216
4286
|
if (at !== void 0) bv.activeTab = at;
|
|
4287
|
+
if (attr(bvEl, "autoFilterDateGrouping") === "0") bv.autoFilterDateGrouping = false;
|
|
4288
|
+
const fs = attrNum(bvEl, "firstSheet");
|
|
4289
|
+
if (fs !== void 0) bv.firstSheet = fs;
|
|
4217
4290
|
if (attr(bvEl, "showHorizontalScroll") === "0") bv.showHorizontalScroll = false;
|
|
4218
4291
|
if (attr(bvEl, "showVerticalScroll") === "0") bv.showVerticalScroll = false;
|
|
4219
4292
|
if (attr(bvEl, "showSheetTabs") === "0") bv.showSheetTabs = false;
|
|
4293
|
+
const tr = attrNum(bvEl, "tabRatio");
|
|
4294
|
+
if (tr !== void 0) bv.tabRatio = tr;
|
|
4220
4295
|
result.bookView = bv;
|
|
4221
4296
|
}
|
|
4222
4297
|
}
|
|
@@ -5052,4 +5127,4 @@ function resolveWsTarget(wsPath, target) {
|
|
|
5052
5127
|
//#endregion
|
|
5053
5128
|
export { Styles as C, sharedStringsDesc as E, worksheetDesc as S, SharedStrings as T, commentsDesc as _, workbookDesc as a, calcChainDesc as b, tableDesc as c, pivotTableDesc as d, PivotFilterType as f, drawingDesc as g, externalLinkDesc as h, buildTablePartsXml as i, pivotCacheDefDesc as l, collectUniqueValues as m, XlsxWriteContext as n, TableType as o, aggregate as p, buildExternalReferencesXml as r, TotalsRowFunction as s, XlsxReadContext as t, pivotCacheRecordsDesc as u, vmlNotesDesc as v, stylesDesc as w, stringifyWorksheet as x, chartsheetDesc as y };
|
|
5054
5129
|
|
|
5055
|
-
//# sourceMappingURL=context-
|
|
5130
|
+
//# sourceMappingURL=context-ChKe3x0r.mjs.map
|