@office-view-suite/viewer-excel 0.0.0-stage → 0.2.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/dist/LICENSE +201 -0
- package/dist/THIRD_PARTY_NOTICES.md +102 -0
- package/dist/asset-manifest.json +18 -0
- package/dist/assets/excel/excel_view_rs_bg.wasm +0 -0
- package/dist/assets/excel/worker.js +1 -0
- package/dist/index.js +588 -0
- package/dist/licenses/aes-0.9.3/LICENSE-APACHE +201 -0
- package/dist/licenses/aes-0.9.3/LICENSE-MIT +26 -0
- package/dist/licenses/aho-corasick-1.1.5/COPYING +3 -0
- package/dist/licenses/aho-corasick-1.1.5/LICENSE-MIT +21 -0
- package/dist/licenses/autocfg-1.5.1/LICENSE-APACHE +201 -0
- package/dist/licenses/autocfg-1.5.1/LICENSE-MIT +25 -0
- package/dist/licenses/base64-0.22.1/LICENSE-APACHE +201 -0
- package/dist/licenses/base64-0.22.1/LICENSE-MIT +21 -0
- package/dist/licenses/bit-set-0.8.0/LICENSE-APACHE +201 -0
- package/dist/licenses/bit-set-0.8.0/LICENSE-MIT +25 -0
- package/dist/licenses/bit-vec-0.8.0/LICENSE-APACHE +201 -0
- package/dist/licenses/bit-vec-0.8.0/LICENSE-MIT +25 -0
- package/dist/licenses/bitflags-1.3.2/LICENSE-APACHE +201 -0
- package/dist/licenses/bitflags-1.3.2/LICENSE-MIT +25 -0
- package/dist/licenses/block-buffer-0.12.1/LICENSE-APACHE +201 -0
- package/dist/licenses/block-buffer-0.12.1/LICENSE-MIT +25 -0
- package/dist/licenses/block-padding-0.4.2/LICENSE-APACHE +201 -0
- package/dist/licenses/block-padding-0.4.2/LICENSE-MIT +25 -0
- package/dist/licenses/bumpalo-3.20.3/LICENSE-APACHE +201 -0
- package/dist/licenses/bumpalo-3.20.3/LICENSE-MIT +25 -0
- package/dist/licenses/bytemuck-1.25.2/LICENSE-APACHE +61 -0
- package/dist/licenses/bytemuck-1.25.2/LICENSE-MIT +9 -0
- package/dist/licenses/bytemuck-1.25.2/LICENSE-ZLIB +11 -0
- package/dist/licenses/byteorder-1.5.0/COPYING +3 -0
- package/dist/licenses/byteorder-1.5.0/LICENSE-MIT +21 -0
- package/dist/licenses/cbc-0.2.1/LICENSE-APACHE +201 -0
- package/dist/licenses/cbc-0.2.1/LICENSE-MIT +26 -0
- package/dist/licenses/cfb-0.14.0/LICENSE +21 -0
- package/dist/licenses/cfg-if-1.0.5/LICENSE-APACHE +201 -0
- package/dist/licenses/cfg-if-1.0.5/LICENSE-MIT +25 -0
- package/dist/licenses/chacha20-0.10.2/LICENSE-APACHE +201 -0
- package/dist/licenses/chacha20-0.10.2/LICENSE-MIT +25 -0
- package/dist/licenses/chrono-0.4.45/LICENSE.txt +240 -0
- package/dist/licenses/cipher-0.5.2/LICENSE-APACHE +201 -0
- package/dist/licenses/cipher-0.5.2/LICENSE-MIT +25 -0
- package/dist/licenses/cmov-0.5.4/LICENSE-APACHE +202 -0
- package/dist/licenses/cmov-0.5.4/LICENSE-MIT +25 -0
- package/dist/licenses/console_error_panic_hook-0.1.7/LICENSE-APACHE +201 -0
- package/dist/licenses/console_error_panic_hook-0.1.7/LICENSE-MIT +25 -0
- package/dist/licenses/const-oid-0.10.2/LICENSE-APACHE +201 -0
- package/dist/licenses/const-oid-0.10.2/LICENSE-MIT +25 -0
- package/dist/licenses/cpubits-0.1.1/LICENSE-APACHE +201 -0
- package/dist/licenses/cpubits-0.1.1/LICENSE-MIT +25 -0
- package/dist/licenses/crc32fast-1.5.2/LICENSE-APACHE +202 -0
- package/dist/licenses/crc32fast-1.5.2/LICENSE-MIT +21 -0
- package/dist/licenses/crypto-common-0.2.2/LICENSE-APACHE +201 -0
- package/dist/licenses/crypto-common-0.2.2/LICENSE-MIT +25 -0
- package/dist/licenses/ctutils-0.4.3/LICENSE-APACHE +202 -0
- package/dist/licenses/ctutils-0.4.3/LICENSE-MIT +25 -0
- package/dist/licenses/defmt-1.1.1/LICENSE-APACHE +201 -0
- package/dist/licenses/defmt-1.1.1/LICENSE-MIT +25 -0
- package/dist/licenses/defmt-macros-1.1.1/LICENSE-APACHE +201 -0
- package/dist/licenses/defmt-macros-1.1.1/LICENSE-MIT +25 -0
- package/dist/licenses/digest-0.11.3/LICENSE-APACHE +201 -0
- package/dist/licenses/digest-0.11.3/LICENSE-MIT +26 -0
- package/dist/licenses/encoding_rs-0.8.42/LICENSE-APACHE +202 -0
- package/dist/licenses/encoding_rs-0.8.42/LICENSE-MIT +25 -0
- package/dist/licenses/encoding_rs-0.8.42/LICENSE-WHATWG +26 -0
- package/dist/licenses/equivalent-1.0.3/LICENSE-APACHE +201 -0
- package/dist/licenses/equivalent-1.0.3/LICENSE-MIT +25 -0
- package/dist/licenses/fancy-regex-0.18.0/LICENSE +21 -0
- package/dist/licenses/fastrand-2.5.0/LICENSE-APACHE +201 -0
- package/dist/licenses/fastrand-2.5.0/LICENSE-MIT +23 -0
- package/dist/licenses/flate2-1.1.10/LICENSE-APACHE +201 -0
- package/dist/licenses/flate2-1.1.10/LICENSE-MIT +25 -0
- package/dist/licenses/fnv-1.0.7/LICENSE-APACHE +201 -0
- package/dist/licenses/fnv-1.0.7/LICENSE-MIT +25 -0
- package/dist/licenses/futures-core-0.3.34/LICENSE-APACHE +202 -0
- package/dist/licenses/futures-core-0.3.34/LICENSE-MIT +26 -0
- package/dist/licenses/futures-task-0.3.34/LICENSE-APACHE +202 -0
- package/dist/licenses/futures-task-0.3.34/LICENSE-MIT +26 -0
- package/dist/licenses/futures-util-0.3.34/LICENSE-APACHE +202 -0
- package/dist/licenses/futures-util-0.3.34/LICENSE-MIT +26 -0
- package/dist/licenses/getrandom-0.4.3/LICENSE-APACHE +201 -0
- package/dist/licenses/getrandom-0.4.3/LICENSE-MIT +26 -0
- package/dist/licenses/hashbrown-0.17.1/LICENSE-APACHE +201 -0
- package/dist/licenses/hashbrown-0.17.1/LICENSE-MIT +25 -0
- package/dist/licenses/hmac-0.13.0/LICENSE-APACHE +201 -0
- package/dist/licenses/hmac-0.13.0/LICENSE-MIT +25 -0
- package/dist/licenses/html5gum-0.8.4/LICENSE +19 -0
- package/dist/licenses/hybrid-array-0.4.15/LICENSE-APACHE +201 -0
- package/dist/licenses/hybrid-array-0.4.15/LICENSE-MIT +25 -0
- package/dist/licenses/imagesize-0.14.0/LICENSE +21 -0
- package/dist/licenses/indexmap-2.14.2/LICENSE-APACHE +201 -0
- package/dist/licenses/indexmap-2.14.2/LICENSE-MIT +25 -0
- package/dist/licenses/inout-0.2.3/LICENSE-APACHE +201 -0
- package/dist/licenses/inout-0.2.3/LICENSE-MIT +26 -0
- package/dist/licenses/jetscii-0.5.3/LICENSE-APACHE +201 -0
- package/dist/licenses/jetscii-0.5.3/LICENSE-MIT +25 -0
- package/dist/licenses/jiff-0.2.38/COPYING +3 -0
- package/dist/licenses/jiff-0.2.38/LICENSE-MIT +21 -0
- package/dist/licenses/jiff-core-0.1.1/COPYING +3 -0
- package/dist/licenses/jiff-core-0.1.1/LICENSE-MIT +21 -0
- package/dist/licenses/js-sys-0.3.106/LICENSE-APACHE +201 -0
- package/dist/licenses/js-sys-0.3.106/LICENSE-MIT +25 -0
- package/dist/licenses/log-0.4.34/LICENSE-APACHE +201 -0
- package/dist/licenses/log-0.4.34/LICENSE-MIT +25 -0
- package/dist/licenses/md-5-0.11.0/LICENSE-APACHE +201 -0
- package/dist/licenses/md-5-0.11.0/LICENSE-MIT +28 -0
- package/dist/licenses/memchr-2.8.3/COPYING +3 -0
- package/dist/licenses/memchr-2.8.3/LICENSE-MIT +21 -0
- package/dist/licenses/multiversion_no_op-1.0.0/LICENSE-APACHE +202 -0
- package/dist/licenses/multiversion_no_op-1.0.0/LICENSE-MIT +25 -0
- package/dist/licenses/num-traits-0.2.19/LICENSE-APACHE +201 -0
- package/dist/licenses/num-traits-0.2.19/LICENSE-MIT +25 -0
- package/dist/licenses/once_cell-1.21.4/LICENSE-APACHE +201 -0
- package/dist/licenses/once_cell-1.21.4/LICENSE-MIT +23 -0
- package/dist/licenses/phf-0.14.0/LICENSE +20 -0
- package/dist/licenses/phf_generator-0.14.0/LICENSE +20 -0
- package/dist/licenses/phf_macros-0.14.0/LICENSE +20 -0
- package/dist/licenses/phf_shared-0.14.0/LICENSE +20 -0
- package/dist/licenses/pin-project-lite-0.2.17/LICENSE-APACHE +177 -0
- package/dist/licenses/pin-project-lite-0.2.17/LICENSE-MIT +23 -0
- package/dist/licenses/proc-macro2-1.0.107/LICENSE-APACHE +176 -0
- package/dist/licenses/proc-macro2-1.0.107/LICENSE-MIT +23 -0
- package/dist/licenses/quick-xml-0.41.0/LICENSE-MIT.md +23 -0
- package/dist/licenses/quote-1.0.47/LICENSE-APACHE +176 -0
- package/dist/licenses/quote-1.0.47/LICENSE-MIT +23 -0
- package/dist/licenses/rand-0.10.3/LICENSE-APACHE +176 -0
- package/dist/licenses/rand-0.10.3/LICENSE-MIT +26 -0
- package/dist/licenses/rand_core-0.10.1/LICENSE-APACHE +187 -0
- package/dist/licenses/rand_core-0.10.1/LICENSE-MIT +25 -0
- package/dist/licenses/regex-automata-0.4.18/LICENSE-APACHE +201 -0
- package/dist/licenses/regex-automata-0.4.18/LICENSE-MIT +25 -0
- package/dist/licenses/regex-syntax-0.8.11/LICENSE-APACHE +201 -0
- package/dist/licenses/regex-syntax-0.8.11/LICENSE-MIT +25 -0
- package/dist/licenses/rgb-0.8.53/LICENSE +21 -0
- package/dist/licenses/rustversion-1.0.23/LICENSE-APACHE +176 -0
- package/dist/licenses/rustversion-1.0.23/LICENSE-MIT +23 -0
- package/dist/licenses/scopeguard-1.2.0/LICENSE-APACHE +201 -0
- package/dist/licenses/scopeguard-1.2.0/LICENSE-MIT +25 -0
- package/dist/licenses/serde-1.0.229/LICENSE-APACHE +176 -0
- package/dist/licenses/serde-1.0.229/LICENSE-MIT +23 -0
- package/dist/licenses/serde-wasm-bindgen-0.6.5/LICENSE +21 -0
- package/dist/licenses/serde_core-1.0.229/LICENSE-APACHE +176 -0
- package/dist/licenses/serde_core-1.0.229/LICENSE-MIT +23 -0
- package/dist/licenses/serde_derive-1.0.229/LICENSE-APACHE +176 -0
- package/dist/licenses/serde_derive-1.0.229/LICENSE-MIT +23 -0
- package/dist/licenses/sha2-0.11.1/LICENSE-APACHE +201 -0
- package/dist/licenses/sha2-0.11.1/LICENSE-MIT +28 -0
- package/dist/licenses/simd-adler32-0.3.10/LICENSE.md +21 -0
- package/dist/licenses/siphasher-1.0.4/COPYING +7 -0
- package/dist/licenses/siphasher-1.0.4/LICENSE-APACHE +202 -0
- package/dist/licenses/siphasher-1.0.4/LICENSE-MIT +17 -0
- package/dist/licenses/slab-0.4.12/LICENSE +25 -0
- package/dist/licenses/syn-2.0.119/LICENSE-APACHE +176 -0
- package/dist/licenses/syn-2.0.119/LICENSE-MIT +23 -0
- package/dist/licenses/syn-3.0.9/LICENSE-APACHE +176 -0
- package/dist/licenses/syn-3.0.9/LICENSE-MIT +23 -0
- package/dist/licenses/thiserror-2.0.21/LICENSE-APACHE +176 -0
- package/dist/licenses/thiserror-2.0.21/LICENSE-MIT +23 -0
- package/dist/licenses/thiserror-impl-2.0.21/LICENSE-APACHE +176 -0
- package/dist/licenses/thiserror-impl-2.0.21/LICENSE-MIT +23 -0
- package/dist/licenses/thousands-0.2.0/LICENSE-APACHE +201 -0
- package/dist/licenses/thousands-0.2.0/LICENSE-MIT +25 -0
- package/dist/licenses/typed-path-0.12.3/LICENSE-APACHE +176 -0
- package/dist/licenses/typed-path-0.12.3/LICENSE-MIT +23 -0
- package/dist/licenses/typenum-1.20.1/LICENSE +1 -0
- package/dist/licenses/typenum-1.20.1/LICENSE-APACHE +201 -0
- package/dist/licenses/typenum-1.20.1/LICENSE-MIT +21 -0
- package/dist/licenses/umya-spreadsheet-3.1.1/LICENSE +21 -0
- package/dist/licenses/unicode-ident-1.0.27/LICENSE-APACHE +176 -0
- package/dist/licenses/unicode-ident-1.0.27/LICENSE-MIT +23 -0
- package/dist/licenses/unicode-ident-1.0.27/LICENSE-UNICODE +39 -0
- package/dist/licenses/uuid-1.28.0/LICENSE-APACHE +201 -0
- package/dist/licenses/uuid-1.28.0/LICENSE-MIT +26 -0
- package/dist/licenses/wasm-bindgen-0.2.129/LICENSE-APACHE +201 -0
- package/dist/licenses/wasm-bindgen-0.2.129/LICENSE-MIT +25 -0
- package/dist/licenses/wasm-bindgen-macro-0.2.129/LICENSE-APACHE +201 -0
- package/dist/licenses/wasm-bindgen-macro-0.2.129/LICENSE-MIT +25 -0
- package/dist/licenses/wasm-bindgen-macro-support-0.2.129/LICENSE-APACHE +201 -0
- package/dist/licenses/wasm-bindgen-macro-support-0.2.129/LICENSE-MIT +25 -0
- package/dist/licenses/wasm-bindgen-shared-0.2.129/LICENSE-APACHE +201 -0
- package/dist/licenses/wasm-bindgen-shared-0.2.129/LICENSE-MIT +25 -0
- package/dist/licenses/web-time-1.1.0/LICENSE-APACHE +201 -0
- package/dist/licenses/web-time-1.1.0/LICENSE-MIT +21 -0
- package/dist/licenses/zip-8.6.0/LICENSE +21 -0
- package/dist/licenses/zlib-rs-0.6.8/LICENSE +19 -0
- package/dist/licenses/zopfli-0.8.4/COPYING +201 -0
- package/dist/types/core/format.d.ts +6 -0
- package/dist/types/core/layout.d.ts +37 -0
- package/dist/types/core/render.d.ts +20 -0
- package/dist/types/core/styles.d.ts +2 -0
- package/dist/types/core/types.d.ts +83 -0
- package/dist/types/core/virtual.d.ts +38 -0
- package/dist/types/index.d.ts +22 -0
- package/package.json +30 -3
- package/README.md +0 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
import { createWorkerAdapter as wt, createOfficeViewerError as xt } from "@office-view-suite/viewer-core";
|
|
2
|
+
const ut = Date.UTC(1899, 11, 30);
|
|
3
|
+
function yt(t) {
|
|
4
|
+
return new Date(ut + t * 864e5);
|
|
5
|
+
}
|
|
6
|
+
function K(t) {
|
|
7
|
+
const e = t.split(";")[0].match(/\.([0#]+)/);
|
|
8
|
+
return e ? e[1].length : 0;
|
|
9
|
+
}
|
|
10
|
+
function dt(t, e) {
|
|
11
|
+
if (!e) return t;
|
|
12
|
+
const n = e.split(";")[0].replace(/\\(.)/g, "$1");
|
|
13
|
+
if (n.includes("@")) return t;
|
|
14
|
+
const r = Number(t), i = t.trim() !== "" && !Number.isNaN(r);
|
|
15
|
+
if (/yyyy|mm|dd|hh|ss/i.test(n) && i) {
|
|
16
|
+
const s = yt(r);
|
|
17
|
+
if (!Number.isNaN(s.getTime())) {
|
|
18
|
+
const f = (w) => String(w).padStart(2, "0");
|
|
19
|
+
return n.replace(/yyyy/i, String(s.getUTCFullYear())).replace(/mm/i, f(s.getUTCMonth() + 1)).replace(/dd/i, f(s.getUTCDate())).replace(/hh/i, f(s.getUTCHours())).replace(/ss/i, f(s.getUTCSeconds()));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!i) return t;
|
|
23
|
+
if (n.includes("%")) {
|
|
24
|
+
const s = K(n);
|
|
25
|
+
return (r * 100).toFixed(s) + "%";
|
|
26
|
+
}
|
|
27
|
+
if (/E\+/i.test(n)) {
|
|
28
|
+
const s = K(n);
|
|
29
|
+
return r.toExponential(s).toUpperCase();
|
|
30
|
+
}
|
|
31
|
+
if (n.includes("#,##")) {
|
|
32
|
+
const s = K(n);
|
|
33
|
+
return r.toLocaleString("en-US", {
|
|
34
|
+
minimumFractionDigits: s,
|
|
35
|
+
maximumFractionDigits: s
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (/^0(\.0+)?$/.test(n)) {
|
|
39
|
+
const s = K(n);
|
|
40
|
+
return r.toFixed(s);
|
|
41
|
+
}
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
44
|
+
const bt = `
|
|
45
|
+
:host { display: block; }
|
|
46
|
+
|
|
47
|
+
.workbook { display: flex; flex-direction: column; gap: 12px; width: 100%; }
|
|
48
|
+
.workbook--bounded { height: var(--office-excel-workbook-height); min-height: 0; }
|
|
49
|
+
.workbook--bounded > .sheet-tabs { flex: 0 0 auto; }
|
|
50
|
+
.workbook--bounded .sheet-pages, .workbook--bounded .sheet:not([hidden]) { display: flex; flex: 1 1 0; flex-direction: column; min-height: 0; }
|
|
51
|
+
.workbook--bounded .grid-wrap { flex: 1 1 0; min-height: 0; max-height: none; }
|
|
52
|
+
.sheet-tabs { position: sticky; top: 0; z-index: 20; display: flex; gap: 0; overflow-x: auto; padding: 6px 0 0; background: #f6f7f9; border-bottom: 1px solid #c9d0d7; }
|
|
53
|
+
.sheet-tab { flex: 0 0 auto; min-height: 34px; padding: 6px 14px; border: 0; border-right: 1px solid #d7dce1; border-bottom: 2px solid transparent; background: #eef1f4; color: #30363d; cursor: pointer; }
|
|
54
|
+
.sheet-tab[aria-selected="true"] { background: #fff; border-bottom-color: #217346; color: #111; font-weight: 600; }
|
|
55
|
+
.sheet[hidden] { display: none; }
|
|
56
|
+
|
|
57
|
+
.grid-wrap { overflow: auto; max-height: 63vh; max-width: var(--office-viewer-viewport-width, none); box-sizing: border-box; background: #fff; border: 1px solid #d0d7de; border-radius: 0; }
|
|
58
|
+
.grid { display: grid; gap: 0; width: max-content; zoom: var(--office-excel-scale, 1);
|
|
59
|
+
border-left: 1px solid #e4e8ec; border-top: 1px solid #e4e8ec; }
|
|
60
|
+
|
|
61
|
+
.cell {
|
|
62
|
+
border-right: 1px solid #e4e8ec;
|
|
63
|
+
border-bottom: 1px solid #e4e8ec;
|
|
64
|
+
padding: 3px 8px;
|
|
65
|
+
font-size: 14px;
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
text-overflow: ellipsis;
|
|
69
|
+
color: #111418;
|
|
70
|
+
background: #fff;
|
|
71
|
+
}
|
|
72
|
+
.frozen-row, .frozen-column { position: sticky; z-index: 5; }
|
|
73
|
+
.frozen-corner { z-index: 6; }
|
|
74
|
+
.virtual-grid { display: block; position: relative; overflow: clip; }
|
|
75
|
+
.virtual-window { position: absolute; overflow: hidden; }
|
|
76
|
+
.virtual-pane { position: absolute; overflow: hidden; background: #fff; }
|
|
77
|
+
.virtual-pane > .cell, .virtual-pane > .sheet-image, .virtual-pane > .sheet-shape {
|
|
78
|
+
position: absolute; box-sizing: border-box;
|
|
79
|
+
}
|
|
80
|
+
.sheet-image { position: relative; z-index: 8; align-self: start; justify-self: start; pointer-events: none; overflow: hidden; }
|
|
81
|
+
.sheet-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
|
|
82
|
+
.sheet-image-cell { width: 100%; height: 100%; align-self: stretch; justify-self: stretch; padding: 2px; box-sizing: border-box; background: #fff; }
|
|
83
|
+
.sheet-shape {
|
|
84
|
+
position: relative;
|
|
85
|
+
z-index: 9;
|
|
86
|
+
box-sizing: border-box;
|
|
87
|
+
align-self: stretch;
|
|
88
|
+
justify-self: stretch;
|
|
89
|
+
min-width: 1px;
|
|
90
|
+
min-height: 1px;
|
|
91
|
+
padding: 4px 6px;
|
|
92
|
+
border: 1px solid transparent;
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-direction: column;
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
pointer-events: none;
|
|
99
|
+
white-space: pre-wrap;
|
|
100
|
+
}
|
|
101
|
+
.sheet-shape-paragraph { width: 100%; text-align: center; line-height: 1.2; }
|
|
102
|
+
.sheet-shape-line { align-self: center; min-height: 0; height: 0 !important; padding: 0; border: 0; border-top: 1px solid #666; background: transparent !important; }
|
|
103
|
+
|
|
104
|
+
@media print { .grid-wrap { overflow: visible; } }
|
|
105
|
+
`;
|
|
106
|
+
function vt(t) {
|
|
107
|
+
let e = t.highestRow, n = t.highestCol;
|
|
108
|
+
const r = (i, s) => {
|
|
109
|
+
if (!Number.isInteger(i) || i < 0 || i > 1048576 || !Number.isInteger(s) || s < 0 || s > 16384)
|
|
110
|
+
throw new Error("Worksheet dimensions exceed Excel limits");
|
|
111
|
+
e = Math.max(e, i), n = Math.max(n, s);
|
|
112
|
+
};
|
|
113
|
+
r(e, n);
|
|
114
|
+
for (const i of t.merges) {
|
|
115
|
+
const s = et(i);
|
|
116
|
+
r(s.r2, s.c2);
|
|
117
|
+
}
|
|
118
|
+
for (const i of t.cells) r(i.row, i.col);
|
|
119
|
+
for (const i of [...t.images, ...t.shapes])
|
|
120
|
+
r(i.row, i.col), r(i.toRow ?? i.row, i.toCol ?? i.col);
|
|
121
|
+
return { rows: e, cols: n };
|
|
122
|
+
}
|
|
123
|
+
function et(t) {
|
|
124
|
+
const e = (s) => {
|
|
125
|
+
const f = /^\$?([A-Z]+)\$?([1-9]\d*)$/i.exec(s);
|
|
126
|
+
if (!f) throw new Error(`Invalid cell range: ${t}`);
|
|
127
|
+
let w = 0;
|
|
128
|
+
for (const u of f[1].toUpperCase()) w = w * 26 + u.charCodeAt(0) - 64;
|
|
129
|
+
const m = Number(f[2]);
|
|
130
|
+
if (w > 16384 || m > 1048576) throw new Error(`Cell range exceeds Excel limits: ${t}`);
|
|
131
|
+
return { col: w, row: m };
|
|
132
|
+
}, n = t.split(":");
|
|
133
|
+
if (n.length > 2) throw new Error(`Invalid cell range: ${t}`);
|
|
134
|
+
const r = e(n[0]), i = e(n[1] ?? n[0]);
|
|
135
|
+
return { c1: Math.min(r.col, i.col), r1: Math.min(r.row, i.row), c2: Math.max(r.col, i.col), r2: Math.max(r.row, i.row) };
|
|
136
|
+
}
|
|
137
|
+
class nt {
|
|
138
|
+
offsets;
|
|
139
|
+
count;
|
|
140
|
+
total;
|
|
141
|
+
constructor(e) {
|
|
142
|
+
this.count = e.length, this.offsets = new Float64Array(e.length + 1);
|
|
143
|
+
for (let n = 0; n < e.length; n++) {
|
|
144
|
+
if (!Number.isFinite(e[n])) throw new Error("Worksheet dimensions must be finite");
|
|
145
|
+
this.offsets[n + 1] = this.offsets[n] + Math.max(1, e[n]);
|
|
146
|
+
}
|
|
147
|
+
this.total = this.offsets[e.length];
|
|
148
|
+
}
|
|
149
|
+
start(e) {
|
|
150
|
+
return this.offsets[Math.max(0, Math.min(this.count, e - 1))];
|
|
151
|
+
}
|
|
152
|
+
end(e) {
|
|
153
|
+
return this.offsets[Math.max(0, Math.min(this.count, e))];
|
|
154
|
+
}
|
|
155
|
+
size(e) {
|
|
156
|
+
return this.end(e) - this.start(e);
|
|
157
|
+
}
|
|
158
|
+
at(e) {
|
|
159
|
+
if (this.count === 0) return 0;
|
|
160
|
+
let n = 0, r = this.count;
|
|
161
|
+
for (; n < r; ) {
|
|
162
|
+
const i = n + r >>> 1;
|
|
163
|
+
this.offsets[i + 1] <= e ? n = i + 1 : r = i;
|
|
164
|
+
}
|
|
165
|
+
return Math.min(this.count, n + 1);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
class tt {
|
|
169
|
+
entries;
|
|
170
|
+
maxEnd;
|
|
171
|
+
constructor(e) {
|
|
172
|
+
this.entries = [...e].sort((r, i) => r.r1 - i.r1);
|
|
173
|
+
let n = 0;
|
|
174
|
+
this.maxEnd = this.entries.map((r) => n = Math.max(n, r.r2));
|
|
175
|
+
}
|
|
176
|
+
intersect(e) {
|
|
177
|
+
let n = 0, r = this.entries.length;
|
|
178
|
+
for (; n < r; ) {
|
|
179
|
+
const s = n + r >>> 1;
|
|
180
|
+
this.entries[s].r1 <= e.r2 ? n = s + 1 : r = s;
|
|
181
|
+
}
|
|
182
|
+
const i = [];
|
|
183
|
+
for (let s = n - 1; s >= 0 && this.maxEnd[s] >= e.r1; s--) {
|
|
184
|
+
const f = this.entries[s];
|
|
185
|
+
f.r2 >= e.r1 && f.c1 <= e.c2 && f.c2 >= e.c1 && i.push(f);
|
|
186
|
+
}
|
|
187
|
+
return i;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function rt(t, e, n, r = 1, i = 2) {
|
|
191
|
+
return n <= 0 || t.count < r || e >= t.total ? { first: 1, last: 0 } : {
|
|
192
|
+
first: Math.max(r, t.at(Math.max(0, e)) - i),
|
|
193
|
+
last: Math.min(t.count, t.at(Math.max(0, e + n - 1e-3)) + i)
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
const Ct = 1e4, it = 2e4;
|
|
197
|
+
function st(t, e, n) {
|
|
198
|
+
if (!Number.isInteger(t.highestRow) || t.highestRow < 0 || t.highestRow > 1048576 || !Number.isInteger(t.highestCol) || t.highestCol < 0 || t.highestCol > 16384)
|
|
199
|
+
throw new Error("Worksheet dimensions exceed Excel limits");
|
|
200
|
+
const r = new Float64Array(t.highestCol).fill(96), i = new Float64Array(t.highestRow).fill(26), s = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
|
|
201
|
+
for (const o of t.colWidths) o.col >= 1 && o.col <= r.length && o.width > 0 && (r[o.col - 1] = Math.max(1, Math.round(o.width * 7 + 5)), s.add(o.col));
|
|
202
|
+
for (const o of t.rowHeights) o.row >= 1 && o.row <= i.length && o.height > 0 && (i[o.row - 1] = Math.max(1, Math.round(o.height * 96 / 72)), f.add(o.row));
|
|
203
|
+
const w = t.merges.map(et), m = new Map(w.map((o) => [`${o.c1}:${o.r1}`, o])), u = new Map(t.cells.map((o) => [`${o.col}:${o.row}`, o])), R = new Set(t.cells.filter((o) => o.wrapText).map((o) => o.col)), N = e.createElement("canvas").getContext("2d"), L = (o, c) => {
|
|
204
|
+
const d = (c?.fontSize ?? o.fontSize ?? 10.5) * 96 / 72, y = c?.fontName ?? o.fontName;
|
|
205
|
+
return N && (N.font = `${c?.italic ?? o.italic ? "italic " : ""}${c?.bold ?? o.bold ? "bold " : ""}${d}px ${y ? `"${y}", ` : ""}${n}`), d;
|
|
206
|
+
}, A = (o) => o.richText?.length ? o.richText : [{ text: dt(o.value, o.numfmt) }], S = (o, c) => N?.measureText(o).width ?? o.length * c;
|
|
207
|
+
for (const o of t.cells) {
|
|
208
|
+
if (o.col < 1 || o.col > r.length || s.has(o.col) || R.has(o.col) || m.has(`${o.col}:${o.row}`)) continue;
|
|
209
|
+
let c = 0;
|
|
210
|
+
for (const d of A(o)) c += S(d.text.replace(/\s+/g, " "), L(o, d));
|
|
211
|
+
r[o.col - 1] = Math.max(r[o.col - 1], Math.ceil(c + 17));
|
|
212
|
+
}
|
|
213
|
+
const k = new nt(r);
|
|
214
|
+
for (const o of t.cells) {
|
|
215
|
+
if (o.row < 1 || o.row > i.length || f.has(o.row)) continue;
|
|
216
|
+
const c = m.get(`${o.col}:${o.row}`);
|
|
217
|
+
if (c && c.r2 > c.r1) continue;
|
|
218
|
+
const d = Math.max(1, k.end(c?.c2 ?? o.col) - k.start(o.col) - 17);
|
|
219
|
+
let y = 1, l = 0, h = 14;
|
|
220
|
+
for (const g of A(o)) {
|
|
221
|
+
const $ = L(o, g);
|
|
222
|
+
if (h = Math.max(h, $), !o.wrapText) continue;
|
|
223
|
+
const M = g.text.match(/[\u2e80-\u9fff]|[^\s\u2e80-\u9fff]+|\s+/g) ?? [];
|
|
224
|
+
for (const F of M) {
|
|
225
|
+
const H = /^\s+$/.test(F), X = S(H ? " " : F, $);
|
|
226
|
+
!H && l > 0 && l + X > d && (y++, l = 0), (!H || l > 0) && (l += X);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
i[o.row - 1] = Math.max(i[o.row - 1], Math.ceil(y * h * 1.25 + 7));
|
|
230
|
+
}
|
|
231
|
+
const x = new nt(i), P = (o, c) => {
|
|
232
|
+
const d = k.start(o.col) + ("offsetXPx" in o ? o.offsetXPx : 0), y = x.start(o.row) + ("offsetYPx" in o ? o.offsetYPx : 0), l = o.toCol ? k.end(o.toCol) - k.start(o.col) : o.widthPx ?? k.size(o.col), h = o.toRow ? x.end(o.toRow) - x.start(o.row) : o.heightPx ?? x.size(o.row);
|
|
233
|
+
return {
|
|
234
|
+
key: c,
|
|
235
|
+
x: d,
|
|
236
|
+
y,
|
|
237
|
+
width: Math.max(1, l),
|
|
238
|
+
height: Math.max(1, h),
|
|
239
|
+
c1: d,
|
|
240
|
+
r1: y,
|
|
241
|
+
c2: d + Math.max(1, l) - 1e-3,
|
|
242
|
+
r2: y + Math.max(1, h) - 1e-3,
|
|
243
|
+
..."data" in o ? { image: o } : { shape: o }
|
|
244
|
+
};
|
|
245
|
+
}, C = [
|
|
246
|
+
...t.images.map((o, c) => P(o, `image:${c}`)),
|
|
247
|
+
...t.shapes.map((o, c) => P(o, `shape:${c}`))
|
|
248
|
+
];
|
|
249
|
+
let a = k.total, p = x.total;
|
|
250
|
+
for (const o of C)
|
|
251
|
+
a = Math.max(a, o.x + o.width), p = Math.max(p, o.y + o.height);
|
|
252
|
+
return { columns: k, rows: x, width: a, height: p, cells: u, merges: new tt(w), overlays: new tt(C) };
|
|
253
|
+
}
|
|
254
|
+
function $t(t, e, n, r, i, s, f, w) {
|
|
255
|
+
r.classList.add("virtual-grid"), e.dataset.virtual = "true";
|
|
256
|
+
const m = e.ownerDocument, u = m.defaultView, R = m.createElement("div");
|
|
257
|
+
R.className = "virtual-window", r.append(R);
|
|
258
|
+
const N = [[!1, !1], [!0, !1], [!1, !0], [!0, !0]].map(([d, y]) => {
|
|
259
|
+
const l = m.createElement("div");
|
|
260
|
+
return l.className = "virtual-pane", R.append(l), { element: l, nodes: /* @__PURE__ */ new Map(), frozenX: d, frozenY: y };
|
|
261
|
+
});
|
|
262
|
+
let L = !1, A = !1, S, k = !1, x = i.layout, P = 0, C = 0;
|
|
263
|
+
const a = () => {
|
|
264
|
+
if (S = void 0, L || n.clientWidth <= 0 || n.clientHeight <= 0) return;
|
|
265
|
+
x || (x = st(t, m, u.getComputedStyle(e).fontFamily || "sans-serif"), i.layout = x);
|
|
266
|
+
const { columns: d, rows: y, cells: l, merges: h, overlays: g } = x;
|
|
267
|
+
r.style.width = `${x.width}px`, r.style.height = `${x.height}px`;
|
|
268
|
+
const $ = Number.parseFloat(u.getComputedStyle(r).zoom) || 1, M = n.clientWidth / $, F = n.clientHeight / $;
|
|
269
|
+
P = n.clientWidth, C = n.clientHeight;
|
|
270
|
+
const H = n.scrollLeft / $, X = n.scrollTop / $;
|
|
271
|
+
R.style.left = `${H}px`, R.style.top = `${X}px`, R.style.width = `${M}px`, R.style.height = `${F}px`;
|
|
272
|
+
const J = Math.max(0, Math.min(d.count, t.frozenColumns)), Q = Math.max(0, Math.min(y.count, t.frozenRows)), V = Math.min(M, d.end(J)), B = Math.min(F, y.end(Q));
|
|
273
|
+
let ht = 0;
|
|
274
|
+
for (const z of N) {
|
|
275
|
+
const mt = z.frozenX ? 0 : V, pt = z.frozenY ? 0 : B, Y = z.frozenX ? V : M - V, O = z.frozenY ? B : F - B;
|
|
276
|
+
z.element.style.left = `${mt}px`, z.element.style.top = `${pt}px`, z.element.style.width = `${Y}px`, z.element.style.height = `${O}px`;
|
|
277
|
+
const G = z.frozenX ? 0 : H + V, Z = z.frozenY ? 0 : X + B, D = rt(d, G, Y, z.frozenX ? 1 : J + 1), W = rt(y, Z, O, z.frozenY ? 1 : Q + 1);
|
|
278
|
+
z.frozenX && (D.last = Math.min(D.last, J)), z.frozenY && (W.last = Math.min(W.last, Q));
|
|
279
|
+
const ot = /* @__PURE__ */ new Set(), q = (E, I, j, b, T, U) => {
|
|
280
|
+
if (++ht > it) throw new Error(`Worksheet viewport exceeds the preview limit of ${it} visible cells and drawings`);
|
|
281
|
+
ot.add(E);
|
|
282
|
+
let v = z.nodes.get(E);
|
|
283
|
+
v || (v = I(), v.classList.contains("cell") && (v.classList.toggle("frozen-column", z.frozenX), v.classList.toggle("frozen-row", z.frozenY), v.classList.toggle("frozen-corner", z.frozenX && z.frozenY)), z.nodes.set(E, v), z.element.append(v)), v.style.left = `${j - G}px`, v.style.top = `${b - Z}px`, v.style.width = `${T}px`, v.style.height = `${U}px`;
|
|
284
|
+
};
|
|
285
|
+
if (Y > 0 && O > 0 && D.last >= D.first && W.last >= W.first) {
|
|
286
|
+
const E = { c1: D.first, c2: D.last, r1: W.first, r2: W.last }, I = h.intersect(E), j = /* @__PURE__ */ new Map();
|
|
287
|
+
for (const b of I) {
|
|
288
|
+
for (let T = Math.max(W.first, b.r1); T <= Math.min(W.last, b.r2); T++) {
|
|
289
|
+
const U = j.get(T) ?? [];
|
|
290
|
+
U.push(b), j.set(T, U);
|
|
291
|
+
}
|
|
292
|
+
q(
|
|
293
|
+
`merge:${b.c1}:${b.r1}`,
|
|
294
|
+
() => s.cell(l.get(`${b.c1}:${b.r1}`), b.r1, b.c1),
|
|
295
|
+
d.start(b.c1),
|
|
296
|
+
y.start(b.r1),
|
|
297
|
+
d.end(b.c2) - d.start(b.c1),
|
|
298
|
+
y.end(b.r2) - y.start(b.r1)
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
for (let b = W.first; b <= W.last; b++) {
|
|
302
|
+
const T = (j.get(b) ?? []).sort((v, gt) => v.c1 - gt.c1);
|
|
303
|
+
let U = 0;
|
|
304
|
+
for (let v = D.first; v <= D.last; v++) {
|
|
305
|
+
for (; U < T.length && T[U].c2 < v; ) U++;
|
|
306
|
+
if (T[U]?.c1 <= v) {
|
|
307
|
+
v = T[U].c2;
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
q(`cell:${v}:${b}`, () => s.cell(l.get(`${v}:${b}`), b, v), d.start(v), y.start(b), d.size(v), y.size(b));
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (Y > 0 && O > 0)
|
|
315
|
+
for (const E of g.intersect({ c1: G, r1: Z, c2: G + Y - 1e-3, r2: Z + O - 1e-3 }))
|
|
316
|
+
q(E.key, () => {
|
|
317
|
+
const I = E.image ? s.image(E.image) : s.shape(E.shape);
|
|
318
|
+
return I.style.transform = "", I;
|
|
319
|
+
}, E.x, E.shape?.geometry === "line" || E.shape?.geometry === "lineInv" ? E.y + E.height / 2 : E.y, E.width, E.height);
|
|
320
|
+
for (const [E, I] of z.nodes) ot.has(E) || (I.remove(), z.nodes.delete(E));
|
|
321
|
+
}
|
|
322
|
+
k && (k = !1, w?.());
|
|
323
|
+
}, p = () => {
|
|
324
|
+
!L && !A && S === void 0 && (S = u.requestAnimationFrame(() => {
|
|
325
|
+
try {
|
|
326
|
+
a();
|
|
327
|
+
} catch (d) {
|
|
328
|
+
if (A = !0, f) f(d instanceof Error ? d : new Error(String(d)));
|
|
329
|
+
else throw d;
|
|
330
|
+
}
|
|
331
|
+
}));
|
|
332
|
+
};
|
|
333
|
+
n.addEventListener("scroll", p, { passive: !0 });
|
|
334
|
+
const o = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(() => {
|
|
335
|
+
(n.clientWidth !== P || n.clientHeight !== C) && p();
|
|
336
|
+
});
|
|
337
|
+
o?.observe(n);
|
|
338
|
+
const c = () => {
|
|
339
|
+
x = void 0, i.layout = void 0, k = !0, p();
|
|
340
|
+
};
|
|
341
|
+
return m.fonts?.addEventListener("loadingdone", c), {
|
|
342
|
+
element: e,
|
|
343
|
+
viewport: n,
|
|
344
|
+
resize() {
|
|
345
|
+
!x && !L && (x = st(t, m, u.getComputedStyle(e).fontFamily || "sans-serif"), i.layout = x), x && (r.style.width = `${x.width}px`, r.style.height = `${x.height}px`), S !== void 0 && (u.cancelAnimationFrame(S), S = void 0), a();
|
|
346
|
+
},
|
|
347
|
+
getContentWidth() {
|
|
348
|
+
return (x?.width ?? 0) + 1;
|
|
349
|
+
},
|
|
350
|
+
dispose() {
|
|
351
|
+
L = !0, S !== void 0 && u.cancelAnimationFrame(S), o?.disconnect(), n.removeEventListener("scroll", p), m.fonts?.removeEventListener("loadingdone", c);
|
|
352
|
+
for (const d of N) d.nodes.clear();
|
|
353
|
+
e.remove();
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
const zt = 96, Mt = 26, _ = {
|
|
358
|
+
thin: "1px solid #9aa3ab",
|
|
359
|
+
medium: "2px solid #666",
|
|
360
|
+
thick: "3px solid #444",
|
|
361
|
+
hair: "1px solid #d0d7de",
|
|
362
|
+
dashed: "1px dashed #888",
|
|
363
|
+
dotted: "1px dotted #888",
|
|
364
|
+
double: "3px double #888"
|
|
365
|
+
}, Et = { Center: "center", Right: "end", Left: "start" };
|
|
366
|
+
function Rt(t, e, n, r) {
|
|
367
|
+
const i = t.shadowRoot ?? t.attachShadow({ mode: "open" });
|
|
368
|
+
i.replaceChildren();
|
|
369
|
+
const s = document.createElement("style");
|
|
370
|
+
s.textContent = bt, i.appendChild(s);
|
|
371
|
+
const f = document.createElement("div");
|
|
372
|
+
f.className = "workbook", i.appendChild(f);
|
|
373
|
+
const w = document.createElement("div");
|
|
374
|
+
w.className = "sheet-tabs", w.setAttribute("role", "tablist");
|
|
375
|
+
const m = document.createElement("div");
|
|
376
|
+
m.className = "sheet-pages", f.append(w, m);
|
|
377
|
+
let u = 0, R = 0, N = 0, L = 0, A = 0;
|
|
378
|
+
const S = [], k = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
|
|
379
|
+
let P = -1, C, a = !1, p = 1;
|
|
380
|
+
const o = () => {
|
|
381
|
+
const l = t.ownerDocument.defaultView.getComputedStyle(t), h = Number.parseFloat(l.getPropertyValue("--office-viewer-viewport-height")), g = Number.isFinite(h) && h > 0;
|
|
382
|
+
f.classList.toggle("workbook--bounded", g), g ? f.style.setProperty("--office-excel-workbook-height", `${h}px`) : f.style.removeProperty("--office-excel-workbook-height");
|
|
383
|
+
}, c = (l) => {
|
|
384
|
+
if (a || l === P || !e.sheets[l]) return;
|
|
385
|
+
const h = C;
|
|
386
|
+
C && k.set(P, { top: C.viewport.scrollTop / p, left: C.viewport.scrollLeft / p });
|
|
387
|
+
const g = x.get(l) ?? {};
|
|
388
|
+
x.set(l, g);
|
|
389
|
+
let $;
|
|
390
|
+
try {
|
|
391
|
+
$ = kt(e.sheets[l], g, n, r), $.element.dataset.sheetIndex = String(l), m.replaceChildren($.element), o(), $.resize();
|
|
392
|
+
const M = k.get(l);
|
|
393
|
+
M && ($.viewport.scrollTop = M.top * p, $.viewport.scrollLeft = M.left * p, $.resize());
|
|
394
|
+
} catch (M) {
|
|
395
|
+
throw $?.dispose(), h && m.replaceChildren(h.element), M;
|
|
396
|
+
}
|
|
397
|
+
h?.dispose(), C = $, P = l, S.forEach((M, F) => M.setAttribute("aria-selected", String(F === l))), h && r?.();
|
|
398
|
+
};
|
|
399
|
+
e.sheets.forEach((l, h) => {
|
|
400
|
+
const g = document.createElement("button");
|
|
401
|
+
g.type = "button", g.className = "sheet-tab", g.textContent = l.name, g.dataset.sheetIndex = String(h), g.setAttribute("role", "tab"), g.setAttribute("aria-selected", h === 0 ? "true" : "false"), S.push(g), w.appendChild(g), u += l.highestRow, R += l.highestCol, N += l.merges.length, L += l.images.length, A += l.shapes.length;
|
|
402
|
+
});
|
|
403
|
+
const d = (l) => {
|
|
404
|
+
const h = l.target.closest(".sheet-tab");
|
|
405
|
+
if (h)
|
|
406
|
+
try {
|
|
407
|
+
c(Number(h.dataset.sheetIndex));
|
|
408
|
+
} catch (g) {
|
|
409
|
+
if (n) n(g instanceof Error ? g : new Error(String(g)));
|
|
410
|
+
else throw g;
|
|
411
|
+
}
|
|
412
|
+
}, y = () => {
|
|
413
|
+
for (const l of x.values()) l.layout = void 0;
|
|
414
|
+
};
|
|
415
|
+
w.addEventListener("click", d), t.ownerDocument.fonts?.addEventListener("loadingdone", y);
|
|
416
|
+
try {
|
|
417
|
+
c(0);
|
|
418
|
+
} catch (l) {
|
|
419
|
+
throw w.removeEventListener("click", d), t.ownerDocument.fonts?.removeEventListener("loadingdone", y), f.remove(), s.remove(), l;
|
|
420
|
+
}
|
|
421
|
+
return {
|
|
422
|
+
stats: { sheets: e.sheets.length, rows: u, cols: R, merges: N, images: L, shapes: A },
|
|
423
|
+
resize() {
|
|
424
|
+
a || (o(), C?.resize());
|
|
425
|
+
},
|
|
426
|
+
setZoom(l) {
|
|
427
|
+
if (a || l === p) return;
|
|
428
|
+
const h = (C?.viewport.scrollTop ?? 0) / p, g = (C?.viewport.scrollLeft ?? 0) / p;
|
|
429
|
+
p = l, f.style.setProperty("--office-excel-scale", String(l)), C && (C.viewport.scrollTop = h * l, C.viewport.scrollLeft = g * l);
|
|
430
|
+
},
|
|
431
|
+
getContentWidth() {
|
|
432
|
+
return a ? 0 : C?.getContentWidth() ?? 0;
|
|
433
|
+
},
|
|
434
|
+
dispose() {
|
|
435
|
+
a = !0, C?.dispose(), C = void 0, w.removeEventListener("click", d), t.ownerDocument.fonts?.removeEventListener("loadingdone", y), x.clear(), k.clear(), f.remove(), s.remove();
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function kt(t, e, n, r) {
|
|
440
|
+
const i = vt(t), s = i.rows * i.cols > Ct;
|
|
441
|
+
s && (t = { ...t, highestRow: i.rows, highestCol: i.cols });
|
|
442
|
+
const f = document.createElement("section");
|
|
443
|
+
f.className = "sheet";
|
|
444
|
+
const w = document.createElement("div");
|
|
445
|
+
w.className = "grid-wrap";
|
|
446
|
+
const m = document.createElement("div");
|
|
447
|
+
if (m.className = "grid", w.appendChild(m), f.appendChild(w), s)
|
|
448
|
+
return $t(t, f, w, m, e, {
|
|
449
|
+
cell: at,
|
|
450
|
+
image: lt,
|
|
451
|
+
shape: ct
|
|
452
|
+
}, n, r);
|
|
453
|
+
const u = (a) => {
|
|
454
|
+
const p = t.colWidths.find((o) => o.col === a);
|
|
455
|
+
return p && p.width > 0 ? Math.round(p.width * 7 + 5) : zt;
|
|
456
|
+
}, R = (a) => {
|
|
457
|
+
const p = t.rowHeights.find((o) => o.row === a);
|
|
458
|
+
return p && p.height > 0 ? Math.round(p.height * (96 / 72)) : Mt;
|
|
459
|
+
}, N = /* @__PURE__ */ new Set();
|
|
460
|
+
for (const a of t.cells)
|
|
461
|
+
a.wrapText && N.add(a.col);
|
|
462
|
+
m.style.gridTemplateColumns = Array.from({ length: t.highestCol }, (a, p) => {
|
|
463
|
+
const o = p + 1;
|
|
464
|
+
return N.has(o) ? `${u(o)}px` : `minmax(${u(o)}px, max-content)`;
|
|
465
|
+
}).join(" ");
|
|
466
|
+
const L = t.merges.map(et), A = new tt(L), S = /* @__PURE__ */ new Map();
|
|
467
|
+
for (const { c1: a, r1: p, c2: o, r2: c } of L)
|
|
468
|
+
S.set(`${a}:${p}`, { cs: o - a + 1, rs: c - p + 1 });
|
|
469
|
+
const k = new Map(t.cells.map((a) => [`${a.col}:${a.row}`, a])), x = /* @__PURE__ */ new Set(), P = /* @__PURE__ */ new Set();
|
|
470
|
+
for (let a = 1; a <= t.highestRow; a++) {
|
|
471
|
+
const p = A.intersect({ c1: 1, c2: t.highestCol, r1: a, r2: a }).sort((c, d) => c.c1 - d.c1);
|
|
472
|
+
let o = 0;
|
|
473
|
+
for (let c = 1; c <= t.highestCol; c++) {
|
|
474
|
+
for (; o < p.length && p[o].c2 < c; ) o++;
|
|
475
|
+
const d = p[o];
|
|
476
|
+
if (d?.c1 <= c && !(a === d.r1 && c === d.c1)) {
|
|
477
|
+
c = d.c2;
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
const y = `${c}:${a}`, l = k.get(y), h = at(l, a, c);
|
|
481
|
+
h.style.gridColumn = `${c}`, h.style.gridRow = `${a}`;
|
|
482
|
+
const g = S.get(y);
|
|
483
|
+
g && (g.cs > 1 && (h.style.gridColumn = `${c} / span ${g.cs}`), g.rs > 1 && (h.style.gridRow = `${a} / span ${g.rs}`)), l && l.wrapText && (h.style.whiteSpace = "normal", x.add(a)), a <= t.frozenRows && (h.classList.add("frozen-row"), h.style.top = `${Array.from({ length: a - 1 }, ($, M) => R(M + 1)).reduce(($, M) => $ + M, 0)}px`), c <= t.frozenColumns && (h.classList.add("frozen-column"), h.style.left = `${Array.from({ length: c - 1 }, ($, M) => u(M + 1)).reduce(($, M) => $ + M, 0)}px`), a <= t.frozenRows && c <= t.frozenColumns && h.classList.add("frozen-corner"), m.appendChild(h);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
for (const a of t.rowHeights)
|
|
487
|
+
a.height > 0 && P.add(a.row);
|
|
488
|
+
for (let a = 1; a <= t.highestRow; a++)
|
|
489
|
+
m.style.gridTemplateRows += ` minmax(${R(a)}px, auto)`;
|
|
490
|
+
for (const a of t.images)
|
|
491
|
+
m.appendChild(lt(a));
|
|
492
|
+
for (const a of t.shapes)
|
|
493
|
+
m.appendChild(ct(a));
|
|
494
|
+
const C = () => r?.();
|
|
495
|
+
return f.ownerDocument.fonts?.addEventListener("loadingdone", C), {
|
|
496
|
+
element: f,
|
|
497
|
+
viewport: w,
|
|
498
|
+
resize() {
|
|
499
|
+
},
|
|
500
|
+
getContentWidth: () => m.scrollWidth + 2,
|
|
501
|
+
dispose() {
|
|
502
|
+
f.ownerDocument.fonts?.removeEventListener("loadingdone", C), f.remove();
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function at(t, e, n) {
|
|
507
|
+
const r = document.createElement("div");
|
|
508
|
+
return r.className = "cell", r.dataset.row = String(e), r.dataset.col = String(n), t?.richText?.length ? ft(r, t.richText) : r.textContent = t ? dt(t.value, t.numfmt) : "", t && (Lt(r, t), t.wrapText && (r.style.whiteSpace = "normal")), r;
|
|
509
|
+
}
|
|
510
|
+
function lt(t) {
|
|
511
|
+
const e = document.createElement("div");
|
|
512
|
+
e.className = t.fitCell ? "sheet-image sheet-image-cell" : "sheet-image", e.style.gridColumn = t.toCol ? `${t.col} / span ${Math.max(1, t.toCol - t.col + 1)}` : `${t.col}`, e.style.gridRow = t.toRow ? `${t.row} / span ${Math.max(1, t.toRow - t.row + 1)}` : `${t.row}`, !t.fitCell && !t.toCol && t.widthPx && (e.style.width = `${t.widthPx}px`), !t.fitCell && !t.toRow && t.heightPx && (e.style.height = `${t.heightPx}px`);
|
|
513
|
+
const n = document.createElement("img");
|
|
514
|
+
return n.src = t.data, n.alt = t.name, n.draggable = !1, e.appendChild(n), e;
|
|
515
|
+
}
|
|
516
|
+
function ct(t) {
|
|
517
|
+
const e = document.createElement("div");
|
|
518
|
+
e.className = "sheet-shape", e.dataset.geometry = t.geometry, e.setAttribute("aria-label", t.name || "形状"), e.style.gridColumn = t.toCol ? `${t.col} / span ${Math.max(1, t.toCol - t.col + 1)}` : `${t.col}`, e.style.gridRow = t.toRow ? `${t.row} / span ${Math.max(1, t.toRow - t.row + 1)}` : `${t.row}`, !t.toCol && t.widthPx && (e.style.width = `${t.widthPx}px`), !t.toRow && t.heightPx && (e.style.height = `${t.heightPx}px`), (t.offsetXPx || t.offsetYPx) && (e.style.transform = `translate(${t.offsetXPx}px, ${t.offsetYPx}px)`), t.fill && (e.style.backgroundColor = t.fill), (t.lineColor || t.lineWidthPx) && (e.style.borderColor = t.lineColor ?? "#666", e.style.borderWidth = `${Math.max(1, t.lineWidthPx ?? 1)}px`), St(e, t.geometry);
|
|
519
|
+
for (const n of t.paragraphs) {
|
|
520
|
+
const r = document.createElement("div");
|
|
521
|
+
r.className = "sheet-shape-paragraph", ft(r, n.runs), e.appendChild(r);
|
|
522
|
+
}
|
|
523
|
+
return e;
|
|
524
|
+
}
|
|
525
|
+
function St(t, e) {
|
|
526
|
+
const n = {
|
|
527
|
+
diamond: "polygon(50% 0, 100% 50%, 50% 100%, 0 50%)",
|
|
528
|
+
triangle: "polygon(50% 0, 100% 100%, 0 100%)",
|
|
529
|
+
rtTriangle: "polygon(0 0, 100% 100%, 0 100%)",
|
|
530
|
+
pentagon: "polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%)",
|
|
531
|
+
hexagon: "polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%)",
|
|
532
|
+
rightArrow: "polygon(0 25%, 65% 25%, 65% 0, 100% 50%, 65% 100%, 65% 75%, 0 75%)",
|
|
533
|
+
leftArrow: "polygon(35% 0, 35% 25%, 100% 25%, 100% 75%, 35% 75%, 35% 100%, 0 50%)",
|
|
534
|
+
upArrow: "polygon(50% 0, 100% 35%, 75% 35%, 75% 100%, 25% 100%, 25% 35%, 0 35%)",
|
|
535
|
+
downArrow: "polygon(25% 0, 75% 0, 75% 65%, 100% 65%, 50% 100%, 0 65%, 25% 65%)",
|
|
536
|
+
chevron: "polygon(0 0, 75% 0, 100% 50%, 75% 100%, 0 100%, 25% 50%)",
|
|
537
|
+
parallelogram: "polygon(25% 0, 100% 0, 75% 100%, 0 100%)",
|
|
538
|
+
trapezoid: "polygon(20% 0, 80% 0, 100% 100%, 0 100%)"
|
|
539
|
+
};
|
|
540
|
+
e === "ellipse" ? t.style.borderRadius = "50%" : e === "roundRect" || e.startsWith("round") ? t.style.borderRadius = "8px" : n[e] ? t.style.clipPath = n[e] : (e === "line" || e === "lineInv") && t.classList.add("sheet-shape-line");
|
|
541
|
+
}
|
|
542
|
+
function ft(t, e) {
|
|
543
|
+
for (const n of e) {
|
|
544
|
+
const r = document.createElement("span");
|
|
545
|
+
r.textContent = n.text, n.fontName && (r.style.fontFamily = `"${n.fontName}", "PingFang SC", "Microsoft YaHei", sans-serif`), n.fontSize && (r.style.fontSize = `${n.fontSize}pt`), n.bold != null && (r.style.fontWeight = n.bold ? "700" : "400"), n.italic != null && (r.style.fontStyle = n.italic ? "italic" : "normal"), n.underline != null && (r.style.textDecoration = n.underline ? "underline" : "none"), n.fontColor && (r.style.color = n.fontColor), t.appendChild(r);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function Lt(t, e) {
|
|
549
|
+
const n = [];
|
|
550
|
+
if (e.fontName && (t.style.fontFamily = `"${e.fontName}", "PingFang SC", "Microsoft YaHei", sans-serif`), e.fontSize && (t.style.fontSize = `${e.fontSize}pt`), e.bold && (t.style.fontWeight = "700"), e.italic && (t.style.fontStyle = "italic"), e.underline && (t.style.textDecoration = "underline"), e.fontColor && (t.style.color = e.fontColor), e.fill && (t.style.background = e.fill), e.hAlign) {
|
|
551
|
+
const r = Et[e.hAlign] ?? "start";
|
|
552
|
+
e.vAlign === "Center" ? t.style.justifyContent = r === "end" ? "flex-end" : r === "center" ? "center" : "flex-start" : t.style.textAlign = r;
|
|
553
|
+
}
|
|
554
|
+
e.vAlign === "Center" && (t.style.display = "flex", t.style.alignItems = "center"), e.borderTop && (t.style.borderTop = _[e.borderTop] ?? _.thin), e.borderLeft && (t.style.borderLeft = _[e.borderLeft] ?? _.thin), e.borderRight && (t.style.borderRight = _[e.borderRight] ?? _.thin), e.borderBottom && (t.style.borderBottom = _[e.borderBottom] ?? _.thin), n.length && t.setAttribute("style", (t.getAttribute("style") ?? "") + n.join(";"));
|
|
555
|
+
}
|
|
556
|
+
function At(t = {}) {
|
|
557
|
+
const e = new URL("" + new URL("assets/excel/worker.js?no-inline", import.meta.url).href, import.meta.url), n = new URL("" + new URL("assets/excel/excel_view_rs_bg.wasm?no-inline", import.meta.url).href, import.meta.url), r = t.assets?.baseUrl ? new URL(String(t.assets.baseUrl), document.baseURI) : void 0;
|
|
558
|
+
r && !r.pathname.endsWith("/") && (r.pathname += "/");
|
|
559
|
+
const i = (m, u, R) => m ? new URL(m, document.baseURI) : r ? new URL(u, r) : R, s = i(t.assets?.excel?.workerUrl, "excel/worker.js", e), f = i(t.assets?.excel?.wasmUrl, "excel/excel_view_rs_bg.wasm", n).href, w = wt({
|
|
560
|
+
format: "xlsx",
|
|
561
|
+
formats: ["xlsx", "xlsm"],
|
|
562
|
+
workerData: { wasmUrl: f },
|
|
563
|
+
createWorker: () => t.workerFactory ? t.workerFactory(s, { type: "module" }) : new Worker(s, { type: "module" })
|
|
564
|
+
});
|
|
565
|
+
return {
|
|
566
|
+
async open(m) {
|
|
567
|
+
const u = await w.open(m);
|
|
568
|
+
return {
|
|
569
|
+
format: m.format ?? "xlsx",
|
|
570
|
+
durationMs: u.durationMs,
|
|
571
|
+
stats: { sheets: u.document.sheets.length },
|
|
572
|
+
itemCount: u.document.sheets.length,
|
|
573
|
+
warnings: u.warnings,
|
|
574
|
+
document: u.document
|
|
575
|
+
};
|
|
576
|
+
},
|
|
577
|
+
render(m, u, R, N) {
|
|
578
|
+
const L = Rt(m, u, R ? (A) => {
|
|
579
|
+
R(xt("RENDER_FAILED", A.message));
|
|
580
|
+
} : void 0, N);
|
|
581
|
+
return { ...L, stats: { ...L.stats } };
|
|
582
|
+
},
|
|
583
|
+
destroy: w.destroy
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
export {
|
|
587
|
+
At as createExcelAdapter
|
|
588
|
+
};
|