@progress/kendo-spreadsheet-common 1.2.10 → 1.2.11-develop.2
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 +103 -44
- package/dist/index.js +103 -44
- 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
|
|
|
@@ -2208,7 +2208,8 @@ FUNCS$1["if"] = function(callback, args) {
|
|
|
2208
2208
|
});
|
|
2209
2209
|
};
|
|
2210
2210
|
|
|
2211
|
-
|
|
2211
|
+
// Short for golden ratio (phi). `phi` is already used elsewhere as a key.
|
|
2212
|
+
FUNCS$1["gr"] = function(callback) {
|
|
2212
2213
|
callback((1 + Math.sqrt(5)) / 2);
|
|
2213
2214
|
};
|
|
2214
2215
|
|
|
@@ -2228,11 +2229,13 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2228
2229
|
var f;
|
|
2229
2230
|
if (haveForced) {
|
|
2230
2231
|
resolve += "this.resolveCells(toResolve, callback); } ";
|
|
2231
|
-
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 };");
|
|
2232
2234
|
} else {
|
|
2233
|
-
f = new Function("kendo", "CalcError", "round",
|
|
2235
|
+
f = new Function("kendo", "CalcError", "round", "limitRef",
|
|
2236
|
+
main + " return { check: check };");
|
|
2234
2237
|
}
|
|
2235
|
-
f = f(calc.kendo, CalcError, limitPrecision$1);
|
|
2238
|
+
f = f(calc.kendo, CalcError, limitPrecision$1, limitRef$1);
|
|
2236
2239
|
if (!hasArrayArgs) {
|
|
2237
2240
|
delete f.arrayArgs;
|
|
2238
2241
|
}
|
|
@@ -2323,6 +2326,26 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2323
2326
|
return "($" + name + " = this.force($" + name + "))";
|
|
2324
2327
|
}
|
|
2325
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
|
+
|
|
2326
2349
|
function forceNum(round) {
|
|
2327
2350
|
return "("
|
|
2328
2351
|
+ (round
|
|
@@ -2377,6 +2400,9 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2377
2400
|
if (type[0] == "null") {
|
|
2378
2401
|
return "(" + cond("null") + " ? (($" + name + " = " + type[1] + "), true) : false)";
|
|
2379
2402
|
}
|
|
2403
|
+
if (type[0] == "#null") {
|
|
2404
|
+
return "(" + cond("#null") + " ? (($" + name + " = " + type[1] + "), true) : false)";
|
|
2405
|
+
}
|
|
2380
2406
|
if (type[0] == "between" || type[0] == "[between]") {
|
|
2381
2407
|
return "(" + force() + " >= " + type[1] + " && " + "$" + name + " <= " + type[2] + " ? true : ((err = 'NUM'), false))";
|
|
2382
2408
|
}
|
|
@@ -2435,6 +2461,14 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2435
2461
|
force();
|
|
2436
2462
|
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2437
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
|
+
}
|
|
2438
2472
|
if (type == "#matrix") {
|
|
2439
2473
|
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2440
2474
|
}
|
|
@@ -2450,6 +2484,9 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2450
2484
|
if (type == "null") {
|
|
2451
2485
|
return "(" + force() + " == null)";
|
|
2452
2486
|
}
|
|
2487
|
+
if (type == "#null") {
|
|
2488
|
+
return "($" + name + " == null)";
|
|
2489
|
+
}
|
|
2453
2490
|
if (type == "anyvalue") {
|
|
2454
2491
|
return "(" + force() + " != null && i <= args.length)";
|
|
2455
2492
|
}
|
|
@@ -2466,6 +2503,18 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2466
2503
|
}
|
|
2467
2504
|
}
|
|
2468
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
|
+
|
|
2469
2518
|
function limitPrecision$1(num, digits) {
|
|
2470
2519
|
return num === parseInt(num, 10) ? num : +num.toPrecision(digits || 16);
|
|
2471
2520
|
}
|
|
@@ -2906,6 +2955,7 @@ calc.runtime.isLeapYear = isLeapYear$1;
|
|
|
2906
2955
|
calc.runtime.daysInYear = daysInYear$1;
|
|
2907
2956
|
calc.runtime.parseDate = parseDate;
|
|
2908
2957
|
calc.runtime.limitPrecision = limitPrecision$1;
|
|
2958
|
+
calc.runtime.limitRef = limitRef$1;
|
|
2909
2959
|
calc.runtime.defineBuiltinFunction = defineBuiltinFunction$1;
|
|
2910
2960
|
calc.runtime.defineAlias = defineAlias$1;
|
|
2911
2961
|
calc.runtime.InputStream = InputStream;
|
|
@@ -23937,6 +23987,7 @@ const {
|
|
|
23937
23987
|
FUNCS,
|
|
23938
23988
|
defineBuiltinFunction,
|
|
23939
23989
|
limitPrecision,
|
|
23990
|
+
limitRef,
|
|
23940
23991
|
packDate: packDate$1,
|
|
23941
23992
|
unpackDate: unpackDate$1,
|
|
23942
23993
|
daysInMonth,
|
|
@@ -29870,8 +29921,11 @@ defineBuiltinFunction('countif', false, function () {
|
|
|
29870
29921
|
|
|
29871
29922
|
function fetchSumRange(continuation) {
|
|
29872
29923
|
return function(callback, range, criteria, sumRange) {
|
|
29873
|
-
|
|
29874
|
-
|
|
29924
|
+
let self = this;
|
|
29925
|
+
let r = sumRange;
|
|
29926
|
+
criteria = parseCriteria(criteria);
|
|
29927
|
+
|
|
29928
|
+
if (r instanceof Ref) {
|
|
29875
29929
|
// make sure it covers the same area as `range`, as the “spec” mentions:
|
|
29876
29930
|
//
|
|
29877
29931
|
// The sum_range argument does not have to be the same size and shape as the
|
|
@@ -29881,7 +29935,7 @@ function fetchSumRange(continuation) {
|
|
|
29881
29935
|
//
|
|
29882
29936
|
// It does make one wonder, since only the top-left cell in `sumRange` matters, why
|
|
29883
29937
|
// should it be a range at all? Oh well, Excel.
|
|
29884
|
-
|
|
29938
|
+
r = r.clone().toRangeRef();
|
|
29885
29939
|
if (r.width() != range.width || r.height() != range.height) {
|
|
29886
29940
|
if (!isFinite(r.topLeft.row)) {
|
|
29887
29941
|
r.topLeft.row = 0;
|
|
@@ -29891,12 +29945,27 @@ function fetchSumRange(continuation) {
|
|
|
29891
29945
|
}
|
|
29892
29946
|
r.bottomRight.row = r.topLeft.row + range.height - 1;
|
|
29893
29947
|
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
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
|
+
});
|
|
29898
29959
|
}
|
|
29899
|
-
|
|
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));
|
|
29900
29969
|
};
|
|
29901
29970
|
}
|
|
29902
29971
|
|
|
@@ -29929,9 +29998,7 @@ defineBuiltinFunction('sumif', true, function () {
|
|
|
29929
29998
|
var $sumRange = args[i++];
|
|
29930
29999
|
if ($sumRange instanceof CalcError)
|
|
29931
30000
|
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;
|
|
30001
|
+
if (!($sumRange instanceof CellRef || $sumRange instanceof RangeRef || ((m = this.asMatrix($sumRange)) ? $sumRange = m : false) || ($sumRange == null ? ($sumRange = $range, true) : false))) {
|
|
29935
30002
|
return new CalcError(err);
|
|
29936
30003
|
}
|
|
29937
30004
|
xargs.push($sumRange);
|
|
@@ -29944,7 +30011,7 @@ defineBuiltinFunction('sumif', true, function () {
|
|
|
29944
30011
|
var toResolve = [], i = 0;
|
|
29945
30012
|
toResolve.push(args[i++]);
|
|
29946
30013
|
toResolve.push(args[i++]);
|
|
29947
|
-
|
|
30014
|
+
i++;
|
|
29948
30015
|
this.resolveCells(toResolve, callback);
|
|
29949
30016
|
}
|
|
29950
30017
|
function arrayArgs(args) {
|
|
@@ -29976,15 +30043,11 @@ defineBuiltinFunction('sumif', true, function () {
|
|
|
29976
30043
|
resolve: resolve,
|
|
29977
30044
|
arrayArgs: arrayArgs
|
|
29978
30045
|
};
|
|
29979
|
-
}(), fetchSumRange(function (
|
|
29980
|
-
|
|
29981
|
-
|
|
29982
|
-
|
|
29983
|
-
|
|
29984
|
-
var v = sumRange.get(row, col);
|
|
29985
|
-
if (numericPredicate(v)) {
|
|
29986
|
-
sum += v || 0;
|
|
29987
|
-
}
|
|
30046
|
+
}(), fetchSumRange(function (matchingCellsData) {
|
|
30047
|
+
let sum = 0;
|
|
30048
|
+
matchingCellsData.forEach(v => {
|
|
30049
|
+
if (numericPredicate(v)) {
|
|
30050
|
+
sum += v || 0;
|
|
29988
30051
|
}
|
|
29989
30052
|
});
|
|
29990
30053
|
return sum;
|
|
@@ -30066,16 +30129,12 @@ defineBuiltinFunction('averageif', true, function () {
|
|
|
30066
30129
|
resolve: resolve,
|
|
30067
30130
|
arrayArgs: arrayArgs
|
|
30068
30131
|
};
|
|
30069
|
-
}(), fetchSumRange(function (
|
|
30070
|
-
|
|
30071
|
-
|
|
30072
|
-
|
|
30073
|
-
|
|
30074
|
-
|
|
30075
|
-
if (numericPredicate(v)) {
|
|
30076
|
-
sum += v || 0;
|
|
30077
|
-
count++;
|
|
30078
|
-
}
|
|
30132
|
+
}(), fetchSumRange(function (matchingCellsData) {
|
|
30133
|
+
let sum = 0, count = 0;
|
|
30134
|
+
matchingCellsData.forEach(v => {
|
|
30135
|
+
if (numericPredicate(v)) {
|
|
30136
|
+
sum += v || 0;
|
|
30137
|
+
count++;
|
|
30079
30138
|
}
|
|
30080
30139
|
});
|
|
30081
30140
|
return count ? sum / count : new CalcError('DIV/0');
|
|
@@ -32789,7 +32848,7 @@ defineBuiltinFunction('hlookup', false, function () {
|
|
|
32789
32848
|
function resolve(args, callback) {
|
|
32790
32849
|
var toResolve = [], i = 0;
|
|
32791
32850
|
toResolve.push(args[i++]);
|
|
32792
|
-
toResolve.push(args[i++]);
|
|
32851
|
+
toResolve.push(limitRef(args[i++], 'topRow'));
|
|
32793
32852
|
toResolve.push(args[i++]);
|
|
32794
32853
|
toResolve.push(args[i++]);
|
|
32795
32854
|
this.resolveCells(toResolve, callback);
|
|
@@ -33322,7 +33381,7 @@ defineBuiltinFunction('vlookup', false, function () {
|
|
|
33322
33381
|
function resolve(args, callback) {
|
|
33323
33382
|
var toResolve = [], i = 0;
|
|
33324
33383
|
toResolve.push(args[i++]);
|
|
33325
|
-
toResolve.push(args[i++]);
|
|
33384
|
+
toResolve.push(limitRef(args[i++], 'leftColumn'));
|
|
33326
33385
|
toResolve.push(args[i++]);
|
|
33327
33386
|
toResolve.push(args[i++]);
|
|
33328
33387
|
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
|
|
|
@@ -2209,7 +2209,8 @@
|
|
|
2209
2209
|
});
|
|
2210
2210
|
};
|
|
2211
2211
|
|
|
2212
|
-
|
|
2212
|
+
// Short for golden ratio (phi). `phi` is already used elsewhere as a key.
|
|
2213
|
+
FUNCS$1["gr"] = function(callback) {
|
|
2213
2214
|
callback((1 + Math.sqrt(5)) / 2);
|
|
2214
2215
|
};
|
|
2215
2216
|
|
|
@@ -2229,11 +2230,13 @@
|
|
|
2229
2230
|
var f;
|
|
2230
2231
|
if (haveForced) {
|
|
2231
2232
|
resolve += "this.resolveCells(toResolve, callback); } ";
|
|
2232
|
-
f = new Function("kendo", "CalcError", "round",
|
|
2233
|
+
f = new Function("kendo", "CalcError", "round", "limitRef",
|
|
2234
|
+
main + resolve + arrayArgs + " return { resolve: resolve, check: check, arrayArgs: arrayArgs };");
|
|
2233
2235
|
} else {
|
|
2234
|
-
f = new Function("kendo", "CalcError", "round",
|
|
2236
|
+
f = new Function("kendo", "CalcError", "round", "limitRef",
|
|
2237
|
+
main + " return { check: check };");
|
|
2235
2238
|
}
|
|
2236
|
-
f = f(calc.kendo, CalcError, limitPrecision$1);
|
|
2239
|
+
f = f(calc.kendo, CalcError, limitPrecision$1, limitRef$1);
|
|
2237
2240
|
if (!hasArrayArgs) {
|
|
2238
2241
|
delete f.arrayArgs;
|
|
2239
2242
|
}
|
|
@@ -2324,6 +2327,26 @@
|
|
|
2324
2327
|
return "($" + name + " = this.force($" + name + "))";
|
|
2325
2328
|
}
|
|
2326
2329
|
|
|
2330
|
+
function forceLeftColumn() {
|
|
2331
|
+
if (forced) {
|
|
2332
|
+
return "$" + name + "";
|
|
2333
|
+
}
|
|
2334
|
+
haveForced = true;
|
|
2335
|
+
forced = true;
|
|
2336
|
+
resolve += "toResolve.push(limitRef(args[i++], 'leftColumn')); ";
|
|
2337
|
+
return "($" + name + " = this.force($" + name + "))";
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
function forceTopRow() {
|
|
2341
|
+
if (forced) {
|
|
2342
|
+
return "$" + name + "";
|
|
2343
|
+
}
|
|
2344
|
+
haveForced = true;
|
|
2345
|
+
forced = true;
|
|
2346
|
+
resolve += "toResolve.push(limitRef(args[i++], 'topRow')); ";
|
|
2347
|
+
return "($" + name + " = this.force($" + name + "))";
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2327
2350
|
function forceNum(round) {
|
|
2328
2351
|
return "("
|
|
2329
2352
|
+ (round
|
|
@@ -2378,6 +2401,9 @@
|
|
|
2378
2401
|
if (type[0] == "null") {
|
|
2379
2402
|
return "(" + cond("null") + " ? (($" + name + " = " + type[1] + "), true) : false)";
|
|
2380
2403
|
}
|
|
2404
|
+
if (type[0] == "#null") {
|
|
2405
|
+
return "(" + cond("#null") + " ? (($" + name + " = " + type[1] + "), true) : false)";
|
|
2406
|
+
}
|
|
2381
2407
|
if (type[0] == "between" || type[0] == "[between]") {
|
|
2382
2408
|
return "(" + force() + " >= " + type[1] + " && " + "$" + name + " <= " + type[2] + " ? true : ((err = 'NUM'), false))";
|
|
2383
2409
|
}
|
|
@@ -2436,6 +2462,14 @@
|
|
|
2436
2462
|
force();
|
|
2437
2463
|
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2438
2464
|
}
|
|
2465
|
+
if (type == "vlookup-matrix") {
|
|
2466
|
+
forceLeftColumn();
|
|
2467
|
+
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2468
|
+
}
|
|
2469
|
+
if (type == "hlookup-matrix") {
|
|
2470
|
+
forceTopRow();
|
|
2471
|
+
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2472
|
+
}
|
|
2439
2473
|
if (type == "#matrix") {
|
|
2440
2474
|
return "((m = this.asMatrix($" + name + ")) ? ($" + name + " = m) : false)";
|
|
2441
2475
|
}
|
|
@@ -2451,6 +2485,9 @@
|
|
|
2451
2485
|
if (type == "null") {
|
|
2452
2486
|
return "(" + force() + " == null)";
|
|
2453
2487
|
}
|
|
2488
|
+
if (type == "#null") {
|
|
2489
|
+
return "($" + name + " == null)";
|
|
2490
|
+
}
|
|
2454
2491
|
if (type == "anyvalue") {
|
|
2455
2492
|
return "(" + force() + " != null && i <= args.length)";
|
|
2456
2493
|
}
|
|
@@ -2467,6 +2504,18 @@
|
|
|
2467
2504
|
}
|
|
2468
2505
|
}
|
|
2469
2506
|
|
|
2507
|
+
function limitRef$1(ref, how) {
|
|
2508
|
+
if (ref instanceof RangeRef) {
|
|
2509
|
+
switch (how) {
|
|
2510
|
+
case "topRow":
|
|
2511
|
+
return ref.topRow();
|
|
2512
|
+
case "leftColumn":
|
|
2513
|
+
return ref.leftColumn();
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
return ret;
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2470
2519
|
function limitPrecision$1(num, digits) {
|
|
2471
2520
|
return num === parseInt(num, 10) ? num : +num.toPrecision(digits || 16);
|
|
2472
2521
|
}
|
|
@@ -2907,6 +2956,7 @@
|
|
|
2907
2956
|
calc.runtime.daysInYear = daysInYear$1;
|
|
2908
2957
|
calc.runtime.parseDate = parseDate;
|
|
2909
2958
|
calc.runtime.limitPrecision = limitPrecision$1;
|
|
2959
|
+
calc.runtime.limitRef = limitRef$1;
|
|
2910
2960
|
calc.runtime.defineBuiltinFunction = defineBuiltinFunction$1;
|
|
2911
2961
|
calc.runtime.defineAlias = defineAlias$1;
|
|
2912
2962
|
calc.runtime.InputStream = InputStream;
|
|
@@ -23938,6 +23988,7 @@
|
|
|
23938
23988
|
FUNCS,
|
|
23939
23989
|
defineBuiltinFunction,
|
|
23940
23990
|
limitPrecision,
|
|
23991
|
+
limitRef,
|
|
23941
23992
|
packDate: packDate$1,
|
|
23942
23993
|
unpackDate: unpackDate$1,
|
|
23943
23994
|
daysInMonth,
|
|
@@ -29871,8 +29922,11 @@
|
|
|
29871
29922
|
|
|
29872
29923
|
function fetchSumRange(continuation) {
|
|
29873
29924
|
return function(callback, range, criteria, sumRange) {
|
|
29874
|
-
|
|
29875
|
-
|
|
29925
|
+
let self = this;
|
|
29926
|
+
let r = sumRange;
|
|
29927
|
+
criteria = parseCriteria(criteria);
|
|
29928
|
+
|
|
29929
|
+
if (r instanceof Ref) {
|
|
29876
29930
|
// make sure it covers the same area as `range`, as the “spec” mentions:
|
|
29877
29931
|
//
|
|
29878
29932
|
// The sum_range argument does not have to be the same size and shape as the
|
|
@@ -29882,7 +29936,7 @@
|
|
|
29882
29936
|
//
|
|
29883
29937
|
// It does make one wonder, since only the top-left cell in `sumRange` matters, why
|
|
29884
29938
|
// should it be a range at all? Oh well, Excel.
|
|
29885
|
-
|
|
29939
|
+
r = r.clone().toRangeRef();
|
|
29886
29940
|
if (r.width() != range.width || r.height() != range.height) {
|
|
29887
29941
|
if (!isFinite(r.topLeft.row)) {
|
|
29888
29942
|
r.topLeft.row = 0;
|
|
@@ -29892,12 +29946,27 @@
|
|
|
29892
29946
|
}
|
|
29893
29947
|
r.bottomRight.row = r.topLeft.row + range.height - 1;
|
|
29894
29948
|
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
29949
|
}
|
|
29950
|
+
let cells = [];
|
|
29951
|
+
range.each(function(val, row, col){
|
|
29952
|
+
if (criteria(val)) {
|
|
29953
|
+
cells.push(r.toCell(row, col));
|
|
29954
|
+
}
|
|
29955
|
+
});
|
|
29956
|
+
return self.resolveCells(cells, function(){
|
|
29957
|
+
let data = cells.map(x => self.getRefData(x));
|
|
29958
|
+
return callback(continuation.call(self, data));
|
|
29959
|
+
});
|
|
29899
29960
|
}
|
|
29900
|
-
|
|
29961
|
+
|
|
29962
|
+
// sumRange must be a Matrix if we get here.
|
|
29963
|
+
let data = [];
|
|
29964
|
+
range.each(function(val, row, col){
|
|
29965
|
+
if (criteria(val)) {
|
|
29966
|
+
data.push(r.get(row, col));
|
|
29967
|
+
}
|
|
29968
|
+
});
|
|
29969
|
+
return callback(continuation.call(self, data));
|
|
29901
29970
|
};
|
|
29902
29971
|
}
|
|
29903
29972
|
|
|
@@ -29930,9 +29999,7 @@
|
|
|
29930
29999
|
var $sumRange = args[i++];
|
|
29931
30000
|
if ($sumRange instanceof CalcError)
|
|
29932
30001
|
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;
|
|
30002
|
+
if (!($sumRange instanceof CellRef || $sumRange instanceof RangeRef || ((m = this.asMatrix($sumRange)) ? $sumRange = m : false) || ($sumRange == null ? ($sumRange = $range, true) : false))) {
|
|
29936
30003
|
return new CalcError(err);
|
|
29937
30004
|
}
|
|
29938
30005
|
xargs.push($sumRange);
|
|
@@ -29945,7 +30012,7 @@
|
|
|
29945
30012
|
var toResolve = [], i = 0;
|
|
29946
30013
|
toResolve.push(args[i++]);
|
|
29947
30014
|
toResolve.push(args[i++]);
|
|
29948
|
-
|
|
30015
|
+
i++;
|
|
29949
30016
|
this.resolveCells(toResolve, callback);
|
|
29950
30017
|
}
|
|
29951
30018
|
function arrayArgs(args) {
|
|
@@ -29977,15 +30044,11 @@
|
|
|
29977
30044
|
resolve: resolve,
|
|
29978
30045
|
arrayArgs: arrayArgs
|
|
29979
30046
|
};
|
|
29980
|
-
}(), fetchSumRange(function (
|
|
29981
|
-
|
|
29982
|
-
|
|
29983
|
-
|
|
29984
|
-
|
|
29985
|
-
var v = sumRange.get(row, col);
|
|
29986
|
-
if (numericPredicate(v)) {
|
|
29987
|
-
sum += v || 0;
|
|
29988
|
-
}
|
|
30047
|
+
}(), fetchSumRange(function (matchingCellsData) {
|
|
30048
|
+
let sum = 0;
|
|
30049
|
+
matchingCellsData.forEach(v => {
|
|
30050
|
+
if (numericPredicate(v)) {
|
|
30051
|
+
sum += v || 0;
|
|
29989
30052
|
}
|
|
29990
30053
|
});
|
|
29991
30054
|
return sum;
|
|
@@ -30067,16 +30130,12 @@
|
|
|
30067
30130
|
resolve: resolve,
|
|
30068
30131
|
arrayArgs: arrayArgs
|
|
30069
30132
|
};
|
|
30070
|
-
}(), fetchSumRange(function (
|
|
30071
|
-
|
|
30072
|
-
|
|
30073
|
-
|
|
30074
|
-
|
|
30075
|
-
|
|
30076
|
-
if (numericPredicate(v)) {
|
|
30077
|
-
sum += v || 0;
|
|
30078
|
-
count++;
|
|
30079
|
-
}
|
|
30133
|
+
}(), fetchSumRange(function (matchingCellsData) {
|
|
30134
|
+
let sum = 0, count = 0;
|
|
30135
|
+
matchingCellsData.forEach(v => {
|
|
30136
|
+
if (numericPredicate(v)) {
|
|
30137
|
+
sum += v || 0;
|
|
30138
|
+
count++;
|
|
30080
30139
|
}
|
|
30081
30140
|
});
|
|
30082
30141
|
return count ? sum / count : new CalcError('DIV/0');
|
|
@@ -32790,7 +32849,7 @@
|
|
|
32790
32849
|
function resolve(args, callback) {
|
|
32791
32850
|
var toResolve = [], i = 0;
|
|
32792
32851
|
toResolve.push(args[i++]);
|
|
32793
|
-
toResolve.push(args[i++]);
|
|
32852
|
+
toResolve.push(limitRef(args[i++], 'topRow'));
|
|
32794
32853
|
toResolve.push(args[i++]);
|
|
32795
32854
|
toResolve.push(args[i++]);
|
|
32796
32855
|
this.resolveCells(toResolve, callback);
|
|
@@ -33323,7 +33382,7 @@
|
|
|
33323
33382
|
function resolve(args, callback) {
|
|
33324
33383
|
var toResolve = [], i = 0;
|
|
33325
33384
|
toResolve.push(args[i++]);
|
|
33326
|
-
toResolve.push(args[i++]);
|
|
33385
|
+
toResolve.push(limitRef(args[i++], 'leftColumn'));
|
|
33327
33386
|
toResolve.push(args[i++]);
|
|
33328
33387
|
toResolve.push(args[i++]);
|
|
33329
33388
|
this.resolveCells(toResolve, callback);
|