@progress/kendo-spreadsheet-common 1.2.10 → 1.2.11-develop.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/index-esm.js +101 -43
- package/dist/index.js +101 -43
- package/package.json +1 -1
package/dist/index-esm.js
CHANGED
|
@@ -1404,7 +1404,7 @@ function createKendoObj(calc, CalcError, Ref, CellRef, RangeRef) {
|
|
|
1404
1404
|
}
|
|
1405
1405
|
|
|
1406
1406
|
/* eslint-disable max-params */
|
|
1407
|
-
|
|
1407
|
+
|
|
1408
1408
|
|
|
1409
1409
|
let calc = {
|
|
1410
1410
|
runtime: {
|
|
@@ -1494,11 +1494,10 @@ class Context {
|
|
|
1494
1494
|
function add(a) {
|
|
1495
1495
|
for (var i = 0; i < a.length; ++i) {
|
|
1496
1496
|
var cell = a[i];
|
|
1497
|
-
if (cell.formula) {
|
|
1497
|
+
if (cell.formula && cell.formula !== context.formula) {
|
|
1498
1498
|
formulas.push(cell.formula);
|
|
1499
1499
|
}
|
|
1500
1500
|
}
|
|
1501
|
-
return true;
|
|
1502
1501
|
}
|
|
1503
1502
|
}
|
|
1504
1503
|
|
|
@@ -1728,7 +1727,7 @@ class Matrix {
|
|
|
1728
1727
|
return new CalcError("N/A");
|
|
1729
1728
|
}
|
|
1730
1729
|
set(row, col, data) {
|
|
1731
|
-
if (col === '__proto__' || col === 'constructor' || col === 'prototype'
|
|
1730
|
+
if (col === '__proto__' || col === 'constructor' || col === 'prototype'
|
|
1732
1731
|
|| row === '__proto__' || row === 'constructor' || row === 'prototype') {
|
|
1733
1732
|
return;
|
|
1734
1733
|
}
|
|
@@ -2040,16 +2039,17 @@ let Formula$1 = class Formula {
|
|
|
2040
2039
|
this.onReady.push(callback);
|
|
2041
2040
|
}
|
|
2042
2041
|
|
|
2043
|
-
|
|
2042
|
+
let p = parentContext;
|
|
2043
|
+
var ctx = new Context(this.resolve, this, ss, p);
|
|
2044
2044
|
var level = 0;
|
|
2045
2045
|
// if the call chain leads back to this same formula, we have a circular dependency.
|
|
2046
|
-
while (
|
|
2047
|
-
if (
|
|
2046
|
+
while (p) {
|
|
2047
|
+
if (p.formula === this) {
|
|
2048
2048
|
this.pending = false;
|
|
2049
2049
|
ctx.resolve(new CalcError("CIRCULAR"));
|
|
2050
2050
|
return;
|
|
2051
2051
|
}
|
|
2052
|
-
|
|
2052
|
+
p = p.parent;
|
|
2053
2053
|
++level;
|
|
2054
2054
|
}
|
|
2055
2055
|
|
|
@@ -2228,11 +2228,13 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2228
2228
|
var f;
|
|
2229
2229
|
if (haveForced) {
|
|
2230
2230
|
resolve += "this.resolveCells(toResolve, callback); } ";
|
|
2231
|
-
f = new Function("kendo", "CalcError", "round",
|
|
2231
|
+
f = new Function("kendo", "CalcError", "round", "limitRef",
|
|
2232
|
+
main + resolve + arrayArgs + " return { resolve: resolve, check: check, arrayArgs: arrayArgs };");
|
|
2232
2233
|
} else {
|
|
2233
|
-
f = new Function("kendo", "CalcError", "round",
|
|
2234
|
+
f = new Function("kendo", "CalcError", "round", "limitRef",
|
|
2235
|
+
main + " return { check: check };");
|
|
2234
2236
|
}
|
|
2235
|
-
f = f(calc.kendo, CalcError, limitPrecision$1);
|
|
2237
|
+
f = f(calc.kendo, CalcError, limitPrecision$1, limitRef$1);
|
|
2236
2238
|
if (!hasArrayArgs) {
|
|
2237
2239
|
delete f.arrayArgs;
|
|
2238
2240
|
}
|
|
@@ -2323,6 +2325,26 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2323
2325
|
return "($" + name + " = this.force($" + name + "))";
|
|
2324
2326
|
}
|
|
2325
2327
|
|
|
2328
|
+
function forceLeftColumn() {
|
|
2329
|
+
if (forced) {
|
|
2330
|
+
return "$" + name + "";
|
|
2331
|
+
}
|
|
2332
|
+
haveForced = true;
|
|
2333
|
+
forced = true;
|
|
2334
|
+
resolve += "toResolve.push(limitRef(args[i++], 'leftColumn')); ";
|
|
2335
|
+
return "($" + name + " = this.force($" + name + "))";
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
function forceTopRow() {
|
|
2339
|
+
if (forced) {
|
|
2340
|
+
return "$" + name + "";
|
|
2341
|
+
}
|
|
2342
|
+
haveForced = true;
|
|
2343
|
+
forced = true;
|
|
2344
|
+
resolve += "toResolve.push(limitRef(args[i++], 'topRow')); ";
|
|
2345
|
+
return "($" + name + " = this.force($" + name + "))";
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2326
2348
|
function forceNum(round) {
|
|
2327
2349
|
return "("
|
|
2328
2350
|
+ (round
|
|
@@ -2377,6 +2399,9 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2377
2399
|
if (type[0] == "null") {
|
|
2378
2400
|
return "(" + cond("null") + " ? (($" + name + " = " + type[1] + "), true) : false)";
|
|
2379
2401
|
}
|
|
2402
|
+
if (type[0] == "#null") {
|
|
2403
|
+
return "(" + cond("#null") + " ? (($" + name + " = " + type[1] + "), true) : false)";
|
|
2404
|
+
}
|
|
2380
2405
|
if (type[0] == "between" || type[0] == "[between]") {
|
|
2381
2406
|
return "(" + force() + " >= " + type[1] + " && " + "$" + name + " <= " + type[2] + " ? true : ((err = 'NUM'), false))";
|
|
2382
2407
|
}
|
|
@@ -2435,6 +2460,14 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2435
2460
|
force();
|
|
2436
2461
|
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2437
2462
|
}
|
|
2463
|
+
if (type == "vlookup-matrix") {
|
|
2464
|
+
forceLeftColumn();
|
|
2465
|
+
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2466
|
+
}
|
|
2467
|
+
if (type == "hlookup-matrix") {
|
|
2468
|
+
forceTopRow();
|
|
2469
|
+
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2470
|
+
}
|
|
2438
2471
|
if (type == "#matrix") {
|
|
2439
2472
|
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2440
2473
|
}
|
|
@@ -2450,6 +2483,9 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2450
2483
|
if (type == "null") {
|
|
2451
2484
|
return "(" + force() + " == null)";
|
|
2452
2485
|
}
|
|
2486
|
+
if (type == "#null") {
|
|
2487
|
+
return "($" + name + " == null)";
|
|
2488
|
+
}
|
|
2453
2489
|
if (type == "anyvalue") {
|
|
2454
2490
|
return "(" + force() + " != null && i <= args.length)";
|
|
2455
2491
|
}
|
|
@@ -2466,6 +2502,18 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2466
2502
|
}
|
|
2467
2503
|
}
|
|
2468
2504
|
|
|
2505
|
+
function limitRef$1(ref, how) {
|
|
2506
|
+
if (ref instanceof RangeRef) {
|
|
2507
|
+
switch (how) {
|
|
2508
|
+
case "topRow":
|
|
2509
|
+
return ref.topRow();
|
|
2510
|
+
case "leftColumn":
|
|
2511
|
+
return ref.leftColumn();
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
return ret;
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2469
2517
|
function limitPrecision$1(num, digits) {
|
|
2470
2518
|
return num === parseInt(num, 10) ? num : +num.toPrecision(digits || 16);
|
|
2471
2519
|
}
|
|
@@ -2906,6 +2954,7 @@ calc.runtime.isLeapYear = isLeapYear$1;
|
|
|
2906
2954
|
calc.runtime.daysInYear = daysInYear$1;
|
|
2907
2955
|
calc.runtime.parseDate = parseDate;
|
|
2908
2956
|
calc.runtime.limitPrecision = limitPrecision$1;
|
|
2957
|
+
calc.runtime.limitRef = limitRef$1;
|
|
2909
2958
|
calc.runtime.defineBuiltinFunction = defineBuiltinFunction$1;
|
|
2910
2959
|
calc.runtime.defineAlias = defineAlias$1;
|
|
2911
2960
|
calc.runtime.InputStream = InputStream;
|
|
@@ -23937,6 +23986,7 @@ const {
|
|
|
23937
23986
|
FUNCS,
|
|
23938
23987
|
defineBuiltinFunction,
|
|
23939
23988
|
limitPrecision,
|
|
23989
|
+
limitRef,
|
|
23940
23990
|
packDate: packDate$1,
|
|
23941
23991
|
unpackDate: unpackDate$1,
|
|
23942
23992
|
daysInMonth,
|
|
@@ -29870,8 +29920,11 @@ defineBuiltinFunction('countif', false, function () {
|
|
|
29870
29920
|
|
|
29871
29921
|
function fetchSumRange(continuation) {
|
|
29872
29922
|
return function(callback, range, criteria, sumRange) {
|
|
29873
|
-
|
|
29874
|
-
|
|
29923
|
+
let self = this;
|
|
29924
|
+
let r = sumRange;
|
|
29925
|
+
criteria = parseCriteria(criteria);
|
|
29926
|
+
|
|
29927
|
+
if (r instanceof Ref) {
|
|
29875
29928
|
// make sure it covers the same area as `range`, as the “spec” mentions:
|
|
29876
29929
|
//
|
|
29877
29930
|
// The sum_range argument does not have to be the same size and shape as the
|
|
@@ -29881,7 +29934,7 @@ function fetchSumRange(continuation) {
|
|
|
29881
29934
|
//
|
|
29882
29935
|
// It does make one wonder, since only the top-left cell in `sumRange` matters, why
|
|
29883
29936
|
// should it be a range at all? Oh well, Excel.
|
|
29884
|
-
|
|
29937
|
+
r = r.clone().toRangeRef();
|
|
29885
29938
|
if (r.width() != range.width || r.height() != range.height) {
|
|
29886
29939
|
if (!isFinite(r.topLeft.row)) {
|
|
29887
29940
|
r.topLeft.row = 0;
|
|
@@ -29891,12 +29944,27 @@ function fetchSumRange(continuation) {
|
|
|
29891
29944
|
}
|
|
29892
29945
|
r.bottomRight.row = r.topLeft.row + range.height - 1;
|
|
29893
29946
|
r.bottomRight.col = r.topLeft.col + range.width - 1;
|
|
29894
|
-
return self.resolveCells([ r ], function(){
|
|
29895
|
-
callback(continuation(range, criteria, self.asMatrix(r)));
|
|
29896
|
-
});
|
|
29897
29947
|
}
|
|
29948
|
+
let cells = [];
|
|
29949
|
+
range.each(function(val, row, col){
|
|
29950
|
+
if (criteria(val)) {
|
|
29951
|
+
cells.push(r.toCell(row, col));
|
|
29952
|
+
}
|
|
29953
|
+
});
|
|
29954
|
+
return self.resolveCells(cells, function(){
|
|
29955
|
+
let data = cells.map(x => self.getRefData(x));
|
|
29956
|
+
return callback(continuation.call(self, data));
|
|
29957
|
+
});
|
|
29898
29958
|
}
|
|
29899
|
-
|
|
29959
|
+
|
|
29960
|
+
// sumRange must be a Matrix if we get here.
|
|
29961
|
+
let data = [];
|
|
29962
|
+
range.each(function(val, row, col){
|
|
29963
|
+
if (criteria(val)) {
|
|
29964
|
+
data.push(r.get(row, col));
|
|
29965
|
+
}
|
|
29966
|
+
});
|
|
29967
|
+
return callback(continuation.call(self, data));
|
|
29900
29968
|
};
|
|
29901
29969
|
}
|
|
29902
29970
|
|
|
@@ -29929,9 +29997,7 @@ defineBuiltinFunction('sumif', true, function () {
|
|
|
29929
29997
|
var $sumRange = args[i++];
|
|
29930
29998
|
if ($sumRange instanceof CalcError)
|
|
29931
29999
|
return $sumRange;
|
|
29932
|
-
if (!($sumRange instanceof CellRef || $sumRange instanceof RangeRef || ((m = this.asMatrix($sumRange)) ? $sumRange = m : false) || (
|
|
29933
|
-
if ($sumRange instanceof CalcError)
|
|
29934
|
-
return $sumRange;
|
|
30000
|
+
if (!($sumRange instanceof CellRef || $sumRange instanceof RangeRef || ((m = this.asMatrix($sumRange)) ? $sumRange = m : false) || ($sumRange == null ? ($sumRange = $range, true) : false))) {
|
|
29935
30001
|
return new CalcError(err);
|
|
29936
30002
|
}
|
|
29937
30003
|
xargs.push($sumRange);
|
|
@@ -29944,7 +30010,7 @@ defineBuiltinFunction('sumif', true, function () {
|
|
|
29944
30010
|
var toResolve = [], i = 0;
|
|
29945
30011
|
toResolve.push(args[i++]);
|
|
29946
30012
|
toResolve.push(args[i++]);
|
|
29947
|
-
|
|
30013
|
+
i++;
|
|
29948
30014
|
this.resolveCells(toResolve, callback);
|
|
29949
30015
|
}
|
|
29950
30016
|
function arrayArgs(args) {
|
|
@@ -29976,15 +30042,11 @@ defineBuiltinFunction('sumif', true, function () {
|
|
|
29976
30042
|
resolve: resolve,
|
|
29977
30043
|
arrayArgs: arrayArgs
|
|
29978
30044
|
};
|
|
29979
|
-
}(), fetchSumRange(function (
|
|
29980
|
-
|
|
29981
|
-
|
|
29982
|
-
|
|
29983
|
-
|
|
29984
|
-
var v = sumRange.get(row, col);
|
|
29985
|
-
if (numericPredicate(v)) {
|
|
29986
|
-
sum += v || 0;
|
|
29987
|
-
}
|
|
30045
|
+
}(), fetchSumRange(function (matchingCellsData) {
|
|
30046
|
+
let sum = 0;
|
|
30047
|
+
matchingCellsData.forEach(v => {
|
|
30048
|
+
if (numericPredicate(v)) {
|
|
30049
|
+
sum += v || 0;
|
|
29988
30050
|
}
|
|
29989
30051
|
});
|
|
29990
30052
|
return sum;
|
|
@@ -30066,16 +30128,12 @@ defineBuiltinFunction('averageif', true, function () {
|
|
|
30066
30128
|
resolve: resolve,
|
|
30067
30129
|
arrayArgs: arrayArgs
|
|
30068
30130
|
};
|
|
30069
|
-
}(), fetchSumRange(function (
|
|
30070
|
-
|
|
30071
|
-
|
|
30072
|
-
|
|
30073
|
-
|
|
30074
|
-
|
|
30075
|
-
if (numericPredicate(v)) {
|
|
30076
|
-
sum += v || 0;
|
|
30077
|
-
count++;
|
|
30078
|
-
}
|
|
30131
|
+
}(), fetchSumRange(function (matchingCellsData) {
|
|
30132
|
+
let sum = 0, count = 0;
|
|
30133
|
+
matchingCellsData.forEach(v => {
|
|
30134
|
+
if (numericPredicate(v)) {
|
|
30135
|
+
sum += v || 0;
|
|
30136
|
+
count++;
|
|
30079
30137
|
}
|
|
30080
30138
|
});
|
|
30081
30139
|
return count ? sum / count : new CalcError('DIV/0');
|
|
@@ -32789,7 +32847,7 @@ defineBuiltinFunction('hlookup', false, function () {
|
|
|
32789
32847
|
function resolve(args, callback) {
|
|
32790
32848
|
var toResolve = [], i = 0;
|
|
32791
32849
|
toResolve.push(args[i++]);
|
|
32792
|
-
toResolve.push(args[i++]);
|
|
32850
|
+
toResolve.push(limitRef(args[i++], 'topRow'));
|
|
32793
32851
|
toResolve.push(args[i++]);
|
|
32794
32852
|
toResolve.push(args[i++]);
|
|
32795
32853
|
this.resolveCells(toResolve, callback);
|
|
@@ -33322,7 +33380,7 @@ defineBuiltinFunction('vlookup', false, function () {
|
|
|
33322
33380
|
function resolve(args, callback) {
|
|
33323
33381
|
var toResolve = [], i = 0;
|
|
33324
33382
|
toResolve.push(args[i++]);
|
|
33325
|
-
toResolve.push(args[i++]);
|
|
33383
|
+
toResolve.push(limitRef(args[i++], 'leftColumn'));
|
|
33326
33384
|
toResolve.push(args[i++]);
|
|
33327
33385
|
toResolve.push(args[i++]);
|
|
33328
33386
|
this.resolveCells(toResolve, callback);
|
package/dist/index.js
CHANGED
|
@@ -1405,7 +1405,7 @@
|
|
|
1405
1405
|
}
|
|
1406
1406
|
|
|
1407
1407
|
/* eslint-disable max-params */
|
|
1408
|
-
|
|
1408
|
+
|
|
1409
1409
|
|
|
1410
1410
|
let calc = {
|
|
1411
1411
|
runtime: {
|
|
@@ -1495,11 +1495,10 @@
|
|
|
1495
1495
|
function add(a) {
|
|
1496
1496
|
for (var i = 0; i < a.length; ++i) {
|
|
1497
1497
|
var cell = a[i];
|
|
1498
|
-
if (cell.formula) {
|
|
1498
|
+
if (cell.formula && cell.formula !== context.formula) {
|
|
1499
1499
|
formulas.push(cell.formula);
|
|
1500
1500
|
}
|
|
1501
1501
|
}
|
|
1502
|
-
return true;
|
|
1503
1502
|
}
|
|
1504
1503
|
}
|
|
1505
1504
|
|
|
@@ -1729,7 +1728,7 @@
|
|
|
1729
1728
|
return new CalcError("N/A");
|
|
1730
1729
|
}
|
|
1731
1730
|
set(row, col, data) {
|
|
1732
|
-
if (col === '__proto__' || col === 'constructor' || col === 'prototype'
|
|
1731
|
+
if (col === '__proto__' || col === 'constructor' || col === 'prototype'
|
|
1733
1732
|
|| row === '__proto__' || row === 'constructor' || row === 'prototype') {
|
|
1734
1733
|
return;
|
|
1735
1734
|
}
|
|
@@ -2041,16 +2040,17 @@
|
|
|
2041
2040
|
this.onReady.push(callback);
|
|
2042
2041
|
}
|
|
2043
2042
|
|
|
2044
|
-
|
|
2043
|
+
let p = parentContext;
|
|
2044
|
+
var ctx = new Context(this.resolve, this, ss, p);
|
|
2045
2045
|
var level = 0;
|
|
2046
2046
|
// if the call chain leads back to this same formula, we have a circular dependency.
|
|
2047
|
-
while (
|
|
2048
|
-
if (
|
|
2047
|
+
while (p) {
|
|
2048
|
+
if (p.formula === this) {
|
|
2049
2049
|
this.pending = false;
|
|
2050
2050
|
ctx.resolve(new CalcError("CIRCULAR"));
|
|
2051
2051
|
return;
|
|
2052
2052
|
}
|
|
2053
|
-
|
|
2053
|
+
p = p.parent;
|
|
2054
2054
|
++level;
|
|
2055
2055
|
}
|
|
2056
2056
|
|
|
@@ -2229,11 +2229,13 @@
|
|
|
2229
2229
|
var f;
|
|
2230
2230
|
if (haveForced) {
|
|
2231
2231
|
resolve += "this.resolveCells(toResolve, callback); } ";
|
|
2232
|
-
f = new Function("kendo", "CalcError", "round",
|
|
2232
|
+
f = new Function("kendo", "CalcError", "round", "limitRef",
|
|
2233
|
+
main + resolve + arrayArgs + " return { resolve: resolve, check: check, arrayArgs: arrayArgs };");
|
|
2233
2234
|
} else {
|
|
2234
|
-
f = new Function("kendo", "CalcError", "round",
|
|
2235
|
+
f = new Function("kendo", "CalcError", "round", "limitRef",
|
|
2236
|
+
main + " return { check: check };");
|
|
2235
2237
|
}
|
|
2236
|
-
f = f(calc.kendo, CalcError, limitPrecision$1);
|
|
2238
|
+
f = f(calc.kendo, CalcError, limitPrecision$1, limitRef$1);
|
|
2237
2239
|
if (!hasArrayArgs) {
|
|
2238
2240
|
delete f.arrayArgs;
|
|
2239
2241
|
}
|
|
@@ -2324,6 +2326,26 @@
|
|
|
2324
2326
|
return "($" + name + " = this.force($" + name + "))";
|
|
2325
2327
|
}
|
|
2326
2328
|
|
|
2329
|
+
function forceLeftColumn() {
|
|
2330
|
+
if (forced) {
|
|
2331
|
+
return "$" + name + "";
|
|
2332
|
+
}
|
|
2333
|
+
haveForced = true;
|
|
2334
|
+
forced = true;
|
|
2335
|
+
resolve += "toResolve.push(limitRef(args[i++], 'leftColumn')); ";
|
|
2336
|
+
return "($" + name + " = this.force($" + name + "))";
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
function forceTopRow() {
|
|
2340
|
+
if (forced) {
|
|
2341
|
+
return "$" + name + "";
|
|
2342
|
+
}
|
|
2343
|
+
haveForced = true;
|
|
2344
|
+
forced = true;
|
|
2345
|
+
resolve += "toResolve.push(limitRef(args[i++], 'topRow')); ";
|
|
2346
|
+
return "($" + name + " = this.force($" + name + "))";
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2327
2349
|
function forceNum(round) {
|
|
2328
2350
|
return "("
|
|
2329
2351
|
+ (round
|
|
@@ -2378,6 +2400,9 @@
|
|
|
2378
2400
|
if (type[0] == "null") {
|
|
2379
2401
|
return "(" + cond("null") + " ? (($" + name + " = " + type[1] + "), true) : false)";
|
|
2380
2402
|
}
|
|
2403
|
+
if (type[0] == "#null") {
|
|
2404
|
+
return "(" + cond("#null") + " ? (($" + name + " = " + type[1] + "), true) : false)";
|
|
2405
|
+
}
|
|
2381
2406
|
if (type[0] == "between" || type[0] == "[between]") {
|
|
2382
2407
|
return "(" + force() + " >= " + type[1] + " && " + "$" + name + " <= " + type[2] + " ? true : ((err = 'NUM'), false))";
|
|
2383
2408
|
}
|
|
@@ -2436,6 +2461,14 @@
|
|
|
2436
2461
|
force();
|
|
2437
2462
|
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2438
2463
|
}
|
|
2464
|
+
if (type == "vlookup-matrix") {
|
|
2465
|
+
forceLeftColumn();
|
|
2466
|
+
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2467
|
+
}
|
|
2468
|
+
if (type == "hlookup-matrix") {
|
|
2469
|
+
forceTopRow();
|
|
2470
|
+
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2471
|
+
}
|
|
2439
2472
|
if (type == "#matrix") {
|
|
2440
2473
|
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2441
2474
|
}
|
|
@@ -2451,6 +2484,9 @@
|
|
|
2451
2484
|
if (type == "null") {
|
|
2452
2485
|
return "(" + force() + " == null)";
|
|
2453
2486
|
}
|
|
2487
|
+
if (type == "#null") {
|
|
2488
|
+
return "($" + name + " == null)";
|
|
2489
|
+
}
|
|
2454
2490
|
if (type == "anyvalue") {
|
|
2455
2491
|
return "(" + force() + " != null && i <= args.length)";
|
|
2456
2492
|
}
|
|
@@ -2467,6 +2503,18 @@
|
|
|
2467
2503
|
}
|
|
2468
2504
|
}
|
|
2469
2505
|
|
|
2506
|
+
function limitRef$1(ref, how) {
|
|
2507
|
+
if (ref instanceof RangeRef) {
|
|
2508
|
+
switch (how) {
|
|
2509
|
+
case "topRow":
|
|
2510
|
+
return ref.topRow();
|
|
2511
|
+
case "leftColumn":
|
|
2512
|
+
return ref.leftColumn();
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
return ret;
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2470
2518
|
function limitPrecision$1(num, digits) {
|
|
2471
2519
|
return num === parseInt(num, 10) ? num : +num.toPrecision(digits || 16);
|
|
2472
2520
|
}
|
|
@@ -2907,6 +2955,7 @@
|
|
|
2907
2955
|
calc.runtime.daysInYear = daysInYear$1;
|
|
2908
2956
|
calc.runtime.parseDate = parseDate;
|
|
2909
2957
|
calc.runtime.limitPrecision = limitPrecision$1;
|
|
2958
|
+
calc.runtime.limitRef = limitRef$1;
|
|
2910
2959
|
calc.runtime.defineBuiltinFunction = defineBuiltinFunction$1;
|
|
2911
2960
|
calc.runtime.defineAlias = defineAlias$1;
|
|
2912
2961
|
calc.runtime.InputStream = InputStream;
|
|
@@ -23938,6 +23987,7 @@
|
|
|
23938
23987
|
FUNCS,
|
|
23939
23988
|
defineBuiltinFunction,
|
|
23940
23989
|
limitPrecision,
|
|
23990
|
+
limitRef,
|
|
23941
23991
|
packDate: packDate$1,
|
|
23942
23992
|
unpackDate: unpackDate$1,
|
|
23943
23993
|
daysInMonth,
|
|
@@ -29871,8 +29921,11 @@
|
|
|
29871
29921
|
|
|
29872
29922
|
function fetchSumRange(continuation) {
|
|
29873
29923
|
return function(callback, range, criteria, sumRange) {
|
|
29874
|
-
|
|
29875
|
-
|
|
29924
|
+
let self = this;
|
|
29925
|
+
let r = sumRange;
|
|
29926
|
+
criteria = parseCriteria(criteria);
|
|
29927
|
+
|
|
29928
|
+
if (r instanceof Ref) {
|
|
29876
29929
|
// make sure it covers the same area as `range`, as the “spec” mentions:
|
|
29877
29930
|
//
|
|
29878
29931
|
// The sum_range argument does not have to be the same size and shape as the
|
|
@@ -29882,7 +29935,7 @@
|
|
|
29882
29935
|
//
|
|
29883
29936
|
// It does make one wonder, since only the top-left cell in `sumRange` matters, why
|
|
29884
29937
|
// should it be a range at all? Oh well, Excel.
|
|
29885
|
-
|
|
29938
|
+
r = r.clone().toRangeRef();
|
|
29886
29939
|
if (r.width() != range.width || r.height() != range.height) {
|
|
29887
29940
|
if (!isFinite(r.topLeft.row)) {
|
|
29888
29941
|
r.topLeft.row = 0;
|
|
@@ -29892,12 +29945,27 @@
|
|
|
29892
29945
|
}
|
|
29893
29946
|
r.bottomRight.row = r.topLeft.row + range.height - 1;
|
|
29894
29947
|
r.bottomRight.col = r.topLeft.col + range.width - 1;
|
|
29895
|
-
return self.resolveCells([ r ], function(){
|
|
29896
|
-
callback(continuation(range, criteria, self.asMatrix(r)));
|
|
29897
|
-
});
|
|
29898
29948
|
}
|
|
29949
|
+
let cells = [];
|
|
29950
|
+
range.each(function(val, row, col){
|
|
29951
|
+
if (criteria(val)) {
|
|
29952
|
+
cells.push(r.toCell(row, col));
|
|
29953
|
+
}
|
|
29954
|
+
});
|
|
29955
|
+
return self.resolveCells(cells, function(){
|
|
29956
|
+
let data = cells.map(x => self.getRefData(x));
|
|
29957
|
+
return callback(continuation.call(self, data));
|
|
29958
|
+
});
|
|
29899
29959
|
}
|
|
29900
|
-
|
|
29960
|
+
|
|
29961
|
+
// sumRange must be a Matrix if we get here.
|
|
29962
|
+
let data = [];
|
|
29963
|
+
range.each(function(val, row, col){
|
|
29964
|
+
if (criteria(val)) {
|
|
29965
|
+
data.push(r.get(row, col));
|
|
29966
|
+
}
|
|
29967
|
+
});
|
|
29968
|
+
return callback(continuation.call(self, data));
|
|
29901
29969
|
};
|
|
29902
29970
|
}
|
|
29903
29971
|
|
|
@@ -29930,9 +29998,7 @@
|
|
|
29930
29998
|
var $sumRange = args[i++];
|
|
29931
29999
|
if ($sumRange instanceof CalcError)
|
|
29932
30000
|
return $sumRange;
|
|
29933
|
-
if (!($sumRange instanceof CellRef || $sumRange instanceof RangeRef || ((m = this.asMatrix($sumRange)) ? $sumRange = m : false) || (
|
|
29934
|
-
if ($sumRange instanceof CalcError)
|
|
29935
|
-
return $sumRange;
|
|
30001
|
+
if (!($sumRange instanceof CellRef || $sumRange instanceof RangeRef || ((m = this.asMatrix($sumRange)) ? $sumRange = m : false) || ($sumRange == null ? ($sumRange = $range, true) : false))) {
|
|
29936
30002
|
return new CalcError(err);
|
|
29937
30003
|
}
|
|
29938
30004
|
xargs.push($sumRange);
|
|
@@ -29945,7 +30011,7 @@
|
|
|
29945
30011
|
var toResolve = [], i = 0;
|
|
29946
30012
|
toResolve.push(args[i++]);
|
|
29947
30013
|
toResolve.push(args[i++]);
|
|
29948
|
-
|
|
30014
|
+
i++;
|
|
29949
30015
|
this.resolveCells(toResolve, callback);
|
|
29950
30016
|
}
|
|
29951
30017
|
function arrayArgs(args) {
|
|
@@ -29977,15 +30043,11 @@
|
|
|
29977
30043
|
resolve: resolve,
|
|
29978
30044
|
arrayArgs: arrayArgs
|
|
29979
30045
|
};
|
|
29980
|
-
}(), fetchSumRange(function (
|
|
29981
|
-
|
|
29982
|
-
|
|
29983
|
-
|
|
29984
|
-
|
|
29985
|
-
var v = sumRange.get(row, col);
|
|
29986
|
-
if (numericPredicate(v)) {
|
|
29987
|
-
sum += v || 0;
|
|
29988
|
-
}
|
|
30046
|
+
}(), fetchSumRange(function (matchingCellsData) {
|
|
30047
|
+
let sum = 0;
|
|
30048
|
+
matchingCellsData.forEach(v => {
|
|
30049
|
+
if (numericPredicate(v)) {
|
|
30050
|
+
sum += v || 0;
|
|
29989
30051
|
}
|
|
29990
30052
|
});
|
|
29991
30053
|
return sum;
|
|
@@ -30067,16 +30129,12 @@
|
|
|
30067
30129
|
resolve: resolve,
|
|
30068
30130
|
arrayArgs: arrayArgs
|
|
30069
30131
|
};
|
|
30070
|
-
}(), fetchSumRange(function (
|
|
30071
|
-
|
|
30072
|
-
|
|
30073
|
-
|
|
30074
|
-
|
|
30075
|
-
|
|
30076
|
-
if (numericPredicate(v)) {
|
|
30077
|
-
sum += v || 0;
|
|
30078
|
-
count++;
|
|
30079
|
-
}
|
|
30132
|
+
}(), fetchSumRange(function (matchingCellsData) {
|
|
30133
|
+
let sum = 0, count = 0;
|
|
30134
|
+
matchingCellsData.forEach(v => {
|
|
30135
|
+
if (numericPredicate(v)) {
|
|
30136
|
+
sum += v || 0;
|
|
30137
|
+
count++;
|
|
30080
30138
|
}
|
|
30081
30139
|
});
|
|
30082
30140
|
return count ? sum / count : new CalcError('DIV/0');
|
|
@@ -32790,7 +32848,7 @@
|
|
|
32790
32848
|
function resolve(args, callback) {
|
|
32791
32849
|
var toResolve = [], i = 0;
|
|
32792
32850
|
toResolve.push(args[i++]);
|
|
32793
|
-
toResolve.push(args[i++]);
|
|
32851
|
+
toResolve.push(limitRef(args[i++], 'topRow'));
|
|
32794
32852
|
toResolve.push(args[i++]);
|
|
32795
32853
|
toResolve.push(args[i++]);
|
|
32796
32854
|
this.resolveCells(toResolve, callback);
|
|
@@ -33323,7 +33381,7 @@
|
|
|
33323
33381
|
function resolve(args, callback) {
|
|
33324
33382
|
var toResolve = [], i = 0;
|
|
33325
33383
|
toResolve.push(args[i++]);
|
|
33326
|
-
toResolve.push(args[i++]);
|
|
33384
|
+
toResolve.push(limitRef(args[i++], 'leftColumn'));
|
|
33327
33385
|
toResolve.push(args[i++]);
|
|
33328
33386
|
toResolve.push(args[i++]);
|
|
33329
33387
|
this.resolveCells(toResolve, callback);
|