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
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Binary input and Blob types shared by the reader and the CSV entry.
|
|
3
|
-
*
|
|
4
|
-
* The package compiles without DOM types, so `Blob` cannot be named directly
|
|
5
|
-
* in a published signature. `BlobType` resolves to the platform's own `Blob`
|
|
6
|
-
* whenever the consumer's TypeScript setup declares one (lib "dom", or
|
|
7
|
-
* @types/node), and to the structural `BlobLike` otherwise.
|
|
8
|
-
*/
|
|
9
|
-
/** The members of `Blob` the library uses. */
|
|
10
|
-
interface BlobLike {
|
|
11
|
-
readonly size: number;
|
|
12
|
-
readonly type: string;
|
|
13
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
14
|
-
}
|
|
15
|
-
/** The platform `Blob` type when the consumer has one, else `BlobLike`. */
|
|
16
|
-
type BlobType = typeof globalThis extends {
|
|
17
|
-
Blob: {
|
|
18
|
-
prototype: infer B;
|
|
19
|
-
};
|
|
20
|
-
} ? B : BlobLike;
|
|
21
|
-
/** Bytes the library can read. A Node `Buffer` is a `Uint8Array`. */
|
|
22
|
-
type BinaryInput = Uint8Array | ArrayBuffer | BlobType;
|
|
23
1
|
/**
|
|
24
2
|
* The workbook model (docs/api.md §3).
|
|
25
3
|
*
|
|
@@ -389,22 +367,4 @@ interface Theme {
|
|
|
389
367
|
/** Minor (body) latin typeface. */
|
|
390
368
|
minorFont?: string | undefined;
|
|
391
369
|
}
|
|
392
|
-
|
|
393
|
-
* Warnings (docs/api.md §7.3).
|
|
394
|
-
*
|
|
395
|
-
* The reader and the CSV parser collect warnings for damage they can recover
|
|
396
|
-
* from, instead of throwing. Each warning is plain data.
|
|
397
|
-
*/
|
|
398
|
-
/** Every warning code the library reports. */
|
|
399
|
-
type ExcelWarningCode = "UNSUPPORTED_PART" | "INVALID_STYLE_INDEX" | "INVALID_SHARED_STRING" | "CELL_OUT_OF_BOUNDS" | "INVALID_CELL_REF" | "DUPLICATE_CELL" | "INVALID_DATE_SERIAL" | "SHARED_FORMULA_UNRESOLVED" | "MISSING_PART" | "BROKEN_OPTIONAL_PART" | "HYPERLINK_RANGE_REDUCED" | "SPLIT_PANE_IGNORED" | "COERCION_FAILED" | "NON_FINITE_NUMBER" | "HYPERLINK_DROPPED" | "CSV_UNTERMINATED_QUOTE" | "CSV_STRAY_QUOTE" | "CSV_FIELD_COUNT" | "CSV_INVALID_ENCODING" | "CSV_ROWS_TRUNCATED" | "WARNINGS_TRUNCATED";
|
|
400
|
-
/** A recoverable problem found while reading or building. */
|
|
401
|
-
interface ExcelWarning {
|
|
402
|
-
code: ExcelWarningCode;
|
|
403
|
-
message: string;
|
|
404
|
-
/** Zip part, e.g. `'xl/worksheets/sheet2.xml'`. */
|
|
405
|
-
part?: string | undefined;
|
|
406
|
-
sheet?: string | undefined;
|
|
407
|
-
/** Cell or range, e.g. `'B3'`. For CSV, the cell the record and field map to. */
|
|
408
|
-
ref?: string | undefined;
|
|
409
|
-
}
|
|
410
|
-
export { SheetView as A, PatternFill as C, RichTextRun as D, RichText as E, BlobLike as F, BlobType as I, Theme as M, Workbook as N, RowProps as O, BinaryInput as P, NumFmt as S, PrintSetup as T, ErrorCode as _, BorderSide as a, GradientFill as b, CellErrorValue as c, CellValue as d, Color as f, DocProperties as g, DefinedName as h, Border as i, Style as j, Sheet as k, CellInput as l, ColumnWidth as m, ExcelWarningCode as n, BorderStyle as o, ColumnProps as p, Alignment as r, Cell as s, ExcelWarning as t, CellType as u, Fill as v, PatternType as w, Hyperlink as x, Font as y };
|
|
370
|
+
export { Theme as A, PrintSetup as C, Sheet as D, RowProps as E, SheetView as O, PatternType as S, RichTextRun as T, Font as _, Cell as a, NumFmt as b, CellType as c, ColumnProps as d, ColumnWidth as f, Fill as g, ErrorCode as h, BorderStyle as i, Workbook as j, Style as k, CellValue as l, DocProperties as m, Border as n, CellErrorValue as o, DefinedName as p, BorderSide as r, CellInput as s, Alignment as t, Color as u, GradientFill as v, RichText as w, PatternFill as x, Hyperlink as y };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// src/numfmt.ts
|
|
2
|
+
/** The built-in number formats ECMA-376 §18.8.30 defines (§11.2). Ids 14–17 and 22 render in the user's locale in Excel. */
|
|
3
|
+
const BUILTIN_NUM_FMTS = Object.freeze({
|
|
4
|
+
0: "General",
|
|
5
|
+
1: "0",
|
|
6
|
+
2: "0.00",
|
|
7
|
+
3: "#,##0",
|
|
8
|
+
4: "#,##0.00",
|
|
9
|
+
9: "0%",
|
|
10
|
+
10: "0.00%",
|
|
11
|
+
11: "0.00E+00",
|
|
12
|
+
12: "# ?/?",
|
|
13
|
+
13: "# ??/??",
|
|
14
|
+
14: "mm-dd-yy",
|
|
15
|
+
15: "d-mmm-yy",
|
|
16
|
+
16: "d-mmm",
|
|
17
|
+
17: "mmm-yy",
|
|
18
|
+
18: "h:mm AM/PM",
|
|
19
|
+
19: "h:mm:ss AM/PM",
|
|
20
|
+
20: "h:mm",
|
|
21
|
+
21: "h:mm:ss",
|
|
22
|
+
22: "m/d/yy h:mm",
|
|
23
|
+
37: "#,##0 ;(#,##0)",
|
|
24
|
+
38: "#,##0 ;[Red](#,##0)",
|
|
25
|
+
39: "#,##0.00;(#,##0.00)",
|
|
26
|
+
40: "#,##0.00;[Red](#,##0.00)",
|
|
27
|
+
45: "mm:ss",
|
|
28
|
+
46: "[h]:mm:ss",
|
|
29
|
+
47: "mmss.0",
|
|
30
|
+
48: "##0.0E+0",
|
|
31
|
+
49: "@"
|
|
32
|
+
});
|
|
33
|
+
/** Built-in ids that are dates or times: 14–22, 45 and 47, and the East Asian locale ids 27–36 and 50–58. 46 is `[h]:mm:ss`, a duration. */
|
|
34
|
+
const DATE_IDS = /* @__PURE__ */ new Set([
|
|
35
|
+
14,
|
|
36
|
+
15,
|
|
37
|
+
16,
|
|
38
|
+
17,
|
|
39
|
+
18,
|
|
40
|
+
19,
|
|
41
|
+
20,
|
|
42
|
+
21,
|
|
43
|
+
22,
|
|
44
|
+
27,
|
|
45
|
+
28,
|
|
46
|
+
29,
|
|
47
|
+
30,
|
|
48
|
+
31,
|
|
49
|
+
32,
|
|
50
|
+
33,
|
|
51
|
+
34,
|
|
52
|
+
35,
|
|
53
|
+
36,
|
|
54
|
+
45,
|
|
55
|
+
47,
|
|
56
|
+
50,
|
|
57
|
+
51,
|
|
58
|
+
52,
|
|
59
|
+
53,
|
|
60
|
+
54,
|
|
61
|
+
55,
|
|
62
|
+
56,
|
|
63
|
+
57,
|
|
64
|
+
58
|
|
65
|
+
]);
|
|
66
|
+
const cache = /* @__PURE__ */ new Map();
|
|
67
|
+
/**
|
|
68
|
+
* True when a number format shows a date or a time of day (§3.4.1): built-in
|
|
69
|
+
* ids 14–22, 45, 47, 27–36 and 50–58, or a custom code that contains a date or
|
|
70
|
+
* time token outside quoted text, escapes and brackets. Elapsed-time formats
|
|
71
|
+
* (`[h]:mm:ss`, built-in 46) are durations and return false.
|
|
72
|
+
*/
|
|
73
|
+
function isDateFormat(fmt) {
|
|
74
|
+
if (fmt === void 0) return false;
|
|
75
|
+
if (typeof fmt === "number") return DATE_IDS.has(fmt);
|
|
76
|
+
let hit = cache.get(fmt);
|
|
77
|
+
if (hit === void 0) {
|
|
78
|
+
hit = detect(fmt);
|
|
79
|
+
if (cache.size < 1e3) cache.set(fmt, hit);
|
|
80
|
+
}
|
|
81
|
+
return hit;
|
|
82
|
+
}
|
|
83
|
+
function detect(code) {
|
|
84
|
+
let s = "";
|
|
85
|
+
let inQuote = false;
|
|
86
|
+
for (let i = 0; i < code.length; i++) {
|
|
87
|
+
const ch = code[i];
|
|
88
|
+
if (inQuote) {
|
|
89
|
+
if (ch === "\"") inQuote = false;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (ch === "\"") {
|
|
93
|
+
inQuote = true;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (ch === "\\" || ch === "_" || ch === "*") {
|
|
97
|
+
i++;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (ch === ";") break;
|
|
101
|
+
if (ch === "[") {
|
|
102
|
+
const end = code.indexOf("]", i + 1);
|
|
103
|
+
if (end === -1) break;
|
|
104
|
+
const inner = code.slice(i + 1, end).toLowerCase();
|
|
105
|
+
if (/^(h+|m+|s+)$/.test(inner)) return false;
|
|
106
|
+
i = end;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
s += ch;
|
|
110
|
+
}
|
|
111
|
+
s = s.replace(/general/gi, "").replace(/e[+-]/gi, "");
|
|
112
|
+
return /[ymdhs]|am\/pm|a\/p|[egb]/i.test(s);
|
|
113
|
+
}
|
|
114
|
+
Object.defineProperty(exports, "BUILTIN_NUM_FMTS", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function() {
|
|
117
|
+
return BUILTIN_NUM_FMTS;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(exports, "isDateFormat", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function() {
|
|
123
|
+
return isDateFormat;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// src/numfmt.ts
|
|
2
|
+
/** The built-in number formats ECMA-376 §18.8.30 defines (§11.2). Ids 14–17 and 22 render in the user's locale in Excel. */
|
|
3
|
+
const BUILTIN_NUM_FMTS = Object.freeze({
|
|
4
|
+
0: "General",
|
|
5
|
+
1: "0",
|
|
6
|
+
2: "0.00",
|
|
7
|
+
3: "#,##0",
|
|
8
|
+
4: "#,##0.00",
|
|
9
|
+
9: "0%",
|
|
10
|
+
10: "0.00%",
|
|
11
|
+
11: "0.00E+00",
|
|
12
|
+
12: "# ?/?",
|
|
13
|
+
13: "# ??/??",
|
|
14
|
+
14: "mm-dd-yy",
|
|
15
|
+
15: "d-mmm-yy",
|
|
16
|
+
16: "d-mmm",
|
|
17
|
+
17: "mmm-yy",
|
|
18
|
+
18: "h:mm AM/PM",
|
|
19
|
+
19: "h:mm:ss AM/PM",
|
|
20
|
+
20: "h:mm",
|
|
21
|
+
21: "h:mm:ss",
|
|
22
|
+
22: "m/d/yy h:mm",
|
|
23
|
+
37: "#,##0 ;(#,##0)",
|
|
24
|
+
38: "#,##0 ;[Red](#,##0)",
|
|
25
|
+
39: "#,##0.00;(#,##0.00)",
|
|
26
|
+
40: "#,##0.00;[Red](#,##0.00)",
|
|
27
|
+
45: "mm:ss",
|
|
28
|
+
46: "[h]:mm:ss",
|
|
29
|
+
47: "mmss.0",
|
|
30
|
+
48: "##0.0E+0",
|
|
31
|
+
49: "@"
|
|
32
|
+
});
|
|
33
|
+
/** Built-in ids that are dates or times: 14–22, 45 and 47, and the East Asian locale ids 27–36 and 50–58. 46 is `[h]:mm:ss`, a duration. */
|
|
34
|
+
const DATE_IDS = /* @__PURE__ */ new Set([
|
|
35
|
+
14,
|
|
36
|
+
15,
|
|
37
|
+
16,
|
|
38
|
+
17,
|
|
39
|
+
18,
|
|
40
|
+
19,
|
|
41
|
+
20,
|
|
42
|
+
21,
|
|
43
|
+
22,
|
|
44
|
+
27,
|
|
45
|
+
28,
|
|
46
|
+
29,
|
|
47
|
+
30,
|
|
48
|
+
31,
|
|
49
|
+
32,
|
|
50
|
+
33,
|
|
51
|
+
34,
|
|
52
|
+
35,
|
|
53
|
+
36,
|
|
54
|
+
45,
|
|
55
|
+
47,
|
|
56
|
+
50,
|
|
57
|
+
51,
|
|
58
|
+
52,
|
|
59
|
+
53,
|
|
60
|
+
54,
|
|
61
|
+
55,
|
|
62
|
+
56,
|
|
63
|
+
57,
|
|
64
|
+
58
|
|
65
|
+
]);
|
|
66
|
+
const cache = /* @__PURE__ */ new Map();
|
|
67
|
+
/**
|
|
68
|
+
* True when a number format shows a date or a time of day (§3.4.1): built-in
|
|
69
|
+
* ids 14–22, 45, 47, 27–36 and 50–58, or a custom code that contains a date or
|
|
70
|
+
* time token outside quoted text, escapes and brackets. Elapsed-time formats
|
|
71
|
+
* (`[h]:mm:ss`, built-in 46) are durations and return false.
|
|
72
|
+
*/
|
|
73
|
+
function isDateFormat(fmt) {
|
|
74
|
+
if (fmt === void 0) return false;
|
|
75
|
+
if (typeof fmt === "number") return DATE_IDS.has(fmt);
|
|
76
|
+
let hit = cache.get(fmt);
|
|
77
|
+
if (hit === void 0) {
|
|
78
|
+
hit = detect(fmt);
|
|
79
|
+
if (cache.size < 1e3) cache.set(fmt, hit);
|
|
80
|
+
}
|
|
81
|
+
return hit;
|
|
82
|
+
}
|
|
83
|
+
function detect(code) {
|
|
84
|
+
let s = "";
|
|
85
|
+
let inQuote = false;
|
|
86
|
+
for (let i = 0; i < code.length; i++) {
|
|
87
|
+
const ch = code[i];
|
|
88
|
+
if (inQuote) {
|
|
89
|
+
if (ch === "\"") inQuote = false;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (ch === "\"") {
|
|
93
|
+
inQuote = true;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (ch === "\\" || ch === "_" || ch === "*") {
|
|
97
|
+
i++;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (ch === ";") break;
|
|
101
|
+
if (ch === "[") {
|
|
102
|
+
const end = code.indexOf("]", i + 1);
|
|
103
|
+
if (end === -1) break;
|
|
104
|
+
const inner = code.slice(i + 1, end).toLowerCase();
|
|
105
|
+
if (/^(h+|m+|s+)$/.test(inner)) return false;
|
|
106
|
+
i = end;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
s += ch;
|
|
110
|
+
}
|
|
111
|
+
s = s.replace(/general/gi, "").replace(/e[+-]/gi, "");
|
|
112
|
+
return /[ymdhs]|am\/pm|a\/p|[egb]/i.test(s);
|
|
113
|
+
}
|
|
114
|
+
export { isDateFormat as n, BUILTIN_NUM_FMTS as t };
|