@cj-tech-master/excelts 1.4.4 → 1.4.5-canary.20251212053535.13d32d8
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/excelts.iife.js +8733 -8668
- package/dist/browser/excelts.iife.js.map +1 -1
- package/dist/browser/excelts.iife.min.js +28 -28
- package/dist/cjs/doc/anchor.js +25 -11
- package/dist/cjs/doc/cell.js +75 -43
- package/dist/cjs/doc/column.js +39 -16
- package/dist/cjs/doc/defined-names.js +53 -7
- package/dist/cjs/doc/image.js +11 -8
- package/dist/cjs/doc/range.js +64 -28
- package/dist/cjs/doc/row.js +33 -17
- package/dist/cjs/doc/table.js +3 -5
- package/dist/cjs/doc/workbook.js +5 -4
- package/dist/cjs/doc/worksheet.js +24 -20
- package/dist/cjs/utils/sheet-utils.js +3 -1
- package/dist/esm/doc/anchor.js +25 -11
- package/dist/esm/doc/cell.js +75 -43
- package/dist/esm/doc/column.js +39 -16
- package/dist/esm/doc/defined-names.js +53 -7
- package/dist/esm/doc/image.js +11 -8
- package/dist/esm/doc/range.js +64 -28
- package/dist/esm/doc/row.js +33 -17
- package/dist/esm/doc/table.js +3 -5
- package/dist/esm/doc/workbook.js +5 -4
- package/dist/esm/doc/worksheet.js +24 -20
- package/dist/esm/utils/sheet-utils.js +3 -1
- package/dist/types/doc/anchor.d.ts +14 -7
- package/dist/types/doc/cell.d.ts +85 -40
- package/dist/types/doc/column.d.ts +39 -34
- package/dist/types/doc/defined-names.d.ts +11 -8
- package/dist/types/doc/image.d.ts +29 -12
- package/dist/types/doc/pivot-table.d.ts +1 -1
- package/dist/types/doc/range.d.ts +15 -4
- package/dist/types/doc/row.d.ts +34 -40
- package/dist/types/doc/table.d.ts +21 -36
- package/dist/types/doc/workbook.d.ts +30 -33
- package/dist/types/doc/worksheet.d.ts +105 -80
- package/dist/types/stream/xlsx/worksheet-reader.d.ts +3 -5
- package/dist/types/types.d.ts +86 -26
- package/dist/types/utils/col-cache.d.ts +11 -8
- package/package.json +8 -8
package/dist/cjs/doc/row.js
CHANGED
|
@@ -83,12 +83,12 @@ class Row {
|
|
|
83
83
|
cDst = this.getCell(i);
|
|
84
84
|
cDst.value = cSrc.value;
|
|
85
85
|
cDst.style = cSrc.style;
|
|
86
|
-
cDst.
|
|
86
|
+
cDst.comment = cSrc.comment;
|
|
87
87
|
}
|
|
88
88
|
else if (cDst) {
|
|
89
89
|
cDst.value = null;
|
|
90
90
|
cDst.style = {};
|
|
91
|
-
cDst.
|
|
91
|
+
cDst.comment = undefined;
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -100,7 +100,7 @@ class Row {
|
|
|
100
100
|
cDst = this.getCell(i + nExpand);
|
|
101
101
|
cDst.value = cSrc.value;
|
|
102
102
|
cDst.style = cSrc.style;
|
|
103
|
-
cDst.
|
|
103
|
+
cDst.comment = cSrc.comment;
|
|
104
104
|
}
|
|
105
105
|
else {
|
|
106
106
|
this._cells[i + nExpand - 1] = undefined;
|
|
@@ -112,13 +112,18 @@ class Row {
|
|
|
112
112
|
cDst = this.getCell(start + i);
|
|
113
113
|
cDst.value = inserts[i];
|
|
114
114
|
cDst.style = {};
|
|
115
|
-
cDst.
|
|
115
|
+
cDst.comment = undefined;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
eachCell(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
eachCell(optionsOrIteratee, maybeIteratee) {
|
|
119
|
+
let options = null;
|
|
120
|
+
let iteratee;
|
|
121
|
+
if (typeof optionsOrIteratee === "function") {
|
|
122
|
+
iteratee = optionsOrIteratee;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
options = optionsOrIteratee;
|
|
126
|
+
iteratee = maybeIteratee;
|
|
122
127
|
}
|
|
123
128
|
if (options && options.includeEmpty) {
|
|
124
129
|
const n = this._cells.length;
|
|
@@ -198,7 +203,7 @@ class Row {
|
|
|
198
203
|
}
|
|
199
204
|
// returns true if the row includes at least one cell with a value
|
|
200
205
|
get hasValues() {
|
|
201
|
-
return this._cells.some(
|
|
206
|
+
return this._cells.some(cell => cell && cell.type !== enums_js_1.Enums.ValueType.Null);
|
|
202
207
|
}
|
|
203
208
|
get cellCount() {
|
|
204
209
|
return this._cells.length;
|
|
@@ -237,46 +242,57 @@ class Row {
|
|
|
237
242
|
this.style[name] = value;
|
|
238
243
|
this._cells.forEach(cell => {
|
|
239
244
|
if (cell) {
|
|
240
|
-
cell[name] = value;
|
|
245
|
+
cell.style[name] = value;
|
|
241
246
|
}
|
|
242
247
|
});
|
|
243
|
-
return value;
|
|
244
248
|
}
|
|
245
249
|
get numFmt() {
|
|
246
250
|
return this.style.numFmt;
|
|
247
251
|
}
|
|
248
252
|
set numFmt(value) {
|
|
249
|
-
|
|
253
|
+
if (value !== undefined) {
|
|
254
|
+
this._applyStyle("numFmt", value);
|
|
255
|
+
}
|
|
250
256
|
}
|
|
251
257
|
get font() {
|
|
252
258
|
return this.style.font;
|
|
253
259
|
}
|
|
254
260
|
set font(value) {
|
|
255
|
-
|
|
261
|
+
if (value !== undefined) {
|
|
262
|
+
this._applyStyle("font", value);
|
|
263
|
+
}
|
|
256
264
|
}
|
|
257
265
|
get alignment() {
|
|
258
266
|
return this.style.alignment;
|
|
259
267
|
}
|
|
260
268
|
set alignment(value) {
|
|
261
|
-
|
|
269
|
+
if (value !== undefined) {
|
|
270
|
+
this._applyStyle("alignment", value);
|
|
271
|
+
}
|
|
262
272
|
}
|
|
263
273
|
get protection() {
|
|
264
274
|
return this.style.protection;
|
|
265
275
|
}
|
|
266
276
|
set protection(value) {
|
|
267
|
-
|
|
277
|
+
if (value !== undefined) {
|
|
278
|
+
this._applyStyle("protection", value);
|
|
279
|
+
}
|
|
268
280
|
}
|
|
269
281
|
get border() {
|
|
270
282
|
return this.style.border;
|
|
271
283
|
}
|
|
272
284
|
set border(value) {
|
|
273
|
-
|
|
285
|
+
if (value !== undefined) {
|
|
286
|
+
this._applyStyle("border", value);
|
|
287
|
+
}
|
|
274
288
|
}
|
|
275
289
|
get fill() {
|
|
276
290
|
return this.style.fill;
|
|
277
291
|
}
|
|
278
292
|
set fill(value) {
|
|
279
|
-
|
|
293
|
+
if (value !== undefined) {
|
|
294
|
+
this._applyStyle("fill", value);
|
|
295
|
+
}
|
|
280
296
|
}
|
|
281
297
|
get hidden() {
|
|
282
298
|
return !!this._hidden;
|
package/dist/cjs/doc/table.js
CHANGED
|
@@ -157,9 +157,7 @@ class Table {
|
|
|
157
157
|
// the sheet...
|
|
158
158
|
const assignStyle = (cell, style) => {
|
|
159
159
|
if (style) {
|
|
160
|
-
Object.
|
|
161
|
-
cell.style[key] = style[key];
|
|
162
|
-
});
|
|
160
|
+
Object.assign(cell.style, style);
|
|
163
161
|
}
|
|
164
162
|
};
|
|
165
163
|
const { worksheet, table } = this;
|
|
@@ -377,10 +375,10 @@ class Table {
|
|
|
377
375
|
this._assign(this.table, "totalsRow", value);
|
|
378
376
|
}
|
|
379
377
|
get theme() {
|
|
380
|
-
return this.table.style.
|
|
378
|
+
return this.table.style.theme;
|
|
381
379
|
}
|
|
382
380
|
set theme(value) {
|
|
383
|
-
this.table.style.
|
|
381
|
+
this.table.style.theme = value;
|
|
384
382
|
}
|
|
385
383
|
get showFirstColumn() {
|
|
386
384
|
return this.table.style.showFirstColumn;
|
package/dist/cjs/doc/workbook.js
CHANGED
|
@@ -53,12 +53,13 @@ class Workbook {
|
|
|
53
53
|
addWorksheet(name, options) {
|
|
54
54
|
const id = this.nextId;
|
|
55
55
|
const lastOrderNo = this._worksheets.reduce((acc, ws) => ((ws && ws.orderNo) > acc ? ws.orderNo : acc), 0);
|
|
56
|
-
const worksheetOptions =
|
|
56
|
+
const worksheetOptions = {
|
|
57
|
+
...options,
|
|
57
58
|
id,
|
|
58
59
|
name,
|
|
59
60
|
orderNo: lastOrderNo + 1,
|
|
60
61
|
workbook: this
|
|
61
|
-
}
|
|
62
|
+
};
|
|
62
63
|
const worksheet = new worksheet_js_1.Worksheet(worksheetOptions);
|
|
63
64
|
this._worksheets[id] = worksheet;
|
|
64
65
|
return worksheet;
|
|
@@ -106,11 +107,11 @@ class Workbook {
|
|
|
106
107
|
addImage(image) {
|
|
107
108
|
// TODO: validation?
|
|
108
109
|
const id = this.media.length;
|
|
109
|
-
this.media.push(
|
|
110
|
+
this.media.push({ ...image, type: "image" });
|
|
110
111
|
return id;
|
|
111
112
|
}
|
|
112
113
|
getImage(id) {
|
|
113
|
-
return this.media[id];
|
|
114
|
+
return this.media[Number(id)];
|
|
114
115
|
}
|
|
115
116
|
get model() {
|
|
116
117
|
return {
|
|
@@ -128,7 +128,7 @@ class Worksheet {
|
|
|
128
128
|
}
|
|
129
129
|
name = name.substring(0, 31);
|
|
130
130
|
}
|
|
131
|
-
if (this._workbook.
|
|
131
|
+
if (this._workbook.worksheets.find(ws => ws && ws.name.toLowerCase() === name.toLowerCase())) {
|
|
132
132
|
throw new Error(`Worksheet name already exists: ${name}`);
|
|
133
133
|
}
|
|
134
134
|
this._name = name;
|
|
@@ -164,7 +164,7 @@ class Worksheet {
|
|
|
164
164
|
set columns(value) {
|
|
165
165
|
// calculate max header row count
|
|
166
166
|
this._headerRowCount = value.reduce((pv, cv) => {
|
|
167
|
-
const headerCount = (cv.header
|
|
167
|
+
const headerCount = Array.isArray(cv.header) ? cv.header.length : cv.header ? 1 : 0;
|
|
168
168
|
return Math.max(pv, headerCount);
|
|
169
169
|
}, 0);
|
|
170
170
|
// construct Column objects
|
|
@@ -220,12 +220,9 @@ class Worksheet {
|
|
|
220
220
|
if (inserts.length > 0) {
|
|
221
221
|
// must iterate over all rows whether they exist yet or not
|
|
222
222
|
for (let i = 0; i < nRows; i++) {
|
|
223
|
-
const
|
|
224
|
-
inserts.forEach(insert => {
|
|
225
|
-
rowArguments.push(insert[i] || null);
|
|
226
|
-
});
|
|
223
|
+
const insertValues = inserts.map(insert => insert[i] || null);
|
|
227
224
|
const row = this.getRow(i + 1);
|
|
228
|
-
row.splice(...
|
|
225
|
+
row.splice(start, count, ...insertValues);
|
|
229
226
|
}
|
|
230
227
|
}
|
|
231
228
|
else {
|
|
@@ -251,7 +248,7 @@ class Worksheet {
|
|
|
251
248
|
}
|
|
252
249
|
}
|
|
253
250
|
for (let i = start; i < start + inserts.length; i++) {
|
|
254
|
-
this.getColumn(i).defn =
|
|
251
|
+
this.getColumn(i).defn = undefined;
|
|
255
252
|
}
|
|
256
253
|
// account for defined names
|
|
257
254
|
this.workbook.definedNames.spliceColumns(this.name, start, count, inserts.length);
|
|
@@ -261,7 +258,7 @@ class Worksheet {
|
|
|
261
258
|
}
|
|
262
259
|
get columnCount() {
|
|
263
260
|
let maxCount = 0;
|
|
264
|
-
this.eachRow(
|
|
261
|
+
this.eachRow(row => {
|
|
265
262
|
maxCount = Math.max(maxCount, row.cellCount);
|
|
266
263
|
});
|
|
267
264
|
return maxCount;
|
|
@@ -270,7 +267,7 @@ class Worksheet {
|
|
|
270
267
|
// performance nightmare - for each row, counts all the columns used
|
|
271
268
|
const counts = [];
|
|
272
269
|
let count = 0;
|
|
273
|
-
this.eachRow(
|
|
270
|
+
this.eachRow(row => {
|
|
274
271
|
row.eachCell(({ col }) => {
|
|
275
272
|
if (!counts[col]) {
|
|
276
273
|
counts[col] = true;
|
|
@@ -451,10 +448,10 @@ class Worksheet {
|
|
|
451
448
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
452
449
|
rDst.getCell(colNumber).style = cell.style;
|
|
453
450
|
// remerge cells accounting for insert offset
|
|
454
|
-
if (cell.
|
|
455
|
-
const cellToBeMerged = this.getRow(cell.
|
|
456
|
-
const prevMaster = cell.
|
|
457
|
-
const newMaster = this.getRow(prevMaster.
|
|
451
|
+
if (cell.type === enums_js_1.Enums.ValueType.Merge) {
|
|
452
|
+
const cellToBeMerged = this.getRow(cell.row + nInserts).getCell(colNumber);
|
|
453
|
+
const prevMaster = cell.master;
|
|
454
|
+
const newMaster = this.getRow(prevMaster.row + nInserts).getCell(prevMaster.col);
|
|
458
455
|
cellToBeMerged.merge(newMaster);
|
|
459
456
|
}
|
|
460
457
|
});
|
|
@@ -473,10 +470,15 @@ class Worksheet {
|
|
|
473
470
|
// account for defined names
|
|
474
471
|
this.workbook.definedNames.spliceRows(this.name, start, count, nInserts);
|
|
475
472
|
}
|
|
476
|
-
eachRow(
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
473
|
+
eachRow(optionsOrIteratee, maybeIteratee) {
|
|
474
|
+
let options;
|
|
475
|
+
let iteratee;
|
|
476
|
+
if (typeof optionsOrIteratee === "function") {
|
|
477
|
+
iteratee = optionsOrIteratee;
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
options = optionsOrIteratee;
|
|
481
|
+
iteratee = maybeIteratee;
|
|
480
482
|
}
|
|
481
483
|
if (options && options.includeEmpty) {
|
|
482
484
|
const n = this._rows.length;
|
|
@@ -614,12 +616,14 @@ class Worksheet {
|
|
|
614
616
|
for (let r = top; r <= bottom; r++) {
|
|
615
617
|
for (let c = left; c <= right; c++) {
|
|
616
618
|
if (first) {
|
|
617
|
-
this.getCell(r, c)
|
|
619
|
+
const cell = this.getCell(r, c);
|
|
620
|
+
const formulaValue = {
|
|
618
621
|
shareType,
|
|
619
622
|
formula,
|
|
620
623
|
ref: range,
|
|
621
624
|
result: getResult(r, c)
|
|
622
625
|
};
|
|
626
|
+
cell.value = formulaValue;
|
|
623
627
|
first = false;
|
|
624
628
|
}
|
|
625
629
|
else {
|
|
@@ -755,7 +759,7 @@ Please leave feedback at https://github.com/excelts/excelts/discussions/2575`);
|
|
|
755
759
|
};
|
|
756
760
|
// =================================================
|
|
757
761
|
// columns
|
|
758
|
-
model.cols = column_js_1.Column.toModel(this.columns);
|
|
762
|
+
model.cols = column_js_1.Column.toModel(this.columns || []);
|
|
759
763
|
// ==========================================================
|
|
760
764
|
// Rows
|
|
761
765
|
const rows = (model.rows = []);
|
|
@@ -132,7 +132,9 @@ function formatValue(value, fmt, dateFormat) {
|
|
|
132
132
|
*/
|
|
133
133
|
function getCellDisplayText(cell, dateFormat) {
|
|
134
134
|
const value = cell.value;
|
|
135
|
-
const
|
|
135
|
+
const numFmt = cell.numFmt;
|
|
136
|
+
// Extract format code string from numFmt (which can be string or NumFmt object)
|
|
137
|
+
const fmt = typeof numFmt === "string" ? numFmt : (numFmt?.formatCode ?? "General");
|
|
136
138
|
// Null/undefined
|
|
137
139
|
if (value == null) {
|
|
138
140
|
return "";
|
package/dist/esm/doc/anchor.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { colCache } from "../utils/col-cache.js";
|
|
2
|
+
function isAnchorModel(value) {
|
|
3
|
+
return (typeof value === "object" &&
|
|
4
|
+
"nativeCol" in value &&
|
|
5
|
+
"nativeRow" in value &&
|
|
6
|
+
"nativeColOff" in value &&
|
|
7
|
+
"nativeRowOff" in value);
|
|
8
|
+
}
|
|
9
|
+
function isSimpleAddress(value) {
|
|
10
|
+
return typeof value === "object" && "col" in value && "row" in value;
|
|
11
|
+
}
|
|
2
12
|
class Anchor {
|
|
3
13
|
constructor(worksheet, address, offset = 0) {
|
|
4
14
|
this.worksheet = worksheet;
|
|
@@ -15,17 +25,15 @@ class Anchor {
|
|
|
15
25
|
this.nativeRow = decoded.row + offset;
|
|
16
26
|
this.nativeRowOff = 0;
|
|
17
27
|
}
|
|
18
|
-
else if (address
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.nativeRowOff = anchor.nativeRowOff || 0;
|
|
28
|
+
else if (isAnchorModel(address)) {
|
|
29
|
+
this.nativeCol = address.nativeCol || 0;
|
|
30
|
+
this.nativeColOff = address.nativeColOff || 0;
|
|
31
|
+
this.nativeRow = address.nativeRow || 0;
|
|
32
|
+
this.nativeRowOff = address.nativeRowOff || 0;
|
|
24
33
|
}
|
|
25
|
-
else if (address
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
this.row = simple.row + offset;
|
|
34
|
+
else if (isSimpleAddress(address)) {
|
|
35
|
+
this.col = address.col + offset;
|
|
36
|
+
this.row = address.row + offset;
|
|
29
37
|
}
|
|
30
38
|
else {
|
|
31
39
|
this.nativeCol = 0;
|
|
@@ -35,7 +43,13 @@ class Anchor {
|
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
45
|
static asInstance(model) {
|
|
38
|
-
|
|
46
|
+
if (model == null) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (model instanceof Anchor) {
|
|
50
|
+
return model;
|
|
51
|
+
}
|
|
52
|
+
return new Anchor(undefined, model);
|
|
39
53
|
}
|
|
40
54
|
get col() {
|
|
41
55
|
return this.nativeCol + Math.min(this.colWidth - 1, this.nativeColOff) / this.colWidth;
|
package/dist/esm/doc/cell.js
CHANGED
|
@@ -184,11 +184,30 @@ class Cell {
|
|
|
184
184
|
this._value = Value.create(Value.getType(v), this, v);
|
|
185
185
|
}
|
|
186
186
|
get note() {
|
|
187
|
-
|
|
187
|
+
if (!this._comment) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
const noteValue = this._comment.note;
|
|
191
|
+
return noteValue;
|
|
188
192
|
}
|
|
189
193
|
set note(note) {
|
|
190
194
|
this._comment = new Note(note);
|
|
191
195
|
}
|
|
196
|
+
// Internal comment accessor for row operations
|
|
197
|
+
get comment() {
|
|
198
|
+
return this._comment;
|
|
199
|
+
}
|
|
200
|
+
set comment(comment) {
|
|
201
|
+
if (comment === undefined) {
|
|
202
|
+
this._comment = undefined;
|
|
203
|
+
}
|
|
204
|
+
else if (comment instanceof Note) {
|
|
205
|
+
this._comment = comment;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
this._comment = new Note(comment);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
192
211
|
get text() {
|
|
193
212
|
return this._value.toString();
|
|
194
213
|
}
|
|
@@ -202,7 +221,7 @@ class Cell {
|
|
|
202
221
|
// if this cell is a string, turn it into a Hyperlink
|
|
203
222
|
if (this.type === Cell.Types.String) {
|
|
204
223
|
this._value = Value.create(Cell.Types.Hyperlink, this, {
|
|
205
|
-
text: this._value.value,
|
|
224
|
+
text: String(this._value.value),
|
|
206
225
|
hyperlink
|
|
207
226
|
});
|
|
208
227
|
}
|
|
@@ -295,8 +314,6 @@ class Cell {
|
|
|
295
314
|
}
|
|
296
315
|
}
|
|
297
316
|
Cell.Types = Enums.ValueType;
|
|
298
|
-
// =============================================================================
|
|
299
|
-
// Internal Value Types
|
|
300
317
|
class NullValue {
|
|
301
318
|
constructor(cell) {
|
|
302
319
|
this.model = {
|
|
@@ -413,7 +430,7 @@ class RichTextValue {
|
|
|
413
430
|
this.model.value = value;
|
|
414
431
|
}
|
|
415
432
|
toString() {
|
|
416
|
-
return this.model.value.richText.map(
|
|
433
|
+
return this.model.value.richText.map(t => t.text).join("");
|
|
417
434
|
}
|
|
418
435
|
get type() {
|
|
419
436
|
return Cell.Types.RichText;
|
|
@@ -482,14 +499,11 @@ class HyperlinkValue {
|
|
|
482
499
|
}
|
|
483
500
|
}
|
|
484
501
|
get value() {
|
|
485
|
-
|
|
486
|
-
text: this.model.text,
|
|
487
|
-
hyperlink: this.model.hyperlink
|
|
502
|
+
return {
|
|
503
|
+
text: this.model.text || "",
|
|
504
|
+
hyperlink: this.model.hyperlink || "",
|
|
505
|
+
tooltip: this.model.tooltip
|
|
488
506
|
};
|
|
489
|
-
if (this.model.tooltip) {
|
|
490
|
-
v.tooltip = this.model.tooltip;
|
|
491
|
-
}
|
|
492
|
-
return v;
|
|
493
507
|
}
|
|
494
508
|
set value(value) {
|
|
495
509
|
this.model.text = value.text;
|
|
@@ -600,24 +614,42 @@ class FormulaValue {
|
|
|
600
614
|
}
|
|
601
615
|
_copyModel(model) {
|
|
602
616
|
const copy = {};
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
617
|
+
if (model.formula) {
|
|
618
|
+
copy.formula = model.formula;
|
|
619
|
+
}
|
|
620
|
+
if (model.result !== undefined) {
|
|
621
|
+
copy.result = model.result;
|
|
622
|
+
}
|
|
623
|
+
if (model.ref) {
|
|
624
|
+
copy.ref = model.ref;
|
|
625
|
+
}
|
|
626
|
+
if (model.shareType) {
|
|
627
|
+
copy.shareType = model.shareType;
|
|
628
|
+
}
|
|
629
|
+
if (model.sharedFormula) {
|
|
630
|
+
copy.sharedFormula = model.sharedFormula;
|
|
631
|
+
}
|
|
614
632
|
return copy;
|
|
615
633
|
}
|
|
616
634
|
get value() {
|
|
617
635
|
return this._copyModel(this.model);
|
|
618
636
|
}
|
|
619
637
|
set value(value) {
|
|
620
|
-
|
|
638
|
+
if (value.formula) {
|
|
639
|
+
this.model.formula = value.formula;
|
|
640
|
+
}
|
|
641
|
+
if (value.result !== undefined) {
|
|
642
|
+
this.model.result = value.result;
|
|
643
|
+
}
|
|
644
|
+
if (value.ref) {
|
|
645
|
+
this.model.ref = value.ref;
|
|
646
|
+
}
|
|
647
|
+
if (value.shareType) {
|
|
648
|
+
this.model.shareType = value.shareType;
|
|
649
|
+
}
|
|
650
|
+
if (value.sharedFormula) {
|
|
651
|
+
this.model.sharedFormula = value.sharedFormula;
|
|
652
|
+
}
|
|
621
653
|
}
|
|
622
654
|
validate(value) {
|
|
623
655
|
switch (Value.getType(value)) {
|
|
@@ -681,11 +713,8 @@ class FormulaValue {
|
|
|
681
713
|
if (v instanceof Date) {
|
|
682
714
|
return Enums.ValueType.Date;
|
|
683
715
|
}
|
|
684
|
-
if (v
|
|
685
|
-
return Enums.ValueType.
|
|
686
|
-
}
|
|
687
|
-
if (v.formula) {
|
|
688
|
-
return Enums.ValueType.Formula;
|
|
716
|
+
if (typeof v === "object" && "error" in v) {
|
|
717
|
+
return Enums.ValueType.Error;
|
|
689
718
|
}
|
|
690
719
|
return Enums.ValueType.Null;
|
|
691
720
|
}
|
|
@@ -868,20 +897,23 @@ const Value = {
|
|
|
868
897
|
if (value instanceof Date) {
|
|
869
898
|
return Cell.Types.Date;
|
|
870
899
|
}
|
|
871
|
-
if (value
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
900
|
+
if (typeof value === "object") {
|
|
901
|
+
if ("text" in value && value.text && "hyperlink" in value && value.hyperlink) {
|
|
902
|
+
return Cell.Types.Hyperlink;
|
|
903
|
+
}
|
|
904
|
+
if (("formula" in value && value.formula) ||
|
|
905
|
+
("sharedFormula" in value && value.sharedFormula)) {
|
|
906
|
+
return Cell.Types.Formula;
|
|
907
|
+
}
|
|
908
|
+
if ("richText" in value && value.richText) {
|
|
909
|
+
return Cell.Types.RichText;
|
|
910
|
+
}
|
|
911
|
+
if ("sharedString" in value && value.sharedString) {
|
|
912
|
+
return Cell.Types.SharedString;
|
|
913
|
+
}
|
|
914
|
+
if ("error" in value && value.error) {
|
|
915
|
+
return Cell.Types.Error;
|
|
916
|
+
}
|
|
885
917
|
}
|
|
886
918
|
return Cell.Types.JSON;
|
|
887
919
|
},
|
package/dist/esm/doc/column.js
CHANGED
|
@@ -60,7 +60,13 @@ class Column {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
get headers() {
|
|
63
|
-
|
|
63
|
+
if (Array.isArray(this._header)) {
|
|
64
|
+
return this._header;
|
|
65
|
+
}
|
|
66
|
+
if (this._header !== undefined) {
|
|
67
|
+
return [this._header];
|
|
68
|
+
}
|
|
69
|
+
return [];
|
|
64
70
|
}
|
|
65
71
|
get header() {
|
|
66
72
|
return this._header;
|
|
@@ -117,6 +123,12 @@ class Column {
|
|
|
117
123
|
this.outlineLevel === other.outlineLevel &&
|
|
118
124
|
isEqual(this.style, other.style));
|
|
119
125
|
}
|
|
126
|
+
equivalentToModel(model) {
|
|
127
|
+
return (this.width === model.width &&
|
|
128
|
+
this.hidden === model.hidden &&
|
|
129
|
+
this.outlineLevel === model.outlineLevel &&
|
|
130
|
+
isEqual(this.style, model.style));
|
|
131
|
+
}
|
|
120
132
|
get isDefault() {
|
|
121
133
|
if (this.isCustomWidth) {
|
|
122
134
|
return false;
|
|
@@ -140,7 +152,7 @@ class Column {
|
|
|
140
152
|
const colNumber = this.number;
|
|
141
153
|
if (!iteratee) {
|
|
142
154
|
iteratee = options;
|
|
143
|
-
options =
|
|
155
|
+
options = {};
|
|
144
156
|
}
|
|
145
157
|
this._worksheet.eachRow(options, (row, rowNumber) => {
|
|
146
158
|
iteratee(row.getCell(colNumber), rowNumber);
|
|
@@ -171,48 +183,59 @@ class Column {
|
|
|
171
183
|
}
|
|
172
184
|
// =========================================================================
|
|
173
185
|
// styles
|
|
174
|
-
_applyStyle(name, value) {
|
|
175
|
-
this.style[name] = value;
|
|
176
|
-
this.eachCell((cell) => {
|
|
177
|
-
cell[name] = value;
|
|
178
|
-
});
|
|
179
|
-
return value;
|
|
180
|
-
}
|
|
181
186
|
get numFmt() {
|
|
182
187
|
return this.style.numFmt;
|
|
183
188
|
}
|
|
184
189
|
set numFmt(value) {
|
|
185
|
-
this.
|
|
190
|
+
this.style.numFmt = value;
|
|
191
|
+
this.eachCell(cell => {
|
|
192
|
+
cell.numFmt = value;
|
|
193
|
+
});
|
|
186
194
|
}
|
|
187
195
|
get font() {
|
|
188
196
|
return this.style.font;
|
|
189
197
|
}
|
|
190
198
|
set font(value) {
|
|
191
|
-
this.
|
|
199
|
+
this.style.font = value;
|
|
200
|
+
this.eachCell(cell => {
|
|
201
|
+
cell.font = value;
|
|
202
|
+
});
|
|
192
203
|
}
|
|
193
204
|
get alignment() {
|
|
194
205
|
return this.style.alignment;
|
|
195
206
|
}
|
|
196
207
|
set alignment(value) {
|
|
197
|
-
this.
|
|
208
|
+
this.style.alignment = value;
|
|
209
|
+
this.eachCell(cell => {
|
|
210
|
+
cell.alignment = value;
|
|
211
|
+
});
|
|
198
212
|
}
|
|
199
213
|
get protection() {
|
|
200
214
|
return this.style.protection;
|
|
201
215
|
}
|
|
202
216
|
set protection(value) {
|
|
203
|
-
this.
|
|
217
|
+
this.style.protection = value;
|
|
218
|
+
this.eachCell(cell => {
|
|
219
|
+
cell.protection = value;
|
|
220
|
+
});
|
|
204
221
|
}
|
|
205
222
|
get border() {
|
|
206
223
|
return this.style.border;
|
|
207
224
|
}
|
|
208
225
|
set border(value) {
|
|
209
|
-
this.
|
|
226
|
+
this.style.border = value;
|
|
227
|
+
this.eachCell(cell => {
|
|
228
|
+
cell.border = value;
|
|
229
|
+
});
|
|
210
230
|
}
|
|
211
231
|
get fill() {
|
|
212
232
|
return this.style.fill;
|
|
213
233
|
}
|
|
214
234
|
set fill(value) {
|
|
215
|
-
this.
|
|
235
|
+
this.style.fill = value;
|
|
236
|
+
this.eachCell(cell => {
|
|
237
|
+
cell.fill = value;
|
|
238
|
+
});
|
|
216
239
|
}
|
|
217
240
|
// =============================================================================
|
|
218
241
|
// static functions
|
|
@@ -227,7 +250,7 @@ class Column {
|
|
|
227
250
|
col = null;
|
|
228
251
|
}
|
|
229
252
|
}
|
|
230
|
-
else if (!col || !column.
|
|
253
|
+
else if (!col || !column.equivalentToModel(col)) {
|
|
231
254
|
col = {
|
|
232
255
|
min: index + 1,
|
|
233
256
|
max: index + 1,
|