javascript-excel 2.3.0 → 2.4.0
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 +1 -1
- package/dist/{csv-f4P3fGs-.cjs → csv-DZ241Y5F.cjs} +24 -0
- package/dist/{csv-Bck8eW_D.js → csv-Dn4MIESx.js} +24 -0
- package/dist/csv.cjs +1 -1
- package/dist/csv.d.cts +8 -0
- package/dist/csv.d.ts +8 -0
- package/dist/csv.js +1 -1
- package/dist/{dataset-DzoMeOG1.cjs → dataset-CbZnEWXu.cjs} +45 -1
- package/dist/{dataset-BLo9CwB-.js → dataset-CyEHVht4.js} +46 -2
- package/dist/import.cjs +1 -1
- package/dist/import.d.cts +1 -1
- package/dist/import.d.ts +1 -1
- package/dist/import.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{pipeline-D1eAhqJu.d.cts → pipeline-4U7Xnuc1.d.cts} +6 -3
- package/dist/{pipeline-Bh7FUyzW.d.ts → pipeline-BegSPu8X.d.ts} +6 -3
- package/dist/{pipeline-LCTU0Eg_.cjs → pipeline-BwkRpV5Z.cjs} +30 -8
- package/dist/{pipeline-2dgQM9E9.js → pipeline-C8F9lecW.js} +30 -8
- package/dist/{read-BYI7EVMo.cjs → read-DmUPztqh.cjs} +308 -89
- package/dist/{read-BnXzPjGc.js → read-cvxu6O-H.js} +297 -90
- package/dist/read.cjs +1 -1
- package/dist/read.d.cts +24 -1
- package/dist/read.d.ts +24 -1
- package/dist/read.js +1 -1
- package/dist/worker.cjs +3 -3
- package/dist/worker.d.cts +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +3 -3
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ const DEFAULT_LIMITS = Object.freeze({
|
|
|
18
18
|
maxItems: 1e7,
|
|
19
19
|
maxSharedStrings: 5e6,
|
|
20
20
|
maxCellTextLength: 1048576,
|
|
21
|
+
maxColumns: 16384,
|
|
21
22
|
maxWarnings: 1e3
|
|
22
23
|
});
|
|
23
24
|
function head(s) {
|
|
@@ -1197,13 +1198,17 @@ function resolveTarget(baseDir, target) {
|
|
|
1197
1198
|
* references, external workbook indexes) are copied unchanged. Returns
|
|
1198
1199
|
* undefined when a shifted reference would leave the sheet, so the caller
|
|
1199
1200
|
* keeps the cached value only.
|
|
1201
|
+
*
|
|
1202
|
+
* A master formula is scanned once (`compileFormula`) into the text between its
|
|
1203
|
+
* references and the references themselves; each cell that shares it then costs
|
|
1204
|
+
* its number of references plus the length of its own text (`shiftCompiled`),
|
|
1205
|
+
* and whether its references stay on the sheet is known in constant time
|
|
1206
|
+
* (`canShift`). Before JSE-62 every cell rescanned the master character by
|
|
1207
|
+
* character and built its text with `+=`, so N cells sharing a long formula
|
|
1208
|
+
* cost N times the master's length in time and much more in memory.
|
|
1200
1209
|
*/
|
|
1201
1210
|
const MAX_ROW = 1048576;
|
|
1202
1211
|
const MAX_COL = 16384;
|
|
1203
|
-
const CELL = /\$?([A-Za-z]{1,3})\$?(\d{1,7})/y;
|
|
1204
|
-
const CELL_PARTS = /^(\$?)([A-Za-z]{1,3})(\$?)(\d{1,7})$/;
|
|
1205
|
-
const COLS = /(\$?)([A-Za-z]{1,3}):(\$?)([A-Za-z]{1,3})/y;
|
|
1206
|
-
const ROWS = /(\$?)(\d{1,7}):(\$?)(\d{1,7})/y;
|
|
1207
1212
|
function colNumber(letters) {
|
|
1208
1213
|
let n = 0;
|
|
1209
1214
|
for (let i = 0; i < letters.length; i++) n = n * 26 + (letters.toUpperCase().charCodeAt(i) - 64);
|
|
@@ -1218,110 +1223,274 @@ function colLetters(n) {
|
|
|
1218
1223
|
}
|
|
1219
1224
|
return s;
|
|
1220
1225
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1226
|
+
/** A letter or digit, by character code (JSE-62: a regex test per character made long masters slow). */
|
|
1227
|
+
function isAlnumCode(c) {
|
|
1228
|
+
return c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122;
|
|
1223
1229
|
}
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1230
|
+
/** Part of a word: a letter, digit, `_`, `.` or `\\`. */
|
|
1231
|
+
function isWordCode(c) {
|
|
1232
|
+
return isAlnumCode(c) || c === 95 || c === 46 || c === 92;
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Excel's own limit on the length of a formula. A shared formula's master that
|
|
1236
|
+
* is longer is not expanded into the cells that share it (JSE-62): no
|
|
1237
|
+
* spreadsheet application writes one, and expanding it multiplied a few KB of
|
|
1238
|
+
* file into gigabytes.
|
|
1239
|
+
*/
|
|
1240
|
+
const MAX_SHARED_FORMULA_LENGTH = 8192;
|
|
1241
|
+
/** Work done by the shifter, for the bounded-work tests (JSE-62). */
|
|
1242
|
+
const shiftWork = {
|
|
1243
|
+
compiles: 0,
|
|
1244
|
+
compiledChars: 0,
|
|
1245
|
+
shifts: 0,
|
|
1246
|
+
shiftedChars: 0
|
|
1247
|
+
};
|
|
1248
|
+
const COLS_REF = 0;
|
|
1249
|
+
const ROWS_REF = 1;
|
|
1250
|
+
const CELL_REF = 2;
|
|
1251
|
+
/**
|
|
1252
|
+
* Scans `formula` once, in time proportional to its length. With `boundsOnly`
|
|
1253
|
+
* only the relative bounds are kept (for `canShift`; no text can be built from
|
|
1254
|
+
* the result): what importDataset needs.
|
|
1255
|
+
*/
|
|
1256
|
+
function compileFormula(formula, boundsOnly = false) {
|
|
1257
|
+
shiftWork.compiles++;
|
|
1258
|
+
shiftWork.compiledChars += formula.length;
|
|
1259
|
+
const segs = [];
|
|
1260
|
+
const refs = [];
|
|
1261
|
+
let rowMin = 1e400;
|
|
1262
|
+
let rowMax = -1e400;
|
|
1263
|
+
let colMin = 1e400;
|
|
1264
|
+
let colMax = -1e400;
|
|
1265
|
+
const relRow = (anchor, v) => {
|
|
1266
|
+
if (anchor === "$") return;
|
|
1267
|
+
if (v < rowMin) rowMin = v;
|
|
1268
|
+
if (v > rowMax) rowMax = v;
|
|
1269
|
+
};
|
|
1270
|
+
const relCol = (anchor, v) => {
|
|
1271
|
+
if (anchor === "$") return;
|
|
1272
|
+
if (v < colMin) colMin = v;
|
|
1273
|
+
if (v > colMax) colMax = v;
|
|
1274
|
+
};
|
|
1275
|
+
let segStart = 0;
|
|
1227
1276
|
let i = 0;
|
|
1228
1277
|
const n = formula.length;
|
|
1229
1278
|
while (i < n) {
|
|
1230
|
-
const
|
|
1231
|
-
if (
|
|
1232
|
-
let j = i + 1;
|
|
1233
|
-
for (; j < n; j++) if (formula[j] === "\"") {
|
|
1234
|
-
if (formula[j + 1] === "\"") j++;
|
|
1235
|
-
else break;
|
|
1236
|
-
}
|
|
1237
|
-
out += formula.slice(i, j + 1);
|
|
1238
|
-
i = j + 1;
|
|
1239
|
-
continue;
|
|
1240
|
-
}
|
|
1241
|
-
if (ch === "'") {
|
|
1279
|
+
const code = formula.charCodeAt(i);
|
|
1280
|
+
if (code === 34 || code === 39) {
|
|
1242
1281
|
let j = i + 1;
|
|
1243
|
-
for (; j < n; j++) if (formula
|
|
1244
|
-
if (formula
|
|
1282
|
+
for (; j < n; j++) if (formula.charCodeAt(j) === code) {
|
|
1283
|
+
if (formula.charCodeAt(j + 1) === code) j++;
|
|
1245
1284
|
else break;
|
|
1246
1285
|
}
|
|
1247
|
-
out += formula.slice(i, j + 1);
|
|
1248
1286
|
i = j + 1;
|
|
1249
1287
|
continue;
|
|
1250
1288
|
}
|
|
1251
|
-
if (
|
|
1289
|
+
if (code === 91) {
|
|
1252
1290
|
let depth = 0;
|
|
1253
1291
|
let j = i;
|
|
1254
|
-
for (; j < n; j++)
|
|
1255
|
-
|
|
1256
|
-
|
|
1292
|
+
for (; j < n; j++) {
|
|
1293
|
+
const c = formula.charCodeAt(j);
|
|
1294
|
+
if (c === 91) depth++;
|
|
1295
|
+
else if (c === 93 && --depth === 0) break;
|
|
1296
|
+
}
|
|
1257
1297
|
i = j + 1;
|
|
1258
1298
|
continue;
|
|
1259
1299
|
}
|
|
1260
|
-
const prev = i > 0 ? formula
|
|
1261
|
-
if ((
|
|
1262
|
-
const
|
|
1263
|
-
if (
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1300
|
+
const prev = i > 0 ? formula.charCodeAt(i - 1) : -1;
|
|
1301
|
+
if ((code === 36 || isAlnumCode(code)) && !isWordCode(prev) && prev !== 36) {
|
|
1302
|
+
const ref = parseRef$1(formula, i);
|
|
1303
|
+
if (ref) {
|
|
1304
|
+
const r = ref.ref;
|
|
1305
|
+
if (!boundsOnly) {
|
|
1306
|
+
segs.push(formula.slice(segStart, i));
|
|
1307
|
+
refs.push(r);
|
|
1308
|
+
}
|
|
1309
|
+
if (r.kind === COLS_REF) {
|
|
1310
|
+
relCol(r.aAnchor, r.a);
|
|
1311
|
+
relCol(r.bAnchor, r.b);
|
|
1312
|
+
} else if (r.kind === ROWS_REF) {
|
|
1313
|
+
relRow(r.aAnchor, r.a);
|
|
1314
|
+
relRow(r.bAnchor, r.b);
|
|
1315
|
+
} else {
|
|
1316
|
+
relCol(r.aAnchor, r.a);
|
|
1317
|
+
relRow(r.bAnchor, r.b);
|
|
1318
|
+
}
|
|
1319
|
+
i = segStart = ref.end;
|
|
1267
1320
|
continue;
|
|
1268
1321
|
}
|
|
1269
1322
|
let j = i + 1;
|
|
1270
|
-
while (j < n &&
|
|
1271
|
-
out += formula.slice(i, j);
|
|
1323
|
+
while (j < n && isWordCode(formula.charCodeAt(j))) j++;
|
|
1272
1324
|
i = j;
|
|
1273
1325
|
continue;
|
|
1274
1326
|
}
|
|
1275
|
-
out += ch;
|
|
1276
1327
|
i++;
|
|
1277
1328
|
}
|
|
1278
|
-
return
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1329
|
+
if (boundsOnly) return {
|
|
1330
|
+
source: formula,
|
|
1331
|
+
segs: [],
|
|
1332
|
+
slots: [],
|
|
1333
|
+
uniq: [],
|
|
1334
|
+
literalLength: 0,
|
|
1335
|
+
rowMin,
|
|
1336
|
+
rowMax,
|
|
1337
|
+
colMin,
|
|
1338
|
+
colMax
|
|
1286
1339
|
};
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1340
|
+
segs.push(formula.slice(segStart));
|
|
1341
|
+
const outSegs = [segs[0]];
|
|
1342
|
+
const slots = [];
|
|
1343
|
+
const uniq = [];
|
|
1344
|
+
const index = /* @__PURE__ */ new Map();
|
|
1345
|
+
for (let k = 0; k < refs.length; k++) {
|
|
1346
|
+
const r = refs[k];
|
|
1347
|
+
const next = segs[k + 1];
|
|
1348
|
+
if (r.aAnchor === "$" && r.bAnchor === "$") {
|
|
1349
|
+
outSegs[outSegs.length - 1] += refText(r, 0, 0) + next;
|
|
1350
|
+
continue;
|
|
1351
|
+
}
|
|
1352
|
+
const key = `${r.kind}${r.aAnchor}${r.a},${r.bAnchor}${r.b}`;
|
|
1353
|
+
let u = index.get(key);
|
|
1354
|
+
if (u === void 0) {
|
|
1355
|
+
u = uniq.length;
|
|
1356
|
+
uniq.push(r);
|
|
1357
|
+
index.set(key, u);
|
|
1358
|
+
}
|
|
1359
|
+
slots.push(u);
|
|
1360
|
+
outSegs.push(next);
|
|
1298
1361
|
}
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1362
|
+
let literalLength = 0;
|
|
1363
|
+
for (const t of outSegs) literalLength += t.length;
|
|
1364
|
+
return {
|
|
1365
|
+
source: formula,
|
|
1366
|
+
segs: outSegs,
|
|
1367
|
+
slots,
|
|
1368
|
+
uniq,
|
|
1369
|
+
literalLength,
|
|
1370
|
+
rowMin,
|
|
1371
|
+
rowMax,
|
|
1372
|
+
colMin,
|
|
1373
|
+
colMax
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
/** Column letters, cached: shifted references format the same columns over and over. */
|
|
1377
|
+
const LETTERS = [];
|
|
1378
|
+
function letters(n) {
|
|
1379
|
+
return LETTERS[n] ??= colLetters(n);
|
|
1380
|
+
}
|
|
1381
|
+
/** The text of `r` shifted by (dRow, dCol); every relative part must stay on the sheet (canShift). */
|
|
1382
|
+
function refText(r, dRow, dCol) {
|
|
1383
|
+
if (r.kind === COLS_REF) return `${r.aAnchor}${letters(shiftPart(r.aAnchor, r.a, dCol, MAX_COL))}:${r.bAnchor}${letters(shiftPart(r.bAnchor, r.b, dCol, MAX_COL))}`;
|
|
1384
|
+
if (r.kind === ROWS_REF) return `${r.aAnchor}${shiftPart(r.aAnchor, r.a, dRow, MAX_ROW)}:${r.bAnchor}${shiftPart(r.bAnchor, r.b, dRow, MAX_ROW)}`;
|
|
1385
|
+
return `${r.aAnchor}${letters(shiftPart(r.aAnchor, r.a, dCol, MAX_COL))}${r.bAnchor}${shiftPart(r.bAnchor, r.b, dRow, MAX_ROW)}`;
|
|
1386
|
+
}
|
|
1387
|
+
/** Whether every relative reference of `c` stays on the sheet when shifted by (dRow, dCol). Constant time. */
|
|
1388
|
+
function canShift(c, dRow, dCol) {
|
|
1389
|
+
if (dRow === 0 && dCol === 0) return true;
|
|
1390
|
+
if (c.rowMin !== 1e400 && (c.rowMin + dRow < 1 || c.rowMax + dRow > MAX_ROW)) return false;
|
|
1391
|
+
if (c.colMin !== 1e400 && (c.colMin + dCol < 1 || c.colMax + dCol > MAX_COL)) return false;
|
|
1392
|
+
return true;
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
* The text of `c` shifted by (dRow, dCol), built once as a flat string; or,
|
|
1396
|
+
* when that text would be longer than `maxLength`, its length (nothing is
|
|
1397
|
+
* built). The caller checks `canShift` first.
|
|
1398
|
+
*/
|
|
1399
|
+
function shiftCompiled(c, dRow, dCol, maxLength = 1e400) {
|
|
1400
|
+
if (dRow === 0 && dCol === 0) return c.source.length > maxLength ? c.source.length : c.source;
|
|
1401
|
+
const { segs, slots, uniq } = c;
|
|
1402
|
+
const texts = [];
|
|
1403
|
+
for (let u = 0; u < uniq.length; u++) texts.push(refText(uniq[u], dRow, dCol));
|
|
1404
|
+
let length = c.literalLength;
|
|
1405
|
+
for (let k = 0; k < slots.length; k++) length += texts[slots[k]].length;
|
|
1406
|
+
if (length > maxLength) return length;
|
|
1407
|
+
const parts = [segs[0]];
|
|
1408
|
+
for (let k = 0; k < slots.length; k++) parts.push(texts[slots[k]], segs[k + 1]);
|
|
1409
|
+
const out = parts.join("");
|
|
1410
|
+
shiftWork.shifts++;
|
|
1411
|
+
shiftWork.shiftedChars += out.length;
|
|
1412
|
+
return out;
|
|
1413
|
+
}
|
|
1414
|
+
/** Whether a reference may end before `end`: no word character, `(`, `!` or `$` follows. */
|
|
1415
|
+
function isEnd(f, end) {
|
|
1416
|
+
if (end >= f.length) return true;
|
|
1417
|
+
const c = f.charCodeAt(end);
|
|
1418
|
+
return !(isWordCode(c) || c === 40 || c === 33 || c === 36);
|
|
1419
|
+
}
|
|
1420
|
+
/** A reference at `i`, or undefined if there is none. Does not depend on the offset. */
|
|
1421
|
+
function parseRef$1(f, i) {
|
|
1422
|
+
const n = f.length;
|
|
1423
|
+
const aAnchor = f.charCodeAt(i) === 36 ? "$" : "";
|
|
1424
|
+
const p = i + aAnchor.length;
|
|
1425
|
+
const la = run(f, p, isLetterCode, 3);
|
|
1426
|
+
const da = la === 0 ? run(f, p, isDigitCode, 7) : 0;
|
|
1427
|
+
const first = la || da;
|
|
1428
|
+
if (first > 0 && f.charCodeAt(p + first) === 58) {
|
|
1429
|
+
const q = p + first + 1;
|
|
1430
|
+
const bAnchor = q < n && f.charCodeAt(q) === 36 ? "$" : "";
|
|
1431
|
+
const r = q + bAnchor.length;
|
|
1432
|
+
const second = run(f, r, la ? isLetterCode : isDigitCode, la ? 3 : 7);
|
|
1433
|
+
if (second > 0 && isEnd(f, r + second)) {
|
|
1434
|
+
if (la) {
|
|
1435
|
+
const a = colNumber(f.slice(p, p + la));
|
|
1436
|
+
const b = colNumber(f.slice(r, r + second));
|
|
1437
|
+
if (a > MAX_COL || b > MAX_COL) return void 0;
|
|
1438
|
+
return {
|
|
1439
|
+
ref: {
|
|
1440
|
+
kind: COLS_REF,
|
|
1441
|
+
aAnchor,
|
|
1442
|
+
a,
|
|
1443
|
+
bAnchor,
|
|
1444
|
+
b
|
|
1445
|
+
},
|
|
1446
|
+
end: r + second
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
return {
|
|
1450
|
+
ref: {
|
|
1451
|
+
kind: ROWS_REF,
|
|
1452
|
+
aAnchor,
|
|
1453
|
+
a: Number(f.slice(p, p + da)),
|
|
1454
|
+
bAnchor,
|
|
1455
|
+
b: Number(f.slice(r, r + second))
|
|
1456
|
+
},
|
|
1457
|
+
end: r + second
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1309
1460
|
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
const
|
|
1314
|
-
const
|
|
1315
|
-
if (
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1461
|
+
if (la > 0) {
|
|
1462
|
+
const q = p + la;
|
|
1463
|
+
const bAnchor = f.charCodeAt(q) === 36 ? "$" : "";
|
|
1464
|
+
const r = q + bAnchor.length;
|
|
1465
|
+
const digits = run(f, r, isDigitCode, 7);
|
|
1466
|
+
if (digits > 0 && isEnd(f, r + digits)) {
|
|
1467
|
+
const col = colNumber(f.slice(p, p + la));
|
|
1468
|
+
if (col > MAX_COL) return void 0;
|
|
1469
|
+
return {
|
|
1470
|
+
ref: {
|
|
1471
|
+
kind: CELL_REF,
|
|
1472
|
+
aAnchor,
|
|
1473
|
+
a: col,
|
|
1474
|
+
bAnchor,
|
|
1475
|
+
b: Number(f.slice(r, r + digits))
|
|
1476
|
+
},
|
|
1477
|
+
end: r + digits
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1323
1480
|
}
|
|
1324
1481
|
}
|
|
1482
|
+
function isLetterCode(c) {
|
|
1483
|
+
return c >= 65 && c <= 90 || c >= 97 && c <= 122;
|
|
1484
|
+
}
|
|
1485
|
+
function isDigitCode(c) {
|
|
1486
|
+
return c >= 48 && c <= 57;
|
|
1487
|
+
}
|
|
1488
|
+
/** Length of the run of `test` characters at `i`, at most `max` (a longer run then fails on the character after: no pattern accepts it there). */
|
|
1489
|
+
function run(f, i, test, max) {
|
|
1490
|
+
let k = 0;
|
|
1491
|
+
while (k < max && i + k < f.length && test(f.charCodeAt(i + k))) k++;
|
|
1492
|
+
return k;
|
|
1493
|
+
}
|
|
1325
1494
|
function shiftPart(anchor, value, delta, max) {
|
|
1326
1495
|
if (anchor === "$") return value;
|
|
1327
1496
|
const v = value + delta;
|
|
@@ -2200,6 +2369,7 @@ var SheetParser = class {
|
|
|
2200
2369
|
colWork = 0;
|
|
2201
2370
|
merges = [];
|
|
2202
2371
|
hyperlinks = [];
|
|
2372
|
+
/** Shared formula masters by `si`; compiled when the first cell that shares one needs it. */
|
|
2203
2373
|
shared = /* @__PURE__ */ new Map();
|
|
2204
2374
|
view;
|
|
2205
2375
|
print;
|
|
@@ -2626,6 +2796,7 @@ var SheetParser = class {
|
|
|
2626
2796
|
if (p.row < 0) return;
|
|
2627
2797
|
const cell = this.convert(p);
|
|
2628
2798
|
if (!cell) return;
|
|
2799
|
+
if (p.col >= this.ctx.limits.maxColumns) this.tooWide(p.col, p.ref);
|
|
2629
2800
|
this.ctx.countCell();
|
|
2630
2801
|
let row = this.rows[p.row];
|
|
2631
2802
|
if (!row) row = this.rows[p.row] = [];
|
|
@@ -2652,6 +2823,20 @@ var SheetParser = class {
|
|
|
2652
2823
|
if (p.col < this.minCol) this.minCol = p.col;
|
|
2653
2824
|
if (p.col > this.maxCol) this.maxCol = p.col;
|
|
2654
2825
|
}
|
|
2826
|
+
/**
|
|
2827
|
+
* A kept cell in a column past maxColumns (JSE-68). Counted on the cells the
|
|
2828
|
+
* sheet actually has, as each is kept, never on `<dimension>`.
|
|
2829
|
+
*/
|
|
2830
|
+
tooWide(col, ref) {
|
|
2831
|
+
const max = this.ctx.limits.maxColumns;
|
|
2832
|
+
throw new LimitError("LIMIT_EXCEEDED", `Sheet "${excerpt(this.sheet.name)}" has a cell in column ${colLetters(col + 1)} (${col + 1}); maxColumns is ${max}.`, { details: {
|
|
2833
|
+
limit: "maxColumns",
|
|
2834
|
+
value: col + 1,
|
|
2835
|
+
max,
|
|
2836
|
+
part: this.part,
|
|
2837
|
+
ref
|
|
2838
|
+
} });
|
|
2839
|
+
}
|
|
2655
2840
|
convert(p) {
|
|
2656
2841
|
const style = this.styles.style(p.s);
|
|
2657
2842
|
let value;
|
|
@@ -2673,6 +2858,7 @@ var SheetParser = class {
|
|
|
2673
2858
|
const sst = this.sharedStrings;
|
|
2674
2859
|
const str = Number.isInteger(idx) && idx >= 0 ? sst[idx] : void 0;
|
|
2675
2860
|
if (str === void 0) {
|
|
2861
|
+
if (p.col >= this.ctx.limits.maxColumns) this.tooWide(p.col, p.ref);
|
|
2676
2862
|
this.ctx.warn("INVALID_SHARED_STRING", `Cell ${p.ref} refers to shared string ${excerpt(v)}, which does not exist; the cell was left empty.`, {
|
|
2677
2863
|
part: this.part,
|
|
2678
2864
|
sheet: this.sheet.name,
|
|
@@ -2776,21 +2962,33 @@ var SheetParser = class {
|
|
|
2776
2962
|
this.shared.set(p.fSi, {
|
|
2777
2963
|
formula: p.f,
|
|
2778
2964
|
row: p.row,
|
|
2779
|
-
col: p.col
|
|
2965
|
+
col: p.col,
|
|
2966
|
+
ref: p.ref,
|
|
2967
|
+
compiled: void 0
|
|
2780
2968
|
});
|
|
2781
2969
|
return { text: p.f };
|
|
2782
2970
|
}
|
|
2783
2971
|
const master = this.shared.get(p.fSi);
|
|
2784
|
-
const
|
|
2785
|
-
if (
|
|
2786
|
-
this.
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2972
|
+
const masterText = this.opts.sharedFormulaText === "master";
|
|
2973
|
+
if (master && !masterText && master.formula.length > 8192) {
|
|
2974
|
+
this.unresolved(p, `: its master formula in cell ${master.ref} has ${master.formula.length} characters, more than Excel's limit of ${MAX_SHARED_FORMULA_LENGTH}`);
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
const dRow = master ? p.row - master.row : 0;
|
|
2978
|
+
const dCol = master ? p.col - master.col : 0;
|
|
2979
|
+
const compiled = master && (dRow !== 0 || dCol !== 0) ? master.compiled ??= compileFormula(master.formula, masterText) : void 0;
|
|
2980
|
+
if (!master || compiled && !canShift(compiled, dRow, dCol)) {
|
|
2981
|
+
this.unresolved(p, "");
|
|
2982
|
+
return;
|
|
2983
|
+
}
|
|
2984
|
+
if (!compiled || masterText) return { text: master.formula };
|
|
2985
|
+
const max = this.ctx.limits.maxCellTextLength;
|
|
2986
|
+
const text = shiftCompiled(compiled, dRow, dCol, max);
|
|
2987
|
+
if (typeof text === "number") {
|
|
2988
|
+
this.unresolved(p, `: shifted, it would have ${text} characters, more than maxCellTextLength (${max})`);
|
|
2791
2989
|
return;
|
|
2792
2990
|
}
|
|
2793
|
-
return { text
|
|
2991
|
+
return { text };
|
|
2794
2992
|
}
|
|
2795
2993
|
if (p.fType === "dataTable") return void 0;
|
|
2796
2994
|
if (p.f === "") return void 0;
|
|
@@ -2800,6 +2998,13 @@ var SheetParser = class {
|
|
|
2800
2998
|
};
|
|
2801
2999
|
return { text: p.f };
|
|
2802
3000
|
}
|
|
3001
|
+
unresolved(p, why) {
|
|
3002
|
+
this.ctx.warn("SHARED_FORMULA_UNRESOLVED", `The shared formula of cell ${p.ref} could not be resolved${why}; only its cached value was read.`, {
|
|
3003
|
+
part: this.part,
|
|
3004
|
+
sheet: this.sheet.name,
|
|
3005
|
+
ref: p.ref
|
|
3006
|
+
});
|
|
3007
|
+
}
|
|
2803
3008
|
/** Set before parsing; the shared strings table. */
|
|
2804
3009
|
sharedStrings = [];
|
|
2805
3010
|
/** When set, shared-string cells are collected here and filled in later (ReadOptions.maxRows). */
|
|
@@ -2951,6 +3156,7 @@ var SheetParser = class {
|
|
|
2951
3156
|
if (!link) return;
|
|
2952
3157
|
const [r, c] = pos;
|
|
2953
3158
|
if (r >= 1048576 || c >= 16384) return;
|
|
3159
|
+
if (c >= this.ctx.limits.maxColumns) this.tooWide(c, `${colLetters(c + 1)}${r + 1}`);
|
|
2954
3160
|
let row = this.rows[r];
|
|
2955
3161
|
if (!row) row = this.rows[r] = [];
|
|
2956
3162
|
const cell = row[c] ?? (row[c] = { type: "empty" });
|
|
@@ -3490,6 +3696,7 @@ async function readImpl(input, options, internal) {
|
|
|
3490
3696
|
const { entry, rel } = listed[i];
|
|
3491
3697
|
const parser = new SheetParser(entry.name, entry.state, ctx, styles, {
|
|
3492
3698
|
formulas: o.formulas !== false,
|
|
3699
|
+
sharedFormulaText: internal?.sharedFormulaText ?? "shifted",
|
|
3493
3700
|
dates: o.dates ?? "date",
|
|
3494
3701
|
dateZone: o.dateZone ?? "local",
|
|
3495
3702
|
richText: o.richText ?? "runs",
|
|
@@ -3677,4 +3884,4 @@ async function read(input, options) {
|
|
|
3677
3884
|
warnings
|
|
3678
3885
|
};
|
|
3679
3886
|
}
|
|
3680
|
-
export {
|
|
3887
|
+
export { readImpl as a, DEFAULT_LIMITS as c, readSheetNames as i, detectFormat as n, excerpt as o, read as r, quoted as s, DEFAULT_READ_LIMITS as t };
|
package/dist/read.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_warnings = require("./warnings-CJPiDqei.cjs");
|
|
3
|
-
const require_read = require("./read-
|
|
3
|
+
const require_read = require("./read-DmUPztqh.cjs");
|
|
4
4
|
exports.DEFAULT_READ_LIMITS = require_read.DEFAULT_READ_LIMITS;
|
|
5
5
|
exports.detectFormat = require_read.detectFormat;
|
|
6
6
|
exports.isDataLossWarning = require_warnings.isDataLossWarning;
|
package/dist/read.d.cts
CHANGED
|
@@ -102,7 +102,10 @@ export interface ReadLimits {
|
|
|
102
102
|
* 2.1 still compiles; when it is left out the default applies.
|
|
103
103
|
*/
|
|
104
104
|
maxSheets?: number;
|
|
105
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* All sheets together. `importDataset` also counts against it, separately, the
|
|
107
|
+
* empty fields its dataset pads short rows with (since 2.4).
|
|
108
|
+
*/
|
|
106
109
|
maxCells: number;
|
|
107
110
|
/**
|
|
108
111
|
* Items other than cells that a read builds, all sheets together (added in
|
|
@@ -137,6 +140,26 @@ export interface ReadLimits {
|
|
|
137
140
|
* 2.2 still compiles; when it is left out the default applies.
|
|
138
141
|
*/
|
|
139
142
|
maxCellTextLength?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Columns a sheet may use: the highest column of any cell a read keeps, on
|
|
145
|
+
* each sheet read (added in 2.4). Checked as each cell is kept, while the
|
|
146
|
+
* sheet streams in, so a wider sheet is refused at its first cell past the
|
|
147
|
+
* limit; `<dimension>` is not trusted. Cells beyond Excel's own width (XFD,
|
|
148
|
+
* 16,384) are skipped with `CELL_OUT_OF_BOUNDS` as before. Default 16,384
|
|
149
|
+
* (`DEFAULT_READ_LIMITS`), so no sheet Excel can write is refused; a server
|
|
150
|
+
* or browser reading untrusted files should set it to the widest sheet it
|
|
151
|
+
* accepts (for example 256). A wide header over short rows costs little to
|
|
152
|
+
* read but a value per column in every row of a dataset (`importDataset`
|
|
153
|
+
* also bounds that, against `maxCells`). On a `LimitError`, `details.value`
|
|
154
|
+
* is the offending cell's column number (1-based), `details.part` names the
|
|
155
|
+
* sheet part and `details.ref` the cell. `readSheetNames` reads no cells; it
|
|
156
|
+
* accepts and checks the member like any other. For CSV the same name
|
|
157
|
+
* limits the fields of one record (`CsvParseOptions.maxColumns`).
|
|
158
|
+
*
|
|
159
|
+
* Optional only so that a complete `ReadLimits` object written for 2.0 to
|
|
160
|
+
* 2.3 still compiles; when it is left out the default applies.
|
|
161
|
+
*/
|
|
162
|
+
maxColumns?: number;
|
|
140
163
|
/**
|
|
141
164
|
* Warnings kept before the cap applies. Past it, informational warnings are dropped and
|
|
142
165
|
* counted in one `WARNINGS_TRUNCATED` (added where the first one is dropped); data-loss
|
package/dist/read.d.ts
CHANGED
|
@@ -102,7 +102,10 @@ export interface ReadLimits {
|
|
|
102
102
|
* 2.1 still compiles; when it is left out the default applies.
|
|
103
103
|
*/
|
|
104
104
|
maxSheets?: number;
|
|
105
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* All sheets together. `importDataset` also counts against it, separately, the
|
|
107
|
+
* empty fields its dataset pads short rows with (since 2.4).
|
|
108
|
+
*/
|
|
106
109
|
maxCells: number;
|
|
107
110
|
/**
|
|
108
111
|
* Items other than cells that a read builds, all sheets together (added in
|
|
@@ -137,6 +140,26 @@ export interface ReadLimits {
|
|
|
137
140
|
* 2.2 still compiles; when it is left out the default applies.
|
|
138
141
|
*/
|
|
139
142
|
maxCellTextLength?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Columns a sheet may use: the highest column of any cell a read keeps, on
|
|
145
|
+
* each sheet read (added in 2.4). Checked as each cell is kept, while the
|
|
146
|
+
* sheet streams in, so a wider sheet is refused at its first cell past the
|
|
147
|
+
* limit; `<dimension>` is not trusted. Cells beyond Excel's own width (XFD,
|
|
148
|
+
* 16,384) are skipped with `CELL_OUT_OF_BOUNDS` as before. Default 16,384
|
|
149
|
+
* (`DEFAULT_READ_LIMITS`), so no sheet Excel can write is refused; a server
|
|
150
|
+
* or browser reading untrusted files should set it to the widest sheet it
|
|
151
|
+
* accepts (for example 256). A wide header over short rows costs little to
|
|
152
|
+
* read but a value per column in every row of a dataset (`importDataset`
|
|
153
|
+
* also bounds that, against `maxCells`). On a `LimitError`, `details.value`
|
|
154
|
+
* is the offending cell's column number (1-based), `details.part` names the
|
|
155
|
+
* sheet part and `details.ref` the cell. `readSheetNames` reads no cells; it
|
|
156
|
+
* accepts and checks the member like any other. For CSV the same name
|
|
157
|
+
* limits the fields of one record (`CsvParseOptions.maxColumns`).
|
|
158
|
+
*
|
|
159
|
+
* Optional only so that a complete `ReadLimits` object written for 2.0 to
|
|
160
|
+
* 2.3 still compiles; when it is left out the default applies.
|
|
161
|
+
*/
|
|
162
|
+
maxColumns?: number;
|
|
140
163
|
/**
|
|
141
164
|
* Warnings kept before the cap applies. Past it, informational warnings are dropped and
|
|
142
165
|
* counted in one `WARNINGS_TRUNCATED` (added where the first one is dropped); data-loss
|
package/dist/read.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as isDataLossWarning } from "./warnings-BPz1Ia3s.js";
|
|
2
|
-
import { i as readSheetNames, n as detectFormat, r as read, t as DEFAULT_READ_LIMITS } from "./read-
|
|
2
|
+
import { i as readSheetNames, n as detectFormat, r as read, t as DEFAULT_READ_LIMITS } from "./read-cvxu6O-H.js";
|
|
3
3
|
export { DEFAULT_READ_LIMITS, detectFormat, isDataLossWarning, read, readSheetNames };
|
package/dist/worker.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_csv = require("./csv-
|
|
2
|
+
const require_csv = require("./csv-DZ241Y5F.cjs");
|
|
3
3
|
const require_errors = require("./errors-DOPrrGS4.cjs");
|
|
4
|
-
const require_read = require("./read-
|
|
5
|
-
const require_pipeline = require("./pipeline-
|
|
4
|
+
const require_read = require("./read-DmUPztqh.cjs");
|
|
5
|
+
const require_pipeline = require("./pipeline-BwkRpV5Z.cjs");
|
|
6
6
|
const require_write = require("./write-DKXhuvKR.cjs");
|
|
7
7
|
// src/worker.ts
|
|
8
8
|
/** Marks the library's messages, so an app can use the same worker for its own messages too. */
|
package/dist/worker.d.cts
CHANGED
|
@@ -25,7 +25,7 @@ import { o as BinaryInput } from "./warnings-DhonqJ7A.cjs";
|
|
|
25
25
|
import { CsvParseOptions, CsvParseResult, CsvReadOptions, CsvWriteOptions } from "./csv.cjs";
|
|
26
26
|
import { D as Sheet, j as Workbook, s as CellInput } from "./model-BUNp7B0Z.cjs";
|
|
27
27
|
import { ReadOptions, ReadResult } from "./read.cjs";
|
|
28
|
-
import { n as ImportDatasetOptions, r as ImportDatasetResult } from "./pipeline-
|
|
28
|
+
import { n as ImportDatasetOptions, r as ImportDatasetResult } from "./pipeline-4U7Xnuc1.cjs";
|
|
29
29
|
import { n as WriteOptions, t as Progress } from "./write-Izl2NG0Y.cjs";
|
|
30
30
|
import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
|
|
31
31
|
/** The side of a message channel the library uses: a `Worker`, the worker's `self`, or a `MessagePort`. */
|
package/dist/worker.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { o as BinaryInput } from "./warnings-DhonqJ7A.js";
|
|
|
25
25
|
import { CsvParseOptions, CsvParseResult, CsvReadOptions, CsvWriteOptions } from "./csv.js";
|
|
26
26
|
import { D as Sheet, j as Workbook, s as CellInput } from "./model-BUNp7B0Z.js";
|
|
27
27
|
import { ReadOptions, ReadResult } from "./read.js";
|
|
28
|
-
import { n as ImportDatasetOptions, r as ImportDatasetResult } from "./pipeline-
|
|
28
|
+
import { n as ImportDatasetOptions, r as ImportDatasetResult } from "./pipeline-BegSPu8X.js";
|
|
29
29
|
import { n as WriteOptions, t as Progress } from "./write-BaMv1Z7W.js";
|
|
30
30
|
import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
|
|
31
31
|
/** The side of a message channel the library uses: a `Worker`, the worker's `self`, or a `MessagePort`. */
|
package/dist/worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as toCsv, r as readCsv } from "./csv-
|
|
1
|
+
import { i as toCsv, r as readCsv } from "./csv-Dn4MIESx.js";
|
|
2
2
|
import { a as LimitError, i as FormatError, n as EnvironmentError, o as ValidationError, r as ExcelError, s as isExcelError, t as CsvError } from "./errors-CvGlfw0E.js";
|
|
3
|
-
import { r as read } from "./read-
|
|
4
|
-
import { t as importDataset } from "./pipeline-
|
|
3
|
+
import { r as read } from "./read-cvxu6O-H.js";
|
|
4
|
+
import { t as importDataset } from "./pipeline-C8F9lecW.js";
|
|
5
5
|
import { r as toUint8Array } from "./write-BVXB2_2C.js";
|
|
6
6
|
// src/worker.ts
|
|
7
7
|
/** Marks the library's messages, so an app can use the same worker for its own messages too. */
|
package/package.json
CHANGED