@office-open/xlsx 0.10.1 → 0.10.3
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-CIu-wLTT.mjs → comments-CQ5dlj-4.mjs} +54 -41
- package/dist/comments-CQ5dlj-4.mjs.map +1 -0
- package/dist/{context-Cru_79gz.mjs → context-CJzw_ObT.mjs} +200 -104
- package/dist/context-CJzw_ObT.mjs.map +1 -0
- package/dist/{file-ATgsKghI.d.mts → file-BanqmJOZ.d.mts} +78 -4
- package/dist/file-BanqmJOZ.d.mts.map +1 -0
- package/dist/{generate-CXy-A9Hp.mjs → generate-DMo2Vn6W.mjs} +11 -14
- package/dist/generate-DMo2Vn6W.mjs.map +1 -0
- package/dist/generate.d.mts +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.d.mts +176 -51
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -14
- package/dist/index.mjs.map +1 -1
- package/dist/parse.d.mts +1 -1
- package/dist/parse.d.mts.map +1 -1
- package/dist/parse.mjs +11 -18
- package/dist/parse.mjs.map +1 -1
- package/dist/patch.d.mts +1 -1
- package/dist/patch.d.mts.map +1 -1
- package/dist/patch.mjs +12 -28
- package/dist/patch.mjs.map +1 -1
- package/dist/{worksheet-DgjBJg_S.d.mts → worksheet-BANE0-5P.d.mts} +5 -5
- package/dist/worksheet-BANE0-5P.d.mts.map +1 -0
- package/package.json +3 -3
- package/dist/comments-CIu-wLTT.mjs.map +0 -1
- package/dist/context-Cru_79gz.mjs.map +0 -1
- package/dist/file-ATgsKghI.d.mts.map +0 -1
- package/dist/generate-CXy-A9Hp.mjs.map +0 -1
- package/dist/worksheet-DgjBJg_S.d.mts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as SharedStrings } from "./comments-
|
|
1
|
+
import { a as SharedStrings } from "./comments-CQ5dlj-4.mjs";
|
|
2
2
|
import { attr, attrNum, attrs, children, escapeXml, findChild, stringify, textOf } from "@office-open/xml";
|
|
3
|
-
import { ChartCollection, Relationships, derivePasswordHash } from "@office-open/core";
|
|
3
|
+
import { ChartCollection, Media, Relationships, derivePasswordHash } from "@office-open/core";
|
|
4
4
|
//#region src/parts/styles.ts
|
|
5
5
|
function fontKey(f) {
|
|
6
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}`;
|
|
@@ -396,14 +396,14 @@ const stylesDesc = {
|
|
|
396
396
|
const result = {};
|
|
397
397
|
const numFmtsEl = findChild(el, "numFmts");
|
|
398
398
|
if (numFmtsEl) {
|
|
399
|
-
const
|
|
399
|
+
const numFmtById = /* @__PURE__ */ new Map();
|
|
400
400
|
for (const nf of numFmtsEl.elements ?? []) {
|
|
401
401
|
if (nf.name !== "numFmt") continue;
|
|
402
402
|
const id = attrNum(nf, "numFmtId");
|
|
403
403
|
const code = attr(nf, "formatCode");
|
|
404
|
-
if (id !== void 0 && code)
|
|
404
|
+
if (id !== void 0 && code) numFmtById.set(id, code);
|
|
405
405
|
}
|
|
406
|
-
result.
|
|
406
|
+
result.customNumFmtById = numFmtById;
|
|
407
407
|
}
|
|
408
408
|
const fontsEl = findChild(el, "fonts");
|
|
409
409
|
if (fontsEl) {
|
|
@@ -833,7 +833,7 @@ const chartsheetDesc = {
|
|
|
833
833
|
if (sheetPr) {
|
|
834
834
|
if (sheetPr.attributes?.["published"] === "1") result.published = true;
|
|
835
835
|
const tabColor = findChild(sheetPr, "tabColor");
|
|
836
|
-
if (tabColor?.attributes?.["rgb"]) result.tabColor = tabColor.attributes["rgb"];
|
|
836
|
+
if (tabColor?.attributes?.["rgb"]) result.tabColor = String(tabColor.attributes["rgb"]);
|
|
837
837
|
}
|
|
838
838
|
const sheetViews = findChild(el, "sheetViews");
|
|
839
839
|
if (sheetViews) {
|
|
@@ -844,10 +844,24 @@ const chartsheetDesc = {
|
|
|
844
844
|
};
|
|
845
845
|
//#endregion
|
|
846
846
|
//#region src/parts/drawing.ts
|
|
847
|
+
/** How a drawing is anchored to the worksheet (xdr:*Anchor element). */
|
|
848
|
+
const ANCHOR_TYPES = {
|
|
849
|
+
twoCell: "twoCell",
|
|
850
|
+
oneCell: "oneCell",
|
|
851
|
+
absolute: "absolute"
|
|
852
|
+
};
|
|
853
|
+
/** editAs behavior for twoCellAnchor (ST_EditAs). */
|
|
854
|
+
const EDIT_AS_TYPES = {
|
|
855
|
+
twoCell: "twoCell",
|
|
856
|
+
oneCell: "oneCell",
|
|
857
|
+
absolute: "absolute"
|
|
858
|
+
};
|
|
847
859
|
const XDR_NS = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing";
|
|
848
860
|
const A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
849
861
|
const R_NS$1 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
850
862
|
const C_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
|
|
863
|
+
const DEFAULT_EXTENT_CX = 4e5;
|
|
864
|
+
const DEFAULT_EXTENT_CY = 3e5;
|
|
851
865
|
const drawingDesc = {
|
|
852
866
|
kind: "custom",
|
|
853
867
|
stringify(opts, _ctx) {
|
|
@@ -857,11 +871,11 @@ const drawingDesc = {
|
|
|
857
871
|
const p = [`<wsDr xmlns="${XDR_NS}" xmlns:a="${A_NS}" xmlns:r="${R_NS$1}">`];
|
|
858
872
|
let id = 1;
|
|
859
873
|
for (const img of images) {
|
|
860
|
-
p.push(
|
|
874
|
+
p.push(stringifyImage(img, id));
|
|
861
875
|
id++;
|
|
862
876
|
}
|
|
863
877
|
for (const chart of charts) {
|
|
864
|
-
p.push(
|
|
878
|
+
p.push(stringifyChart(chart, id));
|
|
865
879
|
id++;
|
|
866
880
|
}
|
|
867
881
|
p.push("</wsDr>");
|
|
@@ -872,47 +886,17 @@ const drawingDesc = {
|
|
|
872
886
|
const images = [];
|
|
873
887
|
const charts = [];
|
|
874
888
|
for (const anchor of el.elements ?? []) {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
findChild(anchor, "to");
|
|
878
|
-
if (!from) continue;
|
|
879
|
-
const col = readNumChild(from, "col") + 1;
|
|
880
|
-
const colOffset = readNumChild(from, "colOff") || void 0;
|
|
881
|
-
const row = readNumChild(from, "row") + 1;
|
|
882
|
-
const rowOffset = readNumChild(from, "rowOff") || void 0;
|
|
889
|
+
const name = anchor.name;
|
|
890
|
+
if (name !== "twoCellAnchor" && name !== "oneCellAnchor" && name !== "absoluteAnchor") continue;
|
|
883
891
|
const pic = findChild(anchor, "pic");
|
|
884
892
|
if (pic) {
|
|
885
|
-
|
|
886
|
-
if (rId) {
|
|
887
|
-
const clientData = findChild(anchor, "clientData");
|
|
888
|
-
images.push({
|
|
889
|
-
col,
|
|
890
|
-
colOffset,
|
|
891
|
-
row,
|
|
892
|
-
rowOffset,
|
|
893
|
-
rId,
|
|
894
|
-
locksWithSheet: clientData?.attributes?.["fLocksWithSheet"] !== "0",
|
|
895
|
-
printsWithSheet: clientData?.attributes?.["fPrintsWithSheet"] !== "0"
|
|
896
|
-
});
|
|
897
|
-
}
|
|
893
|
+
images.push(parseImageAnchor(anchor, pic, name));
|
|
898
894
|
continue;
|
|
899
895
|
}
|
|
900
896
|
const graphicFrame = findChild(anchor, "graphicFrame");
|
|
901
897
|
if (graphicFrame) {
|
|
902
|
-
const
|
|
903
|
-
|
|
904
|
-
if (rId) {
|
|
905
|
-
const clientData = findChild(anchor, "clientData");
|
|
906
|
-
charts.push({
|
|
907
|
-
col,
|
|
908
|
-
colOffset,
|
|
909
|
-
row,
|
|
910
|
-
rowOffset,
|
|
911
|
-
rId,
|
|
912
|
-
locksWithSheet: clientData?.attributes?.["fLocksWithSheet"] !== "0",
|
|
913
|
-
printsWithSheet: clientData?.attributes?.["fPrintsWithSheet"] !== "0"
|
|
914
|
-
});
|
|
915
|
-
}
|
|
898
|
+
const chart = parseChartAnchor(anchor, graphicFrame);
|
|
899
|
+
if (chart) charts.push(chart);
|
|
916
900
|
}
|
|
917
901
|
}
|
|
918
902
|
if (images.length > 0) result.images = images;
|
|
@@ -920,12 +904,137 @@ const drawingDesc = {
|
|
|
920
904
|
return result;
|
|
921
905
|
}
|
|
922
906
|
};
|
|
907
|
+
/** Marker cell (0-based col/row + EMU offsets). */
|
|
908
|
+
function markerXml(col, colOff, row, rowOff) {
|
|
909
|
+
return `<col>${col - 1}</col><colOff>${colOff}</colOff><row>${row - 1}</row><rowOff>${rowOff}</rowOff>`;
|
|
910
|
+
}
|
|
911
|
+
function clientDataXml(img) {
|
|
912
|
+
return `<clientData fLocksWithSheet="${img.locksWithSheet !== false ? 1 : 0}" fPrintsWithSheet="${img.printsWithSheet !== false ? 1 : 0}"/>`;
|
|
913
|
+
}
|
|
914
|
+
function picXml(rId, id, cx, cy) {
|
|
915
|
+
return `<pic><nvPicPr><cNvPr id="${id}" name="Picture ${id}"/><cNvPicPr preferRelativeResize="1"/></nvPicPr><blipFill><a:blip r:embed="${rId}"/><a:stretch><a:fillRect/></a:stretch></blipFill><spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></spPr></pic>`;
|
|
916
|
+
}
|
|
917
|
+
function stringifyImage(img, id) {
|
|
918
|
+
const anchorType = img.anchorType ?? ANCHOR_TYPES.twoCell;
|
|
919
|
+
const cx = img.extentCx ?? DEFAULT_EXTENT_CX;
|
|
920
|
+
const cy = img.extentCy ?? DEFAULT_EXTENT_CY;
|
|
921
|
+
const pic = picXml(img.rId, id, cx, cy);
|
|
922
|
+
const clientData = clientDataXml(img);
|
|
923
|
+
if (anchorType === ANCHOR_TYPES.absolute) return `<absoluteAnchor><pos x="${img.absoluteX ?? 0}" y="${img.absoluteY ?? 0}"/><ext cx="${cx}" cy="${cy}"/>${pic}${clientData}</absoluteAnchor>`;
|
|
924
|
+
const from = markerXml(img.col, img.colOffset ?? 0, img.row, img.rowOffset ?? 0);
|
|
925
|
+
if (anchorType === ANCHOR_TYPES.oneCell) return `<oneCellAnchor><from>${from}</from><ext cx="${cx}" cy="${cy}"/>${pic}${clientData}</oneCellAnchor>`;
|
|
926
|
+
return `<twoCellAnchor editAs="${img.editAs ?? EDIT_AS_TYPES.oneCell}"><from>${from}</from><to>${markerXml(img.toCol ?? img.col + 1, img.toColOffset ?? 0, img.toRow ?? img.row + 1, img.toRowOffset ?? 0)}</to>${pic}${clientData}</twoCellAnchor>`;
|
|
927
|
+
}
|
|
928
|
+
function stringifyChart(chart, id) {
|
|
929
|
+
const from = markerXml(chart.col, chart.colOffset ?? 0, chart.row, chart.rowOffset ?? 0);
|
|
930
|
+
const to = markerXml(chart.col + 9, 0, chart.row + 16, 0);
|
|
931
|
+
const clientData = clientDataXml(chart);
|
|
932
|
+
return `<twoCellAnchor editAs="oneCell"><from>${from}</from><to>${to}</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}</twoCellAnchor>`;
|
|
933
|
+
}
|
|
923
934
|
function readNumChild(el, tag) {
|
|
924
935
|
const child = findChild(el, tag);
|
|
925
936
|
if (!child?.elements?.length) return 0;
|
|
926
937
|
const n = Number(child.elements[0]?.text ?? "");
|
|
927
938
|
return Number.isNaN(n) ? 0 : n;
|
|
928
939
|
}
|
|
940
|
+
function readMarker(el) {
|
|
941
|
+
return {
|
|
942
|
+
col: readNumChild(el, "col") + 1,
|
|
943
|
+
colOffset: readNumChild(el, "colOff") || void 0,
|
|
944
|
+
row: readNumChild(el, "row") + 1,
|
|
945
|
+
rowOffset: readNumChild(el, "rowOff") || void 0
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
function readPicRId(pic) {
|
|
949
|
+
return findChild(findChild(pic, "blipFill") ?? pic, "a:blip")?.attributes?.["r:embed"];
|
|
950
|
+
}
|
|
951
|
+
/** Picture extent from pic/spPr/a:xfrm/a:ext (actual image size in EMU). */
|
|
952
|
+
function readPicExtent(pic) {
|
|
953
|
+
const spPr = findChild(pic, "spPr");
|
|
954
|
+
const xfrm = spPr ? findChild(spPr, "a:xfrm") : void 0;
|
|
955
|
+
const ext = xfrm ? findChild(xfrm, "a:ext") : void 0;
|
|
956
|
+
if (!ext?.attributes) return {};
|
|
957
|
+
const cx = Number(ext.attributes["cx"]);
|
|
958
|
+
const cy = Number(ext.attributes["cy"]);
|
|
959
|
+
return {
|
|
960
|
+
cx: Number.isNaN(cx) ? void 0 : cx,
|
|
961
|
+
cy: Number.isNaN(cy) ? void 0 : cy
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function parseImageAnchor(anchor, pic, name) {
|
|
965
|
+
const result = {
|
|
966
|
+
col: 1,
|
|
967
|
+
row: 1,
|
|
968
|
+
rId: readPicRId(pic) ?? ""
|
|
969
|
+
};
|
|
970
|
+
const ext = readPicExtent(pic);
|
|
971
|
+
if (ext.cx !== void 0) result.extentCx = ext.cx;
|
|
972
|
+
if (ext.cy !== void 0) result.extentCy = ext.cy;
|
|
973
|
+
const clientData = findChild(anchor, "clientData");
|
|
974
|
+
if (clientData?.attributes) {
|
|
975
|
+
if (clientData.attributes["fLocksWithSheet"] !== void 0) result.locksWithSheet = clientData.attributes["fLocksWithSheet"] !== "0";
|
|
976
|
+
if (clientData.attributes["fPrintsWithSheet"] !== void 0) result.printsWithSheet = clientData.attributes["fPrintsWithSheet"] !== "0";
|
|
977
|
+
}
|
|
978
|
+
if (name === "absoluteAnchor") {
|
|
979
|
+
result.anchorType = ANCHOR_TYPES.absolute;
|
|
980
|
+
const pos = findChild(anchor, "pos");
|
|
981
|
+
if (pos?.attributes) {
|
|
982
|
+
const x = Number(pos.attributes["x"]);
|
|
983
|
+
const y = Number(pos.attributes["y"]);
|
|
984
|
+
if (!Number.isNaN(x)) result.absoluteX = x;
|
|
985
|
+
if (!Number.isNaN(y)) result.absoluteY = y;
|
|
986
|
+
}
|
|
987
|
+
return result;
|
|
988
|
+
}
|
|
989
|
+
const from = findChild(anchor, "from");
|
|
990
|
+
if (from) {
|
|
991
|
+
const m = readMarker(from);
|
|
992
|
+
result.col = m.col;
|
|
993
|
+
result.row = m.row;
|
|
994
|
+
if (m.colOffset !== void 0) result.colOffset = m.colOffset;
|
|
995
|
+
if (m.rowOffset !== void 0) result.rowOffset = m.rowOffset;
|
|
996
|
+
}
|
|
997
|
+
if (name === "oneCellAnchor") {
|
|
998
|
+
result.anchorType = ANCHOR_TYPES.oneCell;
|
|
999
|
+
return result;
|
|
1000
|
+
}
|
|
1001
|
+
result.anchorType = ANCHOR_TYPES.twoCell;
|
|
1002
|
+
const to = findChild(anchor, "to");
|
|
1003
|
+
if (to) {
|
|
1004
|
+
const m = readMarker(to);
|
|
1005
|
+
result.toCol = m.col;
|
|
1006
|
+
result.toRow = m.row;
|
|
1007
|
+
if (m.colOffset !== void 0) result.toColOffset = m.colOffset;
|
|
1008
|
+
if (m.rowOffset !== void 0) result.toRowOffset = m.rowOffset;
|
|
1009
|
+
}
|
|
1010
|
+
const editAs = anchor.attributes?.["editAs"];
|
|
1011
|
+
if (editAs) result.editAs = editAs;
|
|
1012
|
+
return result;
|
|
1013
|
+
}
|
|
1014
|
+
function parseChartAnchor(anchor, graphicFrame) {
|
|
1015
|
+
const graphicData = findChild(findChild(graphicFrame, "a:graphic") ?? graphicFrame, "a:graphicData");
|
|
1016
|
+
const rId = (graphicData ? findChild(graphicData, "c:chart") : void 0)?.attributes?.["r:id"];
|
|
1017
|
+
if (!rId) return void 0;
|
|
1018
|
+
const result = {
|
|
1019
|
+
col: 1,
|
|
1020
|
+
row: 1,
|
|
1021
|
+
rId
|
|
1022
|
+
};
|
|
1023
|
+
const from = findChild(anchor, "from");
|
|
1024
|
+
if (from) {
|
|
1025
|
+
const m = readMarker(from);
|
|
1026
|
+
result.col = m.col;
|
|
1027
|
+
result.row = m.row;
|
|
1028
|
+
if (m.colOffset !== void 0) result.colOffset = m.colOffset;
|
|
1029
|
+
if (m.rowOffset !== void 0) result.rowOffset = m.rowOffset;
|
|
1030
|
+
}
|
|
1031
|
+
const clientData = findChild(anchor, "clientData");
|
|
1032
|
+
if (clientData?.attributes) {
|
|
1033
|
+
if (clientData.attributes["fLocksWithSheet"] !== void 0) result.locksWithSheet = clientData.attributes["fLocksWithSheet"] !== "0";
|
|
1034
|
+
if (clientData.attributes["fPrintsWithSheet"] !== void 0) result.printsWithSheet = clientData.attributes["fPrintsWithSheet"] !== "0";
|
|
1035
|
+
}
|
|
1036
|
+
return result;
|
|
1037
|
+
}
|
|
929
1038
|
//#endregion
|
|
930
1039
|
//#region src/parts/external-link.ts
|
|
931
1040
|
const externalLinkDesc = {
|
|
@@ -1002,7 +1111,7 @@ const externalLinkDesc = {
|
|
|
1002
1111
|
const bookEl = findChild(el, "externalBook");
|
|
1003
1112
|
if (bookEl) {
|
|
1004
1113
|
const book = {};
|
|
1005
|
-
if (bookEl.attributes?.["r:id"]) result.bookRId = bookEl.attributes["r:id"];
|
|
1114
|
+
if (bookEl.attributes?.["r:id"]) result.bookRId = String(bookEl.attributes["r:id"]);
|
|
1006
1115
|
const sheetNamesEl = findChild(bookEl, "sheetNames");
|
|
1007
1116
|
if (sheetNamesEl) {
|
|
1008
1117
|
const names = [];
|
|
@@ -1014,8 +1123,7 @@ const externalLinkDesc = {
|
|
|
1014
1123
|
const dns = [];
|
|
1015
1124
|
for (const child of definedNamesEl.elements ?? []) {
|
|
1016
1125
|
if (child.name !== "definedName") continue;
|
|
1017
|
-
const dn = {};
|
|
1018
|
-
if (child.attributes?.["name"]) dn.name = String(child.attributes["name"]);
|
|
1126
|
+
const dn = { name: String(child.attributes?.["name"] ?? "") };
|
|
1019
1127
|
if (child.attributes?.["refersTo"]) dn.refersTo = String(child.attributes["refersTo"]);
|
|
1020
1128
|
if (child.attributes?.["sheetId"] !== void 0) dn.sheetId = Number(child.attributes["sheetId"]);
|
|
1021
1129
|
if (child.attributes?.["publishToServer"]) dn.publishToServer = true;
|
|
@@ -1031,19 +1139,16 @@ const externalLinkDesc = {
|
|
|
1031
1139
|
const sds = [];
|
|
1032
1140
|
for (const sdChild of sheetDataSetEl.elements ?? []) {
|
|
1033
1141
|
if (sdChild.name !== "sheetData") continue;
|
|
1034
|
-
const sd = {};
|
|
1035
|
-
if (sdChild.attributes?.["sheetId"] !== void 0) sd.sheetId = Number(sdChild.attributes["sheetId"]);
|
|
1142
|
+
const sd = { sheetId: Number(sdChild.attributes?.["sheetId"] ?? 0) };
|
|
1036
1143
|
if (sdChild.attributes?.["refreshError"]) sd.refreshError = true;
|
|
1037
1144
|
const rows = [];
|
|
1038
1145
|
for (const rowChild of sdChild.elements ?? []) {
|
|
1039
1146
|
if (rowChild.name !== "row") continue;
|
|
1040
|
-
const row = {};
|
|
1041
|
-
if (rowChild.attributes?.["r"] !== void 0) row.rowNumber = Number(rowChild.attributes["r"]);
|
|
1147
|
+
const row = { rowNumber: Number(rowChild.attributes?.["r"] ?? 0) };
|
|
1042
1148
|
const cells = [];
|
|
1043
1149
|
for (const cellChild of rowChild.elements ?? []) {
|
|
1044
1150
|
if (cellChild.name !== "cell") continue;
|
|
1045
|
-
const cell = {};
|
|
1046
|
-
if (cellChild.attributes?.["r"]) cell.reference = String(cellChild.attributes["r"]);
|
|
1151
|
+
const cell = { reference: String(cellChild.attributes?.["r"] ?? "") };
|
|
1047
1152
|
if (cellChild.attributes?.["t"]) cell.type = String(cellChild.attributes["t"]);
|
|
1048
1153
|
const vEl = findChild(cellChild, "v");
|
|
1049
1154
|
if (vEl && vEl.elements?.[0]?.text !== void 0) cell.value = String(vEl.elements[0].text);
|
|
@@ -1062,14 +1167,13 @@ const externalLinkDesc = {
|
|
|
1062
1167
|
const oleEl = findChild(el, "oleLink");
|
|
1063
1168
|
if (oleEl) {
|
|
1064
1169
|
const ole = {};
|
|
1065
|
-
if (oleEl.attributes?.["r:id"]) result.oleRId = oleEl.attributes["r:id"];
|
|
1170
|
+
if (oleEl.attributes?.["r:id"]) result.oleRId = String(oleEl.attributes["r:id"]);
|
|
1066
1171
|
const oleItemsEl = findChild(oleEl, "oleItems");
|
|
1067
1172
|
if (oleItemsEl) {
|
|
1068
1173
|
const items = [];
|
|
1069
1174
|
for (const child of oleItemsEl.elements ?? []) {
|
|
1070
1175
|
if (child.name !== "oleItem") continue;
|
|
1071
|
-
const item = {};
|
|
1072
|
-
if (child.attributes?.["name"]) item.name = String(child.attributes["name"]);
|
|
1176
|
+
const item = { name: String(child.attributes?.["name"] ?? "") };
|
|
1073
1177
|
if (child.attributes?.["advise"]) item.advise = true;
|
|
1074
1178
|
if (child.attributes?.["prefer"]) item.prefer = true;
|
|
1075
1179
|
items.push(item);
|
|
@@ -1906,7 +2010,8 @@ function parsePivotArea(el) {
|
|
|
1906
2010
|
const result = {};
|
|
1907
2011
|
const field = attrNum(el, "field");
|
|
1908
2012
|
if (field !== void 0) result.field = field;
|
|
1909
|
-
|
|
2013
|
+
const typeVal = attr(el, "type");
|
|
2014
|
+
if (typeVal) result.type = typeVal;
|
|
1910
2015
|
if (attr(el, "dataOnly") === "0") result.dataOnly = false;
|
|
1911
2016
|
if (attr(el, "labelOnly") === "1") result.labelOnly = true;
|
|
1912
2017
|
if (attr(el, "grandRow") === "1") result.grandRow = true;
|
|
@@ -1915,7 +2020,8 @@ function parsePivotArea(el) {
|
|
|
1915
2020
|
if (attr(el, "outline") === "0") result.outline = false;
|
|
1916
2021
|
if (attr(el, "offset")) result.offset = attr(el, "offset");
|
|
1917
2022
|
if (attr(el, "collapsedLevelsAreSubtotals") === "1") result.collapsedLevelsAreSubtotals = true;
|
|
1918
|
-
|
|
2023
|
+
const axisVal = attr(el, "axis");
|
|
2024
|
+
if (axisVal) result.axis = axisVal;
|
|
1919
2025
|
const fp = attrNum(el, "fieldPosition");
|
|
1920
2026
|
if (fp !== void 0) result.fieldPosition = fp;
|
|
1921
2027
|
const refsEl = findChild(el, "references");
|
|
@@ -2015,18 +2121,23 @@ const pivotCacheRecordsDesc = {
|
|
|
2015
2121
|
if (rEl.name !== "r") continue;
|
|
2016
2122
|
const record = [];
|
|
2017
2123
|
for (const fEl of rEl.elements ?? []) {
|
|
2018
|
-
|
|
2019
|
-
if (fEl.name === "x") {
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
}
|
|
2023
|
-
|
|
2124
|
+
let entry;
|
|
2125
|
+
if (fEl.name === "x") entry = {
|
|
2126
|
+
type: "string",
|
|
2127
|
+
v: attrNum(fEl, "v") ?? 0
|
|
2128
|
+
};
|
|
2129
|
+
else if (fEl.name === "n") {
|
|
2024
2130
|
const v = attr(fEl, "v");
|
|
2025
|
-
entry
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
} else if (fEl.name === "
|
|
2131
|
+
entry = {
|
|
2132
|
+
type: "number",
|
|
2133
|
+
v: v !== void 0 ? Number(v) : 0
|
|
2134
|
+
};
|
|
2135
|
+
} else if (fEl.name === "d") entry = {
|
|
2136
|
+
type: "date",
|
|
2137
|
+
v: attr(fEl, "v") ?? ""
|
|
2138
|
+
};
|
|
2139
|
+
else if (fEl.name === "m") entry = { type: "missing" };
|
|
2140
|
+
else continue;
|
|
2030
2141
|
record.push(entry);
|
|
2031
2142
|
}
|
|
2032
2143
|
records.push(record);
|
|
@@ -2521,8 +2632,6 @@ const tableDesc = {
|
|
|
2521
2632
|
for (const colEl of colsEl.elements ?? []) {
|
|
2522
2633
|
if (colEl.name !== "tableColumn") continue;
|
|
2523
2634
|
const col = {};
|
|
2524
|
-
const colId = attrNum(colEl, "id");
|
|
2525
|
-
if (colId !== void 0) col.id = colId;
|
|
2526
2635
|
col.name = attr(colEl, "name") ?? "";
|
|
2527
2636
|
if (attr(colEl, "totalsRowFunction")) col.totalsRowFunction = attr(colEl, "totalsRowFunction");
|
|
2528
2637
|
if (attr(colEl, "totalsRowLabel")) col.totalsRowLabel = attr(colEl, "totalsRowLabel");
|
|
@@ -2745,8 +2854,10 @@ const workbookDesc = {
|
|
|
2745
2854
|
if (attr(webPublishingEl, "vml") === "1") wp.vml = true;
|
|
2746
2855
|
if (attr(webPublishingEl, "allowPng") === "1") wp.allowPng = true;
|
|
2747
2856
|
if (attr(webPublishingEl, "targetScreenSize")) wp.targetScreenSize = attr(webPublishingEl, "targetScreenSize");
|
|
2748
|
-
|
|
2749
|
-
if (
|
|
2857
|
+
const dpi = attrNum(webPublishingEl, "dpi");
|
|
2858
|
+
if (dpi !== void 0) wp.dpi = dpi;
|
|
2859
|
+
const codePage = attrNum(webPublishingEl, "codePage");
|
|
2860
|
+
if (codePage !== void 0) wp.codePage = codePage;
|
|
2750
2861
|
if (attr(webPublishingEl, "characterSet")) wp.characterSet = attr(webPublishingEl, "characterSet");
|
|
2751
2862
|
result.webPublishing = wp;
|
|
2752
2863
|
}
|
|
@@ -2794,9 +2905,7 @@ const workbookDesc = {
|
|
|
2794
2905
|
const objs = [];
|
|
2795
2906
|
for (const wo of wpoEl.elements ?? []) {
|
|
2796
2907
|
if (wo.name !== "webPublishObject") continue;
|
|
2797
|
-
const obj = {};
|
|
2798
|
-
const rId = wo.attributes?.["r:id"];
|
|
2799
|
-
if (rId) obj.rId = rId;
|
|
2908
|
+
const obj = { rId: wo.attributes?.["r:id"] ?? "" };
|
|
2800
2909
|
if (attr(wo, "destinationFile")) obj.destinationFile = attr(wo, "destinationFile");
|
|
2801
2910
|
if (attr(wo, "autoRepublish") === "1") obj.autoRepublish = true;
|
|
2802
2911
|
if (attr(wo, "title")) obj.title = attr(wo, "title");
|
|
@@ -2812,28 +2921,28 @@ const workbookDesc = {
|
|
|
2812
2921
|
for (const vt of vtEl.elements ?? []) {
|
|
2813
2922
|
if (vt.name !== "volType") continue;
|
|
2814
2923
|
const volType = {};
|
|
2815
|
-
|
|
2924
|
+
const typeVal = attr(vt, "type");
|
|
2925
|
+
if (typeVal) volType.type = typeVal;
|
|
2816
2926
|
const mains = [];
|
|
2817
2927
|
for (const m of vt.elements ?? []) {
|
|
2818
2928
|
if (m.name !== "main") continue;
|
|
2819
|
-
const main = {};
|
|
2820
|
-
if (attr(m, "first")) main.first = attr(m, "first");
|
|
2929
|
+
const main = { first: attr(m, "first") ?? "" };
|
|
2821
2930
|
const topics = [];
|
|
2822
2931
|
for (const tp of m.elements ?? []) {
|
|
2823
2932
|
if (tp.name !== "tp") continue;
|
|
2824
|
-
const topic = {};
|
|
2825
2933
|
const vEl = findChild(tp, "v");
|
|
2826
|
-
|
|
2827
|
-
|
|
2934
|
+
const topic = { value: String(vEl?.elements?.[0]?.text ?? "") };
|
|
2935
|
+
const tVal = attr(tp, "t");
|
|
2936
|
+
if (tVal) topic.valueType = tVal;
|
|
2828
2937
|
const stps = [];
|
|
2829
2938
|
const refs = [];
|
|
2830
2939
|
for (const inner of tp.elements ?? []) {
|
|
2831
2940
|
if (inner.name === "stp") stps.push(String(inner.elements?.[0]?.text ?? ""));
|
|
2832
2941
|
if (inner.name === "tr") {
|
|
2833
|
-
const ref = {
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2942
|
+
const ref = {
|
|
2943
|
+
reference: attr(inner, "r") ?? "",
|
|
2944
|
+
sheetIndex: attrNum(inner, "s") ?? 0
|
|
2945
|
+
};
|
|
2837
2946
|
refs.push(ref);
|
|
2838
2947
|
}
|
|
2839
2948
|
}
|
|
@@ -3829,17 +3938,6 @@ var ContentTypes = class {
|
|
|
3829
3938
|
}
|
|
3830
3939
|
};
|
|
3831
3940
|
//#endregion
|
|
3832
|
-
//#region src/parts/media.ts
|
|
3833
|
-
var Media = class {
|
|
3834
|
-
map = /* @__PURE__ */ new Map();
|
|
3835
|
-
addImage(key, data) {
|
|
3836
|
-
this.map.set(key, data);
|
|
3837
|
-
}
|
|
3838
|
-
get array() {
|
|
3839
|
-
return [...this.map.values()];
|
|
3840
|
-
}
|
|
3841
|
-
};
|
|
3842
|
-
//#endregion
|
|
3843
3941
|
//#region src/context.ts
|
|
3844
3942
|
/**
|
|
3845
3943
|
* XLSX compile context — write and read contexts for the descriptor pipeline.
|
|
@@ -3956,7 +4054,7 @@ var XlsxReadContext = class {
|
|
|
3956
4054
|
resolveStyle(styleIndex) {
|
|
3957
4055
|
const ps = this.parsedStyles;
|
|
3958
4056
|
if (!ps) return void 0;
|
|
3959
|
-
const { cellXfs, fonts, fills, borders,
|
|
4057
|
+
const { cellXfs, fonts, fills, borders, customNumFmtById } = ps;
|
|
3960
4058
|
if (!cellXfs || styleIndex >= cellXfs.length) return void 0;
|
|
3961
4059
|
const xf = cellXfs[styleIndex];
|
|
3962
4060
|
const result = {};
|
|
@@ -3967,11 +4065,9 @@ var XlsxReadContext = class {
|
|
|
3967
4065
|
const borderId = xf.borderId;
|
|
3968
4066
|
if (borderId !== void 0 && borders && borderId < borders.length) result.border = borders[borderId];
|
|
3969
4067
|
const numFmtId = xf.numFmtId;
|
|
3970
|
-
if (numFmtId !== void 0 &&
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
break;
|
|
3974
|
-
}
|
|
4068
|
+
if (numFmtId !== void 0 && customNumFmtById) {
|
|
4069
|
+
const code = customNumFmtById.get(numFmtId);
|
|
4070
|
+
if (code !== void 0) result.numFmt = code;
|
|
3975
4071
|
}
|
|
3976
4072
|
if (xf.alignment) result.alignment = xf.alignment;
|
|
3977
4073
|
if (xf.protection) result.protection = xf.protection;
|
|
@@ -3996,6 +4092,6 @@ function resolveWsTarget(wsPath, target) {
|
|
|
3996
4092
|
return dirParts.join("/");
|
|
3997
4093
|
}
|
|
3998
4094
|
//#endregion
|
|
3999
|
-
export {
|
|
4095
|
+
export { Styles as C, calcChainDesc as S, aggregate as _, usersDesc as a, drawingDesc as b, buildTablePartsXml as c, TotalsRowFunction as d, tableDesc as f, PivotFilterType as g, pivotTableDesc as h, revisionLogDesc as i, workbookDesc as l, pivotCacheRecordsDesc as m, XlsxWriteContext as n, Media as o, pivotCacheDefDesc as p, revisionHeadersDesc as r, buildExternalReferencesXml as s, XlsxReadContext as t, TableType as u, collectUniqueValues as v, stylesDesc as w, chartsheetDesc as x, externalLinkDesc as y };
|
|
4000
4096
|
|
|
4001
|
-
//# sourceMappingURL=context-
|
|
4097
|
+
//# sourceMappingURL=context-CJzw_ObT.mjs.map
|