@agile-team/mach-report 2.21.0 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -2
- package/dist/{ExcelBindingWizard-B2xXBOJu.cjs → ExcelBindingWizard-CW79I6Gl.cjs} +1 -1
- package/dist/{ExcelBindingWizard-CixTPQAL.js → ExcelBindingWizard-CZyppD7I.js} +3 -3
- package/dist/{ParamEditor-DhHlNxai.cjs → ParamEditor-CiYCJI0b.cjs} +1 -1
- package/dist/{ParamEditor-gKhvEsnr.js → ParamEditor-DQit-Gdf.js} +2 -2
- package/dist/{ReportBatchPanel-D-lyWKyf.js → ReportBatchPanel-DKTpV7MU.js} +2 -2
- package/dist/{ReportBatchPanel-BUdUfTdm.cjs → ReportBatchPanel-Db6TAfG5.cjs} +1 -1
- package/dist/ReportLabelStudio-B0i9ohQj.cjs +1 -0
- package/dist/ReportLabelStudio-BYnRqmje.js +780 -0
- package/dist/{ReportParamPanel-peB-KEmm.js → ReportParamPanel-BHSKVL8k.js} +231 -224
- package/dist/ReportParamPanel-lngONOEz.cjs +1 -0
- package/dist/ReportPreview-BDgKssYR.js +5887 -0
- package/dist/ReportPreview-Dw-4icG6.cjs +6 -0
- package/dist/{ReportTemplateLibrary-WZl-AK-2.js → ReportTemplateLibrary-BZuKn0YK.js} +1 -1
- package/dist/{ReportTemplateLibrary-Cs9WKneQ.cjs → ReportTemplateLibrary-DEXH07ND.cjs} +1 -1
- package/dist/{RuleEditor-DGpmjCko.js → RuleEditor-CIQn547x.js} +3 -3
- package/dist/{RuleEditor-Dtcq-7LO.cjs → RuleEditor-zSUmPjKa.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-CkCh506f.cjs → TemplateOutlinePanel-B5SfGYVN.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-cxp95OT9.js → TemplateOutlinePanel-D0PgOSQE.js} +2 -2
- package/dist/{TemplateReusePanel-BZ8VTtrO.js → TemplateReusePanel-BKlAEF8-.js} +2 -2
- package/dist/{TemplateReusePanel-CwttuSta.cjs → TemplateReusePanel-DAy_Hwqz.cjs} +1 -1
- package/dist/TemplateReviewPanel-CowmHaQQ.cjs +1 -0
- package/dist/{TemplateReviewPanel-C9cTvsRs.js → TemplateReviewPanel-div-EH_m.js} +2 -2
- package/dist/artifact-integrity.json +76 -76
- package/dist/{auto-Tq7ReIC1.cjs → auto-DcUHlKob.cjs} +1 -1
- package/dist/{auto-BkdGiNtr.js → auto-moShblh1.js} +4 -4
- package/dist/{designer-CIDHt5xz.js → designer-B7jJeAeG.js} +1500 -1455
- package/dist/{designer-CDqok4S5.cjs → designer-BWQVpJeN.cjs} +2 -2
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +149 -2
- package/dist/designer.d.ts +149 -2
- package/dist/designer.js +13 -12
- package/dist/{encoding-BSeUwrN7.js → encoding-DbnhbwI8.js} +2 -2
- package/dist/{encoding-B79hW4zq.cjs → encoding-ncQAvyOv.cjs} +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +38 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +299 -279
- package/dist/{json-snapshot-Kgn459Oj.js → json-snapshot-DvQbZlD7.js} +2 -2
- package/dist/{json-snapshot-I5VI84Vp.cjs → json-snapshot-nyV63AbB.cjs} +1 -1
- package/dist/{plugin-BaRUGORD.cjs → plugin-AcAQ2m9X.cjs} +1 -1
- package/dist/{plugin-D4kAxfLG.js → plugin-w5Nyt08U.js} +1 -1
- package/dist/{prefill-CJSazcVY.js → prefill-BXBxx5We.js} +1 -1
- package/dist/{prefill-Bpyn58AZ.cjs → prefill-DUvejVt1.cjs} +1 -1
- package/dist/prepared-YXy-fVLw.cjs +1 -0
- package/dist/{prepared-BwjwEzFz.js → prepared-rXCKqdHY.js} +35 -34
- package/dist/{protocol-C8VWF9An.cjs → protocol-C9ZaylID.cjs} +1 -1
- package/dist/{protocol-Bs9-ohHN.js → protocol-fjaeKkjf.js} +3 -3
- package/dist/{region-binding-workflow-JNowHd0A.cjs → region-binding-workflow-BiJQ7NU6.cjs} +1 -1
- package/dist/{region-binding-workflow-Cy4GIOUo.js → region-binding-workflow-aA8nxmkZ.js} +1 -1
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/{runtime-BDf5x1i1.js → runtime-BTtpjF3D.js} +4 -4
- package/dist/{runtime-DsJt1PIf.cjs → runtime-Dq0LUsyS.cjs} +1 -1
- package/dist/sbom.cdx.json +1 -1
- package/dist/server/node.d.cts +9 -0
- package/dist/server/node.d.ts +9 -0
- package/dist/server-node.cjs +5 -4
- package/dist/server-node.js +1838 -1760
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +81 -0
- package/dist/server.d.ts +81 -0
- package/dist/server.js +6 -6
- package/dist/style.css +1 -1
- package/dist/template-catalog-CLAM4w7H.cjs +1 -0
- package/dist/{template-catalog-DFwIS9aN.js → template-catalog-JSxSqk5y.js} +3 -3
- package/dist/template-fragments-Ca25Jt7e.cjs +1 -0
- package/dist/{template-fragments-Dng-AlHk.js → template-fragments-D2JFj7Du.js} +18 -18
- package/dist/{template-outline-DiADphlq.js → template-outline-CDWXptuj.js} +1 -1
- package/dist/template-outline-K4jGhATu.cjs +1 -0
- package/dist/template-registry-CWnuGqyP.cjs +1 -0
- package/dist/{template-registry-DhBqoD7W.js → template-registry-Do1Uav2Z.js} +333 -261
- package/dist/template-serialization-CU4n_Miu.js +307 -0
- package/dist/template-serialization-CgqBo6s-.cjs +1 -0
- package/dist/vue/async.d.cts +97 -2
- package/dist/vue/async.d.ts +97 -2
- package/dist/vue/index.d.cts +197 -4
- package/dist/vue/index.d.ts +197 -4
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +75 -70
- package/dist/{workbook-session-NYv01LHe.cjs → workbook-session-BvEBRRMz.cjs} +1 -1
- package/dist/{workbook-session-oinxX3qo.js → workbook-session-f0wVlzst.js} +1 -1
- package/dist/workbook-sheets-CaPAulQ6.cjs +2 -0
- package/dist/workbook-sheets-D4M7XXBh.js +44 -0
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +9 -0
- package/dist/worker.d.ts +9 -0
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.d.cts +39 -2
- package/dist/xlsx.d.ts +39 -2
- package/dist/xlsx.js +290 -270
- package/package.json +1 -1
- package/dist/ReportLabelStudio-BcjQt73a.cjs +0 -1
- package/dist/ReportLabelStudio-N2w6DdaZ.js +0 -764
- package/dist/ReportParamPanel-CVpK8mFc.cjs +0 -1
- package/dist/ReportPreview-BBJNlu2U.js +0 -5740
- package/dist/ReportPreview-nf4Dk1Jc.cjs +0 -6
- package/dist/TemplateReviewPanel-C2YjiaEC.cjs +0 -1
- package/dist/prepared-BiSz_9vN.cjs +0 -1
- package/dist/template-bindings-Cg5oBLFT.cjs +0 -1
- package/dist/template-bindings-TKnXM7ll.js +0 -62
- package/dist/template-catalog-D_2jdnkL.cjs +0 -1
- package/dist/template-fragments-DZVUBhuB.cjs +0 -1
- package/dist/template-outline-DWkzZXVC.cjs +0 -1
- package/dist/template-registry-DpLUSLwF.cjs +0 -1
- package/dist/template-serialization-Cc3h-miv.js +0 -247
- package/dist/template-serialization-D1R5oAqh.cjs +0 -1
package/dist/xlsx.js
CHANGED
|
@@ -1,110 +1,111 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { e as
|
|
3
|
-
import { d as
|
|
4
|
-
import { g as
|
|
5
|
-
import { e as
|
|
6
|
-
import { a as
|
|
7
|
-
import { i as
|
|
8
|
-
import { c as
|
|
9
|
-
import { a as
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { c as S, b as M, o as j } from "./progress-Hc2vxoCs.js";
|
|
2
|
+
import { e as G } from "./index-CPh6tqge.js";
|
|
3
|
+
import { d as H } from "./data-bar-8baGYEZ9.js";
|
|
4
|
+
import { g as p, a as A, r as W } from "./grid-geometry-D3SJgWFv.js";
|
|
5
|
+
import { e as _, E as U, m as T, i as X } from "./workbook-session-f0wVlzst.js";
|
|
6
|
+
import { a as Ve, b as qe, o as Qe } from "./workbook-session-f0wVlzst.js";
|
|
7
|
+
import { i as v } from "./component-tree-1_QCiQJX.js";
|
|
8
|
+
import { c as K } from "./media-Y90dHK9z.js";
|
|
9
|
+
import { a as J, r as V } from "./assets-CxHunY_9.js";
|
|
10
|
+
import { s as q, a as Q } from "./workbook-sheets-D4M7XXBh.js";
|
|
11
|
+
import { b as Ze, c as et, a as tt, d as nt, e as rt, f as it, g as ot, h as at, p as st, i as lt, v as ct, j as ht, k as dt, l as ft, m as gt, n as ut } from "./region-binding-workflow-aA8nxmkZ.js";
|
|
12
|
+
function Y(e) {
|
|
13
|
+
const t = G({ width: 1, height: 1, channels: 4, depth: 8, data: new Uint8Array([1, 3, 5].map((o) => parseInt(e.slice(o, o + 2), 16)).concat(89)) });
|
|
13
14
|
return `data:image/png;base64,${btoa(String.fromCharCode(...t))}`;
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
16
|
+
function Z(e, t, o) {
|
|
17
|
+
const r = /* @__PURE__ */ new Map();
|
|
17
18
|
let i = 0;
|
|
18
|
-
return (a,
|
|
19
|
-
const c =
|
|
19
|
+
return (a, n, s, l) => {
|
|
20
|
+
const c = H(n.cell.dataBar, n.widthMm, n.heightMm, l);
|
|
20
21
|
if (!c) return;
|
|
21
22
|
if (++i > t) throw new Error(`Excel 数据条超过 ${t} 个绘图预算,请缩小范围或调整 maxDataBars`);
|
|
22
|
-
let h =
|
|
23
|
-
h || (h =
|
|
23
|
+
let h = r.get(c.color);
|
|
24
|
+
h || (h = Y(c.color), r.set(c.color, h)), i === 1 && o.push("数据条为静态半透明视觉快照,保留原始单元格值;Excel 编辑不会重算条形,绘图叠加文字的混色与预览可能略有差异。"), e.write(a, { kind: "image", leftMm: 0, topMm: 0, widthMm: c.width, heightMm: c.height, imageData: h }, s, { leftMm: n.xMm + c.x, offsetMm: c.y });
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
async function
|
|
27
|
-
const
|
|
27
|
+
async function ee(e, t, o) {
|
|
28
|
+
const r = e.pages.flatMap((n) => n.components), i = S(o);
|
|
28
29
|
let a = 0;
|
|
29
|
-
for (;
|
|
30
|
-
const
|
|
31
|
-
for (const s of
|
|
30
|
+
for (; r.length; ) {
|
|
31
|
+
const n = r.pop();
|
|
32
|
+
for (const s of n.grid?.cells ?? []) for (const l of s) {
|
|
32
33
|
if (l?.dataBar && l.dataBar.end > l.dataBar.start && ++a > t) throw new Error(`Excel 数据条超过 ${t} 个绘图预算,请缩小范围或调整 maxDataBars`);
|
|
33
|
-
l?.children &&
|
|
34
|
+
l?.children && r.push(...l.children);
|
|
34
35
|
const c = i();
|
|
35
36
|
c && await c;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
function P(e, t) {
|
|
40
|
-
return { richText: e.flatMap((o,
|
|
41
|
-
...
|
|
41
|
+
return { richText: e.flatMap((o, r) => [
|
|
42
|
+
...r ? [{ text: `
|
|
42
43
|
` }] : [],
|
|
43
44
|
...o.segments.map((i) => {
|
|
44
|
-
const a =
|
|
45
|
-
return { text: i.kind === "field" ? i.field ?? "" : i.text ?? "", font: { name: a.fontFamily, bold: a.bold, italic: a.italic, underline: a.underline, size:
|
|
45
|
+
const a = p(t, i.style), n = a.color?.replace(/^#/, "");
|
|
46
|
+
return { text: i.kind === "field" ? i.field ?? "" : i.text ?? "", font: { name: a.fontFamily, bold: a.bold, italic: a.italic, underline: a.underline, size: A(a).fontSizePt, .../^[a-f\d]{6}$/i.test(n ?? "") ? { color: { argb: `FF${n.toUpperCase()}` } } : {} } };
|
|
46
47
|
})
|
|
47
48
|
]) };
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
+
function te(e, t) {
|
|
50
51
|
const o = e.children?.filter((a) => a.kind === "text" && !a.grid) ?? [];
|
|
51
52
|
if (!e.richParagraphs?.length && !o.length) return;
|
|
52
|
-
const
|
|
53
|
+
const r = p(t, e.style), i = e.richParagraphs?.length ? [...e.richParagraphs] : e.text ? [{ segments: [{ text: e.text }] }] : [];
|
|
53
54
|
for (const a of o) {
|
|
54
|
-
const
|
|
55
|
+
const n = p(r, a.style), s = a.richParagraphs?.length ? a.richParagraphs : [{ segments: [{ text: a.lines?.join(`
|
|
55
56
|
`) ?? a.text ?? "" }] }];
|
|
56
|
-
for (const l of s) i.push({ ...l, segments: l.segments.map((c) => ({ ...c, style:
|
|
57
|
+
for (const l of s) i.push({ ...l, segments: l.segments.map((c) => ({ ...c, style: p(n, c.style) })) });
|
|
57
58
|
}
|
|
58
|
-
return P(i,
|
|
59
|
+
return P(i, r);
|
|
59
60
|
}
|
|
60
|
-
function
|
|
61
|
-
let
|
|
62
|
-
if (!Number.isFinite(
|
|
63
|
-
for (;
|
|
61
|
+
function ne(e, t, o) {
|
|
62
|
+
let r = o * 72 / 25.4;
|
|
63
|
+
if (!Number.isFinite(r) || t + Math.ceil(r / 409) - 1 > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
|
|
64
|
+
for (; r > 0; ) {
|
|
64
65
|
if (t > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
|
|
65
|
-
const i = Math.min(409,
|
|
66
|
-
e.getRow(t++).height = i,
|
|
66
|
+
const i = Math.min(409, r);
|
|
67
|
+
e.getRow(t++).height = i, r -= i;
|
|
67
68
|
}
|
|
68
69
|
return t;
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
-
let
|
|
72
|
-
if (!Number.isSafeInteger(
|
|
71
|
+
function re(e, t, o) {
|
|
72
|
+
let r = Math.round(t * 36e3), i = 0;
|
|
73
|
+
if (!Number.isSafeInteger(r)) throw new Error("Excel 图片锚点超出安全坐标范围");
|
|
73
74
|
for (e.properties.defaultColWidth ??= 8.43; i < 16384; ) {
|
|
74
|
-
const a = e.getColumn(i + 1).width ?? e.properties.defaultColWidth,
|
|
75
|
-
if (!Number.isSafeInteger(
|
|
76
|
-
if (
|
|
77
|
-
|
|
75
|
+
const a = e.getColumn(i + 1).width ?? e.properties.defaultColWidth, n = Math.round(_(a) * 36e3);
|
|
76
|
+
if (!Number.isSafeInteger(n) || n <= 0) throw new Error("Excel 图片锚点所在列宽无效");
|
|
77
|
+
if (r < n) return { col: i + r / n, row: o - 1, nativeCol: i, nativeColOff: r, nativeRow: o - 1, nativeRowOff: 0 };
|
|
78
|
+
r -= n, i++;
|
|
78
79
|
}
|
|
79
80
|
throw new Error("Excel 图片锚点超过16384列上限");
|
|
80
81
|
}
|
|
81
|
-
function
|
|
82
|
-
let
|
|
83
|
-
if (!Number.isFinite(
|
|
82
|
+
function ie(e, t, o) {
|
|
83
|
+
let r = o * 72 / 25.4;
|
|
84
|
+
if (!Number.isFinite(r) || Math.abs(r) > 1048576 * 409) throw new Error("Excel 图片纵向偏移超过工作表范围");
|
|
84
85
|
const i = (a) => {
|
|
85
|
-
const
|
|
86
|
-
if (!Number.isFinite(
|
|
87
|
-
return
|
|
86
|
+
const n = e.getRow(a).height ?? e.properties.defaultRowHeight ?? 15;
|
|
87
|
+
if (!Number.isFinite(n) || n <= 0) throw new Error("Excel 图片锚点所在行高无效");
|
|
88
|
+
return n;
|
|
88
89
|
};
|
|
89
|
-
for (;
|
|
90
|
-
for (; t <= 1048576 &&
|
|
91
|
-
if (t > 1048576 ||
|
|
92
|
-
return { nativeRow: t - 1, nativeRowOff: Math.round(
|
|
93
|
-
}
|
|
94
|
-
function
|
|
95
|
-
const
|
|
96
|
-
return { write(a,
|
|
97
|
-
if (![
|
|
98
|
-
if (!
|
|
99
|
-
if (!
|
|
100
|
-
return o.push(`${
|
|
101
|
-
const c = n
|
|
90
|
+
for (; r < 0 && t > 1; ) r += i(--t);
|
|
91
|
+
for (; t <= 1048576 && r >= i(t); ) r -= i(t++);
|
|
92
|
+
if (t > 1048576 || r < 0) throw new Error("Excel 图片移动到工作表边界之外");
|
|
93
|
+
return { nativeRow: t - 1, nativeRowOff: Math.round(r * 25.4 / 72 * 36e3) };
|
|
94
|
+
}
|
|
95
|
+
function oe(e, t, o) {
|
|
96
|
+
const r = K(t), i = /* @__PURE__ */ new Map();
|
|
97
|
+
return { write(a, n, s, l) {
|
|
98
|
+
if (![n.widthMm, n.heightMm, n.leftMm].every(Number.isFinite) || n.widthMm < 0 || n.heightMm < 0 || n.leftMm < 0) throw new Error("Excel 图片尺寸无效");
|
|
99
|
+
if (!n.widthMm || !n.heightMm) return s;
|
|
100
|
+
if (!n.imageData || !/^data:image\/(png|jpe?g);base64,/i.test(n.imageData))
|
|
101
|
+
return o.push(`${n.nid ?? n.kind}: Excel 图片仅支持 PNG/JPEG data URI,已跳过`), s;
|
|
102
|
+
const c = r(n.imageData);
|
|
102
103
|
let h = i.get(c.dataUrl);
|
|
103
104
|
h === void 0 && (h = e.addImage({ base64: c.dataUrl, extension: c.extension }), i.set(c.dataUrl, h));
|
|
104
|
-
const d = l ? s :
|
|
105
|
+
const d = l ? s : ne(a, s, n.heightMm);
|
|
105
106
|
return a.addImage(h, {
|
|
106
|
-
tl: { ...
|
|
107
|
-
ext: { width:
|
|
107
|
+
tl: { ...re(a, l?.leftMm ?? n.leftMm, s), ...l ? ie(a, s, l.offsetMm) : {} },
|
|
108
|
+
ext: { width: n.widthMm * 96 / 25.4, height: n.heightMm * 96 / 25.4 },
|
|
108
109
|
editAs: "oneCell"
|
|
109
110
|
}), d;
|
|
110
111
|
} };
|
|
@@ -112,31 +113,31 @@ function ne(e, t, o) {
|
|
|
112
113
|
function R(e) {
|
|
113
114
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
114
115
|
}
|
|
115
|
-
function
|
|
116
|
+
function F(e, t) {
|
|
116
117
|
const o = e.meta?.xlsxFlow;
|
|
117
118
|
if (o === void 0) return;
|
|
118
119
|
if (!R(o) || o.version !== "1.0" || !Number.isSafeInteger(o.columnStart) || Number(o.columnStart) < 0) throw new Error("Excel 多区域几何标记无效,不能按列序猜测输出");
|
|
119
120
|
if (!e.grid) throw new Error("Excel 多区域输出只接受显式网格组件");
|
|
120
|
-
const
|
|
121
|
-
if (!i?.length ||
|
|
122
|
-
return
|
|
121
|
+
const r = o, i = e.grid.colWidthsMm;
|
|
122
|
+
if (!i?.length || r.columnStart + i.length > t.length || i.some((a, n) => Math.abs(a - t[r.columnStart + n]) > 1e-3)) throw new Error("Excel 多区域列位置与网格列宽不一致");
|
|
123
|
+
return r;
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
+
function I(e) {
|
|
125
126
|
const t = e.meta?.xlsxFlow;
|
|
126
127
|
if (t === void 0) {
|
|
127
|
-
if (e.components.some((
|
|
128
|
+
if (e.components.some((r) => r.meta?.xlsxFlow !== void 0)) throw new Error("Excel 多区域页面缺少完整列几何标记");
|
|
128
129
|
return;
|
|
129
130
|
}
|
|
130
|
-
const o =
|
|
131
|
-
for (const
|
|
132
|
-
const i =
|
|
131
|
+
const o = ae(t, e.meta?.reportScope);
|
|
132
|
+
for (const r of e.components) {
|
|
133
|
+
const i = F(r, o.widths);
|
|
133
134
|
if (!i) throw new Error("Excel 多区域页面混入没有区域几何的组件,请使用独立页面模板");
|
|
134
|
-
const a = o.widths.slice(0, i.columnStart).reduce((s, l) => s + l, e.marginLeftMm ?? 0),
|
|
135
|
-
if (Math.abs(a -
|
|
135
|
+
const a = o.widths.slice(0, i.columnStart).reduce((s, l) => s + l, e.marginLeftMm ?? 0), n = r.grid.colWidthsMm.reduce((s, l) => s + l, 0);
|
|
136
|
+
if (Math.abs(a - r.leftMm) > 0.01 || Math.abs(n - r.widthMm) > 0.01) throw new Error("Excel 多区域标记与真实横向位置不一致");
|
|
136
137
|
}
|
|
137
138
|
return o;
|
|
138
139
|
}
|
|
139
|
-
function
|
|
140
|
+
function ae(e, t) {
|
|
140
141
|
if (!R(e) || e.version !== "1.0" || typeof e.sheet != "string" || !e.sheet.trim() || typeof e.templateId != "string" || !e.templateId.trim()) throw new Error("Excel 多区域工作表标识无效");
|
|
141
142
|
if (!Array.isArray(e.fullWidthsMm) || !e.fullWidthsMm.length || e.fullWidthsMm.length > 16384 || e.fullWidthsMm.some((o) => typeof o != "number" || !Number.isFinite(o) || o <= 0 || o > 2e3)) throw new Error("Excel 多区域完整列宽无效");
|
|
142
143
|
if (t !== void 0 && (typeof t != "string" || !t.trim())) throw new Error("Excel 多区域报表命名空间无效");
|
|
@@ -145,76 +146,76 @@ function re(e, t) {
|
|
|
145
146
|
function y(e) {
|
|
146
147
|
return Math.round(e * 1e6) / 1e6;
|
|
147
148
|
}
|
|
148
|
-
function
|
|
149
|
-
return e.components.filter((a) =>
|
|
149
|
+
function se(e, t, o, r, i) {
|
|
150
|
+
return e.components.filter((a) => r ? a.pageAnchor === "header" ? t === 0 : a.pageAnchor === "footer" ? t === o - 1 : a.table?.role !== "header" ? !0 : i.has(a.table.id) ? !1 : (i.add(a.table.id), !0) : !0);
|
|
150
151
|
}
|
|
151
|
-
function
|
|
152
|
-
const i = e.components.filter((
|
|
153
|
-
return t.map((
|
|
154
|
-
let s =
|
|
155
|
-
return o &&
|
|
152
|
+
function le(e, t, o, r) {
|
|
153
|
+
const i = e.components.filter((n) => !t.includes(n) && n.table?.role === "header"), a = t.filter((n) => !n.pageAnchor).reduce((n, s) => Math.max(n, s.topMm + s.heightMm), e.marginTopMm ?? 0);
|
|
154
|
+
return t.map((n) => {
|
|
155
|
+
let s = n.topMm;
|
|
156
|
+
return o && n.pageAnchor === "footer" && (s = a), s -= i.filter((l) => l.topMm + l.heightMm <= s + 1e-3).reduce((l, c) => l + c.heightMm, 0), { component: n, layout: W(n.grid, n.widthMm, n.heightMm), top: s, column: F(n, r).columnStart };
|
|
156
157
|
});
|
|
157
158
|
}
|
|
158
|
-
function
|
|
159
|
-
const
|
|
160
|
-
if (
|
|
161
|
-
const i = new Map(t.map((s, l) => [s, l])), a = /* @__PURE__ */ new Map(),
|
|
159
|
+
function ce(e, t, o) {
|
|
160
|
+
const r = t.length - 1;
|
|
161
|
+
if (r * o.length > 1e6) throw new Error("Excel 多区域单页超过 100 万几何单元格,请减小预览分页高度或列数");
|
|
162
|
+
const i = new Map(t.map((s, l) => [s, l])), a = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
162
163
|
for (const s of e) for (const l of s.layout.cells) {
|
|
163
164
|
if (!Object.keys(l.cell).length) continue;
|
|
164
165
|
const c = i.get(y(s.top + l.yMm)), h = i.get(y(s.top + l.yMm + l.heightMm)), d = s.column + l.ci, u = d + (l.cell.colSpan ?? 1), f = `${c}:${d}`;
|
|
165
|
-
for (let g = c; g < h; g++) for (let
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
|
|
166
|
+
for (let g = c; g < h; g++) for (let w = d; w < u; w++) {
|
|
167
|
+
const m = `${g}:${w}`;
|
|
168
|
+
if (n.has(m)) throw new Error("Excel 多区域实际单元格互相覆盖,已终止输出,未覆盖已有内容");
|
|
169
|
+
n.set(m, f);
|
|
169
170
|
}
|
|
170
|
-
a.set(f, { ...l.cell, style:
|
|
171
|
+
a.set(f, { ...l.cell, style: p(s.component.style, l.cell.style), rowSpan: h - c, colSpan: u - d });
|
|
171
172
|
}
|
|
172
|
-
return Array.from({ length:
|
|
173
|
+
return Array.from({ length: r }, (s, l) => {
|
|
173
174
|
const c = [];
|
|
174
175
|
for (let h = 0; h < o.length; h++) {
|
|
175
176
|
const d = `${l}:${h}`, u = a.get(d);
|
|
176
|
-
u ? (c.push(u), h += (u.colSpan ?? 1) - 1) :
|
|
177
|
+
u ? (c.push(u), h += (u.colSpan ?? 1) - 1) : n.has(d) || c.push(null);
|
|
177
178
|
}
|
|
178
179
|
return c;
|
|
179
180
|
});
|
|
180
181
|
}
|
|
181
|
-
function
|
|
182
|
-
const o = /* @__PURE__ */ new Set(),
|
|
182
|
+
function he(e, t) {
|
|
183
|
+
const o = /* @__PURE__ */ new Set(), r = [];
|
|
183
184
|
let i;
|
|
184
|
-
for (const [a, { page:
|
|
185
|
-
const s =
|
|
185
|
+
for (const [a, { page: n }] of e.entries()) {
|
|
186
|
+
const s = I(n);
|
|
186
187
|
if (i && (s.key !== i.key || s.widths.length !== i.widths.length || s.widths.some((f, g) => Math.abs(f - i.widths[g]) > 1e-3))) throw new Error("Excel 多区域分页的工作表或列结构不一致");
|
|
187
188
|
i ??= s;
|
|
188
|
-
const l =
|
|
189
|
+
const l = se(n, a, e.length, t, o), c = le(n, l, t, s.widths);
|
|
189
190
|
if (!c.length) continue;
|
|
190
|
-
const h = [...new Set(c.flatMap((f) => [...f.layout.rows.map((g) => y(f.top + g.pos)), y(f.top + f.component.heightMm)]))].sort((f, g) => f - g), d =
|
|
191
|
-
|
|
191
|
+
const h = [...new Set(c.flatMap((f) => [...f.layout.rows.map((g) => y(f.top + g.pos)), y(f.top + f.component.heightMm)]))].sort((f, g) => f - g), d = ce(c, h, s.widths), u = h.slice(1).map((f, g) => f - h[g]);
|
|
192
|
+
r.push({ kind: "rect", leftMm: 0, topMm: 0, widthMm: s.widths.reduce((f, g) => f + g, 0), heightMm: u.reduce((f, g) => f + g, 0), grid: { cells: d, colWidthsMm: s.widths, rowHeightsMm: u } });
|
|
192
193
|
}
|
|
193
|
-
return
|
|
194
|
+
return r;
|
|
194
195
|
}
|
|
195
|
-
const
|
|
196
|
-
function
|
|
196
|
+
const z = 72 / 25.4, de = 32767, fe = 253;
|
|
197
|
+
function x(e, t) {
|
|
197
198
|
if (typeof e != "string") return;
|
|
198
|
-
if (e.length >
|
|
199
|
+
if (e.length > de)
|
|
199
200
|
throw new Error(`Excel 单元格 ${t} 最多支持 32767 个字符,无法无损导出;内容未裁剪`);
|
|
200
201
|
let o = 0;
|
|
201
|
-
for (let
|
|
202
|
-
if (e.charCodeAt(
|
|
202
|
+
for (let r = 0; r < e.length; r++)
|
|
203
|
+
if (e.charCodeAt(r) === 10 && ++o > fe)
|
|
203
204
|
throw new Error(`Excel 单元格 ${t} 最多支持 253 个换行,无法无损导出;内容未改写`);
|
|
204
205
|
}
|
|
205
|
-
function
|
|
206
|
+
function E(e) {
|
|
206
207
|
if (!e) return;
|
|
207
208
|
const t = e.replace("#", "");
|
|
208
209
|
return /^[0-9a-fA-F]{6}$/.test(t) ? `FF${t.toUpperCase()}` : void 0;
|
|
209
210
|
}
|
|
210
|
-
function
|
|
211
|
+
function D(e, t = {}) {
|
|
211
212
|
e.font = {
|
|
212
213
|
name: t.fontFamily,
|
|
213
214
|
bold: t.bold === !0,
|
|
214
215
|
italic: t.italic === !0,
|
|
215
216
|
underline: t.underline === !0,
|
|
216
|
-
size:
|
|
217
|
-
color:
|
|
217
|
+
size: A(t).fontSizePt,
|
|
218
|
+
color: E(t.color) ? { argb: E(t.color) } : void 0
|
|
218
219
|
};
|
|
219
220
|
}
|
|
220
221
|
const b = {
|
|
@@ -222,134 +223,134 @@ const b = {
|
|
|
222
223
|
a4: { width: 210, height: 297, code: 9 },
|
|
223
224
|
a5: { width: 148, height: 210, code: 11 }
|
|
224
225
|
};
|
|
225
|
-
function
|
|
226
|
+
function ge(e, t, o, r) {
|
|
226
227
|
if (t && t !== "auto") return b[t].code;
|
|
227
|
-
const i = Math.min(e.pageWidthMm, e.pageHeightMm), a = Math.max(e.pageWidthMm, e.pageHeightMm),
|
|
228
|
-
return
|
|
228
|
+
const i = Math.min(e.pageWidthMm, e.pageHeightMm), a = Math.max(e.pageWidthMm, e.pageHeightMm), n = Object.values(b).find((s) => Math.abs(i - s.width) <= 1 && Math.abs(a - s.height) <= 1);
|
|
229
|
+
return n ? n.code : (r.push(`page ${o + 1}: 自定义纸张 ${e.pageWidthMm}×${e.pageHeightMm}mm 无对应 Excel 纸型,打印设置回退 A4;可显式配置 paperSize`), b.a4.code);
|
|
229
230
|
}
|
|
230
|
-
function
|
|
231
|
+
function ue(e, t, o, r) {
|
|
231
232
|
const i = typeof t.text == "string" ? t.text : "";
|
|
232
233
|
if (o !== "raw" || !Object.prototype.hasOwnProperty.call(t, "value")) {
|
|
233
|
-
|
|
234
|
+
x(i, e.address), e.value = i;
|
|
234
235
|
return;
|
|
235
236
|
}
|
|
236
237
|
const a = t.value;
|
|
237
238
|
if (a === null || typeof a == "string" || typeof a == "boolean" || typeof a == "number" && Number.isFinite(a)) {
|
|
238
|
-
|
|
239
|
+
x(a, e.address), e.value = a, t.numberFormat && (e.numFmt = t.numberFormat);
|
|
239
240
|
return;
|
|
240
241
|
}
|
|
241
|
-
|
|
242
|
+
x(i, e.address), e.value = i, r.push(`原始单元格值无效,已保留显示文本:${e.address}`);
|
|
242
243
|
}
|
|
243
|
-
function
|
|
244
|
-
const t =
|
|
245
|
-
return t ? { id: `xlsx-flow:${t.key}`, title: t.sheet, wide: !0, flow: !0 } :
|
|
244
|
+
function me(e) {
|
|
245
|
+
const t = I(e);
|
|
246
|
+
return t ? { id: `xlsx-flow:${t.key}`, title: t.sheet, wide: !0, flow: !0 } : we(e);
|
|
246
247
|
}
|
|
247
|
-
function
|
|
248
|
-
const o = e.components.filter((
|
|
248
|
+
function we(e) {
|
|
249
|
+
const o = e.components.filter((r) => r.table !== void 0)[0]?.table;
|
|
249
250
|
if (!(!o || typeof o.id != "string" || !o.id.trim() || !Array.isArray(o.columnKeys) || !o.columnKeys.length)) {
|
|
250
|
-
for (const
|
|
251
|
-
if (
|
|
252
|
-
if (!
|
|
251
|
+
for (const r of e.components) {
|
|
252
|
+
if (r.table) {
|
|
253
|
+
if (!r.grid || r.table.id !== o.id) return;
|
|
253
254
|
continue;
|
|
254
255
|
}
|
|
255
|
-
if (
|
|
256
|
+
if (r.grid || r.kind !== "text" && !v(r)) return;
|
|
256
257
|
}
|
|
257
258
|
return { id: o.id, title: o.title, wide: o.layout === "wide" || e.layout === "wide" };
|
|
258
259
|
}
|
|
259
260
|
}
|
|
260
|
-
function
|
|
261
|
+
function pe(e, t) {
|
|
261
262
|
const o = /* @__PURE__ */ new Set();
|
|
262
|
-
for (const [
|
|
263
|
-
if (!t[
|
|
263
|
+
for (const [r, i] of e.pages.entries())
|
|
264
|
+
if (!t[r])
|
|
264
265
|
for (const a of i.components)
|
|
265
266
|
typeof a.table?.id == "string" && o.add(a.table.id);
|
|
266
267
|
return o;
|
|
267
268
|
}
|
|
268
|
-
function
|
|
269
|
+
function C(e) {
|
|
269
270
|
return e.layout === "wide" || e.components.some((t) => t.table?.layout === "wide");
|
|
270
271
|
}
|
|
271
|
-
function
|
|
272
|
-
const
|
|
273
|
-
for (const [
|
|
274
|
-
const l = i[
|
|
272
|
+
function xe(e, t, o) {
|
|
273
|
+
const r = [], i = e.pages.map(me), a = pe(e, i);
|
|
274
|
+
for (const [n, s] of e.pages.entries()) {
|
|
275
|
+
const l = i[n], c = l && !a.has(l.id), h = t === "pages" || !c ? void 0 : l;
|
|
275
276
|
if (t === "continuous" && !h)
|
|
276
|
-
throw new Error(`page ${
|
|
277
|
+
throw new Error(`page ${n + 1}: continuous Excel 需要完整、单一的逻辑表来源;自由布局请使用 sheetMode: 'pages'`);
|
|
277
278
|
const d = h !== void 0 && (t === "continuous" || h.wide);
|
|
278
|
-
!d && t !== "pages" &&
|
|
279
|
-
const u =
|
|
280
|
-
d && u?.continuous && u.tableId === h.id ? u.pages.push({ page: s, index:
|
|
279
|
+
!d && t !== "pages" && C(s) && o.push(`page ${n + 1}: 混合或缺少逻辑表来源,已保留独立 Sheet,未猜测合并内容`);
|
|
280
|
+
const u = r[r.length - 1];
|
|
281
|
+
d && u?.continuous && u.tableId === h.id ? u.pages.push({ page: s, index: n }) : r.push({ pages: [{ page: s, index: n }], continuous: d, ...d ? { tableId: h.id, title: h.title } : {}, ...l?.flow ? { flow: !0, title: l.title } : {} });
|
|
281
282
|
}
|
|
282
|
-
return
|
|
283
|
+
return r;
|
|
283
284
|
}
|
|
284
|
-
function
|
|
285
|
-
return !e || e.length === t.length && e.every((
|
|
285
|
+
function $(e, t, o) {
|
|
286
|
+
return !e || e.length === t.length && e.every((r, i) => o(r, t[i]));
|
|
286
287
|
}
|
|
287
|
-
function
|
|
288
|
-
const i = e.table, a = t.columns.map((l) => l.size),
|
|
289
|
-
if (i.columnKeys.length !== a.length || !
|
|
288
|
+
function Me(e, t, o, r) {
|
|
289
|
+
const i = e.table, a = t.columns.map((l) => l.size), n = $(r.keys, i.columnKeys, (l, c) => l === c), s = $(r.widths, a, (l, c) => Math.abs(l - c) <= 1e-3);
|
|
290
|
+
if (i.columnKeys.length !== a.length || !n || !s)
|
|
290
291
|
throw new Error(`page ${o + 1}: 连续 Excel 逻辑表 ${i.id} 的列结构或列宽不一致`);
|
|
291
|
-
if (
|
|
292
|
+
if (r.keys ??= i.columnKeys, r.widths ??= a, i.role === "header") {
|
|
292
293
|
if (i.rowIndex !== -1) throw new Error(`page ${o + 1}: 连续 Excel 表头 rowIndex 必须为 -1`);
|
|
293
|
-
|
|
294
|
+
r.headerSeen = !0;
|
|
294
295
|
} else {
|
|
295
|
-
if (!["body", "group-header", "subtotal", "grand-total"].includes(i.role) || i.rowIndex !==
|
|
296
|
-
throw new Error(`page ${o + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${
|
|
297
|
-
|
|
296
|
+
if (!["body", "group-header", "subtotal", "grand-total"].includes(i.role) || i.rowIndex !== r.expectedRow)
|
|
297
|
+
throw new Error(`page ${o + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${r.expectedRow})`);
|
|
298
|
+
r.expectedRow += t.rows.length;
|
|
298
299
|
}
|
|
299
300
|
}
|
|
300
|
-
function
|
|
301
|
+
function Ee(e, t) {
|
|
301
302
|
const o = { expectedRow: 0, headerSeen: !1 };
|
|
302
|
-
for (const { page:
|
|
303
|
-
for (const a of
|
|
304
|
-
const
|
|
305
|
-
a.table &&
|
|
303
|
+
for (const { page: r, index: i } of e.pages)
|
|
304
|
+
for (const a of r.components) {
|
|
305
|
+
const n = t.get(a);
|
|
306
|
+
a.table && n && Me(a, n, i, o);
|
|
306
307
|
}
|
|
307
308
|
if (!o.headerSeen) throw new Error("连续 Excel 逻辑表缺少明确表头来源");
|
|
308
309
|
}
|
|
309
|
-
function
|
|
310
|
-
let
|
|
311
|
-
|
|
312
|
-
let i =
|
|
310
|
+
function be(e, t, o) {
|
|
311
|
+
let r = (e?.replace(/[\\/*?:[\]]/g, " ").replace(/\s+/g, " ").trim() || `Sheet${t + 1}`).slice(0, 31).replace(/^'+|'+$/g, "").trim() || `Sheet${t + 1}`;
|
|
312
|
+
r.toLowerCase() === "history" && (r += " 报表");
|
|
313
|
+
let i = r, a = 1;
|
|
313
314
|
for (; o.has(i.toLowerCase()); ) {
|
|
314
|
-
const
|
|
315
|
-
i =
|
|
315
|
+
const n = ` (${++a})`;
|
|
316
|
+
i = r.slice(0, 31 - n.length) + n;
|
|
316
317
|
}
|
|
317
318
|
return o.add(i.toLowerCase()), i;
|
|
318
319
|
}
|
|
319
|
-
function
|
|
320
|
+
function ye(e) {
|
|
320
321
|
const t = /* @__PURE__ */ new Set();
|
|
321
|
-
function o(
|
|
322
|
-
return
|
|
322
|
+
function o(r, i, a, n) {
|
|
323
|
+
return r <= i ? r : (t.has(a) || (e.push(n), t.add(a)), i);
|
|
323
324
|
}
|
|
324
325
|
return {
|
|
325
|
-
column: (
|
|
326
|
-
row: (
|
|
326
|
+
column: (r) => o(r, 255, "column", "Excel 单列宽度上限为 255 字符,超宽列已收敛至 255;单元格值完整保留,显示范围可能受限"),
|
|
327
|
+
row: (r) => o(r, 409, "row", "Excel 行高上限为 409pt,超高行已收敛至 409pt;单元格值完整保留,显示范围可能受限")
|
|
327
328
|
};
|
|
328
329
|
}
|
|
329
|
-
async function
|
|
330
|
-
const o = e.flow ?
|
|
330
|
+
async function Se(e, t) {
|
|
331
|
+
const o = e.flow ? he(e.pages, e.continuous).map((n) => ({ comp: n, pageIndex: e.pages[0].index })) : e.pages.flatMap(({ page: n, index: s }, l) => n.components.filter((c) => !e.continuous || (c.pageAnchor !== "header" || l === 0) && (c.pageAnchor !== "footer" || l === e.pages.length - 1)).map((c) => ({ comp: c, pageIndex: s }))), r = /* @__PURE__ */ new Map();
|
|
331
332
|
let i = 1, a = 0;
|
|
332
|
-
for (const { comp:
|
|
333
|
-
if (
|
|
334
|
-
const s =
|
|
335
|
-
|
|
333
|
+
for (const { comp: n } of o)
|
|
334
|
+
if (n.grid) {
|
|
335
|
+
const s = W(n.grid, n.widthMm, n.heightMm);
|
|
336
|
+
r.set(n, s), i = Math.max(i, s.columns.length);
|
|
336
337
|
const l = t(s.cells.length);
|
|
337
338
|
l && await l;
|
|
338
|
-
} else
|
|
339
|
+
} else n.kind === "text" && (a = Math.max(a, n.widthMm));
|
|
339
340
|
if (i > 16384) throw new Error("Excel 最多支持 16384 列,无法无损导出此报表");
|
|
340
|
-
return { components: o, grids:
|
|
341
|
+
return { components: o, grids: r, columnCount: i, textWidthMm: a };
|
|
341
342
|
}
|
|
342
|
-
function
|
|
343
|
-
const { page:
|
|
344
|
-
return (e.continuous ||
|
|
345
|
-
paperSize:
|
|
346
|
-
orientation:
|
|
343
|
+
function ve(e, t, o) {
|
|
344
|
+
const { page: r, index: i } = e.pages[0], a = t !== void 0 && t !== "auto";
|
|
345
|
+
return (e.continuous || C(r)) && !a ? {} : { pageSetup: {
|
|
346
|
+
paperSize: ge(r, t, i, o),
|
|
347
|
+
orientation: r.pageWidthMm > r.pageHeightMm ? "landscape" : "portrait",
|
|
347
348
|
fitToPage: !0,
|
|
348
349
|
...e.continuous ? { fitToWidth: 1, fitToHeight: 0 } : {}
|
|
349
350
|
} };
|
|
350
351
|
}
|
|
351
|
-
function
|
|
352
|
-
const t =
|
|
352
|
+
function Ce(e) {
|
|
353
|
+
const t = E(e.borderColor ?? e.lineColor), o = { style: "thin", ...t ? { color: { argb: t } } : {} };
|
|
353
354
|
return {
|
|
354
355
|
...e.borderTop !== !1 ? { top: o } : {},
|
|
355
356
|
...e.borderLeft !== !1 ? { left: o } : {},
|
|
@@ -357,81 +358,81 @@ function ye(e) {
|
|
|
357
358
|
...e.borderRight !== !1 ? { right: o } : {}
|
|
358
359
|
};
|
|
359
360
|
}
|
|
360
|
-
function
|
|
361
|
+
function ke(e, t) {
|
|
361
362
|
e.alignment = { horizontal: t.align ?? "left", vertical: t.verticalAlign ?? "middle", wrapText: !0 };
|
|
362
|
-
const o =
|
|
363
|
-
o && (e.fill = { type: "pattern", pattern: "solid", fgColor: { argb: o } }), e.border =
|
|
363
|
+
const o = E(t.backgroundColor);
|
|
364
|
+
o && (e.fill = { type: "pattern", pattern: "solid", fgColor: { argb: o } }), e.border = Ce(t), D(e, t);
|
|
364
365
|
}
|
|
365
|
-
function
|
|
366
|
-
for (const [o,
|
|
367
|
-
const i = e.sheet.getColumn(o + 1), a = e.limits.column(
|
|
366
|
+
function Be(e, t) {
|
|
367
|
+
for (const [o, r] of t.columns.entries()) {
|
|
368
|
+
const i = e.sheet.getColumn(o + 1), a = e.limits.column(T(r.size));
|
|
368
369
|
(i.width == null || i.width < a) && (i.width = a);
|
|
369
370
|
}
|
|
370
371
|
}
|
|
371
|
-
function
|
|
372
|
-
for (const [
|
|
373
|
-
const a = e.sheet.getRow(o +
|
|
374
|
-
(a.height == null || a.height <
|
|
372
|
+
function $e(e, t, o) {
|
|
373
|
+
for (const [r, i] of t.rows.entries()) {
|
|
374
|
+
const a = e.sheet.getRow(o + r), n = e.limits.row(i.size * z);
|
|
375
|
+
(a.height == null || a.height < n) && (a.height = n);
|
|
375
376
|
}
|
|
376
377
|
}
|
|
377
|
-
function
|
|
378
|
+
function Ae(e, t, o, r) {
|
|
378
379
|
const i = Math.max(1, Math.min(t.cell.colSpan ?? 1, o.columns.length - t.ci)), a = Math.max(1, Math.min(t.cell.rowSpan ?? 1, o.rows.length - t.ri));
|
|
379
|
-
(i > 1 || a > 1) && e.mergeCells(
|
|
380
|
+
(i > 1 || a > 1) && e.mergeCells(r + t.ri, t.ci + 1, r + t.ri + a - 1, t.ci + i);
|
|
380
381
|
}
|
|
381
|
-
async function
|
|
382
|
-
if (
|
|
383
|
-
|
|
382
|
+
async function We(e, t, o, r) {
|
|
383
|
+
if (r + o.rows.length - 1 > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
|
|
384
|
+
$e(e, o, r);
|
|
384
385
|
for (const i of o.cells) {
|
|
385
|
-
const a = e.sheet.getCell(
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
|
|
386
|
+
const a = e.sheet.getCell(r + i.ri, i.ci + 1);
|
|
387
|
+
ue(a, i.cell, e.valueMode, e.warnings);
|
|
388
|
+
const n = te(i.cell, t.style);
|
|
389
|
+
n && (x(n.richText.map((c) => c.text).join(""), a.address), a.value = n);
|
|
389
390
|
const s = t.grid?.paddingMm ?? 0.5;
|
|
390
|
-
e.dataBars(e.sheet, i,
|
|
391
|
+
e.dataBars(e.sheet, i, r + i.ri, s);
|
|
391
392
|
for (const c of i.cell.children ?? [])
|
|
392
|
-
|
|
393
|
-
|
|
393
|
+
v(c) && !c.grid && e.images.write(e.sheet, c, r + i.ri, { leftMm: i.xMm + s + (i.cell.indentMm ?? 0) + c.leftMm, offsetMm: s + c.topMm });
|
|
394
|
+
ke(a, p(t.style, i.cell.style)), i.cell.indentMm && (a.alignment = { ...a.alignment, indent: Math.min(250, Math.max(1, Math.round(i.cell.indentMm / 2.5))) }), Ae(e.sheet, i, o, r);
|
|
394
395
|
const l = e.schedule();
|
|
395
396
|
l && await l;
|
|
396
397
|
}
|
|
397
|
-
return
|
|
398
|
+
return r + o.rows.length;
|
|
398
399
|
}
|
|
399
|
-
function
|
|
400
|
+
function Te(e, t, o, r) {
|
|
400
401
|
const i = Array.isArray(t.lines) && t.lines.length > 0 ? t.lines.join(`
|
|
401
|
-
`) : t.text ?? "", a = e.sheet.getRow(o),
|
|
402
|
-
t.richParagraphs?.length ||
|
|
403
|
-
const s =
|
|
404
|
-
return s && (
|
|
405
|
-
}
|
|
406
|
-
function
|
|
407
|
-
const
|
|
408
|
-
e.views = [{ state: "frozen", ySplit:
|
|
409
|
-
}
|
|
410
|
-
async function
|
|
411
|
-
!t.grids.size && t.textWidthMm > 0 && (e.sheet.getColumn(1).width = e.limits.column(
|
|
412
|
-
for (const
|
|
413
|
-
|
|
414
|
-
const s = e.schedule(
|
|
402
|
+
`) : t.text ?? "", a = e.sheet.getRow(o), n = a.getCell(1);
|
|
403
|
+
t.richParagraphs?.length || x(i, n.address), n.value = t.richParagraphs?.length ? P(t.richParagraphs, t.style) : i, typeof n.value == "object" && n.value && "richText" in n.value && x(n.value.richText.map((l) => l.text).join(""), n.address), n.alignment = { horizontal: t.style?.align ?? "left", vertical: t.style?.verticalAlign ?? "middle", wrapText: !0 };
|
|
404
|
+
const s = E(t.style?.backgroundColor);
|
|
405
|
+
return s && (n.fill = { type: "pattern", pattern: "solid", fgColor: { argb: s } }), D(n, t.style), r > 1 && e.sheet.mergeCells(o, 1, o, r), a.height = e.limits.row(t.heightMm * z), o + 1;
|
|
406
|
+
}
|
|
407
|
+
function Pe(e, t, o) {
|
|
408
|
+
const r = t + o - 1;
|
|
409
|
+
e.views = [{ state: "frozen", ySplit: r, xSplit: 0 }], e.pageSetup.printTitlesRow = `1:${r}`;
|
|
410
|
+
}
|
|
411
|
+
async function Re(e, t, o, r) {
|
|
412
|
+
!t.grids.size && t.textWidthMm > 0 && (e.sheet.getColumn(1).width = e.limits.column(T(t.textWidthMm)));
|
|
413
|
+
for (const n of t.grids.values()) {
|
|
414
|
+
Be(e, n);
|
|
415
|
+
const s = e.schedule(n.columns.length);
|
|
415
416
|
s && await s;
|
|
416
417
|
}
|
|
417
418
|
let i = 1, a = !1;
|
|
418
|
-
for (const { comp:
|
|
419
|
-
const l = o &&
|
|
419
|
+
for (const { comp: n, pageIndex: s } of t.components) {
|
|
420
|
+
const l = o && n.table?.role === "header";
|
|
420
421
|
if (l && a) continue;
|
|
421
422
|
if (i > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
|
|
422
|
-
const c = t.grids.get(
|
|
423
|
+
const c = t.grids.get(n);
|
|
423
424
|
if (c)
|
|
424
|
-
l && (
|
|
425
|
-
else if (
|
|
426
|
-
i =
|
|
427
|
-
else if (
|
|
428
|
-
const h =
|
|
425
|
+
l && (Pe(e.sheet, i, c.rows.length), a = !0), i = await We(e, n, c, i);
|
|
426
|
+
else if (n.kind === "text")
|
|
427
|
+
i = Te(e, n, i, t.columnCount);
|
|
428
|
+
else if (v(n)) {
|
|
429
|
+
const h = X(n, o), d = r.write(e.sheet, n, h?.row ?? i, h);
|
|
429
430
|
h || (i = d);
|
|
430
431
|
} else
|
|
431
|
-
e.warnings.push(`page ${s + 1} ${
|
|
432
|
+
e.warnings.push(`page ${s + 1} ${n.nid ?? n.kind}: 组件类型 ${n.kind} 暂不支持 xlsx 导出,已跳过`);
|
|
432
433
|
}
|
|
433
434
|
}
|
|
434
|
-
function
|
|
435
|
+
function Fe(e) {
|
|
435
436
|
if (e.maxDataBars !== void 0 && (!Number.isSafeInteger(e.maxDataBars) || e.maxDataBars < 0 || e.maxDataBars > 1e5)) throw new Error("xlsx maxDataBars 必须是 0–100000 的整数");
|
|
436
437
|
if (e.valueMode !== void 0 && e.valueMode !== "text" && e.valueMode !== "raw")
|
|
437
438
|
throw new Error("xlsx valueMode 必须是 text 或 raw");
|
|
@@ -440,44 +441,63 @@ function Pe(e) {
|
|
|
440
441
|
if (e.sheetMode !== void 0 && !["auto", "pages", "continuous"].includes(e.sheetMode))
|
|
441
442
|
throw new Error("xlsx sheetMode 必须是 auto、pages 或 continuous");
|
|
442
443
|
}
|
|
443
|
-
async function
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
444
|
+
async function Ie(e, t = {}) {
|
|
445
|
+
const o = q(t.additionalSheets), r = Q(t.sheetNames);
|
|
446
|
+
Fe(t), M(t.signal);
|
|
447
|
+
const i = t.assetRegistry || t.assetRenderers ? await J(e, { ...t, format: "xlsx" }) : { plan: e, diagnostics: [] };
|
|
448
|
+
e = i.plan;
|
|
449
|
+
const a = [...i.diagnostics, ...V(e, "xlsx", t)];
|
|
450
|
+
await ee(e, t.maxDataBars ?? 1e4, t);
|
|
451
|
+
const n = new U.Workbook(), s = [], l = oe(n, t, s), c = [], h = Z(l, t.maxDataBars ?? 1e4, c), d = ye(s), u = xe(e, t.sheetMode, s), f = /* @__PURE__ */ new Set(), g = S(t);
|
|
452
|
+
for (const [w, m] of u.entries()) {
|
|
453
|
+
const k = await Se(m, g);
|
|
454
|
+
m.continuous && !m.flow && Ee(m, k.grids);
|
|
455
|
+
const N = m.pages[0].page, B = r?.[w] ?? t.sheetName?.(w) ?? be(m.title, w, f);
|
|
456
|
+
f.add(B.toLowerCase());
|
|
457
|
+
const L = n.addWorksheet(B, ve(m, t.paperSize, s)), O = t.valueMode ?? (C(N) || m.continuous || m.flow ? "raw" : "text");
|
|
458
|
+
M(t.signal), await Re({ sheet: L, warnings: s, limits: d, valueMode: O, schedule: g, images: l, dataBars: h }, k, m.continuous, l), await j(t, w + 1, u.length);
|
|
459
|
+
}
|
|
460
|
+
return await ze(n, o, t), { workbook: n, warnings: s, diagnostics: a, ...c.length ? { notes: c } : {} };
|
|
461
|
+
}
|
|
462
|
+
async function ze(e, t = [], o) {
|
|
463
|
+
const r = S(o);
|
|
464
|
+
for (const i of t) {
|
|
465
|
+
if (M(o.signal), e.worksheets.some((n) => n.name.toLowerCase() === i.name.toLowerCase())) throw new TypeError(`附加工作表名称已被报表使用 ${i.name}`);
|
|
466
|
+
const a = e.addWorksheet(i.name);
|
|
467
|
+
i.columnWidths && (a.columns = i.columnWidths.map((n) => ({ width: n })));
|
|
468
|
+
for (const n of i.rows) {
|
|
469
|
+
const s = a.addRow([...n]);
|
|
470
|
+
s.alignment = { vertical: "top", wrapText: !0 }, await r(n.length);
|
|
471
|
+
}
|
|
457
472
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
473
|
+
M(o.signal);
|
|
474
|
+
}
|
|
475
|
+
async function Xe(e, t = {}) {
|
|
476
|
+
const o = await Ie(e, t);
|
|
477
|
+
M(t.signal);
|
|
478
|
+
const r = await o.workbook.xlsx.writeBuffer();
|
|
479
|
+
return M(t.signal), { ...o, buffer: r };
|
|
461
480
|
}
|
|
462
481
|
export {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
482
|
+
Ze as bindExcelTemplate,
|
|
483
|
+
et as createExcelBindingDocument,
|
|
484
|
+
tt as createExcelBindingSession,
|
|
485
|
+
nt as createExcelRegionBindingDocument,
|
|
486
|
+
rt as createExcelRegionBindingSession,
|
|
487
|
+
it as excelBindingCellRange,
|
|
488
|
+
ot as excelBindingRowRange,
|
|
489
|
+
at as getExcelSheetWindow,
|
|
490
|
+
Ve as importExcelTemplate,
|
|
491
|
+
qe as inspectExcelWorkbook,
|
|
492
|
+
Qe as openExcelWorkbook,
|
|
493
|
+
st as parseExcelBindingSession,
|
|
494
|
+
lt as parseExcelRegionBindingSession,
|
|
495
|
+
Ie as renderPlanToWorkbook,
|
|
496
|
+
Xe as renderPlanToXlsx,
|
|
497
|
+
ct as validateExcelBindingFields,
|
|
498
|
+
ht as validateExcelBindingRecipe,
|
|
499
|
+
dt as validateExcelBindingRegions,
|
|
500
|
+
ft as validateExcelRegionBindings,
|
|
501
|
+
gt as validateExcelRegionFields,
|
|
502
|
+
ut as validateExcelRegionGeometry
|
|
483
503
|
};
|