@cj-tech-master/excelts 1.1.0 → 1.4.1
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 +1089 -568
- package/dist/browser/excelts.iife.js.map +1 -1
- package/dist/browser/excelts.iife.min.js +18 -18
- package/dist/cjs/doc/data-validations.js +29 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/utils/cell-format.js +815 -0
- package/dist/cjs/utils/parse-sax.js +2 -2
- package/dist/cjs/utils/{extra-utils.js → sheet-utils.js} +114 -89
- package/dist/cjs/utils/stream-buf.js +15 -4
- package/dist/cjs/utils/unzip/parse.js +82 -1
- package/dist/cjs/utils/utils.js +13 -17
- package/dist/cjs/utils/zip-stream.js +20 -32
- package/dist/cjs/xlsx/xform/sheet/data-validations-xform.js +46 -7
- package/dist/cjs/xlsx/xlsx.js +1 -2
- package/dist/esm/doc/data-validations.js +29 -1
- package/dist/esm/index.browser.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/cell-format.js +810 -0
- package/dist/esm/utils/parse-sax.js +1 -1
- package/dist/esm/utils/{extra-utils.js → sheet-utils.js} +97 -72
- package/dist/esm/utils/stream-buf.js +15 -4
- package/dist/esm/utils/unzip/parse.js +83 -2
- package/dist/esm/utils/utils.js +12 -16
- package/dist/esm/utils/zip-stream.js +20 -32
- package/dist/esm/xlsx/xform/sheet/data-validations-xform.js +46 -7
- package/dist/esm/xlsx/xlsx.js +1 -2
- package/dist/types/index.browser.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/cell-format.d.ts +32 -0
- package/dist/types/utils/{extra-utils.d.ts → sheet-utils.d.ts} +51 -52
- package/dist/types/utils/utils.d.ts +5 -2
- package/package.json +5 -5
- package/dist/cjs/utils/browser-buffer-decode.js +0 -13
- package/dist/cjs/utils/browser-buffer-encode.js +0 -13
- package/dist/cjs/utils/browser.js +0 -6
- package/dist/esm/utils/browser-buffer-decode.js +0 -11
- package/dist/esm/utils/browser-buffer-encode.js +0 -11
- package/dist/esm/utils/browser.js +0 -3
- package/dist/types/utils/browser-buffer-decode.d.ts +0 -2
- package/dist/types/utils/browser-buffer-encode.d.ts +0 -2
- package/dist/types/utils/browser.d.ts +0 -1
|
@@ -30,7 +30,32 @@ function optimiseDataValidations(model) {
|
|
|
30
30
|
if (!model) {
|
|
31
31
|
return [];
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
// First, handle range: prefixed keys directly (large ranges stored during parsing)
|
|
34
|
+
const rangeValidations = [];
|
|
35
|
+
const regularModel = {};
|
|
36
|
+
for (const [key, value] of Object.entries(model)) {
|
|
37
|
+
// Skip undefined/null values (removed validations)
|
|
38
|
+
if (value === undefined || value === null) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (key.startsWith("range:")) {
|
|
42
|
+
// Large range stored during parsing - output directly
|
|
43
|
+
const rangeStr = key.slice(6); // Remove "range:" prefix
|
|
44
|
+
const { sqref: _sqref, ...rest } = value;
|
|
45
|
+
rangeValidations.push({
|
|
46
|
+
...rest,
|
|
47
|
+
sqref: rangeStr
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
regularModel[key] = value;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// If no regular entries, just return range validations
|
|
55
|
+
if (Object.keys(regularModel).length === 0) {
|
|
56
|
+
return rangeValidations;
|
|
57
|
+
}
|
|
58
|
+
const dvList = Object.entries(regularModel)
|
|
34
59
|
.map(([address, dataValidation]) => ({
|
|
35
60
|
address,
|
|
36
61
|
dataValidation,
|
|
@@ -41,13 +66,14 @@ function optimiseDataValidations(model) {
|
|
|
41
66
|
const matchCol = (addr, height, col) => {
|
|
42
67
|
for (let i = 0; i < height; i++) {
|
|
43
68
|
const otherAddress = col_cache_js_1.colCache.encodeAddress(addr.row + i, col);
|
|
44
|
-
if (!
|
|
69
|
+
if (!regularModel[otherAddress] ||
|
|
70
|
+
!(0, under_dash_js_1.isEqual)(regularModel[addr.address], regularModel[otherAddress])) {
|
|
45
71
|
return false;
|
|
46
72
|
}
|
|
47
73
|
}
|
|
48
74
|
return true;
|
|
49
75
|
};
|
|
50
|
-
|
|
76
|
+
const optimized = dvList
|
|
51
77
|
.map(dv => {
|
|
52
78
|
if (!dv.marked) {
|
|
53
79
|
const addr = col_cache_js_1.colCache.decodeEx(dv.address);
|
|
@@ -61,7 +87,8 @@ function optimiseDataValidations(model) {
|
|
|
61
87
|
// iterate downwards - finding matching cells
|
|
62
88
|
let height = 1;
|
|
63
89
|
let otherAddress = col_cache_js_1.colCache.encodeAddress(addr.row + height, addr.col);
|
|
64
|
-
while (
|
|
90
|
+
while (regularModel[otherAddress] &&
|
|
91
|
+
(0, under_dash_js_1.isEqual)(dv.dataValidation, regularModel[otherAddress])) {
|
|
65
92
|
height++;
|
|
66
93
|
otherAddress = col_cache_js_1.colCache.encodeAddress(addr.row + height, addr.col);
|
|
67
94
|
}
|
|
@@ -93,6 +120,7 @@ function optimiseDataValidations(model) {
|
|
|
93
120
|
return null;
|
|
94
121
|
})
|
|
95
122
|
.filter(Boolean);
|
|
123
|
+
return [...rangeValidations, ...optimized];
|
|
96
124
|
}
|
|
97
125
|
class DataValidationsXform extends base_xform_js_1.BaseXform {
|
|
98
126
|
get tag() {
|
|
@@ -207,9 +235,20 @@ class DataValidationsXform extends base_xform_js_1.BaseXform {
|
|
|
207
235
|
list.forEach((addr) => {
|
|
208
236
|
if (addr.includes(":")) {
|
|
209
237
|
const range = new range_js_1.Range(addr);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
238
|
+
// Only expand small ranges to avoid performance issues with large ranges
|
|
239
|
+
// like B2:B1048576 (entire column validations)
|
|
240
|
+
const rangeSize = (range.bottom - range.top + 1) * (range.right - range.left + 1);
|
|
241
|
+
if (rangeSize <= 1000) {
|
|
242
|
+
// Small range: expand to individual cells for backward compatibility
|
|
243
|
+
range.forEachAddress((address) => {
|
|
244
|
+
this.model[address] = this._dataValidation;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
// Large range: store as range string with special marker
|
|
249
|
+
// The key format "range:A1:Z100" allows DataValidations.find() to detect it
|
|
250
|
+
this.model[`range:${addr}`] = this._dataValidation;
|
|
251
|
+
}
|
|
213
252
|
}
|
|
214
253
|
else {
|
|
215
254
|
this.model[addr] = this._dataValidation;
|
package/dist/cjs/xlsx/xlsx.js
CHANGED
|
@@ -11,7 +11,6 @@ const zip_stream_js_1 = require("../utils/zip-stream");
|
|
|
11
11
|
const stream_buf_js_1 = require("../utils/stream-buf");
|
|
12
12
|
const utils_js_1 = require("../utils/utils");
|
|
13
13
|
const xml_stream_js_1 = require("../utils/xml-stream");
|
|
14
|
-
const browser_buffer_decode_js_1 = require("../utils/browser-buffer-decode");
|
|
15
14
|
const styles_xform_js_1 = require("./xform/style/styles-xform");
|
|
16
15
|
const core_xform_js_1 = require("./xform/core/core-xform");
|
|
17
16
|
const shared_strings_xform_js_1 = require("./xform/strings/shared-strings-xform");
|
|
@@ -377,7 +376,7 @@ class XLSX {
|
|
|
377
376
|
readableObjectMode: true,
|
|
378
377
|
writableObjectMode: true
|
|
379
378
|
});
|
|
380
|
-
const content = (0,
|
|
379
|
+
const content = (0, utils_js_1.bufferToString)(Buffer.from(entry.data));
|
|
381
380
|
stream.end(content);
|
|
382
381
|
}
|
|
383
382
|
let match;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { colCache } from "../utils/col-cache.js";
|
|
1
2
|
class DataValidations {
|
|
2
3
|
constructor(model) {
|
|
3
4
|
this.model = model || {};
|
|
@@ -6,7 +7,34 @@ class DataValidations {
|
|
|
6
7
|
return (this.model[address] = validation);
|
|
7
8
|
}
|
|
8
9
|
find(address) {
|
|
9
|
-
|
|
10
|
+
// First check direct address match
|
|
11
|
+
const direct = this.model[address];
|
|
12
|
+
if (direct !== undefined) {
|
|
13
|
+
return direct;
|
|
14
|
+
}
|
|
15
|
+
// Check range: prefixed keys in model (from parsing large ranges)
|
|
16
|
+
// Only decode address if we have range keys to check
|
|
17
|
+
const keys = Object.keys(this.model);
|
|
18
|
+
const rangeKeys = keys.filter(k => k.startsWith("range:"));
|
|
19
|
+
if (rangeKeys.length === 0) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const decoded = colCache.decodeAddress(address);
|
|
23
|
+
for (const key of rangeKeys) {
|
|
24
|
+
const rangeStr = key.slice(6); // Remove "range:" prefix
|
|
25
|
+
const rangeDecoded = colCache.decodeEx(rangeStr);
|
|
26
|
+
if (rangeDecoded.dimensions) {
|
|
27
|
+
const tl = rangeDecoded.tl;
|
|
28
|
+
const br = rangeDecoded.br;
|
|
29
|
+
if (decoded.row >= tl.row &&
|
|
30
|
+
decoded.row <= br.row &&
|
|
31
|
+
decoded.col >= tl.col &&
|
|
32
|
+
decoded.col <= br.col) {
|
|
33
|
+
return this.model[key];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
10
38
|
}
|
|
11
39
|
remove(address) {
|
|
12
40
|
this.model[address] = undefined;
|
package/dist/esm/index.js
CHANGED