javascript-excel 2.0.0-alpha.2 → 2.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +151 -21
- package/dist/address-DUn7-5OS.js +75 -0
- package/dist/address-DZBHchLv.cjs +122 -0
- package/dist/{auto-width-2oBzjeNG.d.cts → auto-width-DRHsPKNk.d.cts} +1 -1
- package/dist/cells-CPXU722t.cjs +33 -0
- package/dist/cells-CrMF8h_t.js +28 -0
- package/dist/colors-B8Nf_xTx.js +114 -0
- package/dist/colors-oBpjx97l.cjs +119 -0
- package/dist/csv.d.cts +4 -1
- package/dist/csv.d.ts +4 -1
- package/dist/dataset-KeMzHCGl.js +664 -0
- package/dist/dataset-UUZCzsi3.cjs +687 -0
- package/dist/dates-BXcSWf9_.js +64 -0
- package/dist/dates-CA1dCizp.cjs +75 -0
- package/dist/dom.cjs +5 -2
- package/dist/dom.d.cts +5 -2
- package/dist/dom.d.ts +4 -1
- package/dist/dom.js +4 -1
- package/dist/{numfmt-Dv6AjopS.cjs → dos-time-FZ7-1tot.cjs} +0 -199
- package/dist/{numfmt-BBgB7iQA.js → dos-time-dD0z1YWU.js} +2 -177
- package/dist/format.cjs +1264 -0
- package/dist/format.d.cts +59 -0
- package/dist/format.d.ts +59 -0
- package/dist/format.js +1262 -0
- package/dist/import.cjs +10 -0
- package/dist/import.d.cts +10 -0
- package/dist/import.d.ts +10 -0
- package/dist/import.js +1 -0
- package/dist/index.cjs +24 -607
- package/dist/index.d.cts +32 -6
- package/dist/index.d.ts +31 -5
- package/dist/index.js +10 -594
- package/dist/{warnings-C_12PT4t.d.cts → model-0JikLfuM.d.cts} +1 -41
- package/dist/{warnings-DXJKe1lx.d.ts → model-0JikLfuM.d.ts} +1 -41
- package/dist/numfmt-BmEbm78Y.cjs +125 -0
- package/dist/numfmt-DCDrX9P1.js +114 -0
- package/dist/pipeline-BAJtzBdW.js +1085 -0
- package/dist/pipeline-Bnf7EU3X.cjs +1132 -0
- package/dist/pipeline-CctEa86r.d.cts +186 -0
- package/dist/pipeline-I8SLmV9S.d.ts +186 -0
- package/dist/{read-Ym1voUct.cjs → read-CZEWV4rK.cjs} +181 -17
- package/dist/{read-DDN5ZsPe.js → read-LWti17lz.js} +169 -5
- package/dist/read.cjs +1 -1
- package/dist/read.d.cts +78 -4
- package/dist/read.d.ts +78 -4
- package/dist/read.js +1 -1
- package/dist/render.cjs +751 -0
- package/dist/render.d.cts +215 -0
- package/dist/render.d.ts +215 -0
- package/dist/render.js +732 -0
- package/dist/{sheet-names-uT2EH5Ui.js → sheet-names-7p-joVsG.js} +2 -101
- package/dist/{sheet-names-qpXsvMpM.cjs → sheet-names-B8U5RAW0.cjs} +14 -167
- package/dist/warnings-B1v58nCZ.d.cts +41 -0
- package/dist/warnings-B1v58nCZ.d.ts +41 -0
- package/dist/worker.cjs +10 -2
- package/dist/worker.d.cts +10 -4
- package/dist/worker.d.ts +10 -4
- package/dist/worker.js +10 -2
- package/dist/{write-CYpLGuzl.d.ts → write-DM6ieuQY.d.ts} +2 -1
- package/dist/{write-DubvcG-x.js → write-DjgWy1PK.js} +5 -2
- package/dist/{write-C5JgeIar.d.cts → write-DtjfdIFm.d.cts} +2 -1
- package/dist/{write-BOh9jfu1.cjs → write-f9kcYf5K.cjs} +31 -28
- package/package.json +32 -1
- package/dist/read-C6L7Nyy3.d.cts +0 -78
- package/dist/read-Ddkks7qC.d.ts +0 -78
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// src/colors.ts
|
|
2
|
+
/** The Office theme's colours in clrScheme order (dk1, lt1, dk2, lt2, accent1..6, hlink, folHlink), as the writer embeds it. */
|
|
3
|
+
const DEFAULT_THEME = [
|
|
4
|
+
"000000",
|
|
5
|
+
"FFFFFF",
|
|
6
|
+
"44546A",
|
|
7
|
+
"E7E6E6",
|
|
8
|
+
"4472C4",
|
|
9
|
+
"ED7D31",
|
|
10
|
+
"A5A5A5",
|
|
11
|
+
"FFC000",
|
|
12
|
+
"5B9BD5",
|
|
13
|
+
"70AD47",
|
|
14
|
+
"0563C1",
|
|
15
|
+
"954F72"
|
|
16
|
+
];
|
|
17
|
+
/** The default indexed palette, entries 0–63 (ECMA-376 §18.8.27); 64 is the system foreground, 65 the system background. */
|
|
18
|
+
const PALETTE = "000000 FFFFFF FF0000 00FF00 0000FF FFFF00 FF00FF 00FFFF 000000 FFFFFF FF0000 00FF00 0000FF FFFF00 FF00FF 00FFFF 800000 008000 000080 808000 800080 008080 C0C0C0 808080 9999FF 993366 FFFFCC CCFFFF 660066 FF8080 0066CC CCCCFF 000080 FF00FF FFFF00 00FFFF 800080 800000 008080 0000FF 00CCFF CCFFFF CCFFCC FFFF99 99CCFF FF99CC CC99FF FFCC99 3366FF 33CCCC 99CC00 FFCC00 FF9900 FF6600 666699 969696 003366 339966 003300 333300 993300 993366 333399 333333".split(" ");
|
|
19
|
+
/** Theme colour index (as cells use it) to clrScheme position: the first two pairs are swapped (§3.5.6). */
|
|
20
|
+
const THEME_ORDER = [
|
|
21
|
+
1,
|
|
22
|
+
0,
|
|
23
|
+
3,
|
|
24
|
+
2,
|
|
25
|
+
4,
|
|
26
|
+
5,
|
|
27
|
+
6,
|
|
28
|
+
7,
|
|
29
|
+
8,
|
|
30
|
+
9,
|
|
31
|
+
10,
|
|
32
|
+
11
|
|
33
|
+
];
|
|
34
|
+
function argb(s) {
|
|
35
|
+
if (typeof s !== "string") return void 0;
|
|
36
|
+
const hex = s.startsWith("#") ? s.slice(1) : s;
|
|
37
|
+
if (/^[0-9a-f]{6}$/i.test(hex)) return `FF${hex.toUpperCase()}`;
|
|
38
|
+
if (/^[0-9a-f]{8}$/i.test(hex)) return hex.toUpperCase();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolves any `Color` to ARGB ('FFRRGGBB'). Theme colours use the file's
|
|
42
|
+
* theme and apply the tint (ECMA-376 §18.8.19, on HSL luminance); indexed
|
|
43
|
+
* colours use the file's palette. Without them, the defaults are used.
|
|
44
|
+
* Automatic colour and anything unreadable give black.
|
|
45
|
+
*/
|
|
46
|
+
function resolveColor(color, ctx) {
|
|
47
|
+
if (typeof color === "string") return argb(color) ?? "FF000000";
|
|
48
|
+
if ("rgb" in color) return argb(color.rgb) ?? "FF000000";
|
|
49
|
+
if ("indexed" in color) {
|
|
50
|
+
const i = color.indexed;
|
|
51
|
+
if (i === 64) return "FF000000";
|
|
52
|
+
if (i === 65) return "FFFFFFFF";
|
|
53
|
+
return argb(ctx?.indexedColors?.[i]) ?? (PALETTE[i] ? `FF${PALETTE[i]}` : "FF000000");
|
|
54
|
+
}
|
|
55
|
+
if ("theme" in color) {
|
|
56
|
+
const pos = THEME_ORDER[color.theme];
|
|
57
|
+
if (pos === void 0) return "FF000000";
|
|
58
|
+
const base = argb(ctx?.theme?.colors[pos]) ?? `FF${DEFAULT_THEME[pos]}`;
|
|
59
|
+
return color.tint ? tinted(base, color.tint) : base;
|
|
60
|
+
}
|
|
61
|
+
return "FF000000";
|
|
62
|
+
}
|
|
63
|
+
/** Applies a tint to the HSL luminance: darker for negative tints, lighter for positive ones. */
|
|
64
|
+
function tinted(base, tint) {
|
|
65
|
+
const [h, l, s] = rgbToHls(Number.parseInt(base.slice(2, 4), 16) / 255, Number.parseInt(base.slice(4, 6), 16) / 255, Number.parseInt(base.slice(6, 8), 16) / 255);
|
|
66
|
+
const t = Math.max(-1, Math.min(1, tint));
|
|
67
|
+
const [r2, g2, b2] = hlsToRgb(h, t < 0 ? l * (1 + t) : l * (1 - t) + t, s);
|
|
68
|
+
const hex = (x) => Math.round(Math.max(0, Math.min(1, x)) * 255).toString(16).padStart(2, "0").toUpperCase();
|
|
69
|
+
return `${base.slice(0, 2)}${hex(r2)}${hex(g2)}${hex(b2)}`;
|
|
70
|
+
}
|
|
71
|
+
function rgbToHls(r, g, b) {
|
|
72
|
+
const max = Math.max(r, g, b);
|
|
73
|
+
const min = Math.min(r, g, b);
|
|
74
|
+
const l = (max + min) / 2;
|
|
75
|
+
if (max === min) return [
|
|
76
|
+
0,
|
|
77
|
+
l,
|
|
78
|
+
0
|
|
79
|
+
];
|
|
80
|
+
const d = max - min;
|
|
81
|
+
const s = l <= .5 ? d / (max + min) : d / (2 - max - min);
|
|
82
|
+
let h;
|
|
83
|
+
if (max === r) h = (g - b) / d;
|
|
84
|
+
else if (max === g) h = 2 + (b - r) / d;
|
|
85
|
+
else h = 4 + (r - g) / d;
|
|
86
|
+
h = (h / 6 % 1 + 1) % 1;
|
|
87
|
+
return [
|
|
88
|
+
h,
|
|
89
|
+
l,
|
|
90
|
+
s
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
function hlsToRgb(h, l, s) {
|
|
94
|
+
if (s === 0) return [
|
|
95
|
+
l,
|
|
96
|
+
l,
|
|
97
|
+
l
|
|
98
|
+
];
|
|
99
|
+
const m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
|
|
100
|
+
const m1 = 2 * l - m2;
|
|
101
|
+
const v = (hue) => {
|
|
102
|
+
const x = (hue % 1 + 1) % 1;
|
|
103
|
+
if (x < 1 / 6) return m1 + (m2 - m1) * x * 6;
|
|
104
|
+
if (x < .5) return m2;
|
|
105
|
+
if (x < 2 / 3) return m1 + (m2 - m1) * (2 / 3 - x) * 6;
|
|
106
|
+
return m1;
|
|
107
|
+
};
|
|
108
|
+
return [
|
|
109
|
+
v(h + 1 / 3),
|
|
110
|
+
v(h),
|
|
111
|
+
v(h - 1 / 3)
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
Object.defineProperty(exports, "resolveColor", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function() {
|
|
117
|
+
return resolveColor;
|
|
118
|
+
}
|
|
119
|
+
});
|
package/dist/csv.d.cts
CHANGED
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
* LF and CR newlines, a UTF-8 BOM, and lenient recovery from malformed
|
|
6
6
|
* quoting (warnings) unless `mode: 'strict'`. Pulls in nothing from the xlsx
|
|
7
7
|
* code.
|
|
8
|
+
*
|
|
9
|
+
* @module javascript-excel/csv
|
|
8
10
|
*/
|
|
9
|
-
import {
|
|
11
|
+
import { a as BlobType, i as BlobLike, n as ExcelWarningCode, r as BinaryInput, t as ExcelWarning } from "./warnings-B1v58nCZ.cjs";
|
|
12
|
+
import { D as Sheet, T as RichTextRun, a as Cell, c as CellType, h as ErrorCode, j as Workbook, l as CellValue, o as CellErrorValue, s as CellInput, w as RichText } from "./model-0JikLfuM.cjs";
|
|
10
13
|
import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
|
|
11
14
|
/** Options for `parseCsv` and `readCsv`. */
|
|
12
15
|
export interface CsvParseOptions {
|
package/dist/csv.d.ts
CHANGED
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
* LF and CR newlines, a UTF-8 BOM, and lenient recovery from malformed
|
|
6
6
|
* quoting (warnings) unless `mode: 'strict'`. Pulls in nothing from the xlsx
|
|
7
7
|
* code.
|
|
8
|
+
*
|
|
9
|
+
* @module javascript-excel/csv
|
|
8
10
|
*/
|
|
9
|
-
import {
|
|
11
|
+
import { a as BlobType, i as BlobLike, n as ExcelWarningCode, r as BinaryInput, t as ExcelWarning } from "./warnings-B1v58nCZ.js";
|
|
12
|
+
import { D as Sheet, T as RichTextRun, a as Cell, c as CellType, h as ErrorCode, j as Workbook, l as CellValue, o as CellErrorValue, s as CellInput, w as RichText } from "./model-0JikLfuM.js";
|
|
10
13
|
import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
|
|
11
14
|
/** Options for `parseCsv` and `readCsv`. */
|
|
12
15
|
export interface CsvParseOptions {
|