@cj-tech-master/excelts 5.1.17 → 5.1.18
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/browser/modules/archive/unzip/stream.base.js +11 -4
- package/dist/browser/modules/archive/unzip/stream.browser.js +3 -3
- package/dist/browser/modules/excel/anchor.js +2 -5
- package/dist/browser/modules/excel/cell.js +11 -9
- package/dist/browser/modules/excel/column.js +2 -2
- package/dist/browser/modules/excel/defined-names.js +2 -2
- package/dist/browser/modules/excel/note.js +1 -1
- package/dist/browser/modules/excel/row.js +7 -4
- package/dist/browser/modules/excel/stream/worksheet-reader.js +4 -1
- package/dist/browser/modules/excel/table.d.ts +20 -1
- package/dist/browser/modules/excel/table.js +118 -15
- package/dist/browser/modules/excel/utils/sheet-utils.js +1 -1
- package/dist/browser/modules/excel/worksheet.d.ts +1 -1
- package/dist/browser/modules/excel/worksheet.js +5 -4
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-xform.d.ts +3 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +6 -5
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.d.ts +3 -0
- package/dist/browser/modules/excel/xlsx/xform/style/styles-xform.d.ts +4 -0
- package/dist/browser/modules/stream/streams.browser.d.ts +5 -5
- package/dist/browser/modules/stream/streams.browser.js +12 -4
- package/dist/browser/utils/utils.base.js +1 -1
- package/dist/cjs/modules/archive/unzip/stream.base.js +11 -4
- package/dist/cjs/modules/archive/unzip/stream.browser.js +3 -3
- package/dist/cjs/modules/excel/anchor.js +2 -5
- package/dist/cjs/modules/excel/cell.js +11 -9
- package/dist/cjs/modules/excel/column.js +2 -2
- package/dist/cjs/modules/excel/defined-names.js +2 -2
- package/dist/cjs/modules/excel/note.js +1 -1
- package/dist/cjs/modules/excel/row.js +7 -4
- package/dist/cjs/modules/excel/stream/worksheet-reader.js +4 -1
- package/dist/cjs/modules/excel/table.js +118 -14
- package/dist/cjs/modules/excel/utils/sheet-utils.js +1 -1
- package/dist/cjs/modules/excel/worksheet.js +5 -4
- package/dist/cjs/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +6 -5
- package/dist/cjs/modules/stream/streams.browser.js +12 -4
- package/dist/cjs/utils/utils.base.js +1 -1
- package/dist/esm/modules/archive/unzip/stream.base.js +11 -4
- package/dist/esm/modules/archive/unzip/stream.browser.js +3 -3
- package/dist/esm/modules/excel/anchor.js +2 -5
- package/dist/esm/modules/excel/cell.js +11 -9
- package/dist/esm/modules/excel/column.js +2 -2
- package/dist/esm/modules/excel/defined-names.js +2 -2
- package/dist/esm/modules/excel/note.js +1 -1
- package/dist/esm/modules/excel/row.js +7 -4
- package/dist/esm/modules/excel/stream/worksheet-reader.js +4 -1
- package/dist/esm/modules/excel/table.js +118 -15
- package/dist/esm/modules/excel/utils/sheet-utils.js +1 -1
- package/dist/esm/modules/excel/worksheet.js +5 -4
- package/dist/esm/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +6 -5
- package/dist/esm/modules/stream/streams.browser.js +12 -4
- package/dist/esm/utils/utils.base.js +1 -1
- package/dist/iife/excelts.iife.js +724 -888
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +24 -23
- package/dist/types/modules/excel/table.d.ts +20 -1
- package/dist/types/modules/excel/worksheet.d.ts +1 -1
- package/dist/types/modules/excel/xlsx/xform/book/workbook-xform.d.ts +3 -0
- package/dist/types/modules/excel/xlsx/xform/sheet/worksheet-xform.d.ts +3 -0
- package/dist/types/modules/excel/xlsx/xform/style/styles-xform.d.ts +4 -0
- package/dist/types/modules/stream/streams.browser.d.ts +5 -5
- package/package.json +16 -16
|
@@ -668,7 +668,6 @@ function streamUntilValidatedDataDescriptor(options) {
|
|
|
668
668
|
if (written > 0) {
|
|
669
669
|
source.discard(written);
|
|
670
670
|
bytesEmitted += written;
|
|
671
|
-
available -= written;
|
|
672
671
|
scanner.onConsume(written);
|
|
673
672
|
}
|
|
674
673
|
if (waitingDrain) {
|
|
@@ -678,7 +677,6 @@ function streamUntilValidatedDataDescriptor(options) {
|
|
|
678
677
|
else {
|
|
679
678
|
const ok = output.write(source.read(idx));
|
|
680
679
|
bytesEmitted += idx;
|
|
681
|
-
available -= idx;
|
|
682
680
|
scanner.onConsume(idx);
|
|
683
681
|
if (!ok) {
|
|
684
682
|
waitingDrain = true;
|
|
@@ -979,8 +977,17 @@ async function readFileRecord(opts, io, emitter, inflateFactory, state, threshol
|
|
|
979
977
|
}
|
|
980
978
|
}
|
|
981
979
|
}
|
|
982
|
-
const
|
|
983
|
-
|
|
980
|
+
const zipVars = {
|
|
981
|
+
uncompressedSize: vars.uncompressedSize ?? 0,
|
|
982
|
+
compressedSize: vars.compressedSize ?? 0
|
|
983
|
+
};
|
|
984
|
+
const extra = (0, exports.parseExtraField)(extraFieldData, zipVars);
|
|
985
|
+
vars.lastModifiedDateTime = resolveZipEntryLastModifiedDateTime({
|
|
986
|
+
flags: vars.flags,
|
|
987
|
+
uncompressedSize: zipVars.uncompressedSize,
|
|
988
|
+
lastModifiedDate: vars.lastModifiedDate,
|
|
989
|
+
lastModifiedTime: vars.lastModifiedTime
|
|
990
|
+
}, extra);
|
|
984
991
|
entry.vars = vars;
|
|
985
992
|
entry.extraFields = extra;
|
|
986
993
|
entry.__autodraining = autodraining;
|
|
@@ -179,7 +179,7 @@ class BrowserInflateRaw extends _stream_1.Duplex {
|
|
|
179
179
|
this.writer.abort(error ?? undefined).catch(() => { });
|
|
180
180
|
}
|
|
181
181
|
this.reader.cancel(error ?? undefined).catch(() => { });
|
|
182
|
-
return super.destroy(error);
|
|
182
|
+
return super.destroy(error ?? undefined);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
// =============================================================================
|
|
@@ -398,7 +398,7 @@ class WorkerInflateRaw extends _stream_1.Duplex {
|
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
400
|
this._terminateWorker();
|
|
401
|
-
return super.destroy(error);
|
|
401
|
+
return super.destroy(error ?? undefined);
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
// =============================================================================
|
|
@@ -444,7 +444,7 @@ class FallbackInflateRaw extends _stream_1.Duplex {
|
|
|
444
444
|
destroy(error) {
|
|
445
445
|
this._finished = true;
|
|
446
446
|
this.chunks = [];
|
|
447
|
-
return super.destroy(error);
|
|
447
|
+
return super.destroy(error ?? undefined);
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
// =============================================================================
|
|
@@ -76,11 +76,8 @@ class Anchor {
|
|
|
76
76
|
: 640000;
|
|
77
77
|
}
|
|
78
78
|
get rowHeight() {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.worksheet.getRow(this.nativeRow + 1).height
|
|
82
|
-
? Math.floor(this.worksheet.getRow(this.nativeRow + 1).height * 10000)
|
|
83
|
-
: 180000;
|
|
79
|
+
const height = this.worksheet?.getRow(this.nativeRow + 1)?.height;
|
|
80
|
+
return height ? Math.floor(height * 10000) : 180000;
|
|
84
81
|
}
|
|
85
82
|
get model() {
|
|
86
83
|
return {
|
|
@@ -37,11 +37,11 @@ class Cell {
|
|
|
37
37
|
}
|
|
38
38
|
// help GC by removing cyclic (and other) references
|
|
39
39
|
destroy() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
this.style = undefined;
|
|
41
|
+
this._value = undefined;
|
|
42
|
+
this._row = undefined;
|
|
43
|
+
this._column = undefined;
|
|
44
|
+
this._address = undefined;
|
|
45
45
|
}
|
|
46
46
|
// =========================================================================
|
|
47
47
|
// Styles stuff
|
|
@@ -167,7 +167,7 @@ class Cell {
|
|
|
167
167
|
if (this._value.type !== Cell.Types.Merge) {
|
|
168
168
|
return false;
|
|
169
169
|
}
|
|
170
|
-
return this._value.isMergedTo(master);
|
|
170
|
+
return this._value.isMergedTo ? this._value.isMergedTo(master) : false;
|
|
171
171
|
}
|
|
172
172
|
get master() {
|
|
173
173
|
if (this.type === Cell.Types.Merge) {
|
|
@@ -249,7 +249,7 @@ class Cell {
|
|
|
249
249
|
return this._value.result;
|
|
250
250
|
}
|
|
251
251
|
get formulaType() {
|
|
252
|
-
return this._value.formulaType;
|
|
252
|
+
return this._value.formulaType ?? enums_1.Enums.FormulaType.None;
|
|
253
253
|
}
|
|
254
254
|
// =========================================================================
|
|
255
255
|
// Name stuff
|
|
@@ -611,7 +611,7 @@ class MergeValue {
|
|
|
611
611
|
this._master.releaseMergeRef();
|
|
612
612
|
}
|
|
613
613
|
toString() {
|
|
614
|
-
return this.value.toString();
|
|
614
|
+
return this.value != null ? this.value.toString() : "";
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
617
|
class FormulaValue {
|
|
@@ -744,7 +744,9 @@ class FormulaValue {
|
|
|
744
744
|
const { worksheet } = this.cell;
|
|
745
745
|
const master = worksheet.findCell(this.model.sharedFormula);
|
|
746
746
|
this._translatedFormula =
|
|
747
|
-
master &&
|
|
747
|
+
master && master.formula
|
|
748
|
+
? (0, shared_formula_1.slideFormula)(master.formula, master.address, this.model.address)
|
|
749
|
+
: undefined;
|
|
748
750
|
}
|
|
749
751
|
return this._translatedFormula;
|
|
750
752
|
}
|
|
@@ -113,7 +113,7 @@ class Column {
|
|
|
113
113
|
}
|
|
114
114
|
this._key = value;
|
|
115
115
|
if (value) {
|
|
116
|
-
this._worksheet.setColumnKey(
|
|
116
|
+
this._worksheet.setColumnKey(value, this);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
@@ -138,7 +138,7 @@ class Column {
|
|
|
138
138
|
* Indicate the collapsed state based on outlineLevel
|
|
139
139
|
*/
|
|
140
140
|
get collapsed() {
|
|
141
|
-
return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelCol);
|
|
141
|
+
return !!(this._outlineLevel && this._outlineLevel >= (this._worksheet.properties.outlineLevelCol ?? 0));
|
|
142
142
|
}
|
|
143
143
|
toString() {
|
|
144
144
|
return JSON.stringify({
|
|
@@ -110,7 +110,7 @@ class DefinedNames {
|
|
|
110
110
|
}
|
|
111
111
|
_explore(matrix, cell) {
|
|
112
112
|
cell.mark = false;
|
|
113
|
-
const
|
|
113
|
+
const sheetName = cell.sheetName; // Always set for cells in defined names
|
|
114
114
|
const range = new range_1.Range(cell.row, cell.col, cell.row, cell.col, sheetName);
|
|
115
115
|
let x;
|
|
116
116
|
let y;
|
|
@@ -163,7 +163,7 @@ class DefinedNames {
|
|
|
163
163
|
});
|
|
164
164
|
const ranges = matrix
|
|
165
165
|
.map((cell) => cell.mark && this._explore(matrix, cell))
|
|
166
|
-
.filter(Boolean)
|
|
166
|
+
.filter((range) => Boolean(range))
|
|
167
167
|
.map((range) => range.$shortRange);
|
|
168
168
|
return {
|
|
169
169
|
name,
|
|
@@ -37,9 +37,9 @@ class Row {
|
|
|
37
37
|
* Helps GC by breaking cyclic references
|
|
38
38
|
*/
|
|
39
39
|
destroy() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
this._worksheet = undefined;
|
|
41
|
+
this._cells = undefined;
|
|
42
|
+
this.style = undefined;
|
|
43
43
|
}
|
|
44
44
|
findCell(colNumber) {
|
|
45
45
|
return this._cells[colNumber - 1];
|
|
@@ -361,7 +361,7 @@ class Row {
|
|
|
361
361
|
this._outlineLevel = value;
|
|
362
362
|
}
|
|
363
363
|
get collapsed() {
|
|
364
|
-
return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelRow);
|
|
364
|
+
return !!(this._outlineLevel && this._outlineLevel >= (this._worksheet.properties.outlineLevelRow ?? 0));
|
|
365
365
|
}
|
|
366
366
|
// =========================================================================
|
|
367
367
|
get model() {
|
|
@@ -427,6 +427,9 @@ class Row {
|
|
|
427
427
|
};
|
|
428
428
|
}
|
|
429
429
|
previousAddress = address;
|
|
430
|
+
if (!address) {
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
430
433
|
const cell = this.getCellEx(address);
|
|
431
434
|
cell.model = cellModel;
|
|
432
435
|
break;
|
|
@@ -270,7 +270,10 @@ class WorksheetReader extends _stream_1.EventEmitter {
|
|
|
270
270
|
break;
|
|
271
271
|
case "row":
|
|
272
272
|
if (row) {
|
|
273
|
-
this._dimensions.expandRow(
|
|
273
|
+
this._dimensions.expandRow({
|
|
274
|
+
number: row.number,
|
|
275
|
+
dimensions: row.dimensions ?? undefined
|
|
276
|
+
});
|
|
274
277
|
(worksheetEvents || (worksheetEvents = [])).push({ eventType: "row", value: row });
|
|
275
278
|
}
|
|
276
279
|
row = null;
|
|
@@ -1,7 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Table = void 0;
|
|
4
|
+
exports.sanitizeTableName = sanitizeTableName;
|
|
4
5
|
const col_cache_1 = require("./utils/col-cache.js");
|
|
6
|
+
/**
|
|
7
|
+
* Maximum length for an Excel defined name (and therefore table name).
|
|
8
|
+
*/
|
|
9
|
+
const MAX_TABLE_NAME_LENGTH = 255;
|
|
10
|
+
/**
|
|
11
|
+
* Matches an A1-style cell reference pattern like A1, Z99, XFD1048576.
|
|
12
|
+
* Excel rejects table names that match this pattern.
|
|
13
|
+
*/
|
|
14
|
+
const CELL_REF_PATTERN = /^[A-Za-z]{1,3}\d+$/;
|
|
15
|
+
/**
|
|
16
|
+
* Matches an R1C1-style cell reference, e.g. R1C1, R100C200.
|
|
17
|
+
* Must have at least one digit after R and at least one digit after C
|
|
18
|
+
* to be considered a cell reference. Bare "RC" is NOT a cell reference.
|
|
19
|
+
*/
|
|
20
|
+
const R1C1_PATTERN = /^[Rr]\d+[Cc]\d+$/;
|
|
21
|
+
/**
|
|
22
|
+
* Single-character names that Excel reserves for row/column navigation.
|
|
23
|
+
* Per Microsoft docs: "You cannot use the uppercase and lowercase characters
|
|
24
|
+
* 'C', 'c', 'R', or 'r' as a defined name."
|
|
25
|
+
*/
|
|
26
|
+
const RESERVED_SINGLE_CHARS = new Set(["C", "c", "R", "r"]);
|
|
27
|
+
/**
|
|
28
|
+
* Sanitize a table name to comply with OOXML defined name rules
|
|
29
|
+
* (ECMA-376, 4th edition, Part 1, §18.5.1.2).
|
|
30
|
+
*
|
|
31
|
+
* Rules enforced (per Microsoft documentation):
|
|
32
|
+
* - First character must be a letter (any script), underscore (_), or backslash (\)
|
|
33
|
+
* - Subsequent characters may be letters, digits, underscores, or periods (.)
|
|
34
|
+
* - Backslash is only valid as the first character
|
|
35
|
+
* - Spaces are replaced with underscores
|
|
36
|
+
* - Other invalid characters are stripped
|
|
37
|
+
* - Single-character names "C", "c", "R", "r" are prefixed with _
|
|
38
|
+
* - Names that look like cell references (e.g. A1, R1C1) are prefixed with _
|
|
39
|
+
* - Maximum 255 characters
|
|
40
|
+
* - Empty result falls back to "_Table"
|
|
41
|
+
*
|
|
42
|
+
* This library applies these rules automatically so that generated files
|
|
43
|
+
* always comply with the OOXML schema, avoiding Excel "repair" dialogs.
|
|
44
|
+
*/
|
|
45
|
+
function sanitizeTableName(name) {
|
|
46
|
+
// Replace all whitespace characters (space, tab, newline, etc.) with underscores
|
|
47
|
+
let sanitized = name.replace(/\s/g, "_");
|
|
48
|
+
// Preserve a leading backslash (valid only as first character per spec)
|
|
49
|
+
let leadingBackslash = false;
|
|
50
|
+
if (sanitized.startsWith("\\")) {
|
|
51
|
+
leadingBackslash = true;
|
|
52
|
+
sanitized = sanitized.slice(1);
|
|
53
|
+
}
|
|
54
|
+
// Strip characters not valid in defined names.
|
|
55
|
+
// Subsequent characters: Unicode letters, digits, underscore, period.
|
|
56
|
+
// Backslash is NOT valid in subsequent positions.
|
|
57
|
+
sanitized = sanitized.replace(/[^\p{L}\p{N}_.]/gu, "");
|
|
58
|
+
// Re-attach leading backslash
|
|
59
|
+
if (leadingBackslash) {
|
|
60
|
+
sanitized = `\\${sanitized}`;
|
|
61
|
+
}
|
|
62
|
+
// Ensure the first character is valid (letter, underscore, or backslash)
|
|
63
|
+
if (sanitized.length > 0 && !/^[\p{L}_\\]/u.test(sanitized[0])) {
|
|
64
|
+
sanitized = `_${sanitized}`;
|
|
65
|
+
}
|
|
66
|
+
// Truncate to max length
|
|
67
|
+
if (sanitized.length > MAX_TABLE_NAME_LENGTH) {
|
|
68
|
+
sanitized = sanitized.slice(0, MAX_TABLE_NAME_LENGTH);
|
|
69
|
+
}
|
|
70
|
+
// Fallback if empty after sanitization
|
|
71
|
+
if (sanitized.length === 0) {
|
|
72
|
+
return "_Table";
|
|
73
|
+
}
|
|
74
|
+
// Avoid reserved single-character names (C, c, R, r)
|
|
75
|
+
if (sanitized.length === 1 && RESERVED_SINGLE_CHARS.has(sanitized)) {
|
|
76
|
+
sanitized = `_${sanitized}`;
|
|
77
|
+
}
|
|
78
|
+
// Avoid names that look like cell references
|
|
79
|
+
if (CELL_REF_PATTERN.test(sanitized) || R1C1_PATTERN.test(sanitized)) {
|
|
80
|
+
sanitized = `_${sanitized}`;
|
|
81
|
+
}
|
|
82
|
+
return sanitized;
|
|
83
|
+
}
|
|
5
84
|
class Column {
|
|
6
85
|
constructor(table, column, index) {
|
|
7
86
|
this.table = table;
|
|
@@ -139,16 +218,26 @@ class Table {
|
|
|
139
218
|
assign(table, "headerRow", true);
|
|
140
219
|
assign(table, "totalsRow", false);
|
|
141
220
|
assign(table, "style", {});
|
|
142
|
-
|
|
143
|
-
assign(
|
|
144
|
-
assign(
|
|
145
|
-
assign(
|
|
146
|
-
assign(
|
|
221
|
+
const style = table.style;
|
|
222
|
+
assign(style, "theme", "TableStyleMedium2");
|
|
223
|
+
assign(style, "showFirstColumn", false);
|
|
224
|
+
assign(style, "showLastColumn", false);
|
|
225
|
+
assign(style, "showRowStripes", false);
|
|
226
|
+
assign(style, "showColumnStripes", false);
|
|
227
|
+
// Sanitize table name and displayName to comply with OOXML defined name rules.
|
|
228
|
+
// Excel UI rejects invalid names; here we auto-correct to avoid "repair" dialogs.
|
|
229
|
+
if (table.name) {
|
|
230
|
+
table.name = sanitizeTableName(table.name);
|
|
231
|
+
}
|
|
232
|
+
if (table.displayName) {
|
|
233
|
+
table.displayName = sanitizeTableName(table.displayName);
|
|
234
|
+
}
|
|
147
235
|
const assert = (test, message) => {
|
|
148
236
|
if (!test) {
|
|
149
237
|
throw new Error(message);
|
|
150
238
|
}
|
|
151
239
|
};
|
|
240
|
+
assert(!!table.name, "Table must have a name");
|
|
152
241
|
assert(!!table.ref, "Table must have ref");
|
|
153
242
|
assert(!!table.columns, "Table must have column definitions");
|
|
154
243
|
assert(!!table.rows, "Table must have row definitions");
|
|
@@ -224,7 +313,7 @@ class Table {
|
|
|
224
313
|
const formula = this.getFormula(column);
|
|
225
314
|
if (formula) {
|
|
226
315
|
cell.value = {
|
|
227
|
-
formula
|
|
316
|
+
formula,
|
|
228
317
|
result: column.totalsRowResult
|
|
229
318
|
};
|
|
230
319
|
}
|
|
@@ -266,7 +355,7 @@ class Table {
|
|
|
266
355
|
const formula = this.getFormula(column);
|
|
267
356
|
if (formula) {
|
|
268
357
|
cell.value = {
|
|
269
|
-
formula
|
|
358
|
+
formula,
|
|
270
359
|
result: column.totalsRowResult
|
|
271
360
|
};
|
|
272
361
|
}
|
|
@@ -394,13 +483,13 @@ class Table {
|
|
|
394
483
|
return this.table.name;
|
|
395
484
|
}
|
|
396
485
|
set name(value) {
|
|
397
|
-
this.table.name = value;
|
|
486
|
+
this.table.name = sanitizeTableName(value);
|
|
398
487
|
}
|
|
399
488
|
get displayName() {
|
|
400
489
|
return this.table.displayName || this.table.name;
|
|
401
490
|
}
|
|
402
491
|
set displayName(value) {
|
|
403
|
-
this.table.displayName = value;
|
|
492
|
+
this.table.displayName = sanitizeTableName(value);
|
|
404
493
|
}
|
|
405
494
|
get headerRow() {
|
|
406
495
|
return this.table.headerRow;
|
|
@@ -415,33 +504,48 @@ class Table {
|
|
|
415
504
|
this._assign(this.table, "totalsRow", value);
|
|
416
505
|
}
|
|
417
506
|
get theme() {
|
|
418
|
-
return this.table.style
|
|
507
|
+
return this.table.style?.theme;
|
|
419
508
|
}
|
|
420
509
|
set theme(value) {
|
|
510
|
+
if (!this.table.style) {
|
|
511
|
+
this.table.style = {};
|
|
512
|
+
}
|
|
421
513
|
this.table.style.theme = value;
|
|
422
514
|
}
|
|
423
515
|
get showFirstColumn() {
|
|
424
|
-
return this.table.style
|
|
516
|
+
return this.table.style?.showFirstColumn;
|
|
425
517
|
}
|
|
426
518
|
set showFirstColumn(value) {
|
|
519
|
+
if (!this.table.style) {
|
|
520
|
+
this.table.style = {};
|
|
521
|
+
}
|
|
427
522
|
this.table.style.showFirstColumn = value;
|
|
428
523
|
}
|
|
429
524
|
get showLastColumn() {
|
|
430
|
-
return this.table.style
|
|
525
|
+
return this.table.style?.showLastColumn;
|
|
431
526
|
}
|
|
432
527
|
set showLastColumn(value) {
|
|
528
|
+
if (!this.table.style) {
|
|
529
|
+
this.table.style = {};
|
|
530
|
+
}
|
|
433
531
|
this.table.style.showLastColumn = value;
|
|
434
532
|
}
|
|
435
533
|
get showRowStripes() {
|
|
436
|
-
return this.table.style
|
|
534
|
+
return this.table.style?.showRowStripes;
|
|
437
535
|
}
|
|
438
536
|
set showRowStripes(value) {
|
|
537
|
+
if (!this.table.style) {
|
|
538
|
+
this.table.style = {};
|
|
539
|
+
}
|
|
439
540
|
this.table.style.showRowStripes = value;
|
|
440
541
|
}
|
|
441
542
|
get showColumnStripes() {
|
|
442
|
-
return this.table.style
|
|
543
|
+
return this.table.style?.showColumnStripes;
|
|
443
544
|
}
|
|
444
545
|
set showColumnStripes(value) {
|
|
546
|
+
if (!this.table.style) {
|
|
547
|
+
this.table.style = {};
|
|
548
|
+
}
|
|
445
549
|
this.table.style.showColumnStripes = value;
|
|
446
550
|
}
|
|
447
551
|
}
|
|
@@ -588,7 +588,7 @@ function bookAppendSheet(workbook, worksheet, name) {
|
|
|
588
588
|
});
|
|
589
589
|
// Copy column properties
|
|
590
590
|
worksheet.columns?.forEach((col, idx) => {
|
|
591
|
-
if (col && newWs.columns[idx]) {
|
|
591
|
+
if (col && newWs.columns?.[idx]) {
|
|
592
592
|
if (col.width) {
|
|
593
593
|
newWs.getColumn(idx + 1).width = col.width;
|
|
594
594
|
}
|
|
@@ -475,9 +475,9 @@ class Worksheet {
|
|
|
475
475
|
_copyStyle(src, dest, styleEmpty = false) {
|
|
476
476
|
const rSrc = this.getRow(src);
|
|
477
477
|
const rDst = this.getRow(dest);
|
|
478
|
-
rDst.style = (0, copy_style_1.copyStyle)(rSrc.style);
|
|
478
|
+
rDst.style = (0, copy_style_1.copyStyle)(rSrc.style) ?? {};
|
|
479
479
|
rSrc.eachCell({ includeEmpty: styleEmpty }, (cell, colNumber) => {
|
|
480
|
-
rDst.getCell(colNumber).style = (0, copy_style_1.copyStyle)(cell.style);
|
|
480
|
+
rDst.getCell(colNumber).style = (0, copy_style_1.copyStyle)(cell.style) ?? {};
|
|
481
481
|
});
|
|
482
482
|
rDst.height = rSrc.height;
|
|
483
483
|
}
|
|
@@ -1053,7 +1053,8 @@ class Worksheet {
|
|
|
1053
1053
|
*/
|
|
1054
1054
|
addTable(model) {
|
|
1055
1055
|
const table = new table_1.Table(this, model);
|
|
1056
|
-
|
|
1056
|
+
// Use table.name (sanitized by Table.validate()) as the key
|
|
1057
|
+
this.tables[table.name] = table;
|
|
1057
1058
|
return table;
|
|
1058
1059
|
}
|
|
1059
1060
|
/**
|
|
@@ -1170,7 +1171,7 @@ class Worksheet {
|
|
|
1170
1171
|
}
|
|
1171
1172
|
set model(value) {
|
|
1172
1173
|
this.name = value.name;
|
|
1173
|
-
this._columns = column_1.Column.fromModel(this, value.cols);
|
|
1174
|
+
this._columns = column_1.Column.fromModel(this, value.cols ?? []);
|
|
1174
1175
|
this._parseRows(value);
|
|
1175
1176
|
this._parseMergeCells(value);
|
|
1176
1177
|
this.dataValidations = new data_validations_1.DataValidations(value.dataValidations);
|
|
@@ -25,7 +25,7 @@ class CtrlPropXform extends base_xform_1.BaseXform {
|
|
|
25
25
|
return "formControlPr";
|
|
26
26
|
}
|
|
27
27
|
render(xmlStream, model) {
|
|
28
|
-
const renderModel = model || this.model;
|
|
28
|
+
const renderModel = (model || this.model);
|
|
29
29
|
const attrs = {
|
|
30
30
|
xmlns: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",
|
|
31
31
|
objectType: "CheckBox",
|
|
@@ -20,9 +20,11 @@ class VmlDrawingXform extends base_xform_1.BaseXform {
|
|
|
20
20
|
* Render VML drawing containing both notes and form controls
|
|
21
21
|
*/
|
|
22
22
|
render(xmlStream, model) {
|
|
23
|
-
const renderModel = model || this.model;
|
|
24
|
-
const
|
|
25
|
-
const
|
|
23
|
+
const renderModel = (model || this.model);
|
|
24
|
+
const comments = renderModel.comments;
|
|
25
|
+
const formControls = renderModel.formControls;
|
|
26
|
+
const hasComments = comments && comments.length > 0;
|
|
27
|
+
const hasFormControls = formControls && formControls.length > 0;
|
|
26
28
|
xmlStream.openXml(xml_stream_1.XmlStream.StdDocAttributes);
|
|
27
29
|
xmlStream.openNode(this.tag, VmlDrawingXform.DRAWING_ATTRIBUTES);
|
|
28
30
|
// Shape layout - shared by both notes and form controls
|
|
@@ -62,14 +64,13 @@ class VmlDrawingXform extends base_xform_1.BaseXform {
|
|
|
62
64
|
}
|
|
63
65
|
// Render comment shapes
|
|
64
66
|
if (hasComments) {
|
|
65
|
-
const comments = renderModel.comments;
|
|
66
67
|
for (let i = 0; i < comments.length; i++) {
|
|
67
68
|
this.map["v:shape"].render(xmlStream, comments[i], i);
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
// Render form control shapes
|
|
71
72
|
if (hasFormControls) {
|
|
72
|
-
for (const control of
|
|
73
|
+
for (const control of formControls) {
|
|
73
74
|
this._renderCheckboxShape(xmlStream, control);
|
|
74
75
|
}
|
|
75
76
|
}
|
|
@@ -1718,7 +1718,7 @@ class Transform extends event_emitter_1.EventEmitter {
|
|
|
1718
1718
|
return;
|
|
1719
1719
|
}
|
|
1720
1720
|
const result = userTransform.call(this, chunk);
|
|
1721
|
-
if (result
|
|
1721
|
+
if (result instanceof Promise) {
|
|
1722
1722
|
const awaited = await result;
|
|
1723
1723
|
if (awaited !== undefined) {
|
|
1724
1724
|
this.push(awaited);
|
|
@@ -1775,7 +1775,7 @@ class Transform extends event_emitter_1.EventEmitter {
|
|
|
1775
1775
|
return;
|
|
1776
1776
|
}
|
|
1777
1777
|
const result = userFlush.call(this);
|
|
1778
|
-
if (result
|
|
1778
|
+
if (result instanceof Promise) {
|
|
1779
1779
|
const awaited = await result;
|
|
1780
1780
|
if (awaited !== undefined && awaited !== null) {
|
|
1781
1781
|
this.push(awaited);
|
|
@@ -3381,14 +3381,22 @@ function duplexPair(options) {
|
|
|
3381
3381
|
stream2.push(chunk);
|
|
3382
3382
|
}
|
|
3383
3383
|
stream2.push(null);
|
|
3384
|
-
|
|
3384
|
+
if (typeof chunk === "function") {
|
|
3385
|
+
const cb = chunk;
|
|
3386
|
+
return originalEnd1(cb);
|
|
3387
|
+
}
|
|
3388
|
+
return originalEnd1();
|
|
3385
3389
|
};
|
|
3386
3390
|
stream2.end = function (chunk) {
|
|
3387
3391
|
if (chunk !== undefined && typeof chunk !== "function") {
|
|
3388
3392
|
stream1.push(chunk);
|
|
3389
3393
|
}
|
|
3390
3394
|
stream1.push(null);
|
|
3391
|
-
|
|
3395
|
+
if (typeof chunk === "function") {
|
|
3396
|
+
const cb = chunk;
|
|
3397
|
+
return originalEnd2(cb);
|
|
3398
|
+
}
|
|
3399
|
+
return originalEnd2();
|
|
3392
3400
|
};
|
|
3393
3401
|
return [stream1, stream2];
|
|
3394
3402
|
}
|
|
@@ -107,7 +107,7 @@ function xmlEncode(text) {
|
|
|
107
107
|
let lastIndex = 0;
|
|
108
108
|
for (let i = regexResult.index; i < text.length; i++) {
|
|
109
109
|
const charCode = text.charCodeAt(i);
|
|
110
|
-
let escape
|
|
110
|
+
let escape;
|
|
111
111
|
switch (charCode) {
|
|
112
112
|
case 34: // "
|
|
113
113
|
escape = """;
|
|
@@ -646,7 +646,6 @@ export function streamUntilValidatedDataDescriptor(options) {
|
|
|
646
646
|
if (written > 0) {
|
|
647
647
|
source.discard(written);
|
|
648
648
|
bytesEmitted += written;
|
|
649
|
-
available -= written;
|
|
650
649
|
scanner.onConsume(written);
|
|
651
650
|
}
|
|
652
651
|
if (waitingDrain) {
|
|
@@ -656,7 +655,6 @@ export function streamUntilValidatedDataDescriptor(options) {
|
|
|
656
655
|
else {
|
|
657
656
|
const ok = output.write(source.read(idx));
|
|
658
657
|
bytesEmitted += idx;
|
|
659
|
-
available -= idx;
|
|
660
658
|
scanner.onConsume(idx);
|
|
661
659
|
if (!ok) {
|
|
662
660
|
waitingDrain = true;
|
|
@@ -957,8 +955,17 @@ async function readFileRecord(opts, io, emitter, inflateFactory, state, threshol
|
|
|
957
955
|
}
|
|
958
956
|
}
|
|
959
957
|
}
|
|
960
|
-
const
|
|
961
|
-
|
|
958
|
+
const zipVars = {
|
|
959
|
+
uncompressedSize: vars.uncompressedSize ?? 0,
|
|
960
|
+
compressedSize: vars.compressedSize ?? 0
|
|
961
|
+
};
|
|
962
|
+
const extra = parseExtraField(extraFieldData, zipVars);
|
|
963
|
+
vars.lastModifiedDateTime = resolveZipEntryLastModifiedDateTime({
|
|
964
|
+
flags: vars.flags,
|
|
965
|
+
uncompressedSize: zipVars.uncompressedSize,
|
|
966
|
+
lastModifiedDate: vars.lastModifiedDate,
|
|
967
|
+
lastModifiedTime: vars.lastModifiedTime
|
|
968
|
+
}, extra);
|
|
962
969
|
entry.vars = vars;
|
|
963
970
|
entry.extraFields = extra;
|
|
964
971
|
entry.__autodraining = autodraining;
|
|
@@ -174,7 +174,7 @@ class BrowserInflateRaw extends Duplex {
|
|
|
174
174
|
this.writer.abort(error ?? undefined).catch(() => { });
|
|
175
175
|
}
|
|
176
176
|
this.reader.cancel(error ?? undefined).catch(() => { });
|
|
177
|
-
return super.destroy(error);
|
|
177
|
+
return super.destroy(error ?? undefined);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
// =============================================================================
|
|
@@ -393,7 +393,7 @@ class WorkerInflateRaw extends Duplex {
|
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
this._terminateWorker();
|
|
396
|
-
return super.destroy(error);
|
|
396
|
+
return super.destroy(error ?? undefined);
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
// =============================================================================
|
|
@@ -439,7 +439,7 @@ class FallbackInflateRaw extends Duplex {
|
|
|
439
439
|
destroy(error) {
|
|
440
440
|
this._finished = true;
|
|
441
441
|
this.chunks = [];
|
|
442
|
-
return super.destroy(error);
|
|
442
|
+
return super.destroy(error ?? undefined);
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
// =============================================================================
|
|
@@ -73,11 +73,8 @@ class Anchor {
|
|
|
73
73
|
: 640000;
|
|
74
74
|
}
|
|
75
75
|
get rowHeight() {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.worksheet.getRow(this.nativeRow + 1).height
|
|
79
|
-
? Math.floor(this.worksheet.getRow(this.nativeRow + 1).height * 10000)
|
|
80
|
-
: 180000;
|
|
76
|
+
const height = this.worksheet?.getRow(this.nativeRow + 1)?.height;
|
|
77
|
+
return height ? Math.floor(height * 10000) : 180000;
|
|
81
78
|
}
|
|
82
79
|
get model() {
|
|
83
80
|
return {
|