ooxml-core 0.16.0 → 0.17.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/dist/automation/index.cjs +867 -360
- package/dist/automation/index.mjs +867 -360
- package/dist/xlsx/formula/engine-core.d.ts +9 -0
- package/dist/xlsx/formula/engine-core.d.ts.map +1 -1
- package/dist/xlsx/formula/engine-host.d.ts +2 -0
- package/dist/xlsx/formula/engine-host.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/bonds.d.ts +3 -0
- package/dist/xlsx/formula/functions/bonds.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/coupons.d.ts +21 -0
- package/dist/xlsx/formula/functions/coupons.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/depreciation.d.ts +0 -1
- package/dist/xlsx/formula/functions/depreciation.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/financial.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/securities.d.ts +3 -0
- package/dist/xlsx/formula/functions/securities.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/text-extra.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/text-regex.d.ts +5 -0
- package/dist/xlsx/formula/functions/text-regex.d.ts.map +1 -0
- package/dist/xlsx/index.cjs +850 -343
- package/dist/xlsx/index.mjs +850 -343
- package/dist/xlsx/load/index.cjs +804 -330
- package/dist/xlsx/load/index.mjs +804 -330
- package/dist/xlsx/model.d.ts +9 -0
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/load.d.ts.map +1 -1
- package/dist/xlsx/read/workbook-part.d.ts +5 -0
- package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
- package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/xlsx/index.cjs
CHANGED
|
@@ -4969,6 +4969,67 @@ var ENGINEERING_FUNCTIONS = [
|
|
|
4969
4969
|
)
|
|
4970
4970
|
];
|
|
4971
4971
|
|
|
4972
|
+
// src/xlsx/formula/functions/coupons.ts
|
|
4973
|
+
var C8 = "Financial";
|
|
4974
|
+
function checkSecurity(settlement, maturity, frequency2, basis) {
|
|
4975
|
+
if (![1, 2, 4].includes(frequency2) || basis < 0 || basis > 4 || settlement >= maturity)
|
|
4976
|
+
fail(ERR.NUM);
|
|
4977
|
+
}
|
|
4978
|
+
function couponFacts(settlement, maturity, frequency2, basis, ctx) {
|
|
4979
|
+
const [s, m] = [Math.floor(settlement), Math.floor(maturity)];
|
|
4980
|
+
checkSecurity(s, m, frequency2, basis);
|
|
4981
|
+
const months = 12 / frequency2;
|
|
4982
|
+
const { year, month, day } = serialToYmd(m, ctx.date1904);
|
|
4983
|
+
const monthEnd = day === daysInMonth(year, month);
|
|
4984
|
+
let count2 = 0;
|
|
4985
|
+
let next = m;
|
|
4986
|
+
let previous = addMonths(m, -months, ctx, monthEnd);
|
|
4987
|
+
while (previous > s) {
|
|
4988
|
+
count2 += 1;
|
|
4989
|
+
next = previous;
|
|
4990
|
+
previous = addMonths(m, -months * (count2 + 1), ctx, monthEnd);
|
|
4991
|
+
}
|
|
4992
|
+
count2 += 1;
|
|
4993
|
+
const dayCount = (a, b, european) => basis === 0 || basis === 4 ? days360(a, b, basis === 4 || european, ctx) : b - a;
|
|
4994
|
+
const daysSincePrevious = dayCount(previous, s, false);
|
|
4995
|
+
const daysInPeriod = basis === 1 ? next - previous : basis === 3 ? 365 / frequency2 : 360 / frequency2;
|
|
4996
|
+
const daysToNext = basis === 0 ? daysInPeriod - daysSincePrevious : basis === 4 ? days360(s, next, true, ctx) : next - s;
|
|
4997
|
+
return { previous, next, count: count2, daysSincePrevious, daysInPeriod, daysToNext };
|
|
4998
|
+
}
|
|
4999
|
+
var security = (name, description, pick2) => spec(
|
|
5000
|
+
name,
|
|
5001
|
+
C8,
|
|
5002
|
+
`${name}(settlement, maturity, frequency, [basis])`,
|
|
5003
|
+
description,
|
|
5004
|
+
3,
|
|
5005
|
+
4,
|
|
5006
|
+
(args, ctx) => pick2(
|
|
5007
|
+
couponFacts(
|
|
5008
|
+
serialArg(args[0]),
|
|
5009
|
+
serialArg(args[1]),
|
|
5010
|
+
int(args[2]),
|
|
5011
|
+
args.length > 3 && args[3] !== null ? int(args[3]) : 0,
|
|
5012
|
+
ctx
|
|
5013
|
+
)
|
|
5014
|
+
)
|
|
5015
|
+
);
|
|
5016
|
+
var COUPON_FUNCTIONS = [
|
|
5017
|
+
security("COUPPCD", "The coupon date before the settlement date.", (f) => f.previous),
|
|
5018
|
+
security("COUPNCD", "The coupon date after the settlement date.", (f) => f.next),
|
|
5019
|
+
security("COUPNUM", "The number of coupons between settlement and maturity.", (f) => f.count),
|
|
5020
|
+
security(
|
|
5021
|
+
"COUPDAYBS",
|
|
5022
|
+
"The days from the start of the coupon period to settlement.",
|
|
5023
|
+
(f) => f.daysSincePrevious
|
|
5024
|
+
),
|
|
5025
|
+
security(
|
|
5026
|
+
"COUPDAYS",
|
|
5027
|
+
"The days in the coupon period that contains the settlement date.",
|
|
5028
|
+
(f) => f.daysInPeriod
|
|
5029
|
+
),
|
|
5030
|
+
security("COUPDAYSNC", "The days from settlement to the next coupon date.", (f) => f.daysToNext)
|
|
5031
|
+
];
|
|
5032
|
+
|
|
4972
5033
|
// src/xlsx/formula/functions/financial-core.ts
|
|
4973
5034
|
function pmt(rate, nper, pv2, fv2 = 0, type = 0) {
|
|
4974
5035
|
if (nper === 0) fail(ERR.NUM);
|
|
@@ -5038,12 +5099,185 @@ function cumulative(args, principal) {
|
|
|
5038
5099
|
return total2;
|
|
5039
5100
|
}
|
|
5040
5101
|
|
|
5102
|
+
// src/xlsx/formula/functions/bonds.ts
|
|
5103
|
+
var C9 = "Financial";
|
|
5104
|
+
var basisOf = (args, index2) => {
|
|
5105
|
+
const basis = args.length > index2 && args[index2] !== null ? int(args[index2]) : 0;
|
|
5106
|
+
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
5107
|
+
return basis;
|
|
5108
|
+
};
|
|
5109
|
+
function pricePerHundred(facts, rate, yld, redemption, frequency2) {
|
|
5110
|
+
const { count: n2, daysSincePrevious: a, daysInPeriod: e, daysToNext: dsc } = facts;
|
|
5111
|
+
const coupon = 100 * rate / frequency2;
|
|
5112
|
+
const accrued = coupon * (a / e);
|
|
5113
|
+
if (n2 === 1) return (redemption + coupon) / (1 + dsc / e * yld / frequency2) - accrued;
|
|
5114
|
+
let price = redemption / (1 + yld / frequency2) ** (n2 - 1 + dsc / e);
|
|
5115
|
+
for (let k = 1; k <= n2; k++) price += coupon / (1 + yld / frequency2) ** (k - 1 + dsc / e);
|
|
5116
|
+
return price - accrued;
|
|
5117
|
+
}
|
|
5118
|
+
function bondOf(args, ctx, redemptionAt, basisAt) {
|
|
5119
|
+
const frequency2 = int(args[5]);
|
|
5120
|
+
const facts = couponFacts(
|
|
5121
|
+
serialArg(args[0]),
|
|
5122
|
+
serialArg(args[1]),
|
|
5123
|
+
frequency2,
|
|
5124
|
+
basisOf(args, basisAt),
|
|
5125
|
+
ctx
|
|
5126
|
+
);
|
|
5127
|
+
return { facts, rate: num(args[2]), redemption: num(args[redemptionAt]), frequency: frequency2 };
|
|
5128
|
+
}
|
|
5129
|
+
function duration(bond, yld) {
|
|
5130
|
+
const { facts, rate, frequency: frequency2 } = bond;
|
|
5131
|
+
const { count: n2, daysInPeriod: e, daysToNext: dsc } = facts;
|
|
5132
|
+
const coupon = 100 * rate / frequency2;
|
|
5133
|
+
let weighted = 0;
|
|
5134
|
+
let total2 = 0;
|
|
5135
|
+
for (let k = 1; k <= n2; k++) {
|
|
5136
|
+
const periods = k - 1 + dsc / e;
|
|
5137
|
+
const flow = k === n2 ? coupon + 100 : coupon;
|
|
5138
|
+
const value = flow / (1 + yld / frequency2) ** periods;
|
|
5139
|
+
weighted += periods / frequency2 * value;
|
|
5140
|
+
total2 += value;
|
|
5141
|
+
}
|
|
5142
|
+
return weighted / total2;
|
|
5143
|
+
}
|
|
5144
|
+
function quasiPeriods(anchor, from, to, frequency2, ctx) {
|
|
5145
|
+
const months = 12 / frequency2;
|
|
5146
|
+
const { year, month, day } = serialToYmd(anchor, ctx.date1904);
|
|
5147
|
+
const monthEnd = day === daysInMonth(year, month);
|
|
5148
|
+
const at = (k) => addMonths(anchor, k * months, ctx, monthEnd);
|
|
5149
|
+
let back = 0;
|
|
5150
|
+
while (at(back) > from) back -= 1;
|
|
5151
|
+
const dates = [];
|
|
5152
|
+
for (let k = back; ; k++) {
|
|
5153
|
+
dates.push(at(k));
|
|
5154
|
+
if (at(k) >= to) break;
|
|
5155
|
+
}
|
|
5156
|
+
return dates;
|
|
5157
|
+
}
|
|
5158
|
+
function accruedInterest(args, ctx) {
|
|
5159
|
+
const issue = serialArg(args[0]);
|
|
5160
|
+
const first3 = serialArg(args[1]);
|
|
5161
|
+
const settlement = serialArg(args[2]);
|
|
5162
|
+
const [rate, par] = [num(args[3]), optNum(args, 4, 1e3)];
|
|
5163
|
+
const frequency2 = int(args[5]);
|
|
5164
|
+
const basis = basisOf(args, 6);
|
|
5165
|
+
const fromIssue = args.length > 7 && args[7] !== null ? bool(args[7]) : true;
|
|
5166
|
+
if (rate <= 0 || par <= 0 || ![1, 2, 4].includes(frequency2) || issue >= settlement) fail(ERR.NUM);
|
|
5167
|
+
const start = fromIssue ? issue : Math.max(issue, first3);
|
|
5168
|
+
if (start >= settlement) return 0;
|
|
5169
|
+
const dates = quasiPeriods(first3, start, settlement, frequency2, ctx);
|
|
5170
|
+
const count2 = (a, b) => basis === 0 || basis === 4 ? days360(a, b, basis === 4, ctx) : b - a;
|
|
5171
|
+
let sum2 = 0;
|
|
5172
|
+
for (let i = 0; i + 1 < dates.length; i++) {
|
|
5173
|
+
const [p, q] = [dates[i], dates[i + 1]];
|
|
5174
|
+
const a = count2(Math.max(start, p), Math.min(settlement, q));
|
|
5175
|
+
if (a <= 0) continue;
|
|
5176
|
+
const length = basis === 1 ? q - p : basis === 3 ? 365 / frequency2 : 360 / frequency2;
|
|
5177
|
+
sum2 += a / length;
|
|
5178
|
+
}
|
|
5179
|
+
return par * rate / frequency2 * sum2;
|
|
5180
|
+
}
|
|
5181
|
+
var BOND_ARGS = (name, third, fourth, fifth) => `${name}(settlement, maturity, ${third}, ${fourth}, ${fifth}, frequency, [basis])`;
|
|
5182
|
+
var BOND_FUNCTIONS = [
|
|
5183
|
+
spec(
|
|
5184
|
+
"PRICE",
|
|
5185
|
+
C9,
|
|
5186
|
+
BOND_ARGS("PRICE", "rate", "yld", "redemption"),
|
|
5187
|
+
"The price per 100 face value of a security that pays periodic interest.",
|
|
5188
|
+
6,
|
|
5189
|
+
7,
|
|
5190
|
+
(args, ctx) => {
|
|
5191
|
+
const bond = bondOf(args, ctx, 4, 6);
|
|
5192
|
+
const yld = num(args[3]);
|
|
5193
|
+
if (bond.rate < 0 || yld < 0 || bond.redemption <= 0) fail(ERR.NUM);
|
|
5194
|
+
return pricePerHundred(bond.facts, bond.rate, yld, bond.redemption, bond.frequency);
|
|
5195
|
+
}
|
|
5196
|
+
),
|
|
5197
|
+
spec(
|
|
5198
|
+
"YIELD",
|
|
5199
|
+
C9,
|
|
5200
|
+
BOND_ARGS("YIELD", "rate", "pr", "redemption"),
|
|
5201
|
+
"The yield of a security that pays periodic interest.",
|
|
5202
|
+
6,
|
|
5203
|
+
7,
|
|
5204
|
+
(args, ctx) => {
|
|
5205
|
+
const bond = bondOf(args, ctx, 4, 6);
|
|
5206
|
+
const price = num(args[3]);
|
|
5207
|
+
if (bond.rate < 0 || price <= 0 || bond.redemption <= 0) fail(ERR.NUM);
|
|
5208
|
+
const f = (y) => pricePerHundred(bond.facts, bond.rate, y, bond.redemption, bond.frequency) - price;
|
|
5209
|
+
return solve(f, bond.rate || 0.05);
|
|
5210
|
+
}
|
|
5211
|
+
),
|
|
5212
|
+
...["DURATION", "MDURATION"].map(
|
|
5213
|
+
(name) => spec(
|
|
5214
|
+
name,
|
|
5215
|
+
C9,
|
|
5216
|
+
`${name}(settlement, maturity, coupon, yld, frequency, [basis])`,
|
|
5217
|
+
name === "DURATION" ? "The Macaulay duration of a security with periodic interest." : "The modified Macaulay duration of a security.",
|
|
5218
|
+
5,
|
|
5219
|
+
6,
|
|
5220
|
+
(args, ctx) => {
|
|
5221
|
+
const frequency2 = int(args[4]);
|
|
5222
|
+
const facts = couponFacts(
|
|
5223
|
+
serialArg(args[0]),
|
|
5224
|
+
serialArg(args[1]),
|
|
5225
|
+
frequency2,
|
|
5226
|
+
basisOf(args, 5),
|
|
5227
|
+
ctx
|
|
5228
|
+
);
|
|
5229
|
+
const [rate, yld] = [num(args[2]), num(args[3])];
|
|
5230
|
+
if (rate < 0 || yld < 0) fail(ERR.NUM);
|
|
5231
|
+
const macaulay = duration({ facts, rate, frequency: frequency2 }, yld);
|
|
5232
|
+
return name === "DURATION" ? macaulay : macaulay / (1 + yld / frequency2);
|
|
5233
|
+
}
|
|
5234
|
+
)
|
|
5235
|
+
),
|
|
5236
|
+
spec(
|
|
5237
|
+
"ACCRINT",
|
|
5238
|
+
C9,
|
|
5239
|
+
"ACCRINT(issue, first_interest, settlement, rate, par, frequency, [basis], [calc_method])",
|
|
5240
|
+
"The accrued interest of a security that pays periodic interest.",
|
|
5241
|
+
6,
|
|
5242
|
+
8,
|
|
5243
|
+
(args, ctx) => accruedInterest(args, ctx)
|
|
5244
|
+
),
|
|
5245
|
+
spec(
|
|
5246
|
+
"ACCRINTM",
|
|
5247
|
+
C9,
|
|
5248
|
+
"ACCRINTM(issue, settlement, rate, [par], [basis])",
|
|
5249
|
+
"The accrued interest of a security that pays interest at maturity.",
|
|
5250
|
+
3,
|
|
5251
|
+
5,
|
|
5252
|
+
(args, ctx) => {
|
|
5253
|
+
const [issue, settlement] = [serialArg(args[0]), serialArg(args[1])];
|
|
5254
|
+
const [rate, par] = [num(args[2]), optNum(args, 3, 1e3)];
|
|
5255
|
+
if (rate <= 0 || par <= 0 || issue >= settlement) fail(ERR.NUM);
|
|
5256
|
+
return par * rate * yearFrac(issue, settlement, basisOf(args, 4), ctx);
|
|
5257
|
+
}
|
|
5258
|
+
)
|
|
5259
|
+
];
|
|
5260
|
+
|
|
5041
5261
|
// src/xlsx/formula/functions/depreciation.ts
|
|
5042
|
-
var
|
|
5262
|
+
var C10 = "Financial";
|
|
5263
|
+
function variableDeclining(cost, salvage, life, start, end, factor, noSwitch) {
|
|
5264
|
+
let book = cost;
|
|
5265
|
+
let total2 = 0;
|
|
5266
|
+
for (let period = 1; period - 1 < end; period++) {
|
|
5267
|
+
const declining = book * factor / life;
|
|
5268
|
+
const straight = (book - salvage) / Math.max(life - (period - 1), 1);
|
|
5269
|
+
const wanted = noSwitch ? declining : Math.max(declining, straight);
|
|
5270
|
+
const dep = Math.max(0, Math.min(wanted, book - salvage));
|
|
5271
|
+
const covered = Math.min(end, period) - Math.max(start, period - 1);
|
|
5272
|
+
if (covered > 0) total2 += dep * Math.min(covered, 1);
|
|
5273
|
+
book -= dep;
|
|
5274
|
+
}
|
|
5275
|
+
return total2;
|
|
5276
|
+
}
|
|
5043
5277
|
var DEPRECIATION_FUNCTIONS = [
|
|
5044
5278
|
numeric(
|
|
5045
5279
|
"SLN",
|
|
5046
|
-
|
|
5280
|
+
C10,
|
|
5047
5281
|
"SLN(cost, salvage, life)",
|
|
5048
5282
|
"Straight-line depreciation.",
|
|
5049
5283
|
3,
|
|
@@ -5052,7 +5286,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5052
5286
|
),
|
|
5053
5287
|
numeric(
|
|
5054
5288
|
"SYD",
|
|
5055
|
-
|
|
5289
|
+
C10,
|
|
5056
5290
|
"SYD(cost, salvage, life, per)",
|
|
5057
5291
|
"Sum-of-years' digits depreciation.",
|
|
5058
5292
|
4,
|
|
@@ -5064,7 +5298,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5064
5298
|
),
|
|
5065
5299
|
numeric(
|
|
5066
5300
|
"DDB",
|
|
5067
|
-
|
|
5301
|
+
C10,
|
|
5068
5302
|
"DDB(cost, salvage, life, period, [factor])",
|
|
5069
5303
|
"Double-declining balance depreciation.",
|
|
5070
5304
|
4,
|
|
@@ -5080,9 +5314,33 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5080
5314
|
return dep;
|
|
5081
5315
|
}
|
|
5082
5316
|
),
|
|
5317
|
+
spec(
|
|
5318
|
+
"VDB",
|
|
5319
|
+
C10,
|
|
5320
|
+
"VDB(cost, salvage, life, start_period, end_period, [factor], [no_switch])",
|
|
5321
|
+
"Depreciation over any span of periods, switching to straight-line when that is larger.",
|
|
5322
|
+
5,
|
|
5323
|
+
7,
|
|
5324
|
+
(args) => {
|
|
5325
|
+
const [cost, salvage, life, start, end] = [0, 1, 2, 3, 4].map((i) => num(args[i]));
|
|
5326
|
+
const factor = args.length > 5 && args[5] !== null ? num(args[5]) : 2;
|
|
5327
|
+
const noSwitch = args.length > 6 && args[6] !== null ? bool(args[6]) : false;
|
|
5328
|
+
if ([cost, salvage, life, start, end, factor].some((v) => v === void 0 || Number.isNaN(v)) || cost < 0 || salvage < 0 || life <= 0 || start < 0 || end < start || end > life || factor <= 0)
|
|
5329
|
+
fail(ERR.NUM);
|
|
5330
|
+
return variableDeclining(
|
|
5331
|
+
cost,
|
|
5332
|
+
salvage,
|
|
5333
|
+
life,
|
|
5334
|
+
start,
|
|
5335
|
+
end,
|
|
5336
|
+
factor,
|
|
5337
|
+
noSwitch
|
|
5338
|
+
);
|
|
5339
|
+
}
|
|
5340
|
+
),
|
|
5083
5341
|
numeric(
|
|
5084
5342
|
"DB",
|
|
5085
|
-
|
|
5343
|
+
C10,
|
|
5086
5344
|
"DB(cost, salvage, life, period, [month])",
|
|
5087
5345
|
"Fixed-declining balance depreciation.",
|
|
5088
5346
|
4,
|
|
@@ -5105,7 +5363,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5105
5363
|
),
|
|
5106
5364
|
numeric(
|
|
5107
5365
|
"EFFECT",
|
|
5108
|
-
|
|
5366
|
+
C10,
|
|
5109
5367
|
"EFFECT(nominal_rate, npery)",
|
|
5110
5368
|
"The effective annual interest rate.",
|
|
5111
5369
|
2,
|
|
@@ -5118,7 +5376,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5118
5376
|
),
|
|
5119
5377
|
numeric(
|
|
5120
5378
|
"NOMINAL",
|
|
5121
|
-
|
|
5379
|
+
C10,
|
|
5122
5380
|
"NOMINAL(effect_rate, npery)",
|
|
5123
5381
|
"The nominal annual interest rate.",
|
|
5124
5382
|
2,
|
|
@@ -5131,7 +5389,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5131
5389
|
),
|
|
5132
5390
|
numeric(
|
|
5133
5391
|
"CUMIPMT",
|
|
5134
|
-
|
|
5392
|
+
C10,
|
|
5135
5393
|
"CUMIPMT(rate, nper, pv, start_period, end_period, type)",
|
|
5136
5394
|
"Cumulative interest paid between periods.",
|
|
5137
5395
|
6,
|
|
@@ -5140,7 +5398,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5140
5398
|
),
|
|
5141
5399
|
numeric(
|
|
5142
5400
|
"CUMPRINC",
|
|
5143
|
-
|
|
5401
|
+
C10,
|
|
5144
5402
|
"CUMPRINC(rate, nper, pv, start_period, end_period, type)",
|
|
5145
5403
|
"Cumulative principal paid between periods.",
|
|
5146
5404
|
6,
|
|
@@ -5149,7 +5407,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5149
5407
|
),
|
|
5150
5408
|
numeric(
|
|
5151
5409
|
"ISPMT",
|
|
5152
|
-
|
|
5410
|
+
C10,
|
|
5153
5411
|
"ISPMT(rate, per, nper, pv)",
|
|
5154
5412
|
"Interest paid in a period of a straight-line loan.",
|
|
5155
5413
|
4,
|
|
@@ -5161,7 +5419,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5161
5419
|
),
|
|
5162
5420
|
numeric(
|
|
5163
5421
|
"PDURATION",
|
|
5164
|
-
|
|
5422
|
+
C10,
|
|
5165
5423
|
"PDURATION(rate, pv, fv)",
|
|
5166
5424
|
"Periods required to reach a value.",
|
|
5167
5425
|
3,
|
|
@@ -5173,7 +5431,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5173
5431
|
),
|
|
5174
5432
|
numeric(
|
|
5175
5433
|
"RRI",
|
|
5176
|
-
|
|
5434
|
+
C10,
|
|
5177
5435
|
"RRI(nper, pv, fv)",
|
|
5178
5436
|
"An equivalent interest rate for growth.",
|
|
5179
5437
|
3,
|
|
@@ -5185,7 +5443,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5185
5443
|
),
|
|
5186
5444
|
spec(
|
|
5187
5445
|
"FVSCHEDULE",
|
|
5188
|
-
|
|
5446
|
+
C10,
|
|
5189
5447
|
"FVSCHEDULE(principal, schedule)",
|
|
5190
5448
|
"Future value with a schedule of rates.",
|
|
5191
5449
|
2,
|
|
@@ -5195,7 +5453,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5195
5453
|
),
|
|
5196
5454
|
numeric(
|
|
5197
5455
|
"DOLLARDE",
|
|
5198
|
-
|
|
5456
|
+
C10,
|
|
5199
5457
|
"DOLLARDE(fractional_dollar, fraction)",
|
|
5200
5458
|
"Converts a fractional price to a decimal.",
|
|
5201
5459
|
2,
|
|
@@ -5211,7 +5469,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5211
5469
|
),
|
|
5212
5470
|
numeric(
|
|
5213
5471
|
"DOLLARFR",
|
|
5214
|
-
|
|
5472
|
+
C10,
|
|
5215
5473
|
"DOLLARFR(decimal_dollar, fraction)",
|
|
5216
5474
|
"Converts a decimal price to a fraction.",
|
|
5217
5475
|
2,
|
|
@@ -5227,8 +5485,141 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5227
5485
|
)
|
|
5228
5486
|
];
|
|
5229
5487
|
|
|
5488
|
+
// src/xlsx/formula/functions/securities.ts
|
|
5489
|
+
var C11 = "Financial";
|
|
5490
|
+
var basisOf2 = (args, index2) => {
|
|
5491
|
+
const basis = args.length > index2 && args[index2] !== null ? int(args[index2]) : 0;
|
|
5492
|
+
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
5493
|
+
return basis;
|
|
5494
|
+
};
|
|
5495
|
+
function span(args) {
|
|
5496
|
+
const [s, m] = [Math.floor(serialArg(args[0])), Math.floor(serialArg(args[1]))];
|
|
5497
|
+
if (s >= m) fail(ERR.NUM);
|
|
5498
|
+
return { s, m };
|
|
5499
|
+
}
|
|
5500
|
+
var positive = (...values2) => {
|
|
5501
|
+
for (const v of values2) if (!(v > 0)) fail(ERR.NUM);
|
|
5502
|
+
};
|
|
5503
|
+
var discount = (name, description, syntax, fn) => spec(name, C11, syntax, description, 4, 5, (args, ctx) => {
|
|
5504
|
+
const { s, m } = span(args);
|
|
5505
|
+
const [a, b] = [num(args[2]), num(args[3])];
|
|
5506
|
+
positive(a, b);
|
|
5507
|
+
return fn(a, b, yearFrac(s, m, basisOf2(args, 4), ctx));
|
|
5508
|
+
});
|
|
5509
|
+
var atMaturity = (name, description, syntax, fn) => spec(name, C11, syntax, description, 5, 6, (args, ctx) => {
|
|
5510
|
+
const { s, m } = span(args);
|
|
5511
|
+
const issue = Math.floor(serialArg(args[2]));
|
|
5512
|
+
const [rate, other] = [num(args[3]), num(args[4])];
|
|
5513
|
+
const basis = basisOf2(args, 5);
|
|
5514
|
+
if (issue > s || rate < 0 || other < 0) fail(ERR.NUM);
|
|
5515
|
+
return fn(
|
|
5516
|
+
rate,
|
|
5517
|
+
other,
|
|
5518
|
+
yearFrac(issue, m, basis, ctx),
|
|
5519
|
+
yearFrac(issue, s, basis, ctx),
|
|
5520
|
+
yearFrac(s, m, basis, ctx)
|
|
5521
|
+
);
|
|
5522
|
+
});
|
|
5523
|
+
function billDays(args) {
|
|
5524
|
+
const { s, m } = span(args);
|
|
5525
|
+
const days = m - s;
|
|
5526
|
+
if (days > 365) fail(ERR.NUM);
|
|
5527
|
+
return days;
|
|
5528
|
+
}
|
|
5529
|
+
var SECURITY_FUNCTIONS = [
|
|
5530
|
+
discount(
|
|
5531
|
+
"DISC",
|
|
5532
|
+
"The discount rate of a security.",
|
|
5533
|
+
"DISC(settlement, maturity, pr, redemption, [basis])",
|
|
5534
|
+
(pr, redemption, f) => (redemption - pr) / redemption / f
|
|
5535
|
+
),
|
|
5536
|
+
discount(
|
|
5537
|
+
"PRICEDISC",
|
|
5538
|
+
"The price per 100 face value of a discounted security.",
|
|
5539
|
+
"PRICEDISC(settlement, maturity, discount, redemption, [basis])",
|
|
5540
|
+
(rate, redemption, f) => redemption - rate * redemption * f
|
|
5541
|
+
),
|
|
5542
|
+
discount(
|
|
5543
|
+
"YIELDDISC",
|
|
5544
|
+
"The annual yield of a discounted security.",
|
|
5545
|
+
"YIELDDISC(settlement, maturity, pr, redemption, [basis])",
|
|
5546
|
+
(pr, redemption, f) => (redemption - pr) / pr / f
|
|
5547
|
+
),
|
|
5548
|
+
discount(
|
|
5549
|
+
"INTRATE",
|
|
5550
|
+
"The interest rate of a fully invested security.",
|
|
5551
|
+
"INTRATE(settlement, maturity, investment, redemption, [basis])",
|
|
5552
|
+
(investment, redemption, f) => (redemption - investment) / investment / f
|
|
5553
|
+
),
|
|
5554
|
+
discount(
|
|
5555
|
+
"RECEIVED",
|
|
5556
|
+
"The amount received at maturity for a fully invested security.",
|
|
5557
|
+
"RECEIVED(settlement, maturity, investment, discount, [basis])",
|
|
5558
|
+
(investment, rate, f) => investment / (1 - rate * f)
|
|
5559
|
+
),
|
|
5560
|
+
atMaturity(
|
|
5561
|
+
"PRICEMAT",
|
|
5562
|
+
"The price per 100 face value of a security that pays interest at maturity.",
|
|
5563
|
+
"PRICEMAT(settlement, maturity, issue, rate, yld, [basis])",
|
|
5564
|
+
(rate, yld, dim, a, dsm) => (100 + dim * rate * 100) / (1 + dsm * yld) - a * rate * 100
|
|
5565
|
+
),
|
|
5566
|
+
atMaturity(
|
|
5567
|
+
"YIELDMAT",
|
|
5568
|
+
"The annual yield of a security that pays interest at maturity.",
|
|
5569
|
+
"YIELDMAT(settlement, maturity, issue, rate, pr, [basis])",
|
|
5570
|
+
(rate, price, dim, a, dsm) => (1 + dim * rate - (price / 100 + a * rate)) / (price / 100 + a * rate) / dsm
|
|
5571
|
+
),
|
|
5572
|
+
spec(
|
|
5573
|
+
"TBILLPRICE",
|
|
5574
|
+
C11,
|
|
5575
|
+
"TBILLPRICE(settlement, maturity, discount)",
|
|
5576
|
+
"The price per 100 face value of a Treasury bill.",
|
|
5577
|
+
3,
|
|
5578
|
+
3,
|
|
5579
|
+
(args) => {
|
|
5580
|
+
const days = billDays(args);
|
|
5581
|
+
const rate = num(args[2]);
|
|
5582
|
+
positive(rate);
|
|
5583
|
+
const price = 100 * (1 - rate * days / 360);
|
|
5584
|
+
return price > 0 ? price : fail(ERR.NUM);
|
|
5585
|
+
}
|
|
5586
|
+
),
|
|
5587
|
+
spec(
|
|
5588
|
+
"TBILLYIELD",
|
|
5589
|
+
C11,
|
|
5590
|
+
"TBILLYIELD(settlement, maturity, pr)",
|
|
5591
|
+
"The yield of a Treasury bill.",
|
|
5592
|
+
3,
|
|
5593
|
+
3,
|
|
5594
|
+
(args) => {
|
|
5595
|
+
const days = billDays(args);
|
|
5596
|
+
const price = num(args[2]);
|
|
5597
|
+
positive(price);
|
|
5598
|
+
return (100 - price) / price * (360 / days);
|
|
5599
|
+
}
|
|
5600
|
+
),
|
|
5601
|
+
spec(
|
|
5602
|
+
"TBILLEQ",
|
|
5603
|
+
C11,
|
|
5604
|
+
"TBILLEQ(settlement, maturity, discount)",
|
|
5605
|
+
"The bond-equivalent yield of a Treasury bill.",
|
|
5606
|
+
3,
|
|
5607
|
+
3,
|
|
5608
|
+
(args) => {
|
|
5609
|
+
const days = billDays(args);
|
|
5610
|
+
const rate = num(args[2]);
|
|
5611
|
+
positive(rate);
|
|
5612
|
+
if (days <= 182) return 365 * rate / (360 - rate * days);
|
|
5613
|
+
const price = 100 - rate * 100 * (days / 360);
|
|
5614
|
+
const t = days / 365;
|
|
5615
|
+
const root = Math.sqrt(t * t - (2 * t - 1) * (1 - 100 / price));
|
|
5616
|
+
return (-t + root) / (t - 0.5);
|
|
5617
|
+
}
|
|
5618
|
+
)
|
|
5619
|
+
];
|
|
5620
|
+
|
|
5230
5621
|
// src/xlsx/formula/functions/financial.ts
|
|
5231
|
-
var
|
|
5622
|
+
var C12 = "Financial";
|
|
5232
5623
|
var npv = (rate, values2) => values2.reduce((acc, v, i) => acc + v / Math.pow(1 + rate, i + 1), 0);
|
|
5233
5624
|
function datedFlows(ctx, args) {
|
|
5234
5625
|
const values2 = collectNumbers(ctx, [args[0] ?? null]);
|
|
@@ -5244,9 +5635,12 @@ var xnpv = (rate, values2, dates) => values2.reduce(
|
|
|
5244
5635
|
);
|
|
5245
5636
|
var FINANCIAL_FUNCTIONS = [
|
|
5246
5637
|
...DEPRECIATION_FUNCTIONS,
|
|
5638
|
+
...COUPON_FUNCTIONS,
|
|
5639
|
+
...BOND_FUNCTIONS,
|
|
5640
|
+
...SECURITY_FUNCTIONS,
|
|
5247
5641
|
numeric(
|
|
5248
5642
|
"PMT",
|
|
5249
|
-
|
|
5643
|
+
C12,
|
|
5250
5644
|
"PMT(rate, nper, pv, [fv], [type])",
|
|
5251
5645
|
"The payment for a loan.",
|
|
5252
5646
|
3,
|
|
@@ -5255,7 +5649,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5255
5649
|
),
|
|
5256
5650
|
numeric(
|
|
5257
5651
|
"FV",
|
|
5258
|
-
|
|
5652
|
+
C12,
|
|
5259
5653
|
"FV(rate, nper, pmt, [pv], [type])",
|
|
5260
5654
|
"The future value of an investment.",
|
|
5261
5655
|
3,
|
|
@@ -5264,7 +5658,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5264
5658
|
),
|
|
5265
5659
|
numeric(
|
|
5266
5660
|
"PV",
|
|
5267
|
-
|
|
5661
|
+
C12,
|
|
5268
5662
|
"PV(rate, nper, pmt, [fv], [type])",
|
|
5269
5663
|
"The present value of an investment.",
|
|
5270
5664
|
3,
|
|
@@ -5273,7 +5667,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5273
5667
|
),
|
|
5274
5668
|
numeric(
|
|
5275
5669
|
"NPER",
|
|
5276
|
-
|
|
5670
|
+
C12,
|
|
5277
5671
|
"NPER(rate, pmt, pv, [fv], [type])",
|
|
5278
5672
|
"The number of periods for an investment.",
|
|
5279
5673
|
3,
|
|
@@ -5290,7 +5684,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5290
5684
|
),
|
|
5291
5685
|
numeric(
|
|
5292
5686
|
"IPMT",
|
|
5293
|
-
|
|
5687
|
+
C12,
|
|
5294
5688
|
"IPMT(rate, per, nper, pv, [fv], [type])",
|
|
5295
5689
|
"The interest part of a payment.",
|
|
5296
5690
|
4,
|
|
@@ -5299,7 +5693,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5299
5693
|
),
|
|
5300
5694
|
numeric(
|
|
5301
5695
|
"PPMT",
|
|
5302
|
-
|
|
5696
|
+
C12,
|
|
5303
5697
|
"PPMT(rate, per, nper, pv, [fv], [type])",
|
|
5304
5698
|
"The principal part of a payment.",
|
|
5305
5699
|
4,
|
|
@@ -5308,7 +5702,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5308
5702
|
),
|
|
5309
5703
|
numeric(
|
|
5310
5704
|
"RATE",
|
|
5311
|
-
|
|
5705
|
+
C12,
|
|
5312
5706
|
"RATE(nper, pmt, pv, [fv], [type], [guess])",
|
|
5313
5707
|
"The interest rate per period.",
|
|
5314
5708
|
3,
|
|
@@ -5321,7 +5715,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5321
5715
|
),
|
|
5322
5716
|
spec(
|
|
5323
5717
|
"NPV",
|
|
5324
|
-
|
|
5718
|
+
C12,
|
|
5325
5719
|
"NPV(rate, value1, [value2], ...)",
|
|
5326
5720
|
"The net present value of cash flows.",
|
|
5327
5721
|
2,
|
|
@@ -5331,7 +5725,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5331
5725
|
),
|
|
5332
5726
|
spec(
|
|
5333
5727
|
"IRR",
|
|
5334
|
-
|
|
5728
|
+
C12,
|
|
5335
5729
|
"IRR(values, [guess])",
|
|
5336
5730
|
"The internal rate of return.",
|
|
5337
5731
|
1,
|
|
@@ -5348,7 +5742,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5348
5742
|
),
|
|
5349
5743
|
spec(
|
|
5350
5744
|
"XNPV",
|
|
5351
|
-
|
|
5745
|
+
C12,
|
|
5352
5746
|
"XNPV(rate, values, dates)",
|
|
5353
5747
|
"The net present value of dated cash flows.",
|
|
5354
5748
|
3,
|
|
@@ -5361,7 +5755,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5361
5755
|
),
|
|
5362
5756
|
spec(
|
|
5363
5757
|
"XIRR",
|
|
5364
|
-
|
|
5758
|
+
C12,
|
|
5365
5759
|
"XIRR(values, dates, [guess])",
|
|
5366
5760
|
"The internal rate of return of dated cash flows.",
|
|
5367
5761
|
2,
|
|
@@ -5375,7 +5769,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5375
5769
|
),
|
|
5376
5770
|
spec(
|
|
5377
5771
|
"MIRR",
|
|
5378
|
-
|
|
5772
|
+
C12,
|
|
5379
5773
|
"MIRR(values, finance_rate, reinvest_rate)",
|
|
5380
5774
|
"The modified internal rate of return.",
|
|
5381
5775
|
3,
|
|
@@ -5385,9 +5779,9 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5385
5779
|
const finance = num(args[1]);
|
|
5386
5780
|
const reinvest = num(args[2]);
|
|
5387
5781
|
const n2 = values2.length;
|
|
5388
|
-
const
|
|
5782
|
+
const positive3 = values2.map((v) => v > 0 ? v : 0);
|
|
5389
5783
|
const negative = values2.map((v) => v < 0 ? v : 0);
|
|
5390
|
-
const fvPos =
|
|
5784
|
+
const fvPos = positive3.reduce((acc, v, i) => acc + v * Math.pow(1 + reinvest, n2 - 1 - i), 0);
|
|
5391
5785
|
const pvNeg = negative.reduce((acc, v, i) => acc + v / Math.pow(1 + finance, i), 0);
|
|
5392
5786
|
if (fvPos === 0 || pvNeg === 0) fail(ERR.DIV0);
|
|
5393
5787
|
return Math.pow(-fvPos / pvNeg, 1 / (n2 - 1)) - 1;
|
|
@@ -5592,7 +5986,7 @@ function implicitIntersection(value, frame) {
|
|
|
5592
5986
|
}
|
|
5593
5987
|
|
|
5594
5988
|
// src/xlsx/formula/functions/info.ts
|
|
5595
|
-
var
|
|
5989
|
+
var C13 = "Information";
|
|
5596
5990
|
var ERROR_NUMBERS = {
|
|
5597
5991
|
"#NULL!": 1,
|
|
5598
5992
|
"#DIV/0!": 2,
|
|
@@ -5605,7 +5999,7 @@ var ERROR_NUMBERS = {
|
|
|
5605
5999
|
"#SPILL!": 9,
|
|
5606
6000
|
"#CALC!": 14
|
|
5607
6001
|
};
|
|
5608
|
-
var is = (name, syntax, description, test) => spec(name,
|
|
6002
|
+
var is = (name, syntax, description, test) => spec(name, C13, syntax, description, 1, 1, (args) => test(scalar(args[0])));
|
|
5609
6003
|
var parity = (v, odd) => {
|
|
5610
6004
|
if (isError(v)) fail(v);
|
|
5611
6005
|
if (typeof v === "boolean") fail(ERR.VALUE);
|
|
@@ -5642,7 +6036,7 @@ var INFO_FUNCTIONS = [
|
|
|
5642
6036
|
is("ISODD", "ISODD(number)", "TRUE for odd numbers.", (v) => parity(v, true)),
|
|
5643
6037
|
spec(
|
|
5644
6038
|
"ISREF",
|
|
5645
|
-
|
|
6039
|
+
C13,
|
|
5646
6040
|
"ISREF(value)",
|
|
5647
6041
|
"TRUE for references.",
|
|
5648
6042
|
1,
|
|
@@ -5652,7 +6046,7 @@ var INFO_FUNCTIONS = [
|
|
|
5652
6046
|
),
|
|
5653
6047
|
spec(
|
|
5654
6048
|
"ISFORMULA",
|
|
5655
|
-
|
|
6049
|
+
C13,
|
|
5656
6050
|
"ISFORMULA(reference)",
|
|
5657
6051
|
"TRUE when a cell holds a formula.",
|
|
5658
6052
|
1,
|
|
@@ -5666,17 +6060,17 @@ var INFO_FUNCTIONS = [
|
|
|
5666
6060
|
},
|
|
5667
6061
|
["any"]
|
|
5668
6062
|
),
|
|
5669
|
-
spec("N",
|
|
6063
|
+
spec("N", C13, "N(value)", "A value converted to a number (text is 0).", 1, 1, (args) => {
|
|
5670
6064
|
const v = scalar(args[0]);
|
|
5671
6065
|
if (isError(v)) return v;
|
|
5672
6066
|
if (typeof v === "number") return v;
|
|
5673
6067
|
if (typeof v === "boolean") return v ? 1 : 0;
|
|
5674
6068
|
return 0;
|
|
5675
6069
|
}),
|
|
5676
|
-
spec("NA",
|
|
6070
|
+
spec("NA", C13, "NA()", "The #N/A error value.", 0, 0, () => ERR.NA),
|
|
5677
6071
|
spec(
|
|
5678
6072
|
"TYPE",
|
|
5679
|
-
|
|
6073
|
+
C13,
|
|
5680
6074
|
"TYPE(value)",
|
|
5681
6075
|
"The type of a value: 1 number, 2 text, 4 logical, 16 error, 64 array.",
|
|
5682
6076
|
1,
|
|
@@ -5688,13 +6082,13 @@ var INFO_FUNCTIONS = [
|
|
|
5688
6082
|
},
|
|
5689
6083
|
["any"]
|
|
5690
6084
|
),
|
|
5691
|
-
spec("ERROR.TYPE",
|
|
6085
|
+
spec("ERROR.TYPE", C13, "ERROR.TYPE(error_val)", "The number of an error value.", 1, 1, (args) => {
|
|
5692
6086
|
const v = scalar(args[0]);
|
|
5693
6087
|
return isError(v) ? ERROR_NUMBERS[v.error] ?? ERR.NA : ERR.NA;
|
|
5694
6088
|
}),
|
|
5695
6089
|
spec(
|
|
5696
6090
|
"SHEET",
|
|
5697
|
-
|
|
6091
|
+
C13,
|
|
5698
6092
|
"SHEET([value])",
|
|
5699
6093
|
"The sheet number of a reference or sheet name.",
|
|
5700
6094
|
0,
|
|
@@ -5710,7 +6104,7 @@ var INFO_FUNCTIONS = [
|
|
|
5710
6104
|
),
|
|
5711
6105
|
spec(
|
|
5712
6106
|
"SHEETS",
|
|
5713
|
-
|
|
6107
|
+
C13,
|
|
5714
6108
|
"SHEETS([reference])",
|
|
5715
6109
|
"The number of sheets in a reference (or the workbook).",
|
|
5716
6110
|
0,
|
|
@@ -5725,7 +6119,7 @@ var INFO_FUNCTIONS = [
|
|
|
5725
6119
|
),
|
|
5726
6120
|
spec(
|
|
5727
6121
|
"CELL",
|
|
5728
|
-
|
|
6122
|
+
C13,
|
|
5729
6123
|
"CELL(info_type, [reference])",
|
|
5730
6124
|
"Information about a cell (address, row, col, contents, type, filename, sheet).",
|
|
5731
6125
|
1,
|
|
@@ -5900,7 +6294,7 @@ function broadcast1(a, fn) {
|
|
|
5900
6294
|
}
|
|
5901
6295
|
|
|
5902
6296
|
// src/xlsx/formula/functions/lambda.ts
|
|
5903
|
-
var
|
|
6297
|
+
var C14 = "Logical";
|
|
5904
6298
|
function lambdaArg(value) {
|
|
5905
6299
|
if (!(value instanceof LambdaValue)) fail(ERR.VALUE);
|
|
5906
6300
|
return value;
|
|
@@ -5917,7 +6311,7 @@ function element(ctx, value) {
|
|
|
5917
6311
|
var LAMBDA_HELPERS = [
|
|
5918
6312
|
spec(
|
|
5919
6313
|
"MAP",
|
|
5920
|
-
|
|
6314
|
+
C14,
|
|
5921
6315
|
"MAP(array1, ..., lambda)",
|
|
5922
6316
|
"Applies a LAMBDA to each value of arrays.",
|
|
5923
6317
|
2,
|
|
@@ -5943,7 +6337,7 @@ var LAMBDA_HELPERS = [
|
|
|
5943
6337
|
),
|
|
5944
6338
|
spec(
|
|
5945
6339
|
"REDUCE",
|
|
5946
|
-
|
|
6340
|
+
C14,
|
|
5947
6341
|
"REDUCE([initial_value], array, lambda)",
|
|
5948
6342
|
"Reduces an array to an accumulated value.",
|
|
5949
6343
|
2,
|
|
@@ -5959,7 +6353,7 @@ var LAMBDA_HELPERS = [
|
|
|
5959
6353
|
),
|
|
5960
6354
|
spec(
|
|
5961
6355
|
"SCAN",
|
|
5962
|
-
|
|
6356
|
+
C14,
|
|
5963
6357
|
"SCAN([initial_value], array, lambda)",
|
|
5964
6358
|
"The intermediate values of a reduction, as an array.",
|
|
5965
6359
|
2,
|
|
@@ -5977,7 +6371,7 @@ var LAMBDA_HELPERS = [
|
|
|
5977
6371
|
),
|
|
5978
6372
|
spec(
|
|
5979
6373
|
"BYROW",
|
|
5980
|
-
|
|
6374
|
+
C14,
|
|
5981
6375
|
"BYROW(array, lambda)",
|
|
5982
6376
|
"Applies a LAMBDA to each row, returning a column.",
|
|
5983
6377
|
2,
|
|
@@ -5993,7 +6387,7 @@ var LAMBDA_HELPERS = [
|
|
|
5993
6387
|
),
|
|
5994
6388
|
spec(
|
|
5995
6389
|
"BYCOL",
|
|
5996
|
-
|
|
6390
|
+
C14,
|
|
5997
6391
|
"BYCOL(array, lambda)",
|
|
5998
6392
|
"Applies a LAMBDA to each column, returning a row.",
|
|
5999
6393
|
2,
|
|
@@ -6012,7 +6406,7 @@ var LAMBDA_HELPERS = [
|
|
|
6012
6406
|
),
|
|
6013
6407
|
spec(
|
|
6014
6408
|
"MAKEARRAY",
|
|
6015
|
-
|
|
6409
|
+
C14,
|
|
6016
6410
|
"MAKEARRAY(rows, columns, lambda)",
|
|
6017
6411
|
"An array built by calling a LAMBDA for each position.",
|
|
6018
6412
|
3,
|
|
@@ -6029,7 +6423,7 @@ var LAMBDA_HELPERS = [
|
|
|
6029
6423
|
];
|
|
6030
6424
|
|
|
6031
6425
|
// src/xlsx/formula/functions/logical.ts
|
|
6032
|
-
var
|
|
6426
|
+
var C15 = "Logical";
|
|
6033
6427
|
function deref(ctx, value) {
|
|
6034
6428
|
if (value instanceof RefValue) {
|
|
6035
6429
|
if (value.isCell()) {
|
|
@@ -6099,7 +6493,7 @@ function logicalValues(ctx, args) {
|
|
|
6099
6493
|
if (out.length === 0) fail(ERR.VALUE);
|
|
6100
6494
|
return out;
|
|
6101
6495
|
}
|
|
6102
|
-
var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category =
|
|
6496
|
+
var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category = C15) => ({ name, category, syntax, description, minArgs, maxArgs, lazy });
|
|
6103
6497
|
function localName(arg) {
|
|
6104
6498
|
const node = arg?.node;
|
|
6105
6499
|
if (!node || node.type !== "name" || node.prefix) fail(ERR.VALUE);
|
|
@@ -6193,7 +6587,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6193
6587
|
),
|
|
6194
6588
|
{
|
|
6195
6589
|
name: "NOT",
|
|
6196
|
-
category:
|
|
6590
|
+
category: C15,
|
|
6197
6591
|
syntax: "NOT(logical)",
|
|
6198
6592
|
description: "Reverses a logical value.",
|
|
6199
6593
|
minArgs: 1,
|
|
@@ -6202,7 +6596,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6202
6596
|
},
|
|
6203
6597
|
{
|
|
6204
6598
|
name: "TRUE",
|
|
6205
|
-
category:
|
|
6599
|
+
category: C15,
|
|
6206
6600
|
syntax: "TRUE()",
|
|
6207
6601
|
description: "The logical value TRUE.",
|
|
6208
6602
|
minArgs: 0,
|
|
@@ -6211,7 +6605,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6211
6605
|
},
|
|
6212
6606
|
{
|
|
6213
6607
|
name: "FALSE",
|
|
6214
|
-
category:
|
|
6608
|
+
category: C15,
|
|
6215
6609
|
syntax: "FALSE()",
|
|
6216
6610
|
description: "The logical value FALSE.",
|
|
6217
6611
|
minArgs: 0,
|
|
@@ -6409,7 +6803,7 @@ function xsearch(vector, lookup2, matchMode, searchMode) {
|
|
|
6409
6803
|
}
|
|
6410
6804
|
|
|
6411
6805
|
// src/xlsx/formula/functions/reference.ts
|
|
6412
|
-
var
|
|
6806
|
+
var C16 = "Lookup & Reference";
|
|
6413
6807
|
function refArg(value) {
|
|
6414
6808
|
if (value instanceof RefValue) return value;
|
|
6415
6809
|
if (isError(value)) fail(value);
|
|
@@ -6498,7 +6892,7 @@ function rowsOrCols(value, ctx, axis) {
|
|
|
6498
6892
|
var REFERENCE_FUNCTIONS = [
|
|
6499
6893
|
spec(
|
|
6500
6894
|
"OFFSET",
|
|
6501
|
-
|
|
6895
|
+
C16,
|
|
6502
6896
|
"OFFSET(reference, rows, cols, [height], [width])",
|
|
6503
6897
|
"A reference offset from a starting reference.",
|
|
6504
6898
|
3,
|
|
@@ -6509,7 +6903,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6509
6903
|
),
|
|
6510
6904
|
spec(
|
|
6511
6905
|
"INDIRECT",
|
|
6512
|
-
|
|
6906
|
+
C16,
|
|
6513
6907
|
"INDIRECT(ref_text, [a1])",
|
|
6514
6908
|
"The reference named by a text.",
|
|
6515
6909
|
1,
|
|
@@ -6525,7 +6919,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6525
6919
|
),
|
|
6526
6920
|
spec(
|
|
6527
6921
|
"ROW",
|
|
6528
|
-
|
|
6922
|
+
C16,
|
|
6529
6923
|
"ROW([reference])",
|
|
6530
6924
|
"The row number of a reference.",
|
|
6531
6925
|
0,
|
|
@@ -6535,7 +6929,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6535
6929
|
),
|
|
6536
6930
|
spec(
|
|
6537
6931
|
"COLUMN",
|
|
6538
|
-
|
|
6932
|
+
C16,
|
|
6539
6933
|
"COLUMN([reference])",
|
|
6540
6934
|
"The column number of a reference.",
|
|
6541
6935
|
0,
|
|
@@ -6545,7 +6939,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6545
6939
|
),
|
|
6546
6940
|
spec(
|
|
6547
6941
|
"ROWS",
|
|
6548
|
-
|
|
6942
|
+
C16,
|
|
6549
6943
|
"ROWS(array)",
|
|
6550
6944
|
"The number of rows in a reference or array.",
|
|
6551
6945
|
1,
|
|
@@ -6558,7 +6952,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6558
6952
|
),
|
|
6559
6953
|
spec(
|
|
6560
6954
|
"COLUMNS",
|
|
6561
|
-
|
|
6955
|
+
C16,
|
|
6562
6956
|
"COLUMNS(array)",
|
|
6563
6957
|
"The number of columns in a reference or array.",
|
|
6564
6958
|
1,
|
|
@@ -6571,7 +6965,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6571
6965
|
),
|
|
6572
6966
|
spec(
|
|
6573
6967
|
"AREAS",
|
|
6574
|
-
|
|
6968
|
+
C16,
|
|
6575
6969
|
"AREAS(reference)",
|
|
6576
6970
|
"The number of areas in a reference.",
|
|
6577
6971
|
1,
|
|
@@ -6581,7 +6975,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6581
6975
|
),
|
|
6582
6976
|
spec(
|
|
6583
6977
|
"ADDRESS",
|
|
6584
|
-
|
|
6978
|
+
C16,
|
|
6585
6979
|
"ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])",
|
|
6586
6980
|
"A cell address as text.",
|
|
6587
6981
|
2,
|
|
@@ -6590,7 +6984,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6590
6984
|
),
|
|
6591
6985
|
spec(
|
|
6592
6986
|
"HYPERLINK",
|
|
6593
|
-
|
|
6987
|
+
C16,
|
|
6594
6988
|
"HYPERLINK(link_location, [friendly_name])",
|
|
6595
6989
|
"A link; the cell shows the friendly name.",
|
|
6596
6990
|
1,
|
|
@@ -6599,7 +6993,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6599
6993
|
),
|
|
6600
6994
|
spec(
|
|
6601
6995
|
"ANCHORARRAY",
|
|
6602
|
-
|
|
6996
|
+
C16,
|
|
6603
6997
|
"ANCHORARRAY(reference)",
|
|
6604
6998
|
"The spill range of a dynamic array formula (A1#).",
|
|
6605
6999
|
1,
|
|
@@ -6619,7 +7013,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6619
7013
|
),
|
|
6620
7014
|
spec(
|
|
6621
7015
|
"SINGLE",
|
|
6622
|
-
|
|
7016
|
+
C16,
|
|
6623
7017
|
"SINGLE(value)",
|
|
6624
7018
|
"Implicit intersection (the @ operator).",
|
|
6625
7019
|
1,
|
|
@@ -6629,7 +7023,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6629
7023
|
),
|
|
6630
7024
|
spec(
|
|
6631
7025
|
"FORMULATEXT",
|
|
6632
|
-
|
|
7026
|
+
C16,
|
|
6633
7027
|
"FORMULATEXT(reference)",
|
|
6634
7028
|
"The formula of a cell as text.",
|
|
6635
7029
|
1,
|
|
@@ -6649,7 +7043,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6649
7043
|
];
|
|
6650
7044
|
|
|
6651
7045
|
// src/xlsx/formula/functions/lookup.ts
|
|
6652
|
-
var
|
|
7046
|
+
var C17 = "Lookup & Reference";
|
|
6653
7047
|
function cellOf(value, row2, col) {
|
|
6654
7048
|
if (value instanceof RefValue) {
|
|
6655
7049
|
const area = value.areas[0];
|
|
@@ -6776,7 +7170,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6776
7170
|
...REFERENCE_FUNCTIONS,
|
|
6777
7171
|
spec(
|
|
6778
7172
|
"VLOOKUP",
|
|
6779
|
-
|
|
7173
|
+
C17,
|
|
6780
7174
|
"VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])",
|
|
6781
7175
|
"Looks up a value in the first column of a table.",
|
|
6782
7176
|
3,
|
|
@@ -6786,7 +7180,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6786
7180
|
),
|
|
6787
7181
|
spec(
|
|
6788
7182
|
"HLOOKUP",
|
|
6789
|
-
|
|
7183
|
+
C17,
|
|
6790
7184
|
"HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])",
|
|
6791
7185
|
"Looks up a value in the first row of a table.",
|
|
6792
7186
|
3,
|
|
@@ -6796,7 +7190,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6796
7190
|
),
|
|
6797
7191
|
spec(
|
|
6798
7192
|
"LOOKUP",
|
|
6799
|
-
|
|
7193
|
+
C17,
|
|
6800
7194
|
"LOOKUP(lookup_value, lookup_vector, [result_vector])",
|
|
6801
7195
|
"Looks up a value in a sorted vector or array.",
|
|
6802
7196
|
2,
|
|
@@ -6806,7 +7200,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6806
7200
|
),
|
|
6807
7201
|
spec(
|
|
6808
7202
|
"MATCH",
|
|
6809
|
-
|
|
7203
|
+
C17,
|
|
6810
7204
|
"MATCH(lookup_value, lookup_array, [match_type])",
|
|
6811
7205
|
"The position of a value in a range.",
|
|
6812
7206
|
2,
|
|
@@ -6816,7 +7210,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6816
7210
|
),
|
|
6817
7211
|
spec(
|
|
6818
7212
|
"XMATCH",
|
|
6819
|
-
|
|
7213
|
+
C17,
|
|
6820
7214
|
"XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])",
|
|
6821
7215
|
"The position of a value with flexible matching.",
|
|
6822
7216
|
2,
|
|
@@ -6836,7 +7230,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6836
7230
|
),
|
|
6837
7231
|
spec(
|
|
6838
7232
|
"XLOOKUP",
|
|
6839
|
-
|
|
7233
|
+
C17,
|
|
6840
7234
|
"XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])",
|
|
6841
7235
|
"Searches a range and returns the matching item from another.",
|
|
6842
7236
|
3,
|
|
@@ -6846,7 +7240,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6846
7240
|
),
|
|
6847
7241
|
spec(
|
|
6848
7242
|
"INDEX",
|
|
6849
|
-
|
|
7243
|
+
C17,
|
|
6850
7244
|
"INDEX(array, row_num, [column_num], [area_num])",
|
|
6851
7245
|
"The value or reference at a position.",
|
|
6852
7246
|
1,
|
|
@@ -6856,7 +7250,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6856
7250
|
),
|
|
6857
7251
|
spec(
|
|
6858
7252
|
"CHOOSE",
|
|
6859
|
-
|
|
7253
|
+
C17,
|
|
6860
7254
|
"CHOOSE(index_num, value1, [value2], ...)",
|
|
6861
7255
|
"Chooses a value from a list by index.",
|
|
6862
7256
|
2,
|
|
@@ -7060,7 +7454,7 @@ function liftCriteria(ctx, pairs, fn) {
|
|
|
7060
7454
|
}
|
|
7061
7455
|
|
|
7062
7456
|
// src/xlsx/formula/functions/math-sum.ts
|
|
7063
|
-
var
|
|
7457
|
+
var C18 = "Math & Trig";
|
|
7064
7458
|
var numbersOf = (values2) => values2.filter((v) => typeof v === "number");
|
|
7065
7459
|
function sumProduct(ctx, args) {
|
|
7066
7460
|
const matrices = args.map((a) => ctx.toMatrix(a));
|
|
@@ -7165,7 +7559,7 @@ function aggregate(code, values2, k) {
|
|
|
7165
7559
|
var SUM_FUNCTIONS = [
|
|
7166
7560
|
spec(
|
|
7167
7561
|
"SUM",
|
|
7168
|
-
|
|
7562
|
+
C18,
|
|
7169
7563
|
"SUM(number1, [number2], ...)",
|
|
7170
7564
|
"Adds its arguments.",
|
|
7171
7565
|
0,
|
|
@@ -7175,7 +7569,7 @@ var SUM_FUNCTIONS = [
|
|
|
7175
7569
|
),
|
|
7176
7570
|
spec(
|
|
7177
7571
|
"PRODUCT",
|
|
7178
|
-
|
|
7572
|
+
C18,
|
|
7179
7573
|
"PRODUCT(number1, [number2], ...)",
|
|
7180
7574
|
"Multiplies its arguments.",
|
|
7181
7575
|
1,
|
|
@@ -7188,7 +7582,7 @@ var SUM_FUNCTIONS = [
|
|
|
7188
7582
|
),
|
|
7189
7583
|
spec(
|
|
7190
7584
|
"SUMSQ",
|
|
7191
|
-
|
|
7585
|
+
C18,
|
|
7192
7586
|
"SUMSQ(number1, [number2], ...)",
|
|
7193
7587
|
"The sum of the squares of the arguments.",
|
|
7194
7588
|
1,
|
|
@@ -7198,7 +7592,7 @@ var SUM_FUNCTIONS = [
|
|
|
7198
7592
|
),
|
|
7199
7593
|
spec(
|
|
7200
7594
|
"SUMPRODUCT",
|
|
7201
|
-
|
|
7595
|
+
C18,
|
|
7202
7596
|
"SUMPRODUCT(array1, [array2], ...)",
|
|
7203
7597
|
"The sum of the products of corresponding array elements.",
|
|
7204
7598
|
1,
|
|
@@ -7208,7 +7602,7 @@ var SUM_FUNCTIONS = [
|
|
|
7208
7602
|
),
|
|
7209
7603
|
spec(
|
|
7210
7604
|
"SUMX2MY2",
|
|
7211
|
-
|
|
7605
|
+
C18,
|
|
7212
7606
|
"SUMX2MY2(array_x, array_y)",
|
|
7213
7607
|
"Sum of the differences of squares.",
|
|
7214
7608
|
2,
|
|
@@ -7218,7 +7612,7 @@ var SUM_FUNCTIONS = [
|
|
|
7218
7612
|
),
|
|
7219
7613
|
spec(
|
|
7220
7614
|
"SUMX2PY2",
|
|
7221
|
-
|
|
7615
|
+
C18,
|
|
7222
7616
|
"SUMX2PY2(array_x, array_y)",
|
|
7223
7617
|
"Sum of the sums of squares.",
|
|
7224
7618
|
2,
|
|
@@ -7228,7 +7622,7 @@ var SUM_FUNCTIONS = [
|
|
|
7228
7622
|
),
|
|
7229
7623
|
spec(
|
|
7230
7624
|
"SUMXMY2",
|
|
7231
|
-
|
|
7625
|
+
C18,
|
|
7232
7626
|
"SUMXMY2(array_x, array_y)",
|
|
7233
7627
|
"Sum of the squares of differences.",
|
|
7234
7628
|
2,
|
|
@@ -7238,7 +7632,7 @@ var SUM_FUNCTIONS = [
|
|
|
7238
7632
|
),
|
|
7239
7633
|
spec(
|
|
7240
7634
|
"SUMIF",
|
|
7241
|
-
|
|
7635
|
+
C18,
|
|
7242
7636
|
"SUMIF(range, criteria, [sum_range])",
|
|
7243
7637
|
"Adds the cells that meet a criterion.",
|
|
7244
7638
|
2,
|
|
@@ -7251,7 +7645,7 @@ var SUM_FUNCTIONS = [
|
|
|
7251
7645
|
),
|
|
7252
7646
|
spec(
|
|
7253
7647
|
"SUMIFS",
|
|
7254
|
-
|
|
7648
|
+
C18,
|
|
7255
7649
|
"SUMIFS(sum_range, criteria_range1, criteria1, ...)",
|
|
7256
7650
|
"Adds the cells that meet several criteria.",
|
|
7257
7651
|
3,
|
|
@@ -7265,7 +7659,7 @@ var SUM_FUNCTIONS = [
|
|
|
7265
7659
|
),
|
|
7266
7660
|
spec(
|
|
7267
7661
|
"SUBTOTAL",
|
|
7268
|
-
|
|
7662
|
+
C18,
|
|
7269
7663
|
"SUBTOTAL(function_num, ref1, ...)",
|
|
7270
7664
|
"A subtotal (1-11 include hidden rows, 101-111 ignore them).",
|
|
7271
7665
|
2,
|
|
@@ -7280,7 +7674,7 @@ var SUM_FUNCTIONS = [
|
|
|
7280
7674
|
),
|
|
7281
7675
|
spec(
|
|
7282
7676
|
"AGGREGATE",
|
|
7283
|
-
|
|
7677
|
+
C18,
|
|
7284
7678
|
"AGGREGATE(function_num, options, ref1, ...)",
|
|
7285
7679
|
"An aggregate that can ignore hidden rows and errors.",
|
|
7286
7680
|
3,
|
|
@@ -7320,14 +7714,14 @@ var SUM_FUNCTIONS = [
|
|
|
7320
7714
|
];
|
|
7321
7715
|
|
|
7322
7716
|
// src/xlsx/formula/functions/math-more.ts
|
|
7323
|
-
var
|
|
7717
|
+
var C19 = "Math & Trig";
|
|
7324
7718
|
var MATH_MORE = [
|
|
7325
|
-
numeric("SIN",
|
|
7326
|
-
numeric("COS",
|
|
7327
|
-
numeric("TAN",
|
|
7719
|
+
numeric("SIN", C19, "SIN(number)", "The sine of an angle in radians.", 1, 1, Math.sin),
|
|
7720
|
+
numeric("COS", C19, "COS(number)", "The cosine of an angle in radians.", 1, 1, Math.cos),
|
|
7721
|
+
numeric("TAN", C19, "TAN(number)", "The tangent of an angle in radians.", 1, 1, Math.tan),
|
|
7328
7722
|
numeric(
|
|
7329
7723
|
"ASIN",
|
|
7330
|
-
|
|
7724
|
+
C19,
|
|
7331
7725
|
"ASIN(number)",
|
|
7332
7726
|
"The arcsine in radians.",
|
|
7333
7727
|
1,
|
|
@@ -7336,17 +7730,17 @@ var MATH_MORE = [
|
|
|
7336
7730
|
),
|
|
7337
7731
|
numeric(
|
|
7338
7732
|
"ACOS",
|
|
7339
|
-
|
|
7733
|
+
C19,
|
|
7340
7734
|
"ACOS(number)",
|
|
7341
7735
|
"The arccosine in radians.",
|
|
7342
7736
|
1,
|
|
7343
7737
|
1,
|
|
7344
7738
|
(x) => domain(Math.abs(x) <= 1, Math.acos(x))
|
|
7345
7739
|
),
|
|
7346
|
-
numeric("ATAN",
|
|
7740
|
+
numeric("ATAN", C19, "ATAN(number)", "The arctangent in radians.", 1, 1, Math.atan),
|
|
7347
7741
|
numeric(
|
|
7348
7742
|
"ATAN2",
|
|
7349
|
-
|
|
7743
|
+
C19,
|
|
7350
7744
|
"ATAN2(x_num, y_num)",
|
|
7351
7745
|
"The arctangent of x and y coordinates.",
|
|
7352
7746
|
2,
|
|
@@ -7356,13 +7750,13 @@ var MATH_MORE = [
|
|
|
7356
7750
|
return Math.atan2(y ?? 0, x);
|
|
7357
7751
|
}
|
|
7358
7752
|
),
|
|
7359
|
-
numeric("SINH",
|
|
7360
|
-
numeric("COSH",
|
|
7361
|
-
numeric("TANH",
|
|
7362
|
-
numeric("ASINH",
|
|
7753
|
+
numeric("SINH", C19, "SINH(number)", "The hyperbolic sine.", 1, 1, Math.sinh),
|
|
7754
|
+
numeric("COSH", C19, "COSH(number)", "The hyperbolic cosine.", 1, 1, Math.cosh),
|
|
7755
|
+
numeric("TANH", C19, "TANH(number)", "The hyperbolic tangent.", 1, 1, Math.tanh),
|
|
7756
|
+
numeric("ASINH", C19, "ASINH(number)", "The inverse hyperbolic sine.", 1, 1, Math.asinh),
|
|
7363
7757
|
numeric(
|
|
7364
7758
|
"ACOSH",
|
|
7365
|
-
|
|
7759
|
+
C19,
|
|
7366
7760
|
"ACOSH(number)",
|
|
7367
7761
|
"The inverse hyperbolic cosine.",
|
|
7368
7762
|
1,
|
|
@@ -7371,7 +7765,7 @@ var MATH_MORE = [
|
|
|
7371
7765
|
),
|
|
7372
7766
|
numeric(
|
|
7373
7767
|
"ATANH",
|
|
7374
|
-
|
|
7768
|
+
C19,
|
|
7375
7769
|
"ATANH(number)",
|
|
7376
7770
|
"The inverse hyperbolic tangent.",
|
|
7377
7771
|
1,
|
|
@@ -7380,7 +7774,7 @@ var MATH_MORE = [
|
|
|
7380
7774
|
),
|
|
7381
7775
|
numeric(
|
|
7382
7776
|
"COT",
|
|
7383
|
-
|
|
7777
|
+
C19,
|
|
7384
7778
|
"COT(number)",
|
|
7385
7779
|
"The cotangent of an angle.",
|
|
7386
7780
|
1,
|
|
@@ -7389,7 +7783,7 @@ var MATH_MORE = [
|
|
|
7389
7783
|
),
|
|
7390
7784
|
numeric(
|
|
7391
7785
|
"COTH",
|
|
7392
|
-
|
|
7786
|
+
C19,
|
|
7393
7787
|
"COTH(number)",
|
|
7394
7788
|
"The hyperbolic cotangent.",
|
|
7395
7789
|
1,
|
|
@@ -7398,7 +7792,7 @@ var MATH_MORE = [
|
|
|
7398
7792
|
),
|
|
7399
7793
|
numeric(
|
|
7400
7794
|
"CSC",
|
|
7401
|
-
|
|
7795
|
+
C19,
|
|
7402
7796
|
"CSC(number)",
|
|
7403
7797
|
"The cosecant of an angle.",
|
|
7404
7798
|
1,
|
|
@@ -7407,19 +7801,19 @@ var MATH_MORE = [
|
|
|
7407
7801
|
),
|
|
7408
7802
|
numeric(
|
|
7409
7803
|
"CSCH",
|
|
7410
|
-
|
|
7804
|
+
C19,
|
|
7411
7805
|
"CSCH(number)",
|
|
7412
7806
|
"The hyperbolic cosecant.",
|
|
7413
7807
|
1,
|
|
7414
7808
|
1,
|
|
7415
7809
|
(x) => x === 0 ? fail(ERR.DIV0) : 1 / Math.sinh(x)
|
|
7416
7810
|
),
|
|
7417
|
-
numeric("SEC",
|
|
7418
|
-
numeric("SECH",
|
|
7419
|
-
numeric("ACOT",
|
|
7811
|
+
numeric("SEC", C19, "SEC(number)", "The secant of an angle.", 1, 1, (x) => 1 / Math.cos(x)),
|
|
7812
|
+
numeric("SECH", C19, "SECH(number)", "The hyperbolic secant.", 1, 1, (x) => 1 / Math.cosh(x)),
|
|
7813
|
+
numeric("ACOT", C19, "ACOT(number)", "The arccotangent.", 1, 1, (x) => Math.PI / 2 - Math.atan(x)),
|
|
7420
7814
|
numeric(
|
|
7421
7815
|
"ACOTH",
|
|
7422
|
-
|
|
7816
|
+
C19,
|
|
7423
7817
|
"ACOTH(number)",
|
|
7424
7818
|
"The inverse hyperbolic cotangent.",
|
|
7425
7819
|
1,
|
|
@@ -7428,7 +7822,7 @@ var MATH_MORE = [
|
|
|
7428
7822
|
),
|
|
7429
7823
|
numeric(
|
|
7430
7824
|
"DEGREES",
|
|
7431
|
-
|
|
7825
|
+
C19,
|
|
7432
7826
|
"DEGREES(angle)",
|
|
7433
7827
|
"Converts radians to degrees.",
|
|
7434
7828
|
1,
|
|
@@ -7437,7 +7831,7 @@ var MATH_MORE = [
|
|
|
7437
7831
|
),
|
|
7438
7832
|
numeric(
|
|
7439
7833
|
"RADIANS",
|
|
7440
|
-
|
|
7834
|
+
C19,
|
|
7441
7835
|
"RADIANS(angle)",
|
|
7442
7836
|
"Converts degrees to radians.",
|
|
7443
7837
|
1,
|
|
@@ -7446,7 +7840,7 @@ var MATH_MORE = [
|
|
|
7446
7840
|
),
|
|
7447
7841
|
spec(
|
|
7448
7842
|
"RAND",
|
|
7449
|
-
|
|
7843
|
+
C19,
|
|
7450
7844
|
"RAND()",
|
|
7451
7845
|
"A random number between 0 and 1.",
|
|
7452
7846
|
0,
|
|
@@ -7457,7 +7851,7 @@ var MATH_MORE = [
|
|
|
7457
7851
|
),
|
|
7458
7852
|
spec(
|
|
7459
7853
|
"RANDBETWEEN",
|
|
7460
|
-
|
|
7854
|
+
C19,
|
|
7461
7855
|
"RANDBETWEEN(bottom, top)",
|
|
7462
7856
|
"A random integer between two numbers.",
|
|
7463
7857
|
2,
|
|
@@ -7473,7 +7867,7 @@ var MATH_MORE = [
|
|
|
7473
7867
|
),
|
|
7474
7868
|
spec(
|
|
7475
7869
|
"SERIESSUM",
|
|
7476
|
-
|
|
7870
|
+
C19,
|
|
7477
7871
|
"SERIESSUM(x, n, m, coefficients)",
|
|
7478
7872
|
"The sum of a power series.",
|
|
7479
7873
|
4,
|
|
@@ -7492,7 +7886,7 @@ var MATH_MORE = [
|
|
|
7492
7886
|
];
|
|
7493
7887
|
|
|
7494
7888
|
// src/xlsx/formula/functions/math-combin.ts
|
|
7495
|
-
var
|
|
7889
|
+
var C20 = "Math & Trig";
|
|
7496
7890
|
var fact = (n2) => {
|
|
7497
7891
|
if (n2 < 0) fail(ERR.NUM);
|
|
7498
7892
|
let out = 1;
|
|
@@ -7516,8 +7910,8 @@ function integers(args, ctx) {
|
|
|
7516
7910
|
});
|
|
7517
7911
|
}
|
|
7518
7912
|
var COMBINATORIC_FUNCTIONS = [
|
|
7519
|
-
numeric("FACT",
|
|
7520
|
-
numeric("FACTDOUBLE",
|
|
7913
|
+
numeric("FACT", C20, "FACT(number)", "The factorial of a number.", 1, 1, fact),
|
|
7914
|
+
numeric("FACTDOUBLE", C20, "FACTDOUBLE(number)", "The double factorial of a number.", 1, 1, (n2) => {
|
|
7521
7915
|
if (n2 < -1) fail(ERR.NUM);
|
|
7522
7916
|
let out = 1;
|
|
7523
7917
|
for (let i = Math.trunc(n2); i > 1; i -= 2) out *= i;
|
|
@@ -7525,7 +7919,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7525
7919
|
}),
|
|
7526
7920
|
numeric(
|
|
7527
7921
|
"COMBIN",
|
|
7528
|
-
|
|
7922
|
+
C20,
|
|
7529
7923
|
"COMBIN(number, number_chosen)",
|
|
7530
7924
|
"The number of combinations.",
|
|
7531
7925
|
2,
|
|
@@ -7534,7 +7928,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7534
7928
|
),
|
|
7535
7929
|
numeric(
|
|
7536
7930
|
"COMBINA",
|
|
7537
|
-
|
|
7931
|
+
C20,
|
|
7538
7932
|
"COMBINA(number, number_chosen)",
|
|
7539
7933
|
"Combinations with repetitions.",
|
|
7540
7934
|
2,
|
|
@@ -7546,7 +7940,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7546
7940
|
),
|
|
7547
7941
|
spec(
|
|
7548
7942
|
"MULTINOMIAL",
|
|
7549
|
-
|
|
7943
|
+
C20,
|
|
7550
7944
|
"MULTINOMIAL(number1, ...)",
|
|
7551
7945
|
"The multinomial of a set of numbers.",
|
|
7552
7946
|
1,
|
|
@@ -7560,7 +7954,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7560
7954
|
),
|
|
7561
7955
|
spec(
|
|
7562
7956
|
"GCD",
|
|
7563
|
-
|
|
7957
|
+
C20,
|
|
7564
7958
|
"GCD(number1, ...)",
|
|
7565
7959
|
"The greatest common divisor.",
|
|
7566
7960
|
1,
|
|
@@ -7570,7 +7964,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7570
7964
|
),
|
|
7571
7965
|
spec(
|
|
7572
7966
|
"LCM",
|
|
7573
|
-
|
|
7967
|
+
C20,
|
|
7574
7968
|
"LCM(number1, ...)",
|
|
7575
7969
|
"The least common multiple.",
|
|
7576
7970
|
1,
|
|
@@ -7618,7 +8012,7 @@ function mround(x, m) {
|
|
|
7618
8012
|
}
|
|
7619
8013
|
|
|
7620
8014
|
// src/xlsx/formula/functions/math.ts
|
|
7621
|
-
var
|
|
8015
|
+
var C21 = "Math & Trig";
|
|
7622
8016
|
function roundTo(x, digits2, mode) {
|
|
7623
8017
|
if (!Number.isFinite(x)) return x;
|
|
7624
8018
|
const d = Math.trunc(digits2);
|
|
@@ -7637,10 +8031,10 @@ var quotientMultiple = (x, sig, op) => {
|
|
|
7637
8031
|
var MATH_FUNCTIONS = [
|
|
7638
8032
|
...MATH_MORE,
|
|
7639
8033
|
...SUM_FUNCTIONS,
|
|
7640
|
-
numeric("ABS",
|
|
8034
|
+
numeric("ABS", C21, "ABS(number)", "The absolute value of a number.", 1, 1, Math.abs),
|
|
7641
8035
|
numeric(
|
|
7642
8036
|
"SIGN",
|
|
7643
|
-
|
|
8037
|
+
C21,
|
|
7644
8038
|
"SIGN(number)",
|
|
7645
8039
|
"The sign of a number: 1, 0 or -1.",
|
|
7646
8040
|
1,
|
|
@@ -7649,7 +8043,7 @@ var MATH_FUNCTIONS = [
|
|
|
7649
8043
|
),
|
|
7650
8044
|
numeric(
|
|
7651
8045
|
"INT",
|
|
7652
|
-
|
|
8046
|
+
C21,
|
|
7653
8047
|
"INT(number)",
|
|
7654
8048
|
"Rounds a number down to the nearest integer.",
|
|
7655
8049
|
1,
|
|
@@ -7658,7 +8052,7 @@ var MATH_FUNCTIONS = [
|
|
|
7658
8052
|
),
|
|
7659
8053
|
numeric(
|
|
7660
8054
|
"TRUNC",
|
|
7661
|
-
|
|
8055
|
+
C21,
|
|
7662
8056
|
"TRUNC(number, [num_digits])",
|
|
7663
8057
|
"Truncates a number toward zero.",
|
|
7664
8058
|
1,
|
|
@@ -7667,7 +8061,7 @@ var MATH_FUNCTIONS = [
|
|
|
7667
8061
|
),
|
|
7668
8062
|
numeric(
|
|
7669
8063
|
"ROUND",
|
|
7670
|
-
|
|
8064
|
+
C21,
|
|
7671
8065
|
"ROUND(number, num_digits)",
|
|
7672
8066
|
"Rounds a number to a number of digits.",
|
|
7673
8067
|
2,
|
|
@@ -7676,7 +8070,7 @@ var MATH_FUNCTIONS = [
|
|
|
7676
8070
|
),
|
|
7677
8071
|
numeric(
|
|
7678
8072
|
"ROUNDUP",
|
|
7679
|
-
|
|
8073
|
+
C21,
|
|
7680
8074
|
"ROUNDUP(number, num_digits)",
|
|
7681
8075
|
"Rounds a number away from zero.",
|
|
7682
8076
|
2,
|
|
@@ -7685,7 +8079,7 @@ var MATH_FUNCTIONS = [
|
|
|
7685
8079
|
),
|
|
7686
8080
|
numeric(
|
|
7687
8081
|
"ROUNDDOWN",
|
|
7688
|
-
|
|
8082
|
+
C21,
|
|
7689
8083
|
"ROUNDDOWN(number, num_digits)",
|
|
7690
8084
|
"Rounds a number toward zero.",
|
|
7691
8085
|
2,
|
|
@@ -7694,7 +8088,7 @@ var MATH_FUNCTIONS = [
|
|
|
7694
8088
|
),
|
|
7695
8089
|
numeric(
|
|
7696
8090
|
"MROUND",
|
|
7697
|
-
|
|
8091
|
+
C21,
|
|
7698
8092
|
"MROUND(number, multiple)",
|
|
7699
8093
|
"Rounds a number to the nearest multiple.",
|
|
7700
8094
|
2,
|
|
@@ -7703,7 +8097,7 @@ var MATH_FUNCTIONS = [
|
|
|
7703
8097
|
),
|
|
7704
8098
|
numeric(
|
|
7705
8099
|
"CEILING",
|
|
7706
|
-
|
|
8100
|
+
C21,
|
|
7707
8101
|
"CEILING(number, significance)",
|
|
7708
8102
|
"Rounds a number up to a multiple of significance.",
|
|
7709
8103
|
2,
|
|
@@ -7715,7 +8109,7 @@ var MATH_FUNCTIONS = [
|
|
|
7715
8109
|
),
|
|
7716
8110
|
numeric(
|
|
7717
8111
|
"FLOOR",
|
|
7718
|
-
|
|
8112
|
+
C21,
|
|
7719
8113
|
"FLOOR(number, significance)",
|
|
7720
8114
|
"Rounds a number down to a multiple of significance.",
|
|
7721
8115
|
2,
|
|
@@ -7728,7 +8122,7 @@ var MATH_FUNCTIONS = [
|
|
|
7728
8122
|
),
|
|
7729
8123
|
numeric(
|
|
7730
8124
|
"CEILING.MATH",
|
|
7731
|
-
|
|
8125
|
+
C21,
|
|
7732
8126
|
"CEILING.MATH(number, [significance], [mode])",
|
|
7733
8127
|
"Rounds a number up to an integer or multiple.",
|
|
7734
8128
|
1,
|
|
@@ -7741,7 +8135,7 @@ var MATH_FUNCTIONS = [
|
|
|
7741
8135
|
),
|
|
7742
8136
|
numeric(
|
|
7743
8137
|
"FLOOR.MATH",
|
|
7744
|
-
|
|
8138
|
+
C21,
|
|
7745
8139
|
"FLOOR.MATH(number, [significance], [mode])",
|
|
7746
8140
|
"Rounds a number down to an integer or multiple.",
|
|
7747
8141
|
1,
|
|
@@ -7754,7 +8148,7 @@ var MATH_FUNCTIONS = [
|
|
|
7754
8148
|
),
|
|
7755
8149
|
numeric(
|
|
7756
8150
|
"CEILING.PRECISE",
|
|
7757
|
-
|
|
8151
|
+
C21,
|
|
7758
8152
|
"CEILING.PRECISE(number, [significance])",
|
|
7759
8153
|
"Rounds a number up regardless of sign.",
|
|
7760
8154
|
1,
|
|
@@ -7763,7 +8157,7 @@ var MATH_FUNCTIONS = [
|
|
|
7763
8157
|
),
|
|
7764
8158
|
numeric(
|
|
7765
8159
|
"ISO.CEILING",
|
|
7766
|
-
|
|
8160
|
+
C21,
|
|
7767
8161
|
"ISO.CEILING(number, [significance])",
|
|
7768
8162
|
"Rounds a number up regardless of sign.",
|
|
7769
8163
|
1,
|
|
@@ -7772,7 +8166,7 @@ var MATH_FUNCTIONS = [
|
|
|
7772
8166
|
),
|
|
7773
8167
|
numeric(
|
|
7774
8168
|
"FLOOR.PRECISE",
|
|
7775
|
-
|
|
8169
|
+
C21,
|
|
7776
8170
|
"FLOOR.PRECISE(number, [significance])",
|
|
7777
8171
|
"Rounds a number down regardless of sign.",
|
|
7778
8172
|
1,
|
|
@@ -7781,7 +8175,7 @@ var MATH_FUNCTIONS = [
|
|
|
7781
8175
|
),
|
|
7782
8176
|
numeric(
|
|
7783
8177
|
"EVEN",
|
|
7784
|
-
|
|
8178
|
+
C21,
|
|
7785
8179
|
"EVEN(number)",
|
|
7786
8180
|
"Rounds a number away from zero to an even integer.",
|
|
7787
8181
|
1,
|
|
@@ -7790,7 +8184,7 @@ var MATH_FUNCTIONS = [
|
|
|
7790
8184
|
),
|
|
7791
8185
|
numeric(
|
|
7792
8186
|
"ODD",
|
|
7793
|
-
|
|
8187
|
+
C21,
|
|
7794
8188
|
"ODD(number)",
|
|
7795
8189
|
"Rounds a number away from zero to an odd integer.",
|
|
7796
8190
|
1,
|
|
@@ -7802,7 +8196,7 @@ var MATH_FUNCTIONS = [
|
|
|
7802
8196
|
),
|
|
7803
8197
|
numeric(
|
|
7804
8198
|
"MOD",
|
|
7805
|
-
|
|
8199
|
+
C21,
|
|
7806
8200
|
"MOD(number, divisor)",
|
|
7807
8201
|
"The remainder after division (sign of the divisor).",
|
|
7808
8202
|
2,
|
|
@@ -7811,7 +8205,7 @@ var MATH_FUNCTIONS = [
|
|
|
7811
8205
|
),
|
|
7812
8206
|
numeric(
|
|
7813
8207
|
"QUOTIENT",
|
|
7814
|
-
|
|
8208
|
+
C21,
|
|
7815
8209
|
"QUOTIENT(numerator, denominator)",
|
|
7816
8210
|
"The integer part of a division.",
|
|
7817
8211
|
2,
|
|
@@ -7823,7 +8217,7 @@ var MATH_FUNCTIONS = [
|
|
|
7823
8217
|
),
|
|
7824
8218
|
numeric(
|
|
7825
8219
|
"SQRT",
|
|
7826
|
-
|
|
8220
|
+
C21,
|
|
7827
8221
|
"SQRT(number)",
|
|
7828
8222
|
"The positive square root.",
|
|
7829
8223
|
1,
|
|
@@ -7832,7 +8226,7 @@ var MATH_FUNCTIONS = [
|
|
|
7832
8226
|
),
|
|
7833
8227
|
numeric(
|
|
7834
8228
|
"SQRTPI",
|
|
7835
|
-
|
|
8229
|
+
C21,
|
|
7836
8230
|
"SQRTPI(number)",
|
|
7837
8231
|
"The square root of number * pi.",
|
|
7838
8232
|
1,
|
|
@@ -7841,18 +8235,18 @@ var MATH_FUNCTIONS = [
|
|
|
7841
8235
|
),
|
|
7842
8236
|
numeric(
|
|
7843
8237
|
"POWER",
|
|
7844
|
-
|
|
8238
|
+
C21,
|
|
7845
8239
|
"POWER(number, power)",
|
|
7846
8240
|
"A number raised to a power.",
|
|
7847
8241
|
2,
|
|
7848
8242
|
2,
|
|
7849
8243
|
(b, e) => power(b, e ?? 1)
|
|
7850
8244
|
),
|
|
7851
|
-
numeric("EXP",
|
|
7852
|
-
numeric("LN",
|
|
8245
|
+
numeric("EXP", C21, "EXP(number)", "e raised to a power.", 1, 1, Math.exp),
|
|
8246
|
+
numeric("LN", C21, "LN(number)", "The natural logarithm.", 1, 1, (x) => domain(x > 0, Math.log(x))),
|
|
7853
8247
|
numeric(
|
|
7854
8248
|
"LOG10",
|
|
7855
|
-
|
|
8249
|
+
C21,
|
|
7856
8250
|
"LOG10(number)",
|
|
7857
8251
|
"The base-10 logarithm.",
|
|
7858
8252
|
1,
|
|
@@ -7861,7 +8255,7 @@ var MATH_FUNCTIONS = [
|
|
|
7861
8255
|
),
|
|
7862
8256
|
numeric(
|
|
7863
8257
|
"LOG",
|
|
7864
|
-
|
|
8258
|
+
C21,
|
|
7865
8259
|
"LOG(number, [base])",
|
|
7866
8260
|
"The logarithm to a base (10 by default).",
|
|
7867
8261
|
1,
|
|
@@ -7873,12 +8267,12 @@ var MATH_FUNCTIONS = [
|
|
|
7873
8267
|
return base === 10 ? Math.log10(x) : Math.log(x) / Math.log(base);
|
|
7874
8268
|
}
|
|
7875
8269
|
),
|
|
7876
|
-
numeric("PI",
|
|
8270
|
+
numeric("PI", C21, "PI()", "The value of pi.", 0, 0, () => Math.PI),
|
|
7877
8271
|
...COMBINATORIC_FUNCTIONS
|
|
7878
8272
|
];
|
|
7879
8273
|
|
|
7880
8274
|
// src/xlsx/formula/functions/matrix.ts
|
|
7881
|
-
var
|
|
8275
|
+
var C22 = "Math & Trig";
|
|
7882
8276
|
function numbers2(ctx, value) {
|
|
7883
8277
|
return ctx.toMatrix(value ?? null).data.map(
|
|
7884
8278
|
(row2) => row2.map((v) => {
|
|
@@ -7937,7 +8331,7 @@ function eliminate(input, invert2) {
|
|
|
7937
8331
|
var MATRIX_FUNCTIONS = [
|
|
7938
8332
|
spec(
|
|
7939
8333
|
"MMULT",
|
|
7940
|
-
|
|
8334
|
+
C22,
|
|
7941
8335
|
"MMULT(array1, array2)",
|
|
7942
8336
|
"The matrix product of two arrays.",
|
|
7943
8337
|
2,
|
|
@@ -7958,7 +8352,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
7958
8352
|
),
|
|
7959
8353
|
spec(
|
|
7960
8354
|
"MDETERM",
|
|
7961
|
-
|
|
8355
|
+
C22,
|
|
7962
8356
|
"MDETERM(array)",
|
|
7963
8357
|
"The determinant of a square matrix.",
|
|
7964
8358
|
1,
|
|
@@ -7968,7 +8362,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
7968
8362
|
),
|
|
7969
8363
|
spec(
|
|
7970
8364
|
"MINVERSE",
|
|
7971
|
-
|
|
8365
|
+
C22,
|
|
7972
8366
|
"MINVERSE(array)",
|
|
7973
8367
|
"The inverse of a square matrix.",
|
|
7974
8368
|
1,
|
|
@@ -7980,7 +8374,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
7980
8374
|
},
|
|
7981
8375
|
["any"]
|
|
7982
8376
|
),
|
|
7983
|
-
spec("MUNIT",
|
|
8377
|
+
spec("MUNIT", C22, "MUNIT(dimension)", "The identity matrix.", 1, 1, (args) => {
|
|
7984
8378
|
const n2 = int(args[0]);
|
|
7985
8379
|
if (n2 < 1) fail(ERR.VALUE);
|
|
7986
8380
|
return Matrix.build(n2, n2, (r, c2) => r === c2 ? 1 : 0);
|
|
@@ -8047,7 +8441,7 @@ function fitStatistics(fit2) {
|
|
|
8047
8441
|
}
|
|
8048
8442
|
|
|
8049
8443
|
// src/xlsx/formula/functions/regression.ts
|
|
8050
|
-
var
|
|
8444
|
+
var C23 = "Statistical";
|
|
8051
8445
|
function numbersOf2(ctx, value) {
|
|
8052
8446
|
return ctx.toMatrix(value ?? null).data.map(
|
|
8053
8447
|
(row2) => row2.map((v) => {
|
|
@@ -8116,7 +8510,7 @@ var ARGS = ["any"];
|
|
|
8116
8510
|
var REGRESSION_FUNCTIONS = [
|
|
8117
8511
|
spec(
|
|
8118
8512
|
"LINEST",
|
|
8119
|
-
|
|
8513
|
+
C23,
|
|
8120
8514
|
"LINEST(known_y, [known_x], [const], [stats])",
|
|
8121
8515
|
"The statistics of a straight-line (or multiple linear) least-squares fit.",
|
|
8122
8516
|
1,
|
|
@@ -8130,7 +8524,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
8130
8524
|
),
|
|
8131
8525
|
spec(
|
|
8132
8526
|
"LOGEST",
|
|
8133
|
-
|
|
8527
|
+
C23,
|
|
8134
8528
|
"LOGEST(known_y, [known_x], [const], [stats])",
|
|
8135
8529
|
"The statistics of an exponential-curve fit.",
|
|
8136
8530
|
1,
|
|
@@ -8148,7 +8542,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
8148
8542
|
),
|
|
8149
8543
|
spec(
|
|
8150
8544
|
"TREND",
|
|
8151
|
-
|
|
8545
|
+
C23,
|
|
8152
8546
|
"TREND(known_y, [known_x], [new_x], [const])",
|
|
8153
8547
|
"Values along a linear trend.",
|
|
8154
8548
|
1,
|
|
@@ -8162,7 +8556,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
8162
8556
|
),
|
|
8163
8557
|
spec(
|
|
8164
8558
|
"GROWTH",
|
|
8165
|
-
|
|
8559
|
+
C23,
|
|
8166
8560
|
"GROWTH(known_y, [known_x], [new_x], [const])",
|
|
8167
8561
|
"Values along an exponential trend.",
|
|
8168
8562
|
1,
|
|
@@ -8316,7 +8710,7 @@ var tPdf = (t, df) => Math.exp(
|
|
|
8316
8710
|
gammaLn((df + 1) / 2) - gammaLn(df / 2) - 0.5 * Math.log(df * Math.PI) - (df + 1) / 2 * Math.log(1 + t * t / df)
|
|
8317
8711
|
);
|
|
8318
8712
|
var chiCdf = (x, df) => gammaP(df / 2, x / 2);
|
|
8319
|
-
var
|
|
8713
|
+
var positive2 = (...values2) => {
|
|
8320
8714
|
for (const v of values2) if (v === void 0 || v <= 0) fail(ERR.NUM);
|
|
8321
8715
|
};
|
|
8322
8716
|
var probability = (p) => {
|
|
@@ -8341,13 +8735,13 @@ function poisson(k, mean2, cumulative2) {
|
|
|
8341
8735
|
return Math.exp(kk * Math.log(mean2) - mean2 - gammaLn(kk + 1));
|
|
8342
8736
|
}
|
|
8343
8737
|
var normDist = (x, m, s, cumulative2) => {
|
|
8344
|
-
|
|
8738
|
+
positive2(s);
|
|
8345
8739
|
const z = (x - m) / s;
|
|
8346
8740
|
return cumulative2 ? normCdf(z) : normPdf(z) / s;
|
|
8347
8741
|
};
|
|
8348
8742
|
|
|
8349
8743
|
// src/xlsx/formula/functions/distributions-f.ts
|
|
8350
|
-
var
|
|
8744
|
+
var C24 = "Statistical";
|
|
8351
8745
|
var degrees = (...values2) => {
|
|
8352
8746
|
for (const v of values2) if (v === void 0 || v < 1) fail(ERR.NUM);
|
|
8353
8747
|
};
|
|
@@ -8368,13 +8762,13 @@ var betaScaled = (x, a, b, lo, hi) => {
|
|
|
8368
8762
|
return betaI((x - lo) / (hi - lo), a, b);
|
|
8369
8763
|
};
|
|
8370
8764
|
var betaInverse = (p, a, b, lo, hi) => {
|
|
8371
|
-
|
|
8765
|
+
positive2(a, b);
|
|
8372
8766
|
if (p <= 0 || p > 1 || lo >= hi) fail(ERR.NUM);
|
|
8373
8767
|
return lo + (hi - lo) * invert((t) => betaI(t, a, b), p, 0, 1);
|
|
8374
8768
|
};
|
|
8375
8769
|
var gammaInverse = (p, a, b) => {
|
|
8376
8770
|
prob(p);
|
|
8377
|
-
|
|
8771
|
+
positive2(a, b);
|
|
8378
8772
|
return p === 0 ? 0 : invert((x) => gammaP(a, x / b), p, 0, a * b + 1);
|
|
8379
8773
|
};
|
|
8380
8774
|
function binomInverse(trials, p, alpha) {
|
|
@@ -8406,7 +8800,7 @@ var negbinomPmf = (f, s, p) => {
|
|
|
8406
8800
|
var DISTRIBUTION_F = [
|
|
8407
8801
|
numeric(
|
|
8408
8802
|
"F.DIST",
|
|
8409
|
-
|
|
8803
|
+
C24,
|
|
8410
8804
|
"F.DIST(x, deg_freedom1, deg_freedom2, cumulative)",
|
|
8411
8805
|
"The left-tailed F probability distribution.",
|
|
8412
8806
|
4,
|
|
@@ -8422,7 +8816,7 @@ var DISTRIBUTION_F = [
|
|
|
8422
8816
|
...["F.DIST.RT", "FDIST"].map(
|
|
8423
8817
|
(name) => numeric(
|
|
8424
8818
|
name,
|
|
8425
|
-
|
|
8819
|
+
C24,
|
|
8426
8820
|
`${name}(x, deg_freedom1, deg_freedom2)`,
|
|
8427
8821
|
"The right-tailed F probability distribution.",
|
|
8428
8822
|
3,
|
|
@@ -8436,7 +8830,7 @@ var DISTRIBUTION_F = [
|
|
|
8436
8830
|
),
|
|
8437
8831
|
numeric(
|
|
8438
8832
|
"F.INV",
|
|
8439
|
-
|
|
8833
|
+
C24,
|
|
8440
8834
|
"F.INV(probability, deg_freedom1, deg_freedom2)",
|
|
8441
8835
|
"The inverse of the left-tailed F distribution.",
|
|
8442
8836
|
3,
|
|
@@ -8450,7 +8844,7 @@ var DISTRIBUTION_F = [
|
|
|
8450
8844
|
...["F.INV.RT", "FINV"].map(
|
|
8451
8845
|
(name) => numeric(
|
|
8452
8846
|
name,
|
|
8453
|
-
|
|
8847
|
+
C24,
|
|
8454
8848
|
`${name}(probability, deg_freedom1, deg_freedom2)`,
|
|
8455
8849
|
"The inverse of the right-tailed F distribution.",
|
|
8456
8850
|
3,
|
|
@@ -8465,7 +8859,7 @@ var DISTRIBUTION_F = [
|
|
|
8465
8859
|
...["BETA.INV", "BETAINV"].map(
|
|
8466
8860
|
(name) => numeric(
|
|
8467
8861
|
name,
|
|
8468
|
-
|
|
8862
|
+
C24,
|
|
8469
8863
|
`${name}(probability, alpha, beta, [A], [B])`,
|
|
8470
8864
|
"The inverse of the cumulative beta distribution.",
|
|
8471
8865
|
3,
|
|
@@ -8476,13 +8870,13 @@ var DISTRIBUTION_F = [
|
|
|
8476
8870
|
),
|
|
8477
8871
|
numeric(
|
|
8478
8872
|
"BETADIST",
|
|
8479
|
-
|
|
8873
|
+
C24,
|
|
8480
8874
|
"BETADIST(x, alpha, beta, [A], [B])",
|
|
8481
8875
|
"The cumulative beta distribution.",
|
|
8482
8876
|
3,
|
|
8483
8877
|
5,
|
|
8484
8878
|
(x, a, b, lo, hi) => {
|
|
8485
|
-
|
|
8879
|
+
positive2(a, b);
|
|
8486
8880
|
return betaScaled(x, a ?? 1, b ?? 1, lo ?? 0, hi ?? 1);
|
|
8487
8881
|
},
|
|
8488
8882
|
[0, 0, 0, 0, 1]
|
|
@@ -8490,7 +8884,7 @@ var DISTRIBUTION_F = [
|
|
|
8490
8884
|
...["GAMMA.INV", "GAMMAINV"].map(
|
|
8491
8885
|
(name) => numeric(
|
|
8492
8886
|
name,
|
|
8493
|
-
|
|
8887
|
+
C24,
|
|
8494
8888
|
`${name}(probability, alpha, beta)`,
|
|
8495
8889
|
"The inverse of the gamma cumulative distribution.",
|
|
8496
8890
|
3,
|
|
@@ -8500,14 +8894,14 @@ var DISTRIBUTION_F = [
|
|
|
8500
8894
|
),
|
|
8501
8895
|
numeric(
|
|
8502
8896
|
"GAMMADIST",
|
|
8503
|
-
|
|
8897
|
+
C24,
|
|
8504
8898
|
"GAMMADIST(x, alpha, beta, cumulative)",
|
|
8505
8899
|
"The gamma distribution.",
|
|
8506
8900
|
4,
|
|
8507
8901
|
4,
|
|
8508
8902
|
(x, a, b, c2) => {
|
|
8509
8903
|
if (x < 0) fail(ERR.NUM);
|
|
8510
|
-
|
|
8904
|
+
positive2(a, b);
|
|
8511
8905
|
const al = a ?? 1;
|
|
8512
8906
|
const be = b ?? 1;
|
|
8513
8907
|
return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
|
|
@@ -8515,33 +8909,33 @@ var DISTRIBUTION_F = [
|
|
|
8515
8909
|
),
|
|
8516
8910
|
numeric(
|
|
8517
8911
|
"LOGINV",
|
|
8518
|
-
|
|
8912
|
+
C24,
|
|
8519
8913
|
"LOGINV(probability, mean, standard_dev)",
|
|
8520
8914
|
"The inverse of the lognormal cumulative distribution.",
|
|
8521
8915
|
3,
|
|
8522
8916
|
3,
|
|
8523
8917
|
(p, m, s) => {
|
|
8524
|
-
|
|
8918
|
+
positive2(s);
|
|
8525
8919
|
if (p <= 0 || p >= 1) fail(ERR.NUM);
|
|
8526
8920
|
return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
|
|
8527
8921
|
}
|
|
8528
8922
|
),
|
|
8529
8923
|
numeric(
|
|
8530
8924
|
"LOGNORMDIST",
|
|
8531
|
-
|
|
8925
|
+
C24,
|
|
8532
8926
|
"LOGNORMDIST(x, mean, standard_dev)",
|
|
8533
8927
|
"The cumulative lognormal distribution.",
|
|
8534
8928
|
3,
|
|
8535
8929
|
3,
|
|
8536
8930
|
(x, m, s) => {
|
|
8537
|
-
|
|
8931
|
+
positive2(x, s);
|
|
8538
8932
|
return normCdf((Math.log(x) - (m ?? 0)) / (s ?? 1));
|
|
8539
8933
|
}
|
|
8540
8934
|
),
|
|
8541
8935
|
...["BINOM.INV", "CRITBINOM"].map(
|
|
8542
8936
|
(name) => numeric(
|
|
8543
8937
|
name,
|
|
8544
|
-
|
|
8938
|
+
C24,
|
|
8545
8939
|
`${name}(trials, probability_s, alpha)`,
|
|
8546
8940
|
"The smallest value whose cumulative binomial distribution reaches the criterion.",
|
|
8547
8941
|
3,
|
|
@@ -8551,7 +8945,7 @@ var DISTRIBUTION_F = [
|
|
|
8551
8945
|
),
|
|
8552
8946
|
numeric(
|
|
8553
8947
|
"BINOM.DIST.RANGE",
|
|
8554
|
-
|
|
8948
|
+
C24,
|
|
8555
8949
|
"BINOM.DIST.RANGE(trials, probability_s, number_s, [number_s2])",
|
|
8556
8950
|
"The probability of a trial result within a range, from the binomial distribution.",
|
|
8557
8951
|
3,
|
|
@@ -8569,7 +8963,7 @@ var DISTRIBUTION_F = [
|
|
|
8569
8963
|
),
|
|
8570
8964
|
numeric(
|
|
8571
8965
|
"HYPGEOMDIST",
|
|
8572
|
-
|
|
8966
|
+
C24,
|
|
8573
8967
|
"HYPGEOMDIST(sample_s, number_sample, population_s, number_pop)",
|
|
8574
8968
|
"The hypergeometric distribution.",
|
|
8575
8969
|
4,
|
|
@@ -8578,7 +8972,7 @@ var DISTRIBUTION_F = [
|
|
|
8578
8972
|
),
|
|
8579
8973
|
numeric(
|
|
8580
8974
|
"NEGBINOMDIST",
|
|
8581
|
-
|
|
8975
|
+
C24,
|
|
8582
8976
|
"NEGBINOMDIST(number_f, number_s, probability_s)",
|
|
8583
8977
|
"The negative binomial distribution.",
|
|
8584
8978
|
3,
|
|
@@ -8588,7 +8982,7 @@ var DISTRIBUTION_F = [
|
|
|
8588
8982
|
];
|
|
8589
8983
|
|
|
8590
8984
|
// src/xlsx/formula/functions/statistical-shape.ts
|
|
8591
|
-
var
|
|
8985
|
+
var C25 = "Statistical";
|
|
8592
8986
|
function moments(values2) {
|
|
8593
8987
|
const n2 = values2.length;
|
|
8594
8988
|
return { n: n2, m: mean(values2), s: stdev(values2, true) };
|
|
@@ -8605,7 +8999,7 @@ function frequency(data, bins) {
|
|
|
8605
8999
|
var STATISTICAL_SHAPE = [
|
|
8606
9000
|
spec(
|
|
8607
9001
|
"GEOMEAN",
|
|
8608
|
-
|
|
9002
|
+
C25,
|
|
8609
9003
|
"GEOMEAN(number1, ...)",
|
|
8610
9004
|
"The geometric mean.",
|
|
8611
9005
|
1,
|
|
@@ -8619,7 +9013,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8619
9013
|
),
|
|
8620
9014
|
spec(
|
|
8621
9015
|
"HARMEAN",
|
|
8622
|
-
|
|
9016
|
+
C25,
|
|
8623
9017
|
"HARMEAN(number1, ...)",
|
|
8624
9018
|
"The harmonic mean.",
|
|
8625
9019
|
1,
|
|
@@ -8633,7 +9027,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8633
9027
|
),
|
|
8634
9028
|
spec(
|
|
8635
9029
|
"AVEDEV",
|
|
8636
|
-
|
|
9030
|
+
C25,
|
|
8637
9031
|
"AVEDEV(number1, ...)",
|
|
8638
9032
|
"The mean absolute deviation from the mean.",
|
|
8639
9033
|
1,
|
|
@@ -8648,7 +9042,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8648
9042
|
),
|
|
8649
9043
|
spec(
|
|
8650
9044
|
"DEVSQ",
|
|
8651
|
-
|
|
9045
|
+
C25,
|
|
8652
9046
|
"DEVSQ(number1, ...)",
|
|
8653
9047
|
"The sum of squared deviations from the mean.",
|
|
8654
9048
|
1,
|
|
@@ -8661,7 +9055,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8661
9055
|
),
|
|
8662
9056
|
spec(
|
|
8663
9057
|
"KURT",
|
|
8664
|
-
|
|
9058
|
+
C25,
|
|
8665
9059
|
"KURT(number1, ...)",
|
|
8666
9060
|
"The kurtosis of a data set.",
|
|
8667
9061
|
1,
|
|
@@ -8677,7 +9071,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8677
9071
|
),
|
|
8678
9072
|
spec(
|
|
8679
9073
|
"SKEW",
|
|
8680
|
-
|
|
9074
|
+
C25,
|
|
8681
9075
|
"SKEW(number1, ...)",
|
|
8682
9076
|
"The skewness of a distribution.",
|
|
8683
9077
|
1,
|
|
@@ -8692,7 +9086,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8692
9086
|
),
|
|
8693
9087
|
spec(
|
|
8694
9088
|
"SKEW.P",
|
|
8695
|
-
|
|
9089
|
+
C25,
|
|
8696
9090
|
"SKEW.P(number1, ...)",
|
|
8697
9091
|
"The population skewness.",
|
|
8698
9092
|
1,
|
|
@@ -8708,7 +9102,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8708
9102
|
),
|
|
8709
9103
|
numeric(
|
|
8710
9104
|
"STANDARDIZE",
|
|
8711
|
-
|
|
9105
|
+
C25,
|
|
8712
9106
|
"STANDARDIZE(x, mean, standard_dev)",
|
|
8713
9107
|
"A normalized value.",
|
|
8714
9108
|
3,
|
|
@@ -8720,7 +9114,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8720
9114
|
),
|
|
8721
9115
|
spec(
|
|
8722
9116
|
"TRIMMEAN",
|
|
8723
|
-
|
|
9117
|
+
C25,
|
|
8724
9118
|
"TRIMMEAN(array, percent)",
|
|
8725
9119
|
"The mean of the interior of a data set.",
|
|
8726
9120
|
2,
|
|
@@ -8736,7 +9130,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8736
9130
|
),
|
|
8737
9131
|
spec(
|
|
8738
9132
|
"FREQUENCY",
|
|
8739
|
-
|
|
9133
|
+
C25,
|
|
8740
9134
|
"FREQUENCY(data_array, bins_array)",
|
|
8741
9135
|
"How often values occur within ranges, as a vertical array.",
|
|
8742
9136
|
2,
|
|
@@ -8746,7 +9140,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8746
9140
|
),
|
|
8747
9141
|
numeric(
|
|
8748
9142
|
"PERMUT",
|
|
8749
|
-
|
|
9143
|
+
C25,
|
|
8750
9144
|
"PERMUT(number, number_chosen)",
|
|
8751
9145
|
"The number of permutations.",
|
|
8752
9146
|
2,
|
|
@@ -8762,7 +9156,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8762
9156
|
),
|
|
8763
9157
|
numeric(
|
|
8764
9158
|
"PERMUTATIONA",
|
|
8765
|
-
|
|
9159
|
+
C25,
|
|
8766
9160
|
"PERMUTATIONA(number, number_chosen)",
|
|
8767
9161
|
"Permutations with repetitions.",
|
|
8768
9162
|
2,
|
|
@@ -8772,26 +9166,26 @@ var STATISTICAL_SHAPE = [
|
|
|
8772
9166
|
return Math.pow(Math.trunc(n2), Math.trunc(k ?? 0));
|
|
8773
9167
|
}
|
|
8774
9168
|
),
|
|
8775
|
-
numeric("FISHER",
|
|
9169
|
+
numeric("FISHER", C25, "FISHER(x)", "The Fisher transformation.", 1, 1, (x) => {
|
|
8776
9170
|
if (x <= -1 || x >= 1) fail(ERR.NUM);
|
|
8777
9171
|
return 0.5 * Math.log((1 + x) / (1 - x));
|
|
8778
9172
|
}),
|
|
8779
9173
|
numeric(
|
|
8780
9174
|
"FISHERINV",
|
|
8781
|
-
|
|
9175
|
+
C25,
|
|
8782
9176
|
"FISHERINV(y)",
|
|
8783
9177
|
"The inverse of the Fisher transformation.",
|
|
8784
9178
|
1,
|
|
8785
9179
|
1,
|
|
8786
9180
|
(y) => Math.tanh(y)
|
|
8787
9181
|
),
|
|
8788
|
-
numeric("GAMMA",
|
|
9182
|
+
numeric("GAMMA", C25, "GAMMA(number)", "The gamma function value.", 1, 1, (x) => {
|
|
8789
9183
|
if (x <= 0 && Number.isInteger(x)) fail(ERR.NUM);
|
|
8790
9184
|
return gamma(x);
|
|
8791
9185
|
}),
|
|
8792
9186
|
numeric(
|
|
8793
9187
|
"GAMMALN",
|
|
8794
|
-
|
|
9188
|
+
C25,
|
|
8795
9189
|
"GAMMALN(x)",
|
|
8796
9190
|
"The natural logarithm of the gamma function.",
|
|
8797
9191
|
1,
|
|
@@ -8800,7 +9194,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8800
9194
|
),
|
|
8801
9195
|
numeric(
|
|
8802
9196
|
"GAMMALN.PRECISE",
|
|
8803
|
-
|
|
9197
|
+
C25,
|
|
8804
9198
|
"GAMMALN.PRECISE(x)",
|
|
8805
9199
|
"The natural logarithm of the gamma function.",
|
|
8806
9200
|
1,
|
|
@@ -8810,7 +9204,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8810
9204
|
];
|
|
8811
9205
|
|
|
8812
9206
|
// src/xlsx/formula/functions/statistical-more.ts
|
|
8813
|
-
var
|
|
9207
|
+
var C26 = "Statistical";
|
|
8814
9208
|
function pairedNumbers(ctx, a, b) {
|
|
8815
9209
|
const ma = ctx.toMatrix(a).flat();
|
|
8816
9210
|
const mb = ctx.toMatrix(b).flat();
|
|
@@ -8831,7 +9225,7 @@ function pairedNumbers(ctx, a, b) {
|
|
|
8831
9225
|
}
|
|
8832
9226
|
var pairFn = (name, description, syntax, fn) => spec(
|
|
8833
9227
|
name,
|
|
8834
|
-
|
|
9228
|
+
C26,
|
|
8835
9229
|
syntax,
|
|
8836
9230
|
description,
|
|
8837
9231
|
2,
|
|
@@ -8846,7 +9240,7 @@ var STATISTICAL_MORE = [
|
|
|
8846
9240
|
...STATISTICAL_SHAPE,
|
|
8847
9241
|
spec(
|
|
8848
9242
|
"MODE.MULT",
|
|
8849
|
-
|
|
9243
|
+
C26,
|
|
8850
9244
|
"MODE.MULT(number1, [number2], ...)",
|
|
8851
9245
|
"A vertical array of the most frequent values.",
|
|
8852
9246
|
1,
|
|
@@ -8928,7 +9322,7 @@ var STATISTICAL_MORE = [
|
|
|
8928
9322
|
...["FORECAST", "FORECAST.LINEAR"].map(
|
|
8929
9323
|
(name) => spec(
|
|
8930
9324
|
name,
|
|
8931
|
-
|
|
9325
|
+
C26,
|
|
8932
9326
|
`${name}(x, known_ys, known_xs)`,
|
|
8933
9327
|
"Predicts a value along a linear trend.",
|
|
8934
9328
|
3,
|
|
@@ -8945,7 +9339,7 @@ var STATISTICAL_MORE = [
|
|
|
8945
9339
|
];
|
|
8946
9340
|
|
|
8947
9341
|
// src/xlsx/formula/functions/hypothesis-tests.ts
|
|
8948
|
-
var
|
|
9342
|
+
var C27 = "Statistical";
|
|
8949
9343
|
var ARRAYS = ["any"];
|
|
8950
9344
|
var numbersOf3 = (ctx, value) => collectNumbers(ctx, [value ?? null]);
|
|
8951
9345
|
function tStatistic(a, b, type) {
|
|
@@ -9030,7 +9424,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9030
9424
|
["Z.TEST", "ZTEST"],
|
|
9031
9425
|
(name) => spec(
|
|
9032
9426
|
name,
|
|
9033
|
-
|
|
9427
|
+
C27,
|
|
9034
9428
|
`${name}(array, x, [sigma])`,
|
|
9035
9429
|
"The one-tailed P-value of a z-test.",
|
|
9036
9430
|
2,
|
|
@@ -9049,7 +9443,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9049
9443
|
["T.TEST", "TTEST"],
|
|
9050
9444
|
(name) => spec(
|
|
9051
9445
|
name,
|
|
9052
|
-
|
|
9446
|
+
C27,
|
|
9053
9447
|
`${name}(array1, array2, tails, type)`,
|
|
9054
9448
|
"The probability associated with a Student's t-test.",
|
|
9055
9449
|
4,
|
|
@@ -9070,7 +9464,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9070
9464
|
["F.TEST", "FTEST"],
|
|
9071
9465
|
(name) => spec(
|
|
9072
9466
|
name,
|
|
9073
|
-
|
|
9467
|
+
C27,
|
|
9074
9468
|
`${name}(array1, array2)`,
|
|
9075
9469
|
"The two-tailed probability that the variances of two arrays are not different.",
|
|
9076
9470
|
2,
|
|
@@ -9083,7 +9477,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9083
9477
|
["CHISQ.TEST", "CHITEST"],
|
|
9084
9478
|
(name) => spec(
|
|
9085
9479
|
name,
|
|
9086
|
-
|
|
9480
|
+
C27,
|
|
9087
9481
|
`${name}(actual_range, expected_range)`,
|
|
9088
9482
|
"The chi-squared test of independence.",
|
|
9089
9483
|
2,
|
|
@@ -9094,7 +9488,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9094
9488
|
),
|
|
9095
9489
|
spec(
|
|
9096
9490
|
"PROB",
|
|
9097
|
-
|
|
9491
|
+
C27,
|
|
9098
9492
|
"PROB(x_range, prob_range, lower_limit, [upper_limit])",
|
|
9099
9493
|
"The probability that values in a range are between two limits.",
|
|
9100
9494
|
3,
|
|
@@ -9105,7 +9499,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9105
9499
|
];
|
|
9106
9500
|
|
|
9107
9501
|
// src/xlsx/formula/functions/statistical-spread.ts
|
|
9108
|
-
var
|
|
9502
|
+
var C28 = "Statistical";
|
|
9109
9503
|
var STATISTICAL_SPREAD = [
|
|
9110
9504
|
...[
|
|
9111
9505
|
["STDEV", true, false],
|
|
@@ -9117,7 +9511,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9117
9511
|
].map(
|
|
9118
9512
|
([name, sample, a]) => spec(
|
|
9119
9513
|
name,
|
|
9120
|
-
|
|
9514
|
+
C28,
|
|
9121
9515
|
`${name}(number1, [number2], ...)`,
|
|
9122
9516
|
`The ${sample ? "sample" : "population"} standard deviation${a ? " counting logicals and text" : ""}.`,
|
|
9123
9517
|
1,
|
|
@@ -9136,7 +9530,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9136
9530
|
].map(
|
|
9137
9531
|
([name, sample, a]) => spec(
|
|
9138
9532
|
name,
|
|
9139
|
-
|
|
9533
|
+
C28,
|
|
9140
9534
|
`${name}(number1, [number2], ...)`,
|
|
9141
9535
|
`The ${sample ? "sample" : "population"} variance${a ? " counting logicals and text" : ""}.`,
|
|
9142
9536
|
1,
|
|
@@ -9148,7 +9542,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9148
9542
|
...["PERCENTILE", "PERCENTILE.INC", "PERCENTILE.EXC"].map(
|
|
9149
9543
|
(name) => spec(
|
|
9150
9544
|
name,
|
|
9151
|
-
|
|
9545
|
+
C28,
|
|
9152
9546
|
`${name}(array, k)`,
|
|
9153
9547
|
"The k-th percentile.",
|
|
9154
9548
|
2,
|
|
@@ -9164,7 +9558,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9164
9558
|
...["QUARTILE", "QUARTILE.INC", "QUARTILE.EXC"].map(
|
|
9165
9559
|
(name) => spec(
|
|
9166
9560
|
name,
|
|
9167
|
-
|
|
9561
|
+
C28,
|
|
9168
9562
|
`${name}(array, quart)`,
|
|
9169
9563
|
"A quartile of a data set.",
|
|
9170
9564
|
2,
|
|
@@ -9176,7 +9570,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9176
9570
|
...["PERCENTRANK", "PERCENTRANK.INC", "PERCENTRANK.EXC"].map(
|
|
9177
9571
|
(name) => spec(
|
|
9178
9572
|
name,
|
|
9179
|
-
|
|
9573
|
+
C28,
|
|
9180
9574
|
`${name}(array, x, [significance])`,
|
|
9181
9575
|
"The rank of a value as a percentage of the data set.",
|
|
9182
9576
|
2,
|
|
@@ -9193,7 +9587,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9193
9587
|
];
|
|
9194
9588
|
|
|
9195
9589
|
// src/xlsx/formula/functions/statistical-count.ts
|
|
9196
|
-
var
|
|
9590
|
+
var C29 = "Statistical";
|
|
9197
9591
|
function count(ctx, args) {
|
|
9198
9592
|
let n2 = 0;
|
|
9199
9593
|
for (const arg of args) {
|
|
@@ -9259,7 +9653,7 @@ function countIf(ctx, range, criteria) {
|
|
|
9259
9653
|
var COUNT_FUNCTIONS = [
|
|
9260
9654
|
spec(
|
|
9261
9655
|
"COUNT",
|
|
9262
|
-
|
|
9656
|
+
C29,
|
|
9263
9657
|
"COUNT(value1, [value2], ...)",
|
|
9264
9658
|
"Counts the numbers in the arguments.",
|
|
9265
9659
|
0,
|
|
@@ -9269,7 +9663,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9269
9663
|
),
|
|
9270
9664
|
spec(
|
|
9271
9665
|
"COUNTA",
|
|
9272
|
-
|
|
9666
|
+
C29,
|
|
9273
9667
|
"COUNTA(value1, [value2], ...)",
|
|
9274
9668
|
"Counts the non-empty values.",
|
|
9275
9669
|
1,
|
|
@@ -9279,7 +9673,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9279
9673
|
),
|
|
9280
9674
|
spec(
|
|
9281
9675
|
"COUNTBLANK",
|
|
9282
|
-
|
|
9676
|
+
C29,
|
|
9283
9677
|
"COUNTBLANK(range)",
|
|
9284
9678
|
"Counts the empty cells in a range.",
|
|
9285
9679
|
1,
|
|
@@ -9289,7 +9683,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9289
9683
|
),
|
|
9290
9684
|
spec(
|
|
9291
9685
|
"COUNTIF",
|
|
9292
|
-
|
|
9686
|
+
C29,
|
|
9293
9687
|
"COUNTIF(range, criteria)",
|
|
9294
9688
|
"Counts the cells that meet a criterion.",
|
|
9295
9689
|
2,
|
|
@@ -9299,7 +9693,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9299
9693
|
),
|
|
9300
9694
|
spec(
|
|
9301
9695
|
"COUNTIFS",
|
|
9302
|
-
|
|
9696
|
+
C29,
|
|
9303
9697
|
"COUNTIFS(criteria_range1, criteria1, ...)",
|
|
9304
9698
|
"Counts the cells that meet several criteria.",
|
|
9305
9699
|
2,
|
|
@@ -9312,7 +9706,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9312
9706
|
),
|
|
9313
9707
|
spec(
|
|
9314
9708
|
"AVERAGE",
|
|
9315
|
-
|
|
9709
|
+
C29,
|
|
9316
9710
|
"AVERAGE(number1, [number2], ...)",
|
|
9317
9711
|
"The arithmetic mean.",
|
|
9318
9712
|
1,
|
|
@@ -9323,7 +9717,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9323
9717
|
];
|
|
9324
9718
|
|
|
9325
9719
|
// src/xlsx/formula/functions/statistical.ts
|
|
9326
|
-
var
|
|
9720
|
+
var C30 = "Statistical";
|
|
9327
9721
|
var numbersOf4 = (values2) => values2.filter((v) => typeof v === "number");
|
|
9328
9722
|
var extreme2 = extreme;
|
|
9329
9723
|
var STATISTICAL_FUNCTIONS = [
|
|
@@ -9334,7 +9728,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9334
9728
|
...COUNT_FUNCTIONS,
|
|
9335
9729
|
spec(
|
|
9336
9730
|
"AVERAGEA",
|
|
9337
|
-
|
|
9731
|
+
C30,
|
|
9338
9732
|
"AVERAGEA(value1, [value2], ...)",
|
|
9339
9733
|
"The mean counting text as 0 and logicals.",
|
|
9340
9734
|
1,
|
|
@@ -9344,7 +9738,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9344
9738
|
),
|
|
9345
9739
|
spec(
|
|
9346
9740
|
"AVERAGEIF",
|
|
9347
|
-
|
|
9741
|
+
C30,
|
|
9348
9742
|
"AVERAGEIF(range, criteria, [average_range])",
|
|
9349
9743
|
"The mean of the cells that meet a criterion.",
|
|
9350
9744
|
2,
|
|
@@ -9363,7 +9757,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9363
9757
|
),
|
|
9364
9758
|
spec(
|
|
9365
9759
|
"AVERAGEIFS",
|
|
9366
|
-
|
|
9760
|
+
C30,
|
|
9367
9761
|
"AVERAGEIFS(average_range, criteria_range1, criteria1, ...)",
|
|
9368
9762
|
"The mean of the cells that meet several criteria.",
|
|
9369
9763
|
3,
|
|
@@ -9377,7 +9771,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9377
9771
|
),
|
|
9378
9772
|
spec(
|
|
9379
9773
|
"MAX",
|
|
9380
|
-
|
|
9774
|
+
C30,
|
|
9381
9775
|
"MAX(number1, [number2], ...)",
|
|
9382
9776
|
"The largest value.",
|
|
9383
9777
|
1,
|
|
@@ -9387,7 +9781,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9387
9781
|
),
|
|
9388
9782
|
spec(
|
|
9389
9783
|
"MIN",
|
|
9390
|
-
|
|
9784
|
+
C30,
|
|
9391
9785
|
"MIN(number1, [number2], ...)",
|
|
9392
9786
|
"The smallest value.",
|
|
9393
9787
|
1,
|
|
@@ -9397,7 +9791,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9397
9791
|
),
|
|
9398
9792
|
spec(
|
|
9399
9793
|
"MAXA",
|
|
9400
|
-
|
|
9794
|
+
C30,
|
|
9401
9795
|
"MAXA(value1, [value2], ...)",
|
|
9402
9796
|
"The largest value counting logicals and text.",
|
|
9403
9797
|
1,
|
|
@@ -9407,7 +9801,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9407
9801
|
),
|
|
9408
9802
|
spec(
|
|
9409
9803
|
"MINA",
|
|
9410
|
-
|
|
9804
|
+
C30,
|
|
9411
9805
|
"MINA(value1, [value2], ...)",
|
|
9412
9806
|
"The smallest value counting logicals and text.",
|
|
9413
9807
|
1,
|
|
@@ -9417,7 +9811,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9417
9811
|
),
|
|
9418
9812
|
spec(
|
|
9419
9813
|
"MAXIFS",
|
|
9420
|
-
|
|
9814
|
+
C30,
|
|
9421
9815
|
"MAXIFS(max_range, criteria_range1, criteria1, ...)",
|
|
9422
9816
|
"The largest value meeting criteria.",
|
|
9423
9817
|
3,
|
|
@@ -9431,7 +9825,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9431
9825
|
),
|
|
9432
9826
|
spec(
|
|
9433
9827
|
"MINIFS",
|
|
9434
|
-
|
|
9828
|
+
C30,
|
|
9435
9829
|
"MINIFS(min_range, criteria_range1, criteria1, ...)",
|
|
9436
9830
|
"The smallest value meeting criteria.",
|
|
9437
9831
|
3,
|
|
@@ -9445,7 +9839,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9445
9839
|
),
|
|
9446
9840
|
spec(
|
|
9447
9841
|
"MEDIAN",
|
|
9448
|
-
|
|
9842
|
+
C30,
|
|
9449
9843
|
"MEDIAN(number1, [number2], ...)",
|
|
9450
9844
|
"The median.",
|
|
9451
9845
|
1,
|
|
@@ -9455,7 +9849,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9455
9849
|
),
|
|
9456
9850
|
spec(
|
|
9457
9851
|
"MODE",
|
|
9458
|
-
|
|
9852
|
+
C30,
|
|
9459
9853
|
"MODE(number1, [number2], ...)",
|
|
9460
9854
|
"The most frequent value.",
|
|
9461
9855
|
1,
|
|
@@ -9465,7 +9859,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9465
9859
|
),
|
|
9466
9860
|
spec(
|
|
9467
9861
|
"MODE.SNGL",
|
|
9468
|
-
|
|
9862
|
+
C30,
|
|
9469
9863
|
"MODE.SNGL(number1, [number2], ...)",
|
|
9470
9864
|
"The most frequent value.",
|
|
9471
9865
|
1,
|
|
@@ -9475,7 +9869,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9475
9869
|
),
|
|
9476
9870
|
spec(
|
|
9477
9871
|
"LARGE",
|
|
9478
|
-
|
|
9872
|
+
C30,
|
|
9479
9873
|
"LARGE(array, k)",
|
|
9480
9874
|
"The k-th largest value.",
|
|
9481
9875
|
2,
|
|
@@ -9485,7 +9879,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9485
9879
|
),
|
|
9486
9880
|
spec(
|
|
9487
9881
|
"SMALL",
|
|
9488
|
-
|
|
9882
|
+
C30,
|
|
9489
9883
|
"SMALL(array, k)",
|
|
9490
9884
|
"The k-th smallest value.",
|
|
9491
9885
|
2,
|
|
@@ -9496,7 +9890,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9496
9890
|
...["RANK", "RANK.EQ", "RANK.AVG"].map(
|
|
9497
9891
|
(name) => spec(
|
|
9498
9892
|
name,
|
|
9499
|
-
|
|
9893
|
+
C30,
|
|
9500
9894
|
`${name}(number, ref, [order])`,
|
|
9501
9895
|
"The rank of a number in a list.",
|
|
9502
9896
|
2,
|
|
@@ -9513,11 +9907,11 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9513
9907
|
];
|
|
9514
9908
|
|
|
9515
9909
|
// src/xlsx/formula/functions/distributions-more.ts
|
|
9516
|
-
var
|
|
9910
|
+
var C31 = "Statistical";
|
|
9517
9911
|
var DISTRIBUTION_MORE = [
|
|
9518
9912
|
numeric(
|
|
9519
9913
|
"T.DIST",
|
|
9520
|
-
|
|
9914
|
+
C31,
|
|
9521
9915
|
"T.DIST(x, deg_freedom, cumulative)",
|
|
9522
9916
|
"Student's left-tailed t-distribution.",
|
|
9523
9917
|
3,
|
|
@@ -9529,7 +9923,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9529
9923
|
),
|
|
9530
9924
|
numeric(
|
|
9531
9925
|
"T.DIST.RT",
|
|
9532
|
-
|
|
9926
|
+
C31,
|
|
9533
9927
|
"T.DIST.RT(x, deg_freedom)",
|
|
9534
9928
|
"Student's right-tailed t-distribution.",
|
|
9535
9929
|
2,
|
|
@@ -9541,7 +9935,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9541
9935
|
),
|
|
9542
9936
|
numeric(
|
|
9543
9937
|
"T.DIST.2T",
|
|
9544
|
-
|
|
9938
|
+
C31,
|
|
9545
9939
|
"T.DIST.2T(x, deg_freedom)",
|
|
9546
9940
|
"Student's two-tailed t-distribution.",
|
|
9547
9941
|
2,
|
|
@@ -9553,7 +9947,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9553
9947
|
),
|
|
9554
9948
|
numeric(
|
|
9555
9949
|
"TDIST",
|
|
9556
|
-
|
|
9950
|
+
C31,
|
|
9557
9951
|
"TDIST(x, deg_freedom, tails)",
|
|
9558
9952
|
"Student's t-distribution.",
|
|
9559
9953
|
3,
|
|
@@ -9565,7 +9959,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9565
9959
|
),
|
|
9566
9960
|
numeric(
|
|
9567
9961
|
"T.INV",
|
|
9568
|
-
|
|
9962
|
+
C31,
|
|
9569
9963
|
"T.INV(probability, deg_freedom)",
|
|
9570
9964
|
"The left-tailed inverse of Student's t-distribution.",
|
|
9571
9965
|
2,
|
|
@@ -9580,7 +9974,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9580
9974
|
...["T.INV.2T", "TINV"].map(
|
|
9581
9975
|
(name) => numeric(
|
|
9582
9976
|
name,
|
|
9583
|
-
|
|
9977
|
+
C31,
|
|
9584
9978
|
`${name}(probability, deg_freedom)`,
|
|
9585
9979
|
"The two-tailed inverse of Student's t-distribution.",
|
|
9586
9980
|
2,
|
|
@@ -9593,7 +9987,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9593
9987
|
),
|
|
9594
9988
|
numeric(
|
|
9595
9989
|
"CHISQ.DIST",
|
|
9596
|
-
|
|
9990
|
+
C31,
|
|
9597
9991
|
"CHISQ.DIST(x, deg_freedom, cumulative)",
|
|
9598
9992
|
"The chi-squared distribution.",
|
|
9599
9993
|
3,
|
|
@@ -9607,7 +10001,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9607
10001
|
...["CHISQ.DIST.RT", "CHIDIST"].map(
|
|
9608
10002
|
(name) => numeric(
|
|
9609
10003
|
name,
|
|
9610
|
-
|
|
10004
|
+
C31,
|
|
9611
10005
|
`${name}(x, deg_freedom)`,
|
|
9612
10006
|
"The right-tailed chi-squared probability.",
|
|
9613
10007
|
2,
|
|
@@ -9620,7 +10014,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9620
10014
|
),
|
|
9621
10015
|
numeric(
|
|
9622
10016
|
"CHISQ.INV",
|
|
9623
|
-
|
|
10017
|
+
C31,
|
|
9624
10018
|
"CHISQ.INV(probability, deg_freedom)",
|
|
9625
10019
|
"The inverse of the left-tailed chi-squared distribution.",
|
|
9626
10020
|
2,
|
|
@@ -9633,7 +10027,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9633
10027
|
...["CHISQ.INV.RT", "CHIINV"].map(
|
|
9634
10028
|
(name) => numeric(
|
|
9635
10029
|
name,
|
|
9636
|
-
|
|
10030
|
+
C31,
|
|
9637
10031
|
`${name}(probability, deg_freedom)`,
|
|
9638
10032
|
"The inverse of the right-tailed chi-squared distribution.",
|
|
9639
10033
|
2,
|
|
@@ -9646,7 +10040,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9646
10040
|
),
|
|
9647
10041
|
numeric(
|
|
9648
10042
|
"BETA.DIST",
|
|
9649
|
-
|
|
10043
|
+
C31,
|
|
9650
10044
|
"BETA.DIST(x, alpha, beta, cumulative, [A], [B])",
|
|
9651
10045
|
"The beta distribution.",
|
|
9652
10046
|
4,
|
|
@@ -9654,7 +10048,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9654
10048
|
(x, a, b, c2, lo, hi) => {
|
|
9655
10049
|
const A = lo ?? 0;
|
|
9656
10050
|
const B = hi ?? 1;
|
|
9657
|
-
|
|
10051
|
+
positive2(a, b);
|
|
9658
10052
|
if (x < A || x > B || A === B) fail(ERR.NUM);
|
|
9659
10053
|
const t = (x - A) / (B - A);
|
|
9660
10054
|
const al = a ?? 1;
|
|
@@ -9666,7 +10060,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9666
10060
|
),
|
|
9667
10061
|
numeric(
|
|
9668
10062
|
"NEGBINOM.DIST",
|
|
9669
|
-
|
|
10063
|
+
C31,
|
|
9670
10064
|
"NEGBINOM.DIST(number_f, number_s, probability_s, cumulative)",
|
|
9671
10065
|
"The negative binomial distribution.",
|
|
9672
10066
|
4,
|
|
@@ -9685,7 +10079,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9685
10079
|
),
|
|
9686
10080
|
numeric(
|
|
9687
10081
|
"HYPGEOM.DIST",
|
|
9688
|
-
|
|
10082
|
+
C31,
|
|
9689
10083
|
"HYPGEOM.DIST(sample_s, number_sample, population_s, number_pop, cumulative)",
|
|
9690
10084
|
"The hypergeometric distribution.",
|
|
9691
10085
|
5,
|
|
@@ -9706,13 +10100,13 @@ var DISTRIBUTION_MORE = [
|
|
|
9706
10100
|
];
|
|
9707
10101
|
|
|
9708
10102
|
// src/xlsx/formula/functions/distributions.ts
|
|
9709
|
-
var
|
|
10103
|
+
var C32 = "Statistical";
|
|
9710
10104
|
var DISTRIBUTION_FUNCTIONS = [
|
|
9711
10105
|
...DISTRIBUTION_MORE,
|
|
9712
10106
|
...DISTRIBUTION_F,
|
|
9713
10107
|
numeric(
|
|
9714
10108
|
"NORM.DIST",
|
|
9715
|
-
|
|
10109
|
+
C32,
|
|
9716
10110
|
"NORM.DIST(x, mean, standard_dev, cumulative)",
|
|
9717
10111
|
"The normal distribution.",
|
|
9718
10112
|
4,
|
|
@@ -9721,7 +10115,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9721
10115
|
),
|
|
9722
10116
|
numeric(
|
|
9723
10117
|
"NORMDIST",
|
|
9724
|
-
|
|
10118
|
+
C32,
|
|
9725
10119
|
"NORMDIST(x, mean, standard_dev, cumulative)",
|
|
9726
10120
|
"The normal distribution.",
|
|
9727
10121
|
4,
|
|
@@ -9730,7 +10124,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9730
10124
|
),
|
|
9731
10125
|
numeric(
|
|
9732
10126
|
"NORM.S.DIST",
|
|
9733
|
-
|
|
10127
|
+
C32,
|
|
9734
10128
|
"NORM.S.DIST(z, cumulative)",
|
|
9735
10129
|
"The standard normal distribution.",
|
|
9736
10130
|
2,
|
|
@@ -9739,7 +10133,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9739
10133
|
),
|
|
9740
10134
|
numeric(
|
|
9741
10135
|
"NORMSDIST",
|
|
9742
|
-
|
|
10136
|
+
C32,
|
|
9743
10137
|
"NORMSDIST(z)",
|
|
9744
10138
|
"The standard normal cumulative distribution.",
|
|
9745
10139
|
1,
|
|
@@ -9748,31 +10142,31 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9748
10142
|
),
|
|
9749
10143
|
numeric(
|
|
9750
10144
|
"NORM.INV",
|
|
9751
|
-
|
|
10145
|
+
C32,
|
|
9752
10146
|
"NORM.INV(probability, mean, standard_dev)",
|
|
9753
10147
|
"The inverse of the normal cumulative distribution.",
|
|
9754
10148
|
3,
|
|
9755
10149
|
3,
|
|
9756
10150
|
(p, m, s) => {
|
|
9757
|
-
|
|
10151
|
+
positive2(s);
|
|
9758
10152
|
return (m ?? 0) + (s ?? 1) * normInv(p);
|
|
9759
10153
|
}
|
|
9760
10154
|
),
|
|
9761
10155
|
numeric(
|
|
9762
10156
|
"NORMINV",
|
|
9763
|
-
|
|
10157
|
+
C32,
|
|
9764
10158
|
"NORMINV(probability, mean, standard_dev)",
|
|
9765
10159
|
"The inverse of the normal cumulative distribution.",
|
|
9766
10160
|
3,
|
|
9767
10161
|
3,
|
|
9768
10162
|
(p, m, s) => {
|
|
9769
|
-
|
|
10163
|
+
positive2(s);
|
|
9770
10164
|
return (m ?? 0) + (s ?? 1) * normInv(p);
|
|
9771
10165
|
}
|
|
9772
10166
|
),
|
|
9773
10167
|
numeric(
|
|
9774
10168
|
"NORM.S.INV",
|
|
9775
|
-
|
|
10169
|
+
C32,
|
|
9776
10170
|
"NORM.S.INV(probability)",
|
|
9777
10171
|
"The inverse of the standard normal distribution.",
|
|
9778
10172
|
1,
|
|
@@ -9781,17 +10175,17 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9781
10175
|
),
|
|
9782
10176
|
numeric(
|
|
9783
10177
|
"NORMSINV",
|
|
9784
|
-
|
|
10178
|
+
C32,
|
|
9785
10179
|
"NORMSINV(probability)",
|
|
9786
10180
|
"The inverse of the standard normal distribution.",
|
|
9787
10181
|
1,
|
|
9788
10182
|
1,
|
|
9789
10183
|
normInv
|
|
9790
10184
|
),
|
|
9791
|
-
numeric("PHI",
|
|
10185
|
+
numeric("PHI", C32, "PHI(x)", "The standard normal density.", 1, 1, normPdf),
|
|
9792
10186
|
numeric(
|
|
9793
10187
|
"GAUSS",
|
|
9794
|
-
|
|
10188
|
+
C32,
|
|
9795
10189
|
"GAUSS(z)",
|
|
9796
10190
|
"The probability between the mean and z standard deviations.",
|
|
9797
10191
|
1,
|
|
@@ -9829,14 +10223,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9829
10223
|
...["CONFIDENCE", "CONFIDENCE.NORM"].map(
|
|
9830
10224
|
(name) => numeric(
|
|
9831
10225
|
name,
|
|
9832
|
-
|
|
10226
|
+
C32,
|
|
9833
10227
|
`${name}(alpha, standard_dev, size)`,
|
|
9834
10228
|
"The confidence interval for a population mean (normal).",
|
|
9835
10229
|
3,
|
|
9836
10230
|
3,
|
|
9837
10231
|
(a, s, n2) => {
|
|
9838
10232
|
probability(a);
|
|
9839
|
-
|
|
10233
|
+
positive2(s);
|
|
9840
10234
|
if ((n2 ?? 0) < 1) fail(ERR.NUM);
|
|
9841
10235
|
return normInv(1 - a / 2) * (s ?? 1) / Math.sqrt(Math.trunc(n2 ?? 1));
|
|
9842
10236
|
}
|
|
@@ -9844,14 +10238,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9844
10238
|
),
|
|
9845
10239
|
numeric(
|
|
9846
10240
|
"CONFIDENCE.T",
|
|
9847
|
-
|
|
10241
|
+
C32,
|
|
9848
10242
|
"CONFIDENCE.T(alpha, standard_dev, size)",
|
|
9849
10243
|
"The confidence interval for a population mean (Student's t).",
|
|
9850
10244
|
3,
|
|
9851
10245
|
3,
|
|
9852
10246
|
(a, s, n2) => {
|
|
9853
10247
|
probability(a);
|
|
9854
|
-
|
|
10248
|
+
positive2(s);
|
|
9855
10249
|
const size = Math.trunc(n2 ?? 1);
|
|
9856
10250
|
if (size < 2) fail(ERR.DIV0);
|
|
9857
10251
|
return invert((t) => tCdf(t, size - 1), 1 - a / 2, 0, 10) * (s ?? 1) / Math.sqrt(size);
|
|
@@ -9860,7 +10254,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9860
10254
|
...["BINOM.DIST", "BINOMDIST"].map(
|
|
9861
10255
|
(name) => numeric(
|
|
9862
10256
|
name,
|
|
9863
|
-
|
|
10257
|
+
C32,
|
|
9864
10258
|
`${name}(number_s, trials, probability_s, cumulative)`,
|
|
9865
10259
|
"The binomial distribution probability.",
|
|
9866
10260
|
4,
|
|
@@ -9871,7 +10265,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9871
10265
|
...["POISSON.DIST", "POISSON"].map(
|
|
9872
10266
|
(name) => numeric(
|
|
9873
10267
|
name,
|
|
9874
|
-
|
|
10268
|
+
C32,
|
|
9875
10269
|
`${name}(x, mean, cumulative)`,
|
|
9876
10270
|
"The Poisson distribution.",
|
|
9877
10271
|
3,
|
|
@@ -9882,54 +10276,54 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9882
10276
|
...["EXPON.DIST", "EXPONDIST"].map(
|
|
9883
10277
|
(name) => numeric(
|
|
9884
10278
|
name,
|
|
9885
|
-
|
|
10279
|
+
C32,
|
|
9886
10280
|
`${name}(x, lambda, cumulative)`,
|
|
9887
10281
|
"The exponential distribution.",
|
|
9888
10282
|
3,
|
|
9889
10283
|
3,
|
|
9890
10284
|
(x, l, c2) => {
|
|
9891
10285
|
if (x < 0) fail(ERR.NUM);
|
|
9892
|
-
|
|
10286
|
+
positive2(l);
|
|
9893
10287
|
return c2 ? 1 - Math.exp(-(l ?? 1) * x) : (l ?? 1) * Math.exp(-(l ?? 1) * x);
|
|
9894
10288
|
}
|
|
9895
10289
|
)
|
|
9896
10290
|
),
|
|
9897
10291
|
numeric(
|
|
9898
10292
|
"LOGNORM.DIST",
|
|
9899
|
-
|
|
10293
|
+
C32,
|
|
9900
10294
|
"LOGNORM.DIST(x, mean, standard_dev, cumulative)",
|
|
9901
10295
|
"The lognormal distribution.",
|
|
9902
10296
|
4,
|
|
9903
10297
|
4,
|
|
9904
10298
|
(x, m, s, c2) => {
|
|
9905
|
-
|
|
10299
|
+
positive2(x, s);
|
|
9906
10300
|
const z = (Math.log(x) - (m ?? 0)) / (s ?? 1);
|
|
9907
10301
|
return c2 ? normCdf(z) : normPdf(z) / (x * (s ?? 1));
|
|
9908
10302
|
}
|
|
9909
10303
|
),
|
|
9910
10304
|
numeric(
|
|
9911
10305
|
"LOGNORM.INV",
|
|
9912
|
-
|
|
10306
|
+
C32,
|
|
9913
10307
|
"LOGNORM.INV(probability, mean, standard_dev)",
|
|
9914
10308
|
"The inverse of the lognormal distribution.",
|
|
9915
10309
|
3,
|
|
9916
10310
|
3,
|
|
9917
10311
|
(p, m, s) => {
|
|
9918
|
-
|
|
10312
|
+
positive2(s);
|
|
9919
10313
|
return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
|
|
9920
10314
|
}
|
|
9921
10315
|
),
|
|
9922
10316
|
...["WEIBULL.DIST", "WEIBULL"].map(
|
|
9923
10317
|
(name) => numeric(
|
|
9924
10318
|
name,
|
|
9925
|
-
|
|
10319
|
+
C32,
|
|
9926
10320
|
`${name}(x, alpha, beta, cumulative)`,
|
|
9927
10321
|
"The Weibull distribution.",
|
|
9928
10322
|
4,
|
|
9929
10323
|
4,
|
|
9930
10324
|
(x, a, b, c2) => {
|
|
9931
10325
|
if (x < 0) fail(ERR.NUM);
|
|
9932
|
-
|
|
10326
|
+
positive2(a, b);
|
|
9933
10327
|
const al = a ?? 1;
|
|
9934
10328
|
const be = b ?? 1;
|
|
9935
10329
|
return c2 ? 1 - Math.exp(-Math.pow(x / be, al)) : al / Math.pow(be, al) * Math.pow(x, al - 1) * Math.exp(-Math.pow(x / be, al));
|
|
@@ -9938,14 +10332,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9938
10332
|
),
|
|
9939
10333
|
numeric(
|
|
9940
10334
|
"GAMMA.DIST",
|
|
9941
|
-
|
|
10335
|
+
C32,
|
|
9942
10336
|
"GAMMA.DIST(x, alpha, beta, cumulative)",
|
|
9943
10337
|
"The gamma distribution.",
|
|
9944
10338
|
4,
|
|
9945
10339
|
4,
|
|
9946
10340
|
(x, a, b, c2) => {
|
|
9947
10341
|
if (x < 0) fail(ERR.NUM);
|
|
9948
|
-
|
|
10342
|
+
positive2(a, b);
|
|
9949
10343
|
const al = a ?? 1;
|
|
9950
10344
|
const be = b ?? 1;
|
|
9951
10345
|
return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
|
|
@@ -9954,7 +10348,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9954
10348
|
];
|
|
9955
10349
|
|
|
9956
10350
|
// src/xlsx/formula/functions/text-convert.ts
|
|
9957
|
-
var
|
|
10351
|
+
var C33 = "Text";
|
|
9958
10352
|
var CP1252 = {
|
|
9959
10353
|
128: 8364,
|
|
9960
10354
|
130: 8218,
|
|
@@ -9999,7 +10393,7 @@ function fixed(value, decimals, commas) {
|
|
|
9999
10393
|
var TEXT_CONVERT = [
|
|
10000
10394
|
spec(
|
|
10001
10395
|
"TEXT",
|
|
10002
|
-
|
|
10396
|
+
C33,
|
|
10003
10397
|
"TEXT(value, format_text)",
|
|
10004
10398
|
"Formats a value with a number format.",
|
|
10005
10399
|
2,
|
|
@@ -10012,7 +10406,7 @@ var TEXT_CONVERT = [
|
|
|
10012
10406
|
return formatValue(value, str(args[1]), { date1904: ctx.date1904 }).text;
|
|
10013
10407
|
}
|
|
10014
10408
|
),
|
|
10015
|
-
spec("VALUE",
|
|
10409
|
+
spec("VALUE", C33, "VALUE(text)", "Converts text to a number.", 1, 1, (args) => {
|
|
10016
10410
|
const v = scalar(args[0]);
|
|
10017
10411
|
if (typeof v === "number") return v;
|
|
10018
10412
|
if (v === null) return 0;
|
|
@@ -10022,7 +10416,7 @@ var TEXT_CONVERT = [
|
|
|
10022
10416
|
}),
|
|
10023
10417
|
spec(
|
|
10024
10418
|
"NUMBERVALUE",
|
|
10025
|
-
|
|
10419
|
+
C33,
|
|
10026
10420
|
"NUMBERVALUE(text, [decimal_separator], [group_separator])",
|
|
10027
10421
|
"Converts text to a number with given separators.",
|
|
10028
10422
|
1,
|
|
@@ -10049,7 +10443,7 @@ var TEXT_CONVERT = [
|
|
|
10049
10443
|
),
|
|
10050
10444
|
spec(
|
|
10051
10445
|
"FIXED",
|
|
10052
|
-
|
|
10446
|
+
C33,
|
|
10053
10447
|
"FIXED(number, [decimals], [no_commas])",
|
|
10054
10448
|
"Formats a number as text with fixed decimals.",
|
|
10055
10449
|
1,
|
|
@@ -10058,7 +10452,7 @@ var TEXT_CONVERT = [
|
|
|
10058
10452
|
),
|
|
10059
10453
|
spec(
|
|
10060
10454
|
"DOLLAR",
|
|
10061
|
-
|
|
10455
|
+
C33,
|
|
10062
10456
|
"DOLLAR(number, [decimals])",
|
|
10063
10457
|
"Formats a number as currency text.",
|
|
10064
10458
|
1,
|
|
@@ -10069,28 +10463,28 @@ var TEXT_CONVERT = [
|
|
|
10069
10463
|
return value < 0 && text2.replace(/[0.,]/g, "") !== "" ? `($${text2})` : `$${text2}`;
|
|
10070
10464
|
}
|
|
10071
10465
|
),
|
|
10072
|
-
spec("CHAR",
|
|
10466
|
+
spec("CHAR", C33, "CHAR(number)", "The character for a code (Windows-1252).", 1, 1, (args) => {
|
|
10073
10467
|
const n2 = int(args[0]);
|
|
10074
10468
|
if (n2 < 1 || n2 > 255) fail(ERR.VALUE);
|
|
10075
10469
|
return String.fromCharCode(CP1252[n2] ?? n2);
|
|
10076
10470
|
}),
|
|
10077
|
-
spec("CODE",
|
|
10471
|
+
spec("CODE", C33, "CODE(text)", "The code of the first character (Windows-1252).", 1, 1, (args) => {
|
|
10078
10472
|
const text2 = str(args[0]);
|
|
10079
10473
|
if (text2 === "") fail(ERR.VALUE);
|
|
10080
10474
|
const code = text2.charCodeAt(0);
|
|
10081
10475
|
return CP1252_REVERSE.get(code) ?? (code <= 255 ? code : 63);
|
|
10082
10476
|
}),
|
|
10083
|
-
spec("UNICHAR",
|
|
10477
|
+
spec("UNICHAR", C33, "UNICHAR(number)", "The Unicode character for a code point.", 1, 1, (args) => {
|
|
10084
10478
|
const n2 = int(args[0]);
|
|
10085
10479
|
if (n2 < 1 || n2 > 1114111) fail(ERR.VALUE);
|
|
10086
10480
|
return String.fromCodePoint(n2);
|
|
10087
10481
|
}),
|
|
10088
|
-
spec("UNICODE",
|
|
10482
|
+
spec("UNICODE", C33, "UNICODE(text)", "The code point of the first character.", 1, 1, (args) => {
|
|
10089
10483
|
const text2 = str(args[0]);
|
|
10090
10484
|
if (text2 === "") fail(ERR.VALUE);
|
|
10091
10485
|
return text2.codePointAt(0) ?? fail(ERR.VALUE);
|
|
10092
10486
|
}),
|
|
10093
|
-
spec("T",
|
|
10487
|
+
spec("T", C33, "T(value)", "The text of a value, or empty text.", 1, 1, (args) => {
|
|
10094
10488
|
const v = scalar(args[0]);
|
|
10095
10489
|
if (isError(v)) return v;
|
|
10096
10490
|
return typeof v === "string" ? v : "";
|
|
@@ -10140,7 +10534,7 @@ function right(text2, n2) {
|
|
|
10140
10534
|
}
|
|
10141
10535
|
|
|
10142
10536
|
// src/xlsx/formula/functions/text.ts
|
|
10143
|
-
var
|
|
10537
|
+
var C34 = "Text";
|
|
10144
10538
|
var MAX_TEXT = 32767;
|
|
10145
10539
|
var limit = (text2) => text2.length > MAX_TEXT ? fail(ERR.VALUE) : text2;
|
|
10146
10540
|
function find(args, insensitive) {
|
|
@@ -10173,7 +10567,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10173
10567
|
...TEXT_CONVERT,
|
|
10174
10568
|
spec(
|
|
10175
10569
|
"CONCATENATE",
|
|
10176
|
-
|
|
10570
|
+
C34,
|
|
10177
10571
|
"CONCATENATE(text1, [text2], ...)",
|
|
10178
10572
|
"Joins text items.",
|
|
10179
10573
|
1,
|
|
@@ -10182,7 +10576,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10182
10576
|
),
|
|
10183
10577
|
spec(
|
|
10184
10578
|
"CONCAT",
|
|
10185
|
-
|
|
10579
|
+
C34,
|
|
10186
10580
|
"CONCAT(text1, [text2], ...)",
|
|
10187
10581
|
"Joins text from items and ranges.",
|
|
10188
10582
|
1,
|
|
@@ -10192,7 +10586,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10192
10586
|
),
|
|
10193
10587
|
spec(
|
|
10194
10588
|
"TEXTJOIN",
|
|
10195
|
-
|
|
10589
|
+
C34,
|
|
10196
10590
|
"TEXTJOIN(delimiter, ignore_empty, text1, ...)",
|
|
10197
10591
|
"Joins text with a delimiter.",
|
|
10198
10592
|
3,
|
|
@@ -10211,14 +10605,14 @@ var TEXT_FUNCTIONS = [
|
|
|
10211
10605
|
["any"]
|
|
10212
10606
|
),
|
|
10213
10607
|
...["LEFT", "LEFTB"].map(
|
|
10214
|
-
(name) => spec(name,
|
|
10608
|
+
(name) => spec(name, C34, `${name}(text, [num_chars])`, "The first characters of a text.", 1, 2, (args) => {
|
|
10215
10609
|
const n2 = optNum(args, 1, 1);
|
|
10216
10610
|
if (n2 < 0) fail(ERR.VALUE);
|
|
10217
10611
|
return left(str(args[0]), Math.trunc(n2));
|
|
10218
10612
|
})
|
|
10219
10613
|
),
|
|
10220
10614
|
...["RIGHT", "RIGHTB"].map(
|
|
10221
|
-
(name) => spec(name,
|
|
10615
|
+
(name) => spec(name, C34, `${name}(text, [num_chars])`, "The last characters of a text.", 1, 2, (args) => {
|
|
10222
10616
|
const n2 = Math.trunc(optNum(args, 1, 1));
|
|
10223
10617
|
if (n2 < 0) fail(ERR.VALUE);
|
|
10224
10618
|
return right(str(args[0]), n2);
|
|
@@ -10227,7 +10621,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10227
10621
|
...["MID", "MIDB"].map(
|
|
10228
10622
|
(name) => spec(
|
|
10229
10623
|
name,
|
|
10230
|
-
|
|
10624
|
+
C34,
|
|
10231
10625
|
`${name}(text, start_num, num_chars)`,
|
|
10232
10626
|
"Characters from the middle of a text.",
|
|
10233
10627
|
3,
|
|
@@ -10243,7 +10637,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10243
10637
|
...["LEN", "LENB"].map(
|
|
10244
10638
|
(name) => spec(
|
|
10245
10639
|
name,
|
|
10246
|
-
|
|
10640
|
+
C34,
|
|
10247
10641
|
`${name}(text)`,
|
|
10248
10642
|
"The number of characters in a text.",
|
|
10249
10643
|
1,
|
|
@@ -10253,7 +10647,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10253
10647
|
),
|
|
10254
10648
|
spec(
|
|
10255
10649
|
"LOWER",
|
|
10256
|
-
|
|
10650
|
+
C34,
|
|
10257
10651
|
"LOWER(text)",
|
|
10258
10652
|
"Converts text to lower case.",
|
|
10259
10653
|
1,
|
|
@@ -10262,7 +10656,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10262
10656
|
),
|
|
10263
10657
|
spec(
|
|
10264
10658
|
"UPPER",
|
|
10265
|
-
|
|
10659
|
+
C34,
|
|
10266
10660
|
"UPPER(text)",
|
|
10267
10661
|
"Converts text to upper case.",
|
|
10268
10662
|
1,
|
|
@@ -10271,7 +10665,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10271
10665
|
),
|
|
10272
10666
|
spec(
|
|
10273
10667
|
"PROPER",
|
|
10274
|
-
|
|
10668
|
+
C34,
|
|
10275
10669
|
"PROPER(text)",
|
|
10276
10670
|
"Capitalizes the first letter of each word.",
|
|
10277
10671
|
1,
|
|
@@ -10280,7 +10674,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10280
10674
|
),
|
|
10281
10675
|
spec(
|
|
10282
10676
|
"TRIM",
|
|
10283
|
-
|
|
10677
|
+
C34,
|
|
10284
10678
|
"TRIM(text)",
|
|
10285
10679
|
"Removes extra spaces.",
|
|
10286
10680
|
1,
|
|
@@ -10289,7 +10683,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10289
10683
|
),
|
|
10290
10684
|
spec(
|
|
10291
10685
|
"CLEAN",
|
|
10292
|
-
|
|
10686
|
+
C34,
|
|
10293
10687
|
"CLEAN(text)",
|
|
10294
10688
|
"Removes non-printable characters.",
|
|
10295
10689
|
1,
|
|
@@ -10301,7 +10695,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10301
10695
|
),
|
|
10302
10696
|
spec(
|
|
10303
10697
|
"SUBSTITUTE",
|
|
10304
|
-
|
|
10698
|
+
C34,
|
|
10305
10699
|
"SUBSTITUTE(text, old_text, new_text, [instance_num])",
|
|
10306
10700
|
"Replaces occurrences of a text.",
|
|
10307
10701
|
3,
|
|
@@ -10325,7 +10719,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10325
10719
|
...["REPLACE", "REPLACEB"].map(
|
|
10326
10720
|
(name) => spec(
|
|
10327
10721
|
name,
|
|
10328
|
-
|
|
10722
|
+
C34,
|
|
10329
10723
|
`${name}(old_text, start_num, num_chars, new_text)`,
|
|
10330
10724
|
"Replaces part of a text.",
|
|
10331
10725
|
4,
|
|
@@ -10342,7 +10736,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10342
10736
|
...["FIND", "FINDB"].map(
|
|
10343
10737
|
(name) => spec(
|
|
10344
10738
|
name,
|
|
10345
|
-
|
|
10739
|
+
C34,
|
|
10346
10740
|
`${name}(find_text, within_text, [start_num])`,
|
|
10347
10741
|
"The position of a text (case-sensitive).",
|
|
10348
10742
|
2,
|
|
@@ -10353,7 +10747,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10353
10747
|
...["SEARCH", "SEARCHB"].map(
|
|
10354
10748
|
(name) => spec(
|
|
10355
10749
|
name,
|
|
10356
|
-
|
|
10750
|
+
C34,
|
|
10357
10751
|
`${name}(find_text, within_text, [start_num])`,
|
|
10358
10752
|
"The position of a text (wildcards, any case).",
|
|
10359
10753
|
2,
|
|
@@ -10361,7 +10755,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10361
10755
|
(args) => find(args, true)
|
|
10362
10756
|
)
|
|
10363
10757
|
),
|
|
10364
|
-
spec("REPT",
|
|
10758
|
+
spec("REPT", C34, "REPT(text, number_times)", "Repeats a text.", 2, 2, (args) => {
|
|
10365
10759
|
const n2 = Math.trunc(num(args[1]));
|
|
10366
10760
|
const text2 = str(args[0]);
|
|
10367
10761
|
if (n2 < 0 || text2.length * n2 > MAX_TEXT) fail(ERR.VALUE);
|
|
@@ -10369,7 +10763,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10369
10763
|
}),
|
|
10370
10764
|
spec(
|
|
10371
10765
|
"EXACT",
|
|
10372
|
-
|
|
10766
|
+
C34,
|
|
10373
10767
|
"EXACT(text1, text2)",
|
|
10374
10768
|
"Whether two texts are identical (case-sensitive).",
|
|
10375
10769
|
2,
|
|
@@ -10378,8 +10772,78 @@ var TEXT_FUNCTIONS = [
|
|
|
10378
10772
|
)
|
|
10379
10773
|
];
|
|
10380
10774
|
|
|
10775
|
+
// src/xlsx/formula/functions/text-regex.ts
|
|
10776
|
+
var C35 = "Text";
|
|
10777
|
+
function compile(pattern, caseMode2, global) {
|
|
10778
|
+
if (caseMode2 !== 0 && caseMode2 !== 1) fail(ERR.VALUE);
|
|
10779
|
+
try {
|
|
10780
|
+
return new RegExp(pattern, `${global ? "g" : ""}${caseMode2 === 1 ? "i" : ""}u`);
|
|
10781
|
+
} catch {
|
|
10782
|
+
return fail(ERR.VALUE);
|
|
10783
|
+
}
|
|
10784
|
+
}
|
|
10785
|
+
var caseMode = (args, index2) => optNum(args, index2, 0);
|
|
10786
|
+
function encodeUrl(text2) {
|
|
10787
|
+
return encodeURIComponent(text2).replace(
|
|
10788
|
+
/[!'()*]/g,
|
|
10789
|
+
(c2) => `%${c2.charCodeAt(0).toString(16).toUpperCase()}`
|
|
10790
|
+
);
|
|
10791
|
+
}
|
|
10792
|
+
var TEXT_REGEX_FUNCTIONS = [
|
|
10793
|
+
spec(
|
|
10794
|
+
"ENCODEURL",
|
|
10795
|
+
C35,
|
|
10796
|
+
"ENCODEURL(text)",
|
|
10797
|
+
"Percent-encodes text for use in a URL.",
|
|
10798
|
+
1,
|
|
10799
|
+
1,
|
|
10800
|
+
(args) => encodeUrl(str(args[0]))
|
|
10801
|
+
),
|
|
10802
|
+
spec(
|
|
10803
|
+
"REGEXTEST",
|
|
10804
|
+
C35,
|
|
10805
|
+
"REGEXTEST(text, pattern, [case_sensitivity])",
|
|
10806
|
+
"Whether any part of the text matches the pattern.",
|
|
10807
|
+
2,
|
|
10808
|
+
3,
|
|
10809
|
+
(args) => compile(str(args[1]), caseMode(args, 2), false).test(str(args[0]))
|
|
10810
|
+
),
|
|
10811
|
+
spec(
|
|
10812
|
+
"REGEXEXTRACT",
|
|
10813
|
+
C35,
|
|
10814
|
+
"REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])",
|
|
10815
|
+
"The first part of the text that matches the pattern.",
|
|
10816
|
+
2,
|
|
10817
|
+
4,
|
|
10818
|
+
(args) => {
|
|
10819
|
+
if (optNum(args, 2, 0) !== 0) fail(ERR.VALUE);
|
|
10820
|
+
const match2 = compile(str(args[1]), caseMode(args, 3), false).exec(str(args[0]));
|
|
10821
|
+
return match2 ? match2[0] : fail(ERR.NA);
|
|
10822
|
+
}
|
|
10823
|
+
),
|
|
10824
|
+
spec(
|
|
10825
|
+
"REGEXREPLACE",
|
|
10826
|
+
C35,
|
|
10827
|
+
"REGEXREPLACE(text, pattern, replacement, [occurrence], [case_sensitivity])",
|
|
10828
|
+
"Replaces the parts of the text that match the pattern.",
|
|
10829
|
+
3,
|
|
10830
|
+
5,
|
|
10831
|
+
(args) => {
|
|
10832
|
+
const text2 = str(args[0]);
|
|
10833
|
+
const regex = compile(str(args[1]), caseMode(args, 4), true);
|
|
10834
|
+
const replacement = str(args[2]);
|
|
10835
|
+
const occurrence = args.length > 3 && args[3] !== null ? int(args[3]) : 0;
|
|
10836
|
+
if (occurrence === 0) return text2.replace(regex, replacement);
|
|
10837
|
+
const matches2 = [...text2.matchAll(regex)];
|
|
10838
|
+
const picked = occurrence > 0 ? matches2[occurrence - 1] : matches2.at(occurrence);
|
|
10839
|
+
if (!picked || picked.index === void 0) return text2;
|
|
10840
|
+
return text2.slice(0, picked.index) + picked[0].replace(new RegExp(regex.source, regex.flags.replace("g", "")), replacement) + text2.slice(picked.index + picked[0].length);
|
|
10841
|
+
}
|
|
10842
|
+
)
|
|
10843
|
+
];
|
|
10844
|
+
|
|
10381
10845
|
// src/xlsx/formula/functions/text-extra.ts
|
|
10382
|
-
var
|
|
10846
|
+
var C36 = "Text";
|
|
10383
10847
|
function delimitersOf(ctx, value) {
|
|
10384
10848
|
if (value === void 0 || value === null) return [];
|
|
10385
10849
|
return ctx.toMatrix(value).flat().map((v) => {
|
|
@@ -10445,9 +10909,10 @@ function valueToText(value, strict) {
|
|
|
10445
10909
|
return toText(value);
|
|
10446
10910
|
}
|
|
10447
10911
|
var TEXT_EXTRA_FUNCTIONS = [
|
|
10912
|
+
...TEXT_REGEX_FUNCTIONS,
|
|
10448
10913
|
spec(
|
|
10449
10914
|
"TEXTBEFORE",
|
|
10450
|
-
|
|
10915
|
+
C36,
|
|
10451
10916
|
"TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
|
|
10452
10917
|
"The text before a delimiter.",
|
|
10453
10918
|
2,
|
|
@@ -10457,7 +10922,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
10457
10922
|
),
|
|
10458
10923
|
spec(
|
|
10459
10924
|
"TEXTAFTER",
|
|
10460
|
-
|
|
10925
|
+
C36,
|
|
10461
10926
|
"TEXTAFTER(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
|
|
10462
10927
|
"The text after a delimiter.",
|
|
10463
10928
|
2,
|
|
@@ -10467,7 +10932,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
10467
10932
|
),
|
|
10468
10933
|
spec(
|
|
10469
10934
|
"TEXTSPLIT",
|
|
10470
|
-
|
|
10935
|
+
C36,
|
|
10471
10936
|
"TEXTSPLIT(text, col_delimiter, [row_delimiter], [ignore_empty], [match_mode], [pad_with])",
|
|
10472
10937
|
"Splits text into an array.",
|
|
10473
10938
|
2,
|
|
@@ -10490,7 +10955,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
10490
10955
|
),
|
|
10491
10956
|
spec(
|
|
10492
10957
|
"VALUETOTEXT",
|
|
10493
|
-
|
|
10958
|
+
C36,
|
|
10494
10959
|
"VALUETOTEXT(value, [format])",
|
|
10495
10960
|
"Text for any value.",
|
|
10496
10961
|
1,
|
|
@@ -10499,7 +10964,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
10499
10964
|
),
|
|
10500
10965
|
spec(
|
|
10501
10966
|
"ARRAYTOTEXT",
|
|
10502
|
-
|
|
10967
|
+
C36,
|
|
10503
10968
|
"ARRAYTOTEXT(array, [format])",
|
|
10504
10969
|
"Text for an array.",
|
|
10505
10970
|
1,
|
|
@@ -11265,6 +11730,8 @@ var EngineHost = class {
|
|
|
11265
11730
|
inProgress = /* @__PURE__ */ new Set();
|
|
11266
11731
|
cycles = /* @__PURE__ */ new Set();
|
|
11267
11732
|
dynamicCycleHits = /* @__PURE__ */ new Set();
|
|
11733
|
+
/** Set while a circular group is iterated: reads of a formula in progress see its stored value. */
|
|
11734
|
+
iterating = false;
|
|
11268
11735
|
pending;
|
|
11269
11736
|
columnIndex;
|
|
11270
11737
|
reverseIndex;
|
|
@@ -11304,6 +11771,7 @@ var EngineHost = class {
|
|
|
11304
11771
|
const node = this.nodes.get(sheet)?.get(cellKey(row2, col));
|
|
11305
11772
|
if (!node) return;
|
|
11306
11773
|
if (this.inProgress.has(node)) {
|
|
11774
|
+
if (this.iterating) return;
|
|
11307
11775
|
this.dynamicCycleHits.add(node);
|
|
11308
11776
|
this.dynamicCycleHit = true;
|
|
11309
11777
|
this.cycleReads++;
|
|
@@ -11622,6 +12090,10 @@ function storeResult(sheet, node, cell, result2, claims) {
|
|
|
11622
12090
|
|
|
11623
12091
|
// src/xlsx/formula/engine-core.ts
|
|
11624
12092
|
var MAX_ROUNDS = 8;
|
|
12093
|
+
function valueChange(before, after) {
|
|
12094
|
+
if (typeof before === "number" && typeof after === "number") return Math.abs(after - before);
|
|
12095
|
+
return before === after ? 0 : Number.POSITIVE_INFINITY;
|
|
12096
|
+
}
|
|
11625
12097
|
var EngineCore = class extends EngineHost {
|
|
11626
12098
|
releaseAllSpills() {
|
|
11627
12099
|
for (const sheet of this.workbook.sheets) {
|
|
@@ -11707,7 +12179,9 @@ var EngineCore = class extends EngineHost {
|
|
|
11707
12179
|
for (const component of order.components) {
|
|
11708
12180
|
const first3 = component.nodes[0];
|
|
11709
12181
|
if (component.cyclic) {
|
|
11710
|
-
|
|
12182
|
+
const iterate = this.workbook.iterate;
|
|
12183
|
+
if (iterate) this.iterateGroup(component.nodes, iterate);
|
|
12184
|
+
else for (const node of component.nodes) this.markCycle(node);
|
|
11711
12185
|
} else if (this.pending.has(first3)) {
|
|
11712
12186
|
this.computeFrom(first3);
|
|
11713
12187
|
}
|
|
@@ -11749,6 +12223,30 @@ var EngineCore = class extends EngineHost {
|
|
|
11749
12223
|
}
|
|
11750
12224
|
}
|
|
11751
12225
|
}
|
|
12226
|
+
/**
|
|
12227
|
+
* Iterative calculation of a circular group (`calcPr iterate`): every member is recomputed in
|
|
12228
|
+
* turn, reading the others' values from the previous step, until the largest change is within
|
|
12229
|
+
* `delta` or `count` passes have run. The group starts from the values the cells hold.
|
|
12230
|
+
*/
|
|
12231
|
+
iterateGroup(nodes, limits) {
|
|
12232
|
+
for (const node of nodes) this.pending?.delete(node);
|
|
12233
|
+
const cellOf2 = (node) => this.workbook.sheets[node.sheet]?.rows.get(node.row)?.get(node.col);
|
|
12234
|
+
this.iterating = true;
|
|
12235
|
+
try {
|
|
12236
|
+
for (let pass = 0; pass < limits.count; pass++) {
|
|
12237
|
+
let change = 0;
|
|
12238
|
+
for (const node of nodes) {
|
|
12239
|
+
const before = cellOf2(node)?.value ?? null;
|
|
12240
|
+
this.compute(node);
|
|
12241
|
+
const after = cellOf2(node)?.value ?? null;
|
|
12242
|
+
change = Math.max(change, valueChange(before, after));
|
|
12243
|
+
}
|
|
12244
|
+
if (change <= limits.delta) break;
|
|
12245
|
+
}
|
|
12246
|
+
} finally {
|
|
12247
|
+
this.iterating = false;
|
|
12248
|
+
}
|
|
12249
|
+
}
|
|
11752
12250
|
markCycle(node) {
|
|
11753
12251
|
this.pending?.delete(node);
|
|
11754
12252
|
this.cycles.add(node);
|
|
@@ -13762,8 +14260,14 @@ function parseWorkbookPart(xml) {
|
|
|
13762
14260
|
const protection = xFirst(root, "workbookProtection");
|
|
13763
14261
|
const password = att(protection, "workbookPassword");
|
|
13764
14262
|
const modernHash = readModernHash(protection, "workbook");
|
|
13765
|
-
const
|
|
14263
|
+
const calcPr = xFirst(root, "calcPr");
|
|
14264
|
+
const calcMode = att(calcPr, "calcMode");
|
|
14265
|
+
const iterate = boolAttr(calcPr, "iterate", false) ? {
|
|
14266
|
+
count: numAttr(calcPr, "iterateCount") ?? 100,
|
|
14267
|
+
delta: numAttr(calcPr, "iterateDelta") ?? 1e-3
|
|
14268
|
+
} : void 0;
|
|
13766
14269
|
return {
|
|
14270
|
+
...iterate ? { iterate } : {},
|
|
13767
14271
|
...password ? { workbookPasswordHash: password } : {},
|
|
13768
14272
|
...modernHash ? { workbookModernHash: modernHash } : {},
|
|
13769
14273
|
...calcMode === "manual" ? { calcMode: "manual" } : {},
|
|
@@ -15911,6 +16415,7 @@ async function loadXlsx(input) {
|
|
|
15911
16415
|
if (book.workbookPasswordHash) workbook.workbookPasswordHash = book.workbookPasswordHash;
|
|
15912
16416
|
if (book.workbookModernHash) workbook.workbookModernHash = book.workbookModernHash;
|
|
15913
16417
|
if (book.calcMode) workbook.calcMode = book.calcMode;
|
|
16418
|
+
if (book.iterate) workbook.iterate = book.iterate;
|
|
15914
16419
|
if (signatures.hasSignatures)
|
|
15915
16420
|
workbook.signatures = { count: signatures.signatureCount, parts: signatures.signaturePaths };
|
|
15916
16421
|
if (!sheets.length) throw new Error("XLSX workbook has no sheets");
|
|
@@ -16586,16 +17091,16 @@ function shiftIndexClamped(index2, shift2) {
|
|
|
16586
17091
|
}
|
|
16587
17092
|
function shiftRange(range, shift2) {
|
|
16588
17093
|
if (shift2.axis === "row") {
|
|
16589
|
-
const
|
|
16590
|
-
return
|
|
16591
|
-
start: { row:
|
|
16592
|
-
end: { row:
|
|
17094
|
+
const span4 = shiftSpan(range.start.row, range.end.row, shift2);
|
|
17095
|
+
return span4 && {
|
|
17096
|
+
start: { row: span4.start, col: range.start.col },
|
|
17097
|
+
end: { row: span4.end, col: range.end.col }
|
|
16593
17098
|
};
|
|
16594
17099
|
}
|
|
16595
|
-
const
|
|
16596
|
-
return
|
|
16597
|
-
start: { row: range.start.row, col:
|
|
16598
|
-
end: { row: range.end.row, col:
|
|
17100
|
+
const span3 = shiftSpan(range.start.col, range.end.col, shift2);
|
|
17101
|
+
return span3 && {
|
|
17102
|
+
start: { row: range.start.row, col: span3.start },
|
|
17103
|
+
end: { row: range.end.row, col: span3.end }
|
|
16599
17104
|
};
|
|
16600
17105
|
}
|
|
16601
17106
|
function shiftRangeInBand(range, shift2, lo, hi) {
|
|
@@ -17407,7 +17912,9 @@ function workbookXml(workbook, sheets, activeTab, sourceXml) {
|
|
|
17407
17912
|
).join("")}</definedNames>`;
|
|
17408
17913
|
const calc = kept.get("calcPr");
|
|
17409
17914
|
const mode = workbook.calcMode === "manual" ? ' calcMode="manual"' : "";
|
|
17410
|
-
|
|
17915
|
+
const iterate = workbook.iterate ? ` iterate="1" iterateCount="${workbook.iterate.count}" iterateDelta="${workbook.iterate.delta}"` : "";
|
|
17916
|
+
const owned = ["fullCalcOnLoad", "calcId", "calcMode", "iterate", "iterateCount", "iterateDelta"];
|
|
17917
|
+
out += `<calcPr${copyAttrs(calc, owned)} calcId="191029"${mode}${iterate} fullCalcOnLoad="1"/>`;
|
|
17411
17918
|
out += raw(KEPT_TAIL);
|
|
17412
17919
|
return `${out}</workbook>`;
|
|
17413
17920
|
}
|
|
@@ -19597,8 +20104,8 @@ function shiftAxisFormats(sheet, shift2) {
|
|
|
19597
20104
|
}
|
|
19598
20105
|
sheet.columns = normalizeColumns(
|
|
19599
20106
|
sheet.columns.flatMap((info) => {
|
|
19600
|
-
const
|
|
19601
|
-
return
|
|
20107
|
+
const span3 = shiftSpan(info.min, info.max, shift2);
|
|
20108
|
+
return span3 ? [{ ...info, min: span3.start, max: span3.end }] : [];
|
|
19602
20109
|
})
|
|
19603
20110
|
);
|
|
19604
20111
|
}
|
|
@@ -19775,11 +20282,11 @@ function toHtml(cells, theme2) {
|
|
|
19775
20282
|
if (covered.has(`${r},${c2}`)) continue;
|
|
19776
20283
|
const cell = cells.data[r]?.[c2] ?? null;
|
|
19777
20284
|
const attrs2 = [];
|
|
19778
|
-
const
|
|
19779
|
-
if (
|
|
19780
|
-
attrs2.push(`rowspan="${
|
|
19781
|
-
if (
|
|
19782
|
-
attrs2.push(`colspan="${
|
|
20285
|
+
const span3 = spans2.get(`${r},${c2}`);
|
|
20286
|
+
if (span3 && span3.end.row > span3.start.row)
|
|
20287
|
+
attrs2.push(`rowspan="${span3.end.row - span3.start.row + 1}"`);
|
|
20288
|
+
if (span3 && span3.end.col > span3.start.col)
|
|
20289
|
+
attrs2.push(`colspan="${span3.end.col - span3.start.col + 1}"`);
|
|
19783
20290
|
if (cell && typeof cell.value === "number") attrs2.push(`x:num="${cell.value}"`);
|
|
19784
20291
|
const css = cssFor(cell?.style, theme2);
|
|
19785
20292
|
if (css) attrs2.push(`style="${escapeHtml(css)}"`);
|
|
@@ -21997,7 +22504,7 @@ var MAX_OUTLINE_LEVEL = 7;
|
|
|
21997
22504
|
function nextLevel(level, delta) {
|
|
21998
22505
|
return Math.max(0, Math.min(MAX_OUTLINE_LEVEL, (level ?? 0) + delta));
|
|
21999
22506
|
}
|
|
22000
|
-
function
|
|
22507
|
+
function span2(from, to) {
|
|
22001
22508
|
const lo = Math.max(0, Math.min(from, to));
|
|
22002
22509
|
const hi = Math.max(from, to);
|
|
22003
22510
|
return Array.from({ length: hi - lo + 1 }, (_v, i) => lo + i);
|
|
@@ -22009,7 +22516,7 @@ function outlineRows(ctx, s, from, to, delta) {
|
|
|
22009
22516
|
"structure",
|
|
22010
22517
|
[{ kind: "sheet", sheet: s }],
|
|
22011
22518
|
() => {
|
|
22012
|
-
for (const row2 of
|
|
22519
|
+
for (const row2 of span2(from, to)) {
|
|
22013
22520
|
const info = { ...sheet.rowInfo.get(row2) };
|
|
22014
22521
|
const level = nextLevel(info.outlineLevel, delta);
|
|
22015
22522
|
if (level) info.outlineLevel = level;
|
|
@@ -22030,7 +22537,7 @@ function outlineColumns(ctx, s, from, to, delta) {
|
|
|
22030
22537
|
delta > 0 ? "Group columns" : "Ungroup columns",
|
|
22031
22538
|
"structure",
|
|
22032
22539
|
[{ kind: "sheet", sheet: s }],
|
|
22033
|
-
() => editColumns(sheet,
|
|
22540
|
+
() => editColumns(sheet, span2(from, to), (info) => {
|
|
22034
22541
|
const level = nextLevel(info.outlineLevel, delta);
|
|
22035
22542
|
if (level) info.outlineLevel = level;
|
|
22036
22543
|
else {
|
|
@@ -25151,8 +25658,8 @@ function axes2(model, area, out) {
|
|
|
25151
25658
|
w: Math.max(1, area.w - labelW - 4),
|
|
25152
25659
|
h: Math.max(1, area.h - 20)
|
|
25153
25660
|
};
|
|
25154
|
-
const
|
|
25155
|
-
const value = horizontal ? (v) => plot.x + (v - scale2.min) /
|
|
25661
|
+
const span3 = scale2.max - scale2.min || 1;
|
|
25662
|
+
const value = horizontal ? (v) => plot.x + (v - scale2.min) / span3 * plot.w : (v) => plot.y + plot.h - (v - scale2.min) / span3 * plot.h;
|
|
25156
25663
|
const bandSize = (horizontal ? plot.h : plot.w) / cats;
|
|
25157
25664
|
const band = horizontal ? (i) => plot.y + plot.h - bandSize * (i + 0.5) : (i) => plot.x + bandSize * (i + 0.5);
|
|
25158
25665
|
scale2.ticks.forEach((t, i) => {
|