@cj-tech-master/excelts 1.4.3 → 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/README.md +3 -3
- package/README_zh.md +3 -3
- package/dist/browser/excelts.iife.js +13026 -7610
- package/dist/browser/excelts.iife.js.map +1 -1
- package/dist/browser/excelts.iife.min.js +87 -24
- 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/stream/xlsx/workbook-writer.js +3 -2
- package/dist/cjs/utils/sheet-utils.js +3 -1
- package/dist/cjs/utils/unzip/extract.js +166 -0
- package/dist/cjs/utils/unzip/index.js +7 -1
- package/dist/cjs/utils/xml-stream.js +25 -3
- package/dist/cjs/utils/zip/compress.js +261 -0
- package/dist/cjs/utils/zip/crc32.js +154 -0
- package/dist/cjs/utils/zip/index.js +70 -0
- package/dist/cjs/utils/zip/zip-builder.js +378 -0
- package/dist/cjs/utils/zip-stream.js +30 -34
- package/dist/cjs/xlsx/xform/book/defined-name-xform.js +36 -2
- package/dist/cjs/xlsx/xform/list-xform.js +6 -0
- package/dist/cjs/xlsx/xform/sheet/cell-xform.js +6 -1
- package/dist/cjs/xlsx/xform/sheet/row-xform.js +24 -2
- package/dist/cjs/xlsx/xform/table/filter-column-xform.js +4 -0
- 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/stream/xlsx/workbook-writer.js +3 -2
- package/dist/esm/utils/sheet-utils.js +3 -1
- package/dist/esm/utils/unzip/extract.js +160 -0
- package/dist/esm/utils/unzip/index.js +2 -0
- package/dist/esm/utils/xml-stream.js +25 -3
- package/dist/esm/utils/zip/compress.js +220 -0
- package/dist/esm/utils/zip/crc32.js +116 -0
- package/dist/esm/utils/zip/index.js +55 -0
- package/dist/esm/utils/zip/zip-builder.js +372 -0
- package/dist/esm/utils/zip-stream.js +30 -34
- package/dist/esm/xlsx/xform/book/defined-name-xform.js +36 -2
- package/dist/esm/xlsx/xform/list-xform.js +6 -0
- package/dist/esm/xlsx/xform/sheet/cell-xform.js +6 -1
- package/dist/esm/xlsx/xform/sheet/row-xform.js +24 -2
- package/dist/esm/xlsx/xform/table/filter-column-xform.js +4 -0
- 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/dist/types/utils/unzip/extract.d.ts +92 -0
- package/dist/types/utils/unzip/index.d.ts +1 -0
- package/dist/types/utils/xml-stream.d.ts +2 -0
- package/dist/types/utils/zip/compress.d.ts +83 -0
- package/dist/types/utils/zip/crc32.d.ts +55 -0
- package/dist/types/utils/zip/index.d.ts +52 -0
- package/dist/types/utils/zip/zip-builder.d.ts +110 -0
- package/dist/types/utils/zip-stream.d.ts +6 -12
- package/dist/types/xlsx/xform/list-xform.d.ts +1 -0
- package/dist/types/xlsx/xform/sheet/row-xform.d.ts +2 -0
- package/package.json +8 -8
package/dist/cjs/doc/anchor.js
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Anchor = void 0;
|
|
4
4
|
const col_cache_js_1 = require("../utils/col-cache");
|
|
5
|
+
function isAnchorModel(value) {
|
|
6
|
+
return (typeof value === "object" &&
|
|
7
|
+
"nativeCol" in value &&
|
|
8
|
+
"nativeRow" in value &&
|
|
9
|
+
"nativeColOff" in value &&
|
|
10
|
+
"nativeRowOff" in value);
|
|
11
|
+
}
|
|
12
|
+
function isSimpleAddress(value) {
|
|
13
|
+
return typeof value === "object" && "col" in value && "row" in value;
|
|
14
|
+
}
|
|
5
15
|
class Anchor {
|
|
6
16
|
constructor(worksheet, address, offset = 0) {
|
|
7
17
|
this.worksheet = worksheet;
|
|
@@ -18,17 +28,15 @@ class Anchor {
|
|
|
18
28
|
this.nativeRow = decoded.row + offset;
|
|
19
29
|
this.nativeRowOff = 0;
|
|
20
30
|
}
|
|
21
|
-
else if (address
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
this.nativeRowOff = anchor.nativeRowOff || 0;
|
|
31
|
+
else if (isAnchorModel(address)) {
|
|
32
|
+
this.nativeCol = address.nativeCol || 0;
|
|
33
|
+
this.nativeColOff = address.nativeColOff || 0;
|
|
34
|
+
this.nativeRow = address.nativeRow || 0;
|
|
35
|
+
this.nativeRowOff = address.nativeRowOff || 0;
|
|
27
36
|
}
|
|
28
|
-
else if (address
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
this.row = simple.row + offset;
|
|
37
|
+
else if (isSimpleAddress(address)) {
|
|
38
|
+
this.col = address.col + offset;
|
|
39
|
+
this.row = address.row + offset;
|
|
32
40
|
}
|
|
33
41
|
else {
|
|
34
42
|
this.nativeCol = 0;
|
|
@@ -38,7 +46,13 @@ class Anchor {
|
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
static asInstance(model) {
|
|
41
|
-
|
|
49
|
+
if (model == null) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if (model instanceof Anchor) {
|
|
53
|
+
return model;
|
|
54
|
+
}
|
|
55
|
+
return new Anchor(undefined, model);
|
|
42
56
|
}
|
|
43
57
|
get col() {
|
|
44
58
|
return this.nativeCol + Math.min(this.colWidth - 1, this.nativeColOff) / this.colWidth;
|
package/dist/cjs/doc/cell.js
CHANGED
|
@@ -187,11 +187,30 @@ class Cell {
|
|
|
187
187
|
this._value = Value.create(Value.getType(v), this, v);
|
|
188
188
|
}
|
|
189
189
|
get note() {
|
|
190
|
-
|
|
190
|
+
if (!this._comment) {
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
const noteValue = this._comment.note;
|
|
194
|
+
return noteValue;
|
|
191
195
|
}
|
|
192
196
|
set note(note) {
|
|
193
197
|
this._comment = new note_js_1.Note(note);
|
|
194
198
|
}
|
|
199
|
+
// Internal comment accessor for row operations
|
|
200
|
+
get comment() {
|
|
201
|
+
return this._comment;
|
|
202
|
+
}
|
|
203
|
+
set comment(comment) {
|
|
204
|
+
if (comment === undefined) {
|
|
205
|
+
this._comment = undefined;
|
|
206
|
+
}
|
|
207
|
+
else if (comment instanceof note_js_1.Note) {
|
|
208
|
+
this._comment = comment;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
this._comment = new note_js_1.Note(comment);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
195
214
|
get text() {
|
|
196
215
|
return this._value.toString();
|
|
197
216
|
}
|
|
@@ -205,7 +224,7 @@ class Cell {
|
|
|
205
224
|
// if this cell is a string, turn it into a Hyperlink
|
|
206
225
|
if (this.type === Cell.Types.String) {
|
|
207
226
|
this._value = Value.create(Cell.Types.Hyperlink, this, {
|
|
208
|
-
text: this._value.value,
|
|
227
|
+
text: String(this._value.value),
|
|
209
228
|
hyperlink
|
|
210
229
|
});
|
|
211
230
|
}
|
|
@@ -299,8 +318,6 @@ class Cell {
|
|
|
299
318
|
}
|
|
300
319
|
exports.Cell = Cell;
|
|
301
320
|
Cell.Types = enums_js_1.Enums.ValueType;
|
|
302
|
-
// =============================================================================
|
|
303
|
-
// Internal Value Types
|
|
304
321
|
class NullValue {
|
|
305
322
|
constructor(cell) {
|
|
306
323
|
this.model = {
|
|
@@ -417,7 +434,7 @@ class RichTextValue {
|
|
|
417
434
|
this.model.value = value;
|
|
418
435
|
}
|
|
419
436
|
toString() {
|
|
420
|
-
return this.model.value.richText.map(
|
|
437
|
+
return this.model.value.richText.map(t => t.text).join("");
|
|
421
438
|
}
|
|
422
439
|
get type() {
|
|
423
440
|
return Cell.Types.RichText;
|
|
@@ -486,14 +503,11 @@ class HyperlinkValue {
|
|
|
486
503
|
}
|
|
487
504
|
}
|
|
488
505
|
get value() {
|
|
489
|
-
|
|
490
|
-
text: this.model.text,
|
|
491
|
-
hyperlink: this.model.hyperlink
|
|
506
|
+
return {
|
|
507
|
+
text: this.model.text || "",
|
|
508
|
+
hyperlink: this.model.hyperlink || "",
|
|
509
|
+
tooltip: this.model.tooltip
|
|
492
510
|
};
|
|
493
|
-
if (this.model.tooltip) {
|
|
494
|
-
v.tooltip = this.model.tooltip;
|
|
495
|
-
}
|
|
496
|
-
return v;
|
|
497
511
|
}
|
|
498
512
|
set value(value) {
|
|
499
513
|
this.model.text = value.text;
|
|
@@ -604,24 +618,42 @@ class FormulaValue {
|
|
|
604
618
|
}
|
|
605
619
|
_copyModel(model) {
|
|
606
620
|
const copy = {};
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
621
|
+
if (model.formula) {
|
|
622
|
+
copy.formula = model.formula;
|
|
623
|
+
}
|
|
624
|
+
if (model.result !== undefined) {
|
|
625
|
+
copy.result = model.result;
|
|
626
|
+
}
|
|
627
|
+
if (model.ref) {
|
|
628
|
+
copy.ref = model.ref;
|
|
629
|
+
}
|
|
630
|
+
if (model.shareType) {
|
|
631
|
+
copy.shareType = model.shareType;
|
|
632
|
+
}
|
|
633
|
+
if (model.sharedFormula) {
|
|
634
|
+
copy.sharedFormula = model.sharedFormula;
|
|
635
|
+
}
|
|
618
636
|
return copy;
|
|
619
637
|
}
|
|
620
638
|
get value() {
|
|
621
639
|
return this._copyModel(this.model);
|
|
622
640
|
}
|
|
623
641
|
set value(value) {
|
|
624
|
-
|
|
642
|
+
if (value.formula) {
|
|
643
|
+
this.model.formula = value.formula;
|
|
644
|
+
}
|
|
645
|
+
if (value.result !== undefined) {
|
|
646
|
+
this.model.result = value.result;
|
|
647
|
+
}
|
|
648
|
+
if (value.ref) {
|
|
649
|
+
this.model.ref = value.ref;
|
|
650
|
+
}
|
|
651
|
+
if (value.shareType) {
|
|
652
|
+
this.model.shareType = value.shareType;
|
|
653
|
+
}
|
|
654
|
+
if (value.sharedFormula) {
|
|
655
|
+
this.model.sharedFormula = value.sharedFormula;
|
|
656
|
+
}
|
|
625
657
|
}
|
|
626
658
|
validate(value) {
|
|
627
659
|
switch (Value.getType(value)) {
|
|
@@ -685,11 +717,8 @@ class FormulaValue {
|
|
|
685
717
|
if (v instanceof Date) {
|
|
686
718
|
return enums_js_1.Enums.ValueType.Date;
|
|
687
719
|
}
|
|
688
|
-
if (v
|
|
689
|
-
return enums_js_1.Enums.ValueType.
|
|
690
|
-
}
|
|
691
|
-
if (v.formula) {
|
|
692
|
-
return enums_js_1.Enums.ValueType.Formula;
|
|
720
|
+
if (typeof v === "object" && "error" in v) {
|
|
721
|
+
return enums_js_1.Enums.ValueType.Error;
|
|
693
722
|
}
|
|
694
723
|
return enums_js_1.Enums.ValueType.Null;
|
|
695
724
|
}
|
|
@@ -872,20 +901,23 @@ const Value = {
|
|
|
872
901
|
if (value instanceof Date) {
|
|
873
902
|
return Cell.Types.Date;
|
|
874
903
|
}
|
|
875
|
-
if (value
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
904
|
+
if (typeof value === "object") {
|
|
905
|
+
if ("text" in value && value.text && "hyperlink" in value && value.hyperlink) {
|
|
906
|
+
return Cell.Types.Hyperlink;
|
|
907
|
+
}
|
|
908
|
+
if (("formula" in value && value.formula) ||
|
|
909
|
+
("sharedFormula" in value && value.sharedFormula)) {
|
|
910
|
+
return Cell.Types.Formula;
|
|
911
|
+
}
|
|
912
|
+
if ("richText" in value && value.richText) {
|
|
913
|
+
return Cell.Types.RichText;
|
|
914
|
+
}
|
|
915
|
+
if ("sharedString" in value && value.sharedString) {
|
|
916
|
+
return Cell.Types.SharedString;
|
|
917
|
+
}
|
|
918
|
+
if ("error" in value && value.error) {
|
|
919
|
+
return Cell.Types.Error;
|
|
920
|
+
}
|
|
889
921
|
}
|
|
890
922
|
return Cell.Types.JSON;
|
|
891
923
|
},
|
package/dist/cjs/doc/column.js
CHANGED
|
@@ -63,7 +63,13 @@ class Column {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
get headers() {
|
|
66
|
-
|
|
66
|
+
if (Array.isArray(this._header)) {
|
|
67
|
+
return this._header;
|
|
68
|
+
}
|
|
69
|
+
if (this._header !== undefined) {
|
|
70
|
+
return [this._header];
|
|
71
|
+
}
|
|
72
|
+
return [];
|
|
67
73
|
}
|
|
68
74
|
get header() {
|
|
69
75
|
return this._header;
|
|
@@ -120,6 +126,12 @@ class Column {
|
|
|
120
126
|
this.outlineLevel === other.outlineLevel &&
|
|
121
127
|
(0, under_dash_js_1.isEqual)(this.style, other.style));
|
|
122
128
|
}
|
|
129
|
+
equivalentToModel(model) {
|
|
130
|
+
return (this.width === model.width &&
|
|
131
|
+
this.hidden === model.hidden &&
|
|
132
|
+
this.outlineLevel === model.outlineLevel &&
|
|
133
|
+
(0, under_dash_js_1.isEqual)(this.style, model.style));
|
|
134
|
+
}
|
|
123
135
|
get isDefault() {
|
|
124
136
|
if (this.isCustomWidth) {
|
|
125
137
|
return false;
|
|
@@ -143,7 +155,7 @@ class Column {
|
|
|
143
155
|
const colNumber = this.number;
|
|
144
156
|
if (!iteratee) {
|
|
145
157
|
iteratee = options;
|
|
146
|
-
options =
|
|
158
|
+
options = {};
|
|
147
159
|
}
|
|
148
160
|
this._worksheet.eachRow(options, (row, rowNumber) => {
|
|
149
161
|
iteratee(row.getCell(colNumber), rowNumber);
|
|
@@ -174,48 +186,59 @@ class Column {
|
|
|
174
186
|
}
|
|
175
187
|
// =========================================================================
|
|
176
188
|
// styles
|
|
177
|
-
_applyStyle(name, value) {
|
|
178
|
-
this.style[name] = value;
|
|
179
|
-
this.eachCell((cell) => {
|
|
180
|
-
cell[name] = value;
|
|
181
|
-
});
|
|
182
|
-
return value;
|
|
183
|
-
}
|
|
184
189
|
get numFmt() {
|
|
185
190
|
return this.style.numFmt;
|
|
186
191
|
}
|
|
187
192
|
set numFmt(value) {
|
|
188
|
-
this.
|
|
193
|
+
this.style.numFmt = value;
|
|
194
|
+
this.eachCell(cell => {
|
|
195
|
+
cell.numFmt = value;
|
|
196
|
+
});
|
|
189
197
|
}
|
|
190
198
|
get font() {
|
|
191
199
|
return this.style.font;
|
|
192
200
|
}
|
|
193
201
|
set font(value) {
|
|
194
|
-
this.
|
|
202
|
+
this.style.font = value;
|
|
203
|
+
this.eachCell(cell => {
|
|
204
|
+
cell.font = value;
|
|
205
|
+
});
|
|
195
206
|
}
|
|
196
207
|
get alignment() {
|
|
197
208
|
return this.style.alignment;
|
|
198
209
|
}
|
|
199
210
|
set alignment(value) {
|
|
200
|
-
this.
|
|
211
|
+
this.style.alignment = value;
|
|
212
|
+
this.eachCell(cell => {
|
|
213
|
+
cell.alignment = value;
|
|
214
|
+
});
|
|
201
215
|
}
|
|
202
216
|
get protection() {
|
|
203
217
|
return this.style.protection;
|
|
204
218
|
}
|
|
205
219
|
set protection(value) {
|
|
206
|
-
this.
|
|
220
|
+
this.style.protection = value;
|
|
221
|
+
this.eachCell(cell => {
|
|
222
|
+
cell.protection = value;
|
|
223
|
+
});
|
|
207
224
|
}
|
|
208
225
|
get border() {
|
|
209
226
|
return this.style.border;
|
|
210
227
|
}
|
|
211
228
|
set border(value) {
|
|
212
|
-
this.
|
|
229
|
+
this.style.border = value;
|
|
230
|
+
this.eachCell(cell => {
|
|
231
|
+
cell.border = value;
|
|
232
|
+
});
|
|
213
233
|
}
|
|
214
234
|
get fill() {
|
|
215
235
|
return this.style.fill;
|
|
216
236
|
}
|
|
217
237
|
set fill(value) {
|
|
218
|
-
this.
|
|
238
|
+
this.style.fill = value;
|
|
239
|
+
this.eachCell(cell => {
|
|
240
|
+
cell.fill = value;
|
|
241
|
+
});
|
|
219
242
|
}
|
|
220
243
|
// =============================================================================
|
|
221
244
|
// static functions
|
|
@@ -230,7 +253,7 @@ class Column {
|
|
|
230
253
|
col = null;
|
|
231
254
|
}
|
|
232
255
|
}
|
|
233
|
-
else if (!col || !column.
|
|
256
|
+
else if (!col || !column.equivalentToModel(col)) {
|
|
234
257
|
col = {
|
|
235
258
|
min: index + 1,
|
|
236
259
|
max: index + 1,
|
|
@@ -16,11 +16,15 @@ class DefinedNames {
|
|
|
16
16
|
// add a name to a cell. locStr in the form SheetName!$col$row or SheetName!$c1$r1:$c2:$r2
|
|
17
17
|
add(locStr, name) {
|
|
18
18
|
const location = col_cache_js_1.colCache.decodeEx(locStr);
|
|
19
|
+
if ("error" in location) {
|
|
20
|
+
return; // Invalid reference, skip
|
|
21
|
+
}
|
|
19
22
|
this.addEx(location, name);
|
|
20
23
|
}
|
|
21
24
|
addEx(location, name) {
|
|
22
25
|
const matrix = this.getMatrix(name);
|
|
23
|
-
if (location
|
|
26
|
+
if ("top" in location) {
|
|
27
|
+
// It's a range (DecodedRange has top/left/bottom/right from Location)
|
|
24
28
|
for (let col = location.left; col <= location.right; col++) {
|
|
25
29
|
for (let row = location.top; row <= location.bottom; row++) {
|
|
26
30
|
const address = {
|
|
@@ -34,20 +38,54 @@ class DefinedNames {
|
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
else {
|
|
41
|
+
// It's a single cell address
|
|
37
42
|
matrix.addCellEx(location);
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
remove(locStr, name) {
|
|
41
46
|
const location = col_cache_js_1.colCache.decodeEx(locStr);
|
|
47
|
+
if ("error" in location) {
|
|
48
|
+
return; // Invalid reference, skip
|
|
49
|
+
}
|
|
42
50
|
this.removeEx(location, name);
|
|
43
51
|
}
|
|
44
52
|
removeEx(location, name) {
|
|
45
53
|
const matrix = this.getMatrix(name);
|
|
46
|
-
|
|
54
|
+
if ("top" in location) {
|
|
55
|
+
// Range - remove each cell
|
|
56
|
+
for (let col = location.left; col <= location.right; col++) {
|
|
57
|
+
for (let row = location.top; row <= location.bottom; row++) {
|
|
58
|
+
matrix.removeCellEx({
|
|
59
|
+
sheetName: location.sheetName,
|
|
60
|
+
address: col_cache_js_1.colCache.n2l(col) + row,
|
|
61
|
+
row,
|
|
62
|
+
col
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
matrix.removeCellEx(location);
|
|
69
|
+
}
|
|
47
70
|
}
|
|
48
71
|
removeAllNames(location) {
|
|
49
72
|
Object.values(this.matrixMap).forEach((matrix) => {
|
|
50
|
-
|
|
73
|
+
if ("top" in location) {
|
|
74
|
+
// Range - remove each cell
|
|
75
|
+
for (let col = location.left; col <= location.right; col++) {
|
|
76
|
+
for (let row = location.top; row <= location.bottom; row++) {
|
|
77
|
+
matrix.removeCellEx({
|
|
78
|
+
sheetName: location.sheetName,
|
|
79
|
+
address: col_cache_js_1.colCache.n2l(col) + row,
|
|
80
|
+
row,
|
|
81
|
+
col
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
matrix.removeCellEx(location);
|
|
88
|
+
}
|
|
51
89
|
});
|
|
52
90
|
}
|
|
53
91
|
forEach(callback) {
|
|
@@ -59,12 +97,16 @@ class DefinedNames {
|
|
|
59
97
|
}
|
|
60
98
|
// get all the names of a cell
|
|
61
99
|
getNames(addressStr) {
|
|
62
|
-
|
|
100
|
+
const location = col_cache_js_1.colCache.decodeEx(addressStr);
|
|
101
|
+
if ("error" in location || "top" in location) {
|
|
102
|
+
return []; // Invalid reference or range not supported
|
|
103
|
+
}
|
|
104
|
+
return this.getNamesEx(location);
|
|
63
105
|
}
|
|
64
106
|
getNamesEx(address) {
|
|
65
107
|
return Object.entries(this.matrixMap)
|
|
66
108
|
.map(([name, matrix]) => matrix.findCellEx(address, false) && name)
|
|
67
|
-
.filter(Boolean);
|
|
109
|
+
.filter((name) => Boolean(name));
|
|
68
110
|
}
|
|
69
111
|
_explore(matrix, cell) {
|
|
70
112
|
cell.mark = false;
|
|
@@ -72,9 +114,13 @@ class DefinedNames {
|
|
|
72
114
|
const range = new range_js_1.Range(cell.row, cell.col, cell.row, cell.col, sheetName);
|
|
73
115
|
let x;
|
|
74
116
|
let y;
|
|
117
|
+
// Helper to get cell with proper type
|
|
118
|
+
const getCell = (row, col) => {
|
|
119
|
+
return matrix.findCellAt(sheetName, row, col);
|
|
120
|
+
};
|
|
75
121
|
// grow vertical - only one col to worry about
|
|
76
122
|
function vGrow(yy, edge) {
|
|
77
|
-
const c =
|
|
123
|
+
const c = getCell(yy, cell.col);
|
|
78
124
|
if (!c || !c.mark) {
|
|
79
125
|
return false;
|
|
80
126
|
}
|
|
@@ -88,7 +134,7 @@ class DefinedNames {
|
|
|
88
134
|
function hGrow(xx, edge) {
|
|
89
135
|
const cells = [];
|
|
90
136
|
for (y = range.top; y <= range.bottom; y++) {
|
|
91
|
-
const c =
|
|
137
|
+
const c = getCell(y, xx);
|
|
92
138
|
if (c && c.mark) {
|
|
93
139
|
cells.push(c);
|
|
94
140
|
}
|
package/dist/cjs/doc/image.js
CHANGED
|
@@ -39,19 +39,22 @@ class Image {
|
|
|
39
39
|
if (type === "image") {
|
|
40
40
|
if (typeof range === "string") {
|
|
41
41
|
const decoded = col_cache_js_1.colCache.decode(range);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
if ("top" in decoded) {
|
|
43
|
+
// It's a Location (range like "A1:C3")
|
|
44
|
+
this.range = {
|
|
45
|
+
tl: new anchor_js_1.Anchor(this.worksheet, { col: decoded.left, row: decoded.top }, -1),
|
|
46
|
+
br: new anchor_js_1.Anchor(this.worksheet, { col: decoded.right, row: decoded.bottom }, 0),
|
|
47
|
+
editAs: "oneCell"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
47
50
|
}
|
|
48
|
-
else {
|
|
51
|
+
else if (range) {
|
|
49
52
|
this.range = {
|
|
50
53
|
tl: new anchor_js_1.Anchor(this.worksheet, range.tl, 0),
|
|
51
|
-
br: range.br
|
|
54
|
+
br: range.br ? new anchor_js_1.Anchor(this.worksheet, range.br, 0) : undefined,
|
|
52
55
|
ext: range.ext,
|
|
53
56
|
editAs: range.editAs,
|
|
54
|
-
hyperlinks: hyperlinks || range.hyperlinks
|
|
57
|
+
hyperlinks: hyperlinks || ("hyperlinks" in range ? range.hyperlinks : undefined)
|
|
55
58
|
};
|
|
56
59
|
}
|
|
57
60
|
}
|
package/dist/cjs/doc/range.js
CHANGED
|
@@ -5,11 +5,17 @@ const col_cache_js_1 = require("../utils/col-cache");
|
|
|
5
5
|
// used by worksheet to calculate sheet dimensions
|
|
6
6
|
class Range {
|
|
7
7
|
constructor(...args) {
|
|
8
|
+
this.model = {
|
|
9
|
+
top: 0,
|
|
10
|
+
left: 0,
|
|
11
|
+
bottom: 0,
|
|
12
|
+
right: 0
|
|
13
|
+
};
|
|
8
14
|
this.decode(args);
|
|
9
15
|
}
|
|
10
16
|
setTLBR(t, l, b, r, s) {
|
|
11
|
-
if (
|
|
12
|
-
// setTLBR(tl, br, s)
|
|
17
|
+
if (typeof t === "string" && typeof l === "string") {
|
|
18
|
+
// setTLBR(tl, br, s) - t and l are address strings
|
|
13
19
|
const tl = col_cache_js_1.colCache.decodeAddress(t);
|
|
14
20
|
const br = col_cache_js_1.colCache.decodeAddress(l);
|
|
15
21
|
this.model = {
|
|
@@ -17,12 +23,14 @@ class Range {
|
|
|
17
23
|
left: Math.min(tl.col, br.col),
|
|
18
24
|
bottom: Math.max(tl.row, br.row),
|
|
19
25
|
right: Math.max(tl.col, br.col),
|
|
20
|
-
sheetName: b
|
|
26
|
+
sheetName: typeof b === "string" ? b : undefined
|
|
21
27
|
};
|
|
22
|
-
this.setTLBR(tl.row, tl.col, br.row, br.col, s);
|
|
23
28
|
}
|
|
24
|
-
else
|
|
25
|
-
|
|
29
|
+
else if (typeof t === "number" &&
|
|
30
|
+
typeof l === "number" &&
|
|
31
|
+
typeof b === "number" &&
|
|
32
|
+
typeof r === "number") {
|
|
33
|
+
// setTLBR(t, l, b, r, s) - all numbers
|
|
26
34
|
this.model = {
|
|
27
35
|
top: Math.min(t, b),
|
|
28
36
|
left: Math.min(l, r),
|
|
@@ -35,16 +43,33 @@ class Range {
|
|
|
35
43
|
decode(argv) {
|
|
36
44
|
switch (argv.length) {
|
|
37
45
|
case 5: // [t,l,b,r,s]
|
|
38
|
-
|
|
46
|
+
if (typeof argv[0] === "number" &&
|
|
47
|
+
typeof argv[1] === "number" &&
|
|
48
|
+
typeof argv[2] === "number" &&
|
|
49
|
+
typeof argv[3] === "number" &&
|
|
50
|
+
typeof argv[4] === "string") {
|
|
51
|
+
this.setTLBR(argv[0], argv[1], argv[2], argv[3], argv[4]);
|
|
52
|
+
}
|
|
39
53
|
break;
|
|
40
54
|
case 4: // [t,l,b,r]
|
|
41
|
-
|
|
55
|
+
if (typeof argv[0] === "number" &&
|
|
56
|
+
typeof argv[1] === "number" &&
|
|
57
|
+
typeof argv[2] === "number" &&
|
|
58
|
+
typeof argv[3] === "number") {
|
|
59
|
+
this.setTLBR(argv[0], argv[1], argv[2], argv[3]);
|
|
60
|
+
}
|
|
42
61
|
break;
|
|
43
62
|
case 3: // [tl,br,s]
|
|
44
|
-
|
|
63
|
+
if (typeof argv[0] === "string" &&
|
|
64
|
+
typeof argv[1] === "string" &&
|
|
65
|
+
typeof argv[2] === "string") {
|
|
66
|
+
this.setTLBR(argv[0], argv[1], argv[2]);
|
|
67
|
+
}
|
|
45
68
|
break;
|
|
46
69
|
case 2: // [tl,br]
|
|
47
|
-
|
|
70
|
+
if (typeof argv[0] === "string" && typeof argv[1] === "string") {
|
|
71
|
+
this.setTLBR(argv[0], argv[1]);
|
|
72
|
+
}
|
|
48
73
|
break;
|
|
49
74
|
case 1: {
|
|
50
75
|
const value = argv[0];
|
|
@@ -58,11 +83,15 @@ class Range {
|
|
|
58
83
|
sheetName: value.sheetName
|
|
59
84
|
};
|
|
60
85
|
}
|
|
61
|
-
else if (value
|
|
86
|
+
else if (Array.isArray(value)) {
|
|
62
87
|
// an arguments array
|
|
63
88
|
this.decode(value);
|
|
64
89
|
}
|
|
65
|
-
else if (
|
|
90
|
+
else if (typeof value === "object" &&
|
|
91
|
+
"top" in value &&
|
|
92
|
+
"left" in value &&
|
|
93
|
+
"bottom" in value &&
|
|
94
|
+
"right" in value) {
|
|
66
95
|
// a model
|
|
67
96
|
this.model = {
|
|
68
97
|
top: value.top,
|
|
@@ -72,25 +101,27 @@ class Range {
|
|
|
72
101
|
sheetName: value.sheetName
|
|
73
102
|
};
|
|
74
103
|
}
|
|
75
|
-
else {
|
|
104
|
+
else if (typeof value === "string") {
|
|
76
105
|
// [sheetName!]tl:br
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
106
|
+
const decoded = col_cache_js_1.colCache.decodeEx(value);
|
|
107
|
+
if ("top" in decoded) {
|
|
108
|
+
// It's a DecodedRange
|
|
79
109
|
this.model = {
|
|
80
|
-
top:
|
|
81
|
-
left:
|
|
82
|
-
bottom:
|
|
83
|
-
right:
|
|
84
|
-
sheetName:
|
|
110
|
+
top: decoded.top,
|
|
111
|
+
left: decoded.left,
|
|
112
|
+
bottom: decoded.bottom,
|
|
113
|
+
right: decoded.right,
|
|
114
|
+
sheetName: decoded.sheetName
|
|
85
115
|
};
|
|
86
116
|
}
|
|
87
|
-
else {
|
|
117
|
+
else if ("row" in decoded) {
|
|
118
|
+
// It's an Address
|
|
88
119
|
this.model = {
|
|
89
|
-
top:
|
|
90
|
-
left:
|
|
91
|
-
bottom:
|
|
92
|
-
right:
|
|
93
|
-
sheetName:
|
|
120
|
+
top: decoded.row,
|
|
121
|
+
left: decoded.col,
|
|
122
|
+
bottom: decoded.row,
|
|
123
|
+
right: decoded.col,
|
|
124
|
+
sheetName: decoded.sheetName
|
|
94
125
|
};
|
|
95
126
|
}
|
|
96
127
|
}
|
|
@@ -172,7 +203,9 @@ class Range {
|
|
|
172
203
|
}
|
|
173
204
|
expandToAddress(addressStr) {
|
|
174
205
|
const address = col_cache_js_1.colCache.decodeEx(addressStr);
|
|
175
|
-
|
|
206
|
+
if ("row" in address && "col" in address) {
|
|
207
|
+
this.expand(address.row, address.col, address.row, address.col);
|
|
208
|
+
}
|
|
176
209
|
}
|
|
177
210
|
get tl() {
|
|
178
211
|
return col_cache_js_1.colCache.n2l(this.left) + this.top;
|
|
@@ -224,7 +257,10 @@ class Range {
|
|
|
224
257
|
}
|
|
225
258
|
contains(addressStr) {
|
|
226
259
|
const address = col_cache_js_1.colCache.decodeEx(addressStr);
|
|
227
|
-
|
|
260
|
+
if ("row" in address && "col" in address) {
|
|
261
|
+
return this.containsEx(address);
|
|
262
|
+
}
|
|
263
|
+
return false;
|
|
228
264
|
}
|
|
229
265
|
containsEx(address) {
|
|
230
266
|
if (address.sheetName && this.sheetName && address.sheetName !== this.sheetName) {
|