@agile-team/mach-report 2.21.1 → 2.23.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 +20 -5
- package/dist/{ExcelBindingWizard-mnAO2qOX.js → ExcelBindingWizard-D4FLind-.js} +3 -3
- package/dist/{ExcelBindingWizard-Bu0LUlzl.cjs → ExcelBindingWizard-D4RS5Bpg.cjs} +1 -1
- package/dist/{ParamEditor-38ZfNrPU.cjs → ParamEditor-C-6C9rd2.cjs} +1 -1
- package/dist/{ParamEditor-C8l0EC8m.js → ParamEditor-CASZt-Ma.js} +2 -2
- package/dist/{ReportBatchPanel-CfUVhvkO.js → ReportBatchPanel-Bq7t8a5r.js} +2 -2
- package/dist/{ReportBatchPanel-nCC06Nfp.cjs → ReportBatchPanel-YVj5IO5y.cjs} +1 -1
- package/dist/ReportLabelStudio-Cqhita1b.cjs +1 -0
- package/dist/ReportLabelStudio-Dj7GXhuv.js +783 -0
- package/dist/ReportParamPanel-DZbFVmDL.cjs +1 -0
- package/dist/{ReportParamPanel-peB-KEmm.js → ReportParamPanel-Dgmqro1Y.js} +265 -244
- package/dist/ReportPreview-DeWzG8jQ.js +6257 -0
- package/dist/ReportPreview-FFIryrIr.cjs +6 -0
- package/dist/{ReportTemplateLibrary-DVlsf72p.cjs → ReportTemplateLibrary-BaWodmpm.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-B5t_EcIs.js → ReportTemplateLibrary-DdAAAD2I.js} +1 -1
- package/dist/{RuleEditor-kT1JsZ9f.js → RuleEditor-D2UwQGF6.js} +59 -59
- package/dist/{RuleEditor-xFkCVlii.cjs → RuleEditor-DcT9xI1v.cjs} +1 -1
- package/dist/TemplateOutlinePanel-CUHFFiNM.cjs +1 -0
- package/dist/{TemplateOutlinePanel-BesgGR1P.js → TemplateOutlinePanel-DrT7XN0m.js} +2 -2
- package/dist/{TemplateReusePanel-BNFU6V-W.js → TemplateReusePanel-4eejkNqi.js} +2 -2
- package/dist/{TemplateReusePanel-BG9Or5-P.cjs → TemplateReusePanel-DZMyiX5I.cjs} +1 -1
- package/dist/{TemplateReviewPanel-CwvwyCSs.js → TemplateReviewPanel-BIhNLeNw.js} +2 -2
- package/dist/TemplateReviewPanel-DnYImiXu.cjs +1 -0
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.js +26 -26
- package/dist/artifact-integrity.json +108 -106
- package/dist/assets-D2gHc4Mz.cjs +1 -0
- package/dist/assets-T_gDeFaz.js +132 -0
- package/dist/auto-4pK9HePf.cjs +1 -0
- package/dist/auto-CTIJ6PnR.js +257 -0
- package/dist/capabilities-DiBj4Qgl.cjs +1 -0
- package/dist/capabilities-pg7j7VLT.js +106 -0
- package/dist/charts-Cjw5AYkg.cjs +1 -0
- package/dist/{charts-Dlv8j2AG.js → charts-CxJZ0XaY.js} +1 -1
- package/dist/computed-DK6BruFz.cjs +1 -0
- package/dist/{computed-C8NRZQss.js → computed-f3pOqWLX.js} +381 -301
- package/dist/data-bar-CeZuFmYl.cjs +1 -0
- package/dist/{data-bar-8baGYEZ9.js → data-bar-IkI6VvMQ.js} +1 -1
- package/dist/designer-DhrE7jzw.js +7169 -0
- package/dist/designer-IAZu6kBX.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +246 -46
- package/dist/designer.d.ts +246 -46
- package/dist/designer.js +15 -14
- package/dist/dom-ChE5D-L-.cjs +1 -0
- package/dist/dom-JWrchIre.js +452 -0
- package/dist/dom-cell-address-DLD1mkTB.cjs +1 -0
- package/dist/dom-cell-address-Fn-8nk7D.js +11 -0
- package/dist/{encoding-B79hW4zq.cjs → encoding-BefcaHdp.cjs} +1 -1
- package/dist/{encoding-BSeUwrN7.js → encoding-CL6rXEkR.js} +2 -2
- package/dist/{font-loader-Di0lQKFf.js → font-loader-BT5baV-o.js} +1 -1
- package/dist/{font-loader-BB372_XN.cjs → font-loader-Ga51c2VC.cjs} +1 -1
- package/dist/grid-strokes-Be24LGuV.cjs +1 -0
- package/dist/grid-strokes-EoY66L2f.js +53 -0
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +961 -1256
- package/dist/json-snapshot-1tvQNzQE.cjs +2 -0
- package/dist/{json-snapshot-Kgn459Oj.js → json-snapshot-OqkPyUk5.js} +763 -776
- package/dist/matrix-B8QWbsGM.cjs +1 -0
- package/dist/matrix-C6e_r_vp.js +302 -0
- package/dist/{pdf-CARdBcuw.cjs → pdf-HiEeXe9H.cjs} +42 -42
- package/dist/{pdf-DmlnL5eB.js → pdf-aobetCsy.js} +20 -20
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-BaRUGORD.cjs → plugin-BFANt-i8.cjs} +1 -1
- package/dist/{plugin-D4kAxfLG.js → plugin-DeYYAL6F.js} +1 -1
- package/dist/{prefill-CJSazcVY.js → prefill-Dk4C6S5R.js} +21 -21
- package/dist/prefill-DsUD5OoK.cjs +1 -0
- package/dist/prepared-DCIxhKFo.js +94 -0
- package/dist/prepared-Dv-XM3i1.cjs +1 -0
- package/dist/progress-ByiOxUD3.js +250 -0
- package/dist/progress-WomPRP3B.cjs +1 -0
- package/dist/{protocol-C8VWF9An.cjs → protocol-B9YgfQ_d.cjs} +1 -1
- package/dist/{protocol-Bs9-ohHN.js → protocol-DxeUKGYG.js} +3 -3
- package/dist/record-bindings-DatJZv_e.js +200 -0
- package/dist/record-bindings-MBxbeBsi.cjs +1 -0
- package/dist/{region-binding-workflow-Cy4GIOUo.js → region-binding-workflow-DjrXuR1q.js} +2 -2
- package/dist/{region-binding-workflow-JNowHd0A.cjs → region-binding-workflow-l7NGfagJ.cjs} +2 -2
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/rich-text-layout-Ciwa6D2o.js +52 -0
- package/dist/rich-text-layout-DK7A_a5r.cjs +3 -0
- package/dist/{runtime-BDf5x1i1.js → runtime-75Y5Oq5B.js} +52 -51
- package/dist/runtime-DKlGd_D4.cjs +1 -0
- 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 +2178 -2044
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +81 -0
- package/dist/server.d.ts +81 -0
- package/dist/server.js +24 -24
- package/dist/style.css +1 -1
- package/dist/{template-catalog-DFwIS9aN.js → template-catalog--cjxzgH7.js} +17 -17
- package/dist/template-catalog-CoT7jm_6.cjs +1 -0
- package/dist/{template-fragments-Dng-AlHk.js → template-fragments-CPpGpQoz.js} +24 -24
- package/dist/{template-fragments-DZVUBhuB.cjs → template-fragments-GVjpew_q.cjs} +1 -1
- package/dist/template-registry-DI59PXVK.cjs +1 -0
- package/dist/{template-registry-DhBqoD7W.js → template-registry-O0hNIOfB.js} +333 -261
- package/dist/template-serialization-CWmHq7lX.js +307 -0
- package/dist/template-serialization-CqQY4zDg.cjs +1 -0
- package/dist/{textwrap-CkGjRFT3.js → textwrap-BIjtEWmq.js} +1 -1
- package/dist/textwrap-Cy7o1hIR.cjs +4 -0
- package/dist/vue/async.d.cts +121 -2
- package/dist/vue/async.d.ts +121 -2
- package/dist/vue/index.d.cts +222 -5
- package/dist/vue/index.d.ts +222 -5
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +101 -91
- package/dist/{workbook-session-NYv01LHe.cjs → workbook-session-C6-SrnCT.cjs} +4 -4
- package/dist/{workbook-session-oinxX3qo.js → workbook-session-C9ZmCBwY.js} +15 -16
- 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 +300 -275
- package/package.json +1 -1
- package/dist/ReportLabelStudio-CaEvYuSK.cjs +0 -1
- package/dist/ReportLabelStudio-DQPBmh4v.js +0 -765
- package/dist/ReportParamPanel-CVpK8mFc.cjs +0 -1
- package/dist/ReportPreview-BBJNlu2U.js +0 -5740
- package/dist/ReportPreview-nf4Dk1Jc.cjs +0 -6
- package/dist/TemplateOutlinePanel-CDI6mfWx.cjs +0 -1
- package/dist/TemplateReviewPanel-BmBrjt6P.cjs +0 -1
- package/dist/assets-CxHunY_9.js +0 -232
- package/dist/assets-vbjAGgk8.cjs +0 -1
- package/dist/auto-BkdGiNtr.js +0 -240
- package/dist/auto-Tq7ReIC1.cjs +0 -1
- package/dist/charts-aCtoswXq.cjs +0 -1
- package/dist/component-tree-1_QCiQJX.js +0 -67
- package/dist/component-tree-BjZIp6w9.cjs +0 -1
- package/dist/computed-4TnxzgIh.cjs +0 -1
- package/dist/data-bar-YltqGTaC.cjs +0 -1
- package/dist/designer-DU3yDWgs.cjs +0 -2
- package/dist/designer-HQi-03R6.js +0 -6869
- package/dist/grid-geometry-D3SJgWFv.js +0 -136
- package/dist/grid-geometry-D8ReblRV.cjs +0 -1
- package/dist/json-snapshot-I5VI84Vp.cjs +0 -2
- package/dist/matrix-0hywp0-F.cjs +0 -1
- package/dist/matrix-Dy-tyY7E.js +0 -381
- package/dist/prefill-Bpyn58AZ.cjs +0 -1
- package/dist/prepared-BiSz_9vN.cjs +0 -1
- package/dist/prepared-BwjwEzFz.js +0 -87
- package/dist/progress-B0ctFpKf.cjs +0 -1
- package/dist/progress-Hc2vxoCs.js +0 -52
- package/dist/record-bindings-Ct1HkPrc.cjs +0 -1
- package/dist/record-bindings-VZGS-Qd8.js +0 -155
- package/dist/rich-text-layout-K48VHUoW.cjs +0 -3
- package/dist/rich-text-layout-wxBhnAS7.js +0 -102
- package/dist/runtime-DsJt1PIf.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-outline-DWkzZXVC.cjs +0 -1
- package/dist/template-outline-DiADphlq.js +0 -88
- 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/textwrap-OTOUMr4f.cjs +0 -4
package/dist/xlsx.js
CHANGED
|
@@ -1,355 +1,355 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as
|
|
3
|
-
import { d as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { b as
|
|
11
|
-
function
|
|
12
|
-
const t =
|
|
1
|
+
import { t as v, m as x, a as W, r as T, v as E, o as R, x as P, i as C } from "./progress-ByiOxUD3.js";
|
|
2
|
+
import { e as _ } from "./index-CPh6tqge.js";
|
|
3
|
+
import { d as U } from "./data-bar-IkI6VvMQ.js";
|
|
4
|
+
import { e as X, E as K, m as F, i as J } from "./workbook-session-C9ZmCBwY.js";
|
|
5
|
+
import { a as qe, b as Qe, o as Ye } from "./workbook-session-C9ZmCBwY.js";
|
|
6
|
+
import { c as V } from "./media-Y90dHK9z.js";
|
|
7
|
+
import { r as q } from "./capabilities-pg7j7VLT.js";
|
|
8
|
+
import { r as Q } from "./assets-T_gDeFaz.js";
|
|
9
|
+
import { s as Y, a as Z } from "./workbook-sheets-D4M7XXBh.js";
|
|
10
|
+
import { b as et, c as tt, a as nt, d as rt, e as it, f as ot, g as at, h as st, p as lt, i as ct, v as ht, j as dt, k as ft, l as gt, m as ut, n as mt } from "./region-binding-workflow-DjrXuR1q.js";
|
|
11
|
+
function ee(e) {
|
|
12
|
+
const t = _({ 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
13
|
return `data:image/png;base64,${btoa(String.fromCharCode(...t))}`;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
15
|
+
function te(e, t, o) {
|
|
16
|
+
const r = /* @__PURE__ */ new Map();
|
|
17
17
|
let i = 0;
|
|
18
|
-
return (a,
|
|
19
|
-
const c =
|
|
18
|
+
return (a, n, s, l) => {
|
|
19
|
+
const c = U(n.cell.dataBar, n.widthMm, n.heightMm, l);
|
|
20
20
|
if (!c) return;
|
|
21
21
|
if (++i > t) throw new Error(`Excel 数据条超过 ${t} 个绘图预算,请缩小范围或调整 maxDataBars`);
|
|
22
|
-
let h =
|
|
23
|
-
h || (h =
|
|
22
|
+
let h = r.get(c.color);
|
|
23
|
+
h || (h = ee(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
24
|
};
|
|
25
25
|
}
|
|
26
|
-
async function
|
|
27
|
-
const
|
|
26
|
+
async function ne(e, t, o) {
|
|
27
|
+
const r = e.pages.flatMap((n) => n.components), i = v(o);
|
|
28
28
|
let a = 0;
|
|
29
|
-
for (;
|
|
30
|
-
const
|
|
31
|
-
for (const s of
|
|
29
|
+
for (; r.length; ) {
|
|
30
|
+
const n = r.pop();
|
|
31
|
+
for (const s of n.grid?.cells ?? []) for (const l of s) {
|
|
32
32
|
if (l?.dataBar && l.dataBar.end > l.dataBar.start && ++a > t) throw new Error(`Excel 数据条超过 ${t} 个绘图预算,请缩小范围或调整 maxDataBars`);
|
|
33
|
-
l?.children &&
|
|
33
|
+
l?.children && r.push(...l.children);
|
|
34
34
|
const c = i();
|
|
35
35
|
c && await c;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return { richText: e.flatMap((o,
|
|
41
|
-
...
|
|
39
|
+
function I(e, t) {
|
|
40
|
+
return { richText: e.flatMap((o, r) => [
|
|
41
|
+
...r ? [{ text: `
|
|
42
42
|
` }] : [],
|
|
43
43
|
...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:
|
|
44
|
+
const a = x(t, i.style), n = a.color?.replace(/^#/, "");
|
|
45
|
+
return { text: i.kind === "field" ? i.field ?? "" : i.text ?? "", font: { name: a.fontFamily, bold: a.bold, italic: a.italic, underline: a.underline, size: W(a).fontSizePt, .../^[a-f\d]{6}$/i.test(n ?? "") ? { color: { argb: `FF${n.toUpperCase()}` } } : {} } };
|
|
46
46
|
})
|
|
47
47
|
]) };
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function re(e, t) {
|
|
50
50
|
const o = e.children?.filter((a) => a.kind === "text" && !a.grid) ?? [];
|
|
51
51
|
if (!e.richParagraphs?.length && !o.length) return;
|
|
52
|
-
const
|
|
52
|
+
const r = x(t, e.style), i = e.richParagraphs?.length ? [...e.richParagraphs] : e.text ? [{ segments: [{ text: e.text }] }] : [];
|
|
53
53
|
for (const a of o) {
|
|
54
|
-
const
|
|
54
|
+
const n = x(r, a.style), s = a.richParagraphs?.length ? a.richParagraphs : [{ segments: [{ text: a.lines?.join(`
|
|
55
55
|
`) ?? a.text ?? "" }] }];
|
|
56
|
-
for (const l of s) i.push({ ...l, segments: l.segments.map((c) => ({ ...c, style:
|
|
56
|
+
for (const l of s) i.push({ ...l, segments: l.segments.map((c) => ({ ...c, style: x(n, c.style) })) });
|
|
57
57
|
}
|
|
58
|
-
return
|
|
58
|
+
return I(i, r);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
let
|
|
62
|
-
if (!Number.isFinite(
|
|
63
|
-
for (;
|
|
60
|
+
function ie(e, t, o) {
|
|
61
|
+
let r = o * 72 / 25.4;
|
|
62
|
+
if (!Number.isFinite(r) || t + Math.ceil(r / 409) - 1 > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
|
|
63
|
+
for (; r > 0; ) {
|
|
64
64
|
if (t > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
|
|
65
|
-
const i = Math.min(409,
|
|
66
|
-
e.getRow(t++).height = i,
|
|
65
|
+
const i = Math.min(409, r);
|
|
66
|
+
e.getRow(t++).height = i, r -= i;
|
|
67
67
|
}
|
|
68
68
|
return t;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
let
|
|
72
|
-
if (!Number.isSafeInteger(
|
|
70
|
+
function oe(e, t, o) {
|
|
71
|
+
let r = Math.round(t * 36e3), i = 0;
|
|
72
|
+
if (!Number.isSafeInteger(r)) throw new Error("Excel 图片锚点超出安全坐标范围");
|
|
73
73
|
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
|
-
|
|
74
|
+
const a = e.getColumn(i + 1).width ?? e.properties.defaultColWidth, n = Math.round(X(a) * 36e3);
|
|
75
|
+
if (!Number.isSafeInteger(n) || n <= 0) throw new Error("Excel 图片锚点所在列宽无效");
|
|
76
|
+
if (r < n) return { col: i + r / n, row: o - 1, nativeCol: i, nativeColOff: r, nativeRow: o - 1, nativeRowOff: 0 };
|
|
77
|
+
r -= n, i++;
|
|
78
78
|
}
|
|
79
79
|
throw new Error("Excel 图片锚点超过16384列上限");
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
let
|
|
83
|
-
if (!Number.isFinite(
|
|
81
|
+
function ae(e, t, o) {
|
|
82
|
+
let r = o * 72 / 25.4;
|
|
83
|
+
if (!Number.isFinite(r) || Math.abs(r) > 1048576 * 409) throw new Error("Excel 图片纵向偏移超过工作表范围");
|
|
84
84
|
const i = (a) => {
|
|
85
|
-
const
|
|
86
|
-
if (!Number.isFinite(
|
|
87
|
-
return
|
|
85
|
+
const n = e.getRow(a).height ?? e.properties.defaultRowHeight ?? 15;
|
|
86
|
+
if (!Number.isFinite(n) || n <= 0) throw new Error("Excel 图片锚点所在行高无效");
|
|
87
|
+
return n;
|
|
88
88
|
};
|
|
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
|
|
89
|
+
for (; r < 0 && t > 1; ) r += i(--t);
|
|
90
|
+
for (; t <= 1048576 && r >= i(t); ) r -= i(t++);
|
|
91
|
+
if (t > 1048576 || r < 0) throw new Error("Excel 图片移动到工作表边界之外");
|
|
92
|
+
return { nativeRow: t - 1, nativeRowOff: Math.round(r * 25.4 / 72 * 36e3) };
|
|
93
|
+
}
|
|
94
|
+
function se(e, t, o) {
|
|
95
|
+
const r = V(t), i = /* @__PURE__ */ new Map();
|
|
96
|
+
return { write(a, n, s, l) {
|
|
97
|
+
if (![n.widthMm, n.heightMm, n.leftMm].every(Number.isFinite) || n.widthMm < 0 || n.heightMm < 0 || n.leftMm < 0) throw new Error("Excel 图片尺寸无效");
|
|
98
|
+
if (!n.widthMm || !n.heightMm) return s;
|
|
99
|
+
if (!n.imageData || !/^data:image\/(png|jpe?g);base64,/i.test(n.imageData))
|
|
100
|
+
return o.push(`${n.nid ?? n.kind}: Excel 图片仅支持 PNG/JPEG data URI,已跳过`), s;
|
|
101
|
+
const c = r(n.imageData);
|
|
102
102
|
let h = i.get(c.dataUrl);
|
|
103
103
|
h === void 0 && (h = e.addImage({ base64: c.dataUrl, extension: c.extension }), i.set(c.dataUrl, h));
|
|
104
|
-
const d = l ? s :
|
|
104
|
+
const d = l ? s : ie(a, s, n.heightMm);
|
|
105
105
|
return a.addImage(h, {
|
|
106
|
-
tl: { ...
|
|
107
|
-
ext: { width:
|
|
106
|
+
tl: { ...oe(a, l?.leftMm ?? n.leftMm, s), ...l ? ae(a, s, l.offsetMm) : {} },
|
|
107
|
+
ext: { width: n.widthMm * 96 / 25.4, height: n.heightMm * 96 / 25.4 },
|
|
108
108
|
editAs: "oneCell"
|
|
109
109
|
}), d;
|
|
110
110
|
} };
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function z(e) {
|
|
113
113
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function D(e, t) {
|
|
116
116
|
const o = e.meta?.xlsxFlow;
|
|
117
117
|
if (o === void 0) return;
|
|
118
|
-
if (!
|
|
118
|
+
if (!z(o) || o.version !== "1.0" || !Number.isSafeInteger(o.columnStart) || Number(o.columnStart) < 0) throw new Error("Excel 多区域几何标记无效,不能按列序猜测输出");
|
|
119
119
|
if (!e.grid) throw new Error("Excel 多区域输出只接受显式网格组件");
|
|
120
|
-
const
|
|
121
|
-
if (!i?.length ||
|
|
122
|
-
return
|
|
120
|
+
const r = o, i = e.grid.colWidthsMm;
|
|
121
|
+
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 多区域列位置与网格列宽不一致");
|
|
122
|
+
return r;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function N(e) {
|
|
125
125
|
const t = e.meta?.xlsxFlow;
|
|
126
126
|
if (t === void 0) {
|
|
127
|
-
if (e.components.some((
|
|
127
|
+
if (e.components.some((r) => r.meta?.xlsxFlow !== void 0)) throw new Error("Excel 多区域页面缺少完整列几何标记");
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
|
-
const o =
|
|
131
|
-
for (const
|
|
132
|
-
const i =
|
|
130
|
+
const o = le(t, e.meta?.reportScope);
|
|
131
|
+
for (const r of e.components) {
|
|
132
|
+
const i = D(r, o.widths);
|
|
133
133
|
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 -
|
|
134
|
+
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);
|
|
135
|
+
if (Math.abs(a - r.leftMm) > 0.01 || Math.abs(n - r.widthMm) > 0.01) throw new Error("Excel 多区域标记与真实横向位置不一致");
|
|
136
136
|
}
|
|
137
137
|
return o;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
if (!
|
|
139
|
+
function le(e, t) {
|
|
140
|
+
if (!z(e) || e.version !== "1.0" || typeof e.sheet != "string" || !e.sheet.trim() || typeof e.templateId != "string" || !e.templateId.trim()) throw new Error("Excel 多区域工作表标识无效");
|
|
141
141
|
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
142
|
if (t !== void 0 && (typeof t != "string" || !t.trim())) throw new Error("Excel 多区域报表命名空间无效");
|
|
143
143
|
return { key: JSON.stringify([t ?? e.templateId, e.sheet]), sheet: e.sheet, widths: e.fullWidthsMm };
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function S(e) {
|
|
146
146
|
return Math.round(e * 1e6) / 1e6;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
return e.components.filter((a) =>
|
|
148
|
+
function ce(e, t, o, r, i) {
|
|
149
|
+
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
150
|
}
|
|
151
|
-
function
|
|
152
|
-
const i = e.components.filter((
|
|
153
|
-
return t.map((
|
|
154
|
-
let s =
|
|
155
|
-
return o &&
|
|
151
|
+
function he(e, t, o, r) {
|
|
152
|
+
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);
|
|
153
|
+
return t.map((n) => {
|
|
154
|
+
let s = n.topMm;
|
|
155
|
+
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: T(n.grid, n.widthMm, n.heightMm), top: s, column: D(n, r).columnStart };
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
-
function
|
|
159
|
-
const
|
|
160
|
-
if (
|
|
161
|
-
const i = new Map(t.map((s, l) => [s, l])), a = /* @__PURE__ */ new Map(),
|
|
158
|
+
function de(e, t, o) {
|
|
159
|
+
const r = t.length - 1;
|
|
160
|
+
if (r * o.length > 1e6) throw new Error("Excel 多区域单页超过 100 万几何单元格,请减小预览分页高度或列数");
|
|
161
|
+
const i = new Map(t.map((s, l) => [s, l])), a = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
162
162
|
for (const s of e) for (const l of s.layout.cells) {
|
|
163
163
|
if (!Object.keys(l.cell).length) continue;
|
|
164
|
-
const c = i.get(
|
|
165
|
-
for (let g = c; g < h; g++) for (let
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
|
|
164
|
+
const c = i.get(S(s.top + l.yMm)), h = i.get(S(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 p = d; p < u; p++) {
|
|
166
|
+
const w = `${g}:${p}`;
|
|
167
|
+
if (n.has(w)) throw new Error("Excel 多区域实际单元格互相覆盖,已终止输出,未覆盖已有内容");
|
|
168
|
+
n.set(w, f);
|
|
169
169
|
}
|
|
170
|
-
a.set(f, { ...l.cell, style:
|
|
170
|
+
a.set(f, { ...l.cell, style: x(s.component.style, l.cell.style), rowSpan: h - c, colSpan: u - d });
|
|
171
171
|
}
|
|
172
|
-
return Array.from({ length:
|
|
172
|
+
return Array.from({ length: r }, (s, l) => {
|
|
173
173
|
const c = [];
|
|
174
174
|
for (let h = 0; h < o.length; h++) {
|
|
175
175
|
const d = `${l}:${h}`, u = a.get(d);
|
|
176
|
-
u ? (c.push(u), h += (u.colSpan ?? 1) - 1) :
|
|
176
|
+
u ? (c.push(u), h += (u.colSpan ?? 1) - 1) : n.has(d) || c.push(null);
|
|
177
177
|
}
|
|
178
178
|
return c;
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
|
-
function
|
|
182
|
-
const o = /* @__PURE__ */ new Set(),
|
|
181
|
+
function fe(e, t) {
|
|
182
|
+
const o = /* @__PURE__ */ new Set(), r = [];
|
|
183
183
|
let i;
|
|
184
|
-
for (const [a, { page:
|
|
185
|
-
const s =
|
|
184
|
+
for (const [a, { page: n }] of e.entries()) {
|
|
185
|
+
const s = N(n);
|
|
186
186
|
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
187
|
i ??= s;
|
|
188
|
-
const l =
|
|
188
|
+
const l = ce(n, a, e.length, t, o), c = he(n, l, t, s.widths);
|
|
189
189
|
if (!c.length) continue;
|
|
190
|
-
const h = [...new Set(c.flatMap((f) => [...f.layout.rows.map((g) =>
|
|
191
|
-
|
|
190
|
+
const h = [...new Set(c.flatMap((f) => [...f.layout.rows.map((g) => S(f.top + g.pos)), S(f.top + f.component.heightMm)]))].sort((f, g) => f - g), d = de(c, h, s.widths), u = h.slice(1).map((f, g) => f - h[g]);
|
|
191
|
+
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
192
|
}
|
|
193
|
-
return
|
|
193
|
+
return r;
|
|
194
194
|
}
|
|
195
|
-
const
|
|
196
|
-
function
|
|
195
|
+
const O = 72 / 25.4, ge = 32767, ue = 253;
|
|
196
|
+
function M(e, t) {
|
|
197
197
|
if (typeof e != "string") return;
|
|
198
|
-
if (e.length >
|
|
198
|
+
if (e.length > ge)
|
|
199
199
|
throw new Error(`Excel 单元格 ${t} 最多支持 32767 个字符,无法无损导出;内容未裁剪`);
|
|
200
200
|
let o = 0;
|
|
201
|
-
for (let
|
|
202
|
-
if (e.charCodeAt(
|
|
201
|
+
for (let r = 0; r < e.length; r++)
|
|
202
|
+
if (e.charCodeAt(r) === 10 && ++o > ue)
|
|
203
203
|
throw new Error(`Excel 单元格 ${t} 最多支持 253 个换行,无法无损导出;内容未改写`);
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function b(e) {
|
|
206
206
|
if (!e) return;
|
|
207
207
|
const t = e.replace("#", "");
|
|
208
208
|
return /^[0-9a-fA-F]{6}$/.test(t) ? `FF${t.toUpperCase()}` : void 0;
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function L(e, t = {}) {
|
|
211
211
|
e.font = {
|
|
212
212
|
name: t.fontFamily,
|
|
213
213
|
bold: t.bold === !0,
|
|
214
214
|
italic: t.italic === !0,
|
|
215
215
|
underline: t.underline === !0,
|
|
216
|
-
size:
|
|
217
|
-
color:
|
|
216
|
+
size: W(t).fontSizePt,
|
|
217
|
+
color: b(t.color) ? { argb: b(t.color) } : void 0
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
|
-
const
|
|
220
|
+
const y = {
|
|
221
221
|
a3: { width: 297, height: 420, code: 8 },
|
|
222
222
|
a4: { width: 210, height: 297, code: 9 },
|
|
223
223
|
a5: { width: 148, height: 210, code: 11 }
|
|
224
224
|
};
|
|
225
|
-
function
|
|
226
|
-
if (t && t !== "auto") return
|
|
227
|
-
const i = Math.min(e.pageWidthMm, e.pageHeightMm), a = Math.max(e.pageWidthMm, e.pageHeightMm),
|
|
228
|
-
return
|
|
225
|
+
function me(e, t, o, r) {
|
|
226
|
+
if (t && t !== "auto") return y[t].code;
|
|
227
|
+
const i = Math.min(e.pageWidthMm, e.pageHeightMm), a = Math.max(e.pageWidthMm, e.pageHeightMm), n = Object.values(y).find((s) => Math.abs(i - s.width) <= 1 && Math.abs(a - s.height) <= 1);
|
|
228
|
+
return n ? n.code : (r.push(`page ${o + 1}: 自定义纸张 ${e.pageWidthMm}×${e.pageHeightMm}mm 无对应 Excel 纸型,打印设置回退 A4;可显式配置 paperSize`), y.a4.code);
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function we(e, t, o, r) {
|
|
231
231
|
const i = typeof t.text == "string" ? t.text : "";
|
|
232
232
|
if (o !== "raw" || !Object.prototype.hasOwnProperty.call(t, "value")) {
|
|
233
|
-
|
|
233
|
+
M(i, e.address), e.value = i;
|
|
234
234
|
return;
|
|
235
235
|
}
|
|
236
236
|
const a = t.value;
|
|
237
237
|
if (a === null || typeof a == "string" || typeof a == "boolean" || typeof a == "number" && Number.isFinite(a)) {
|
|
238
|
-
|
|
238
|
+
M(a, e.address), e.value = a, t.numberFormat && (e.numFmt = t.numberFormat);
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
241
|
-
|
|
241
|
+
M(i, e.address), e.value = i, r.push(`原始单元格值无效,已保留显示文本:${e.address}`);
|
|
242
242
|
}
|
|
243
|
-
function
|
|
244
|
-
const t =
|
|
245
|
-
return t ? { id: `xlsx-flow:${t.key}`, title: t.sheet, wide: !0, flow: !0 } :
|
|
243
|
+
function pe(e) {
|
|
244
|
+
const t = N(e);
|
|
245
|
+
return t ? { id: `xlsx-flow:${t.key}`, title: t.sheet, wide: !0, flow: !0 } : xe(e);
|
|
246
246
|
}
|
|
247
|
-
function
|
|
248
|
-
const o = e.components.filter((
|
|
247
|
+
function xe(e) {
|
|
248
|
+
const o = e.components.filter((r) => r.table !== void 0)[0]?.table;
|
|
249
249
|
if (!(!o || typeof o.id != "string" || !o.id.trim() || !Array.isArray(o.columnKeys) || !o.columnKeys.length)) {
|
|
250
|
-
for (const
|
|
251
|
-
if (
|
|
252
|
-
if (!
|
|
250
|
+
for (const r of e.components) {
|
|
251
|
+
if (r.table) {
|
|
252
|
+
if (!r.grid || r.table.id !== o.id) return;
|
|
253
253
|
continue;
|
|
254
254
|
}
|
|
255
|
-
if (
|
|
255
|
+
if (r.grid || r.kind !== "text" && !C(r)) return;
|
|
256
256
|
}
|
|
257
257
|
return { id: o.id, title: o.title, wide: o.layout === "wide" || e.layout === "wide" };
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function Me(e, t) {
|
|
261
261
|
const o = /* @__PURE__ */ new Set();
|
|
262
|
-
for (const [
|
|
263
|
-
if (!t[
|
|
262
|
+
for (const [r, i] of e.pages.entries())
|
|
263
|
+
if (!t[r])
|
|
264
264
|
for (const a of i.components)
|
|
265
265
|
typeof a.table?.id == "string" && o.add(a.table.id);
|
|
266
266
|
return o;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function k(e) {
|
|
269
269
|
return e.layout === "wide" || e.components.some((t) => t.table?.layout === "wide");
|
|
270
270
|
}
|
|
271
|
-
function
|
|
272
|
-
const
|
|
273
|
-
for (const [
|
|
274
|
-
const l = i[
|
|
271
|
+
function Ee(e, t, o) {
|
|
272
|
+
const r = [], i = e.pages.map(pe), a = Me(e, i);
|
|
273
|
+
for (const [n, s] of e.pages.entries()) {
|
|
274
|
+
const l = i[n], c = l && !a.has(l.id), h = t === "pages" || !c ? void 0 : l;
|
|
275
275
|
if (t === "continuous" && !h)
|
|
276
|
-
throw new Error(`page ${
|
|
276
|
+
throw new Error(`page ${n + 1}: continuous Excel 需要完整、单一的逻辑表来源;自由布局请使用 sheetMode: 'pages'`);
|
|
277
277
|
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:
|
|
278
|
+
!d && t !== "pages" && k(s) && o.push(`page ${n + 1}: 混合或缺少逻辑表来源,已保留独立 Sheet,未猜测合并内容`);
|
|
279
|
+
const u = r[r.length - 1];
|
|
280
|
+
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
281
|
}
|
|
282
|
-
return
|
|
282
|
+
return r;
|
|
283
283
|
}
|
|
284
|
-
function
|
|
285
|
-
return !e || e.length === t.length && e.every((
|
|
284
|
+
function A(e, t, o) {
|
|
285
|
+
return !e || e.length === t.length && e.every((r, i) => o(r, t[i]));
|
|
286
286
|
}
|
|
287
|
-
function
|
|
288
|
-
const i = e.table, a = t.columns.map((l) => l.size),
|
|
289
|
-
if (i.columnKeys.length !== a.length || !
|
|
287
|
+
function be(e, t, o, r) {
|
|
288
|
+
const i = e.table, a = t.columns.map((l) => l.size), n = A(r.keys, i.columnKeys, (l, c) => l === c), s = A(r.widths, a, (l, c) => Math.abs(l - c) <= 1e-3);
|
|
289
|
+
if (i.columnKeys.length !== a.length || !n || !s)
|
|
290
290
|
throw new Error(`page ${o + 1}: 连续 Excel 逻辑表 ${i.id} 的列结构或列宽不一致`);
|
|
291
|
-
if (
|
|
291
|
+
if (r.keys ??= i.columnKeys, r.widths ??= a, i.role === "header") {
|
|
292
292
|
if (i.rowIndex !== -1) throw new Error(`page ${o + 1}: 连续 Excel 表头 rowIndex 必须为 -1`);
|
|
293
|
-
|
|
293
|
+
r.headerSeen = !0;
|
|
294
294
|
} else {
|
|
295
|
-
if (!["body", "group-header", "subtotal", "grand-total"].includes(i.role) || i.rowIndex !==
|
|
296
|
-
throw new Error(`page ${o + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${
|
|
297
|
-
|
|
295
|
+
if (!["body", "group-header", "subtotal", "grand-total"].includes(i.role) || i.rowIndex !== r.expectedRow)
|
|
296
|
+
throw new Error(`page ${o + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${r.expectedRow})`);
|
|
297
|
+
r.expectedRow += t.rows.length;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function ye(e, t) {
|
|
301
301
|
const o = { expectedRow: 0, headerSeen: !1 };
|
|
302
|
-
for (const { page:
|
|
303
|
-
for (const a of
|
|
304
|
-
const
|
|
305
|
-
a.table &&
|
|
302
|
+
for (const { page: r, index: i } of e.pages)
|
|
303
|
+
for (const a of r.components) {
|
|
304
|
+
const n = t.get(a);
|
|
305
|
+
a.table && n && be(a, n, i, o);
|
|
306
306
|
}
|
|
307
307
|
if (!o.headerSeen) throw new Error("连续 Excel 逻辑表缺少明确表头来源");
|
|
308
308
|
}
|
|
309
|
-
function
|
|
310
|
-
let
|
|
311
|
-
|
|
312
|
-
let i =
|
|
309
|
+
function Se(e, t, o) {
|
|
310
|
+
let r = (e?.replace(/[\\/*?:[\]]/g, " ").replace(/\s+/g, " ").trim() || `Sheet${t + 1}`).slice(0, 31).replace(/^'+|'+$/g, "").trim() || `Sheet${t + 1}`;
|
|
311
|
+
r.toLowerCase() === "history" && (r += " 报表");
|
|
312
|
+
let i = r, a = 1;
|
|
313
313
|
for (; o.has(i.toLowerCase()); ) {
|
|
314
|
-
const
|
|
315
|
-
i =
|
|
314
|
+
const n = ` (${++a})`;
|
|
315
|
+
i = r.slice(0, 31 - n.length) + n;
|
|
316
316
|
}
|
|
317
317
|
return o.add(i.toLowerCase()), i;
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function ve(e) {
|
|
320
320
|
const t = /* @__PURE__ */ new Set();
|
|
321
|
-
function o(
|
|
322
|
-
return
|
|
321
|
+
function o(r, i, a, n) {
|
|
322
|
+
return r <= i ? r : (t.has(a) || (e.push(n), t.add(a)), i);
|
|
323
323
|
}
|
|
324
324
|
return {
|
|
325
|
-
column: (
|
|
326
|
-
row: (
|
|
325
|
+
column: (r) => o(r, 255, "column", "Excel 单列宽度上限为 255 字符,超宽列已收敛至 255;单元格值完整保留,显示范围可能受限"),
|
|
326
|
+
row: (r) => o(r, 409, "row", "Excel 行高上限为 409pt,超高行已收敛至 409pt;单元格值完整保留,显示范围可能受限")
|
|
327
327
|
};
|
|
328
328
|
}
|
|
329
|
-
async function
|
|
330
|
-
const o = e.flow ?
|
|
329
|
+
async function Ce(e, t) {
|
|
330
|
+
const o = e.flow ? fe(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
331
|
let i = 1, a = 0;
|
|
332
|
-
for (const { comp:
|
|
333
|
-
if (
|
|
334
|
-
const s =
|
|
335
|
-
|
|
332
|
+
for (const { comp: n } of o)
|
|
333
|
+
if (n.grid) {
|
|
334
|
+
const s = T(n.grid, n.widthMm, n.heightMm);
|
|
335
|
+
r.set(n, s), i = Math.max(i, s.columns.length);
|
|
336
336
|
const l = t(s.cells.length);
|
|
337
337
|
l && await l;
|
|
338
|
-
} else
|
|
338
|
+
} else n.kind === "text" && (a = Math.max(a, n.widthMm));
|
|
339
339
|
if (i > 16384) throw new Error("Excel 最多支持 16384 列,无法无损导出此报表");
|
|
340
|
-
return { components: o, grids:
|
|
340
|
+
return { components: o, grids: r, columnCount: i, textWidthMm: a };
|
|
341
341
|
}
|
|
342
|
-
function
|
|
343
|
-
const { page:
|
|
344
|
-
return (e.continuous ||
|
|
345
|
-
paperSize:
|
|
346
|
-
orientation:
|
|
342
|
+
function ke(e, t, o) {
|
|
343
|
+
const { page: r, index: i } = e.pages[0], a = t !== void 0 && t !== "auto";
|
|
344
|
+
return (e.continuous || k(r)) && !a ? {} : { pageSetup: {
|
|
345
|
+
paperSize: me(r, t, i, o),
|
|
346
|
+
orientation: r.pageWidthMm > r.pageHeightMm ? "landscape" : "portrait",
|
|
347
347
|
fitToPage: !0,
|
|
348
348
|
...e.continuous ? { fitToWidth: 1, fitToHeight: 0 } : {}
|
|
349
349
|
} };
|
|
350
350
|
}
|
|
351
|
-
function
|
|
352
|
-
const t =
|
|
351
|
+
function Be(e) {
|
|
352
|
+
const t = b(e.borderColor ?? e.lineColor), o = { style: "thin", ...t ? { color: { argb: t } } : {} };
|
|
353
353
|
return {
|
|
354
354
|
...e.borderTop !== !1 ? { top: o } : {},
|
|
355
355
|
...e.borderLeft !== !1 ? { left: o } : {},
|
|
@@ -357,127 +357,152 @@ function ye(e) {
|
|
|
357
357
|
...e.borderRight !== !1 ? { right: o } : {}
|
|
358
358
|
};
|
|
359
359
|
}
|
|
360
|
-
function
|
|
360
|
+
function $e(e, t) {
|
|
361
361
|
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 =
|
|
362
|
+
const o = b(t.backgroundColor);
|
|
363
|
+
o && (e.fill = { type: "pattern", pattern: "solid", fgColor: { argb: o } }), e.border = Be(t), L(e, t);
|
|
364
364
|
}
|
|
365
|
-
function
|
|
366
|
-
for (const [o,
|
|
367
|
-
const i = e.sheet.getColumn(o + 1), a = e.limits.column(F(
|
|
365
|
+
function Pe(e, t) {
|
|
366
|
+
for (const [o, r] of t.columns.entries()) {
|
|
367
|
+
const i = e.sheet.getColumn(o + 1), a = e.limits.column(F(r.size));
|
|
368
368
|
(i.width == null || i.width < a) && (i.width = a);
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
|
-
function
|
|
372
|
-
for (const [
|
|
373
|
-
const a = e.sheet.getRow(o +
|
|
374
|
-
(a.height == null || a.height <
|
|
371
|
+
function Ae(e, t, o) {
|
|
372
|
+
for (const [r, i] of t.rows.entries()) {
|
|
373
|
+
const a = e.sheet.getRow(o + r), n = e.limits.row(i.size * O);
|
|
374
|
+
(a.height == null || a.height < n) && (a.height = n);
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
function
|
|
377
|
+
function We(e, t, o, r) {
|
|
378
378
|
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(
|
|
379
|
+
(i > 1 || a > 1) && e.mergeCells(r + t.ri, t.ci + 1, r + t.ri + a - 1, t.ci + i);
|
|
380
380
|
}
|
|
381
|
-
async function
|
|
382
|
-
if (
|
|
383
|
-
|
|
381
|
+
async function Te(e, t, o, r) {
|
|
382
|
+
if (r + o.rows.length - 1 > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
|
|
383
|
+
Ae(e, o, r);
|
|
384
384
|
for (const i of o.cells) {
|
|
385
|
-
const a = e.sheet.getCell(
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
|
|
385
|
+
const a = e.sheet.getCell(r + i.ri, i.ci + 1);
|
|
386
|
+
we(a, i.cell, e.valueMode, e.warnings);
|
|
387
|
+
const n = re(i.cell, t.style);
|
|
388
|
+
n && (M(n.richText.map((c) => c.text).join(""), a.address), a.value = n);
|
|
389
389
|
const s = t.grid?.paddingMm ?? 0.5;
|
|
390
|
-
e.dataBars(e.sheet, i,
|
|
390
|
+
e.dataBars(e.sheet, i, r + i.ri, s);
|
|
391
391
|
for (const c of i.cell.children ?? [])
|
|
392
|
-
|
|
393
|
-
|
|
392
|
+
C(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 });
|
|
393
|
+
$e(a, x(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))) }), We(e.sheet, i, o, r);
|
|
394
394
|
const l = e.schedule();
|
|
395
395
|
l && await l;
|
|
396
396
|
}
|
|
397
|
-
return
|
|
397
|
+
return r + o.rows.length;
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function Re(e, t, o, r) {
|
|
400
400
|
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 && (
|
|
401
|
+
`) : t.text ?? "", a = e.sheet.getRow(o), n = a.getCell(1);
|
|
402
|
+
t.richParagraphs?.length || M(i, n.address), n.value = t.richParagraphs?.length ? I(t.richParagraphs, t.style) : i, typeof n.value == "object" && n.value && "richText" in n.value && M(n.value.richText.map((l) => l.text).join(""), n.address), n.alignment = { horizontal: t.style?.align ?? "left", vertical: t.style?.verticalAlign ?? "middle", wrapText: !0 };
|
|
403
|
+
const s = b(t.style?.backgroundColor);
|
|
404
|
+
return s && (n.fill = { type: "pattern", pattern: "solid", fgColor: { argb: s } }), L(n, t.style), r > 1 && e.sheet.mergeCells(o, 1, o, r), a.height = e.limits.row(t.heightMm * O), o + 1;
|
|
405
405
|
}
|
|
406
|
-
function
|
|
407
|
-
const
|
|
408
|
-
e.views = [{ state: "frozen", ySplit:
|
|
406
|
+
function Fe(e, t, o) {
|
|
407
|
+
const r = t + o - 1;
|
|
408
|
+
e.views = [{ state: "frozen", ySplit: r, xSplit: 0 }], e.pageSetup.printTitlesRow = `1:${r}`;
|
|
409
409
|
}
|
|
410
|
-
async function
|
|
410
|
+
async function Ie(e, t, o, r) {
|
|
411
411
|
!t.grids.size && t.textWidthMm > 0 && (e.sheet.getColumn(1).width = e.limits.column(F(t.textWidthMm)));
|
|
412
|
-
for (const
|
|
413
|
-
|
|
414
|
-
const s = e.schedule(
|
|
412
|
+
for (const n of t.grids.values()) {
|
|
413
|
+
Pe(e, n);
|
|
414
|
+
const s = e.schedule(n.columns.length);
|
|
415
415
|
s && await s;
|
|
416
416
|
}
|
|
417
417
|
let i = 1, a = !1;
|
|
418
|
-
for (const { comp:
|
|
419
|
-
const l = o &&
|
|
418
|
+
for (const { comp: n, pageIndex: s } of t.components) {
|
|
419
|
+
const l = o && n.table?.role === "header";
|
|
420
420
|
if (l && a) continue;
|
|
421
421
|
if (i > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
|
|
422
|
-
const c = t.grids.get(
|
|
422
|
+
const c = t.grids.get(n);
|
|
423
423
|
if (c)
|
|
424
|
-
l && (
|
|
425
|
-
else if (
|
|
426
|
-
i =
|
|
427
|
-
else if (
|
|
428
|
-
const h =
|
|
424
|
+
l && (Fe(e.sheet, i, c.rows.length), a = !0), i = await Te(e, n, c, i);
|
|
425
|
+
else if (n.kind === "text")
|
|
426
|
+
i = Re(e, n, i, t.columnCount);
|
|
427
|
+
else if (C(n)) {
|
|
428
|
+
const h = J(n, o), d = r.write(e.sheet, n, h?.row ?? i, h);
|
|
429
429
|
h || (i = d);
|
|
430
430
|
} else
|
|
431
|
-
e.warnings.push(`page ${s + 1} ${
|
|
431
|
+
e.warnings.push(`page ${s + 1} ${n.nid ?? n.kind}: 组件类型 ${n.kind} 暂不支持 xlsx 导出,已跳过`);
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
-
function
|
|
434
|
+
function ze(e) {
|
|
435
435
|
if (e.maxDataBars !== void 0 && (!Number.isSafeInteger(e.maxDataBars) || e.maxDataBars < 0 || e.maxDataBars > 1e5)) throw new Error("xlsx maxDataBars 必须是 0–100000 的整数");
|
|
436
436
|
if (e.valueMode !== void 0 && e.valueMode !== "text" && e.valueMode !== "raw")
|
|
437
437
|
throw new Error("xlsx valueMode 必须是 text 或 raw");
|
|
438
|
-
if (e.paperSize !== void 0 && e.paperSize !== "auto" && !Object.prototype.hasOwnProperty.call(
|
|
438
|
+
if (e.paperSize !== void 0 && e.paperSize !== "auto" && !Object.prototype.hasOwnProperty.call(y, e.paperSize))
|
|
439
439
|
throw new Error("xlsx paperSize 必须是 auto、a3、a4 或 a5");
|
|
440
440
|
if (e.sheetMode !== void 0 && !["auto", "pages", "continuous"].includes(e.sheetMode))
|
|
441
441
|
throw new Error("xlsx sheetMode 必须是 auto、pages 或 continuous");
|
|
442
442
|
}
|
|
443
|
-
async function
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
443
|
+
async function De(e, t = {}) {
|
|
444
|
+
const o = Y(t.additionalSheets), r = Z(t.sheetNames);
|
|
445
|
+
ze(t), E(t.signal);
|
|
446
|
+
const i = t.assetRegistry || t.assetRenderers ? await Q(e, { ...t, format: "xlsx" }) : { plan: e, diagnostics: [] };
|
|
447
|
+
e = i.plan;
|
|
448
|
+
const a = [...i.diagnostics, ...q(e, "xlsx", t)];
|
|
449
|
+
await ne(e, t.maxDataBars ?? 1e4, t);
|
|
450
|
+
const n = new K.Workbook(), s = [], l = se(n, t, s), c = [], h = te(l, t.maxDataBars ?? 1e4, c), d = ve(s), u = Ee(e, t.sheetMode, s), f = u.length + (o?.length ?? 0), g = /* @__PURE__ */ new Set(), p = v(t);
|
|
451
|
+
for (const [w, m] of u.entries()) {
|
|
452
|
+
const B = await Ce(m, p);
|
|
453
|
+
m.continuous && !m.flow && ye(m, B.grids);
|
|
454
|
+
const j = m.pages[0].page, $ = r?.[w] ?? t.sheetName?.(w) ?? Se(m.title, w, g);
|
|
455
|
+
g.add($.toLowerCase());
|
|
456
|
+
const G = n.addWorksheet($, ke(m, t.paperSize, s)), H = t.valueMode ?? (k(j) || m.continuous || m.flow ? "raw" : "text");
|
|
457
|
+
E(t.signal), await Ie({ sheet: G, warnings: s, limits: d, valueMode: H, schedule: p, images: l, dataBars: h }, B, m.continuous, l), await R(t, w + 1, f);
|
|
457
458
|
}
|
|
459
|
+
return await Ne(n, o, t, u.length, f), { workbook: n, warnings: s, diagnostics: a, ...c.length ? { notes: c } : {} };
|
|
460
|
+
}
|
|
461
|
+
async function Ne(e, t = [], o, r, i) {
|
|
462
|
+
const a = v(o);
|
|
463
|
+
for (const n of t) {
|
|
464
|
+
if (E(o.signal), e.worksheets.some((l) => l.name.toLowerCase() === n.name.toLowerCase())) throw new TypeError(`附加工作表名称已被报表使用 ${n.name}`);
|
|
465
|
+
const s = e.addWorksheet(n.name);
|
|
466
|
+
n.columnWidths && (s.columns = n.columnWidths.map((l) => ({ width: l })));
|
|
467
|
+
for (const l of n.rows) {
|
|
468
|
+
const c = s.addRow([...l]);
|
|
469
|
+
c.alignment = { vertical: "top", wrapText: !0 };
|
|
470
|
+
const h = a(l.length);
|
|
471
|
+
h && await h;
|
|
472
|
+
}
|
|
473
|
+
await R(o, ++r, i);
|
|
474
|
+
}
|
|
475
|
+
E(o.signal);
|
|
476
|
+
}
|
|
477
|
+
async function Ke(e, t = {}) {
|
|
478
|
+
let o = 1;
|
|
479
|
+
const r = t.onProgress ? (n, s) => {
|
|
480
|
+
o = s + 1, P(t, n, o);
|
|
481
|
+
} : void 0, i = await De(e, { ...t, onProgress: r });
|
|
458
482
|
E(t.signal);
|
|
459
|
-
const
|
|
460
|
-
return E(t.signal),
|
|
483
|
+
const a = await i.workbook.xlsx.writeBuffer();
|
|
484
|
+
return E(t.signal), P(t, o, o), { ...i, buffer: a };
|
|
461
485
|
}
|
|
462
486
|
export {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
487
|
+
et as bindExcelTemplate,
|
|
488
|
+
tt as createExcelBindingDocument,
|
|
489
|
+
nt as createExcelBindingSession,
|
|
490
|
+
rt as createExcelRegionBindingDocument,
|
|
491
|
+
it as createExcelRegionBindingSession,
|
|
492
|
+
ot as excelBindingCellRange,
|
|
493
|
+
at as excelBindingRowRange,
|
|
494
|
+
st as getExcelSheetWindow,
|
|
495
|
+
qe as importExcelTemplate,
|
|
496
|
+
Qe as inspectExcelWorkbook,
|
|
497
|
+
Ye as openExcelWorkbook,
|
|
498
|
+
lt as parseExcelBindingSession,
|
|
499
|
+
ct as parseExcelRegionBindingSession,
|
|
500
|
+
De as renderPlanToWorkbook,
|
|
501
|
+
Ke as renderPlanToXlsx,
|
|
502
|
+
ht as validateExcelBindingFields,
|
|
503
|
+
dt as validateExcelBindingRecipe,
|
|
504
|
+
ft as validateExcelBindingRegions,
|
|
505
|
+
gt as validateExcelRegionBindings,
|
|
506
|
+
ut as validateExcelRegionFields,
|
|
507
|
+
mt as validateExcelRegionGeometry
|
|
483
508
|
};
|