ooxml-core 0.16.0 → 0.18.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/docx/document-stats.d.ts +18 -0
- package/dist/docx/document-stats.d.ts.map +1 -0
- package/dist/docx/index.cjs +34 -0
- package/dist/docx/index.d.ts +1 -0
- package/dist/docx/index.d.ts.map +1 -1
- package/dist/docx/index.mjs +33 -1
- package/dist/xlsx/formula/editor-text.d.ts +60 -0
- package/dist/xlsx/formula/editor-text.d.ts.map +1 -0
- 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/formula/index.d.ts +1 -0
- package/dist/xlsx/formula/index.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +1021 -343
- package/dist/xlsx/index.mjs +1008 -344
- 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 +2 -1
package/dist/xlsx/index.mjs
CHANGED
|
@@ -4963,6 +4963,67 @@ var ENGINEERING_FUNCTIONS = [
|
|
|
4963
4963
|
)
|
|
4964
4964
|
];
|
|
4965
4965
|
|
|
4966
|
+
// src/xlsx/formula/functions/coupons.ts
|
|
4967
|
+
var C8 = "Financial";
|
|
4968
|
+
function checkSecurity(settlement, maturity, frequency2, basis) {
|
|
4969
|
+
if (![1, 2, 4].includes(frequency2) || basis < 0 || basis > 4 || settlement >= maturity)
|
|
4970
|
+
fail(ERR.NUM);
|
|
4971
|
+
}
|
|
4972
|
+
function couponFacts(settlement, maturity, frequency2, basis, ctx) {
|
|
4973
|
+
const [s, m] = [Math.floor(settlement), Math.floor(maturity)];
|
|
4974
|
+
checkSecurity(s, m, frequency2, basis);
|
|
4975
|
+
const months = 12 / frequency2;
|
|
4976
|
+
const { year, month, day } = serialToYmd(m, ctx.date1904);
|
|
4977
|
+
const monthEnd = day === daysInMonth(year, month);
|
|
4978
|
+
let count2 = 0;
|
|
4979
|
+
let next = m;
|
|
4980
|
+
let previous = addMonths(m, -months, ctx, monthEnd);
|
|
4981
|
+
while (previous > s) {
|
|
4982
|
+
count2 += 1;
|
|
4983
|
+
next = previous;
|
|
4984
|
+
previous = addMonths(m, -months * (count2 + 1), ctx, monthEnd);
|
|
4985
|
+
}
|
|
4986
|
+
count2 += 1;
|
|
4987
|
+
const dayCount = (a, b, european) => basis === 0 || basis === 4 ? days360(a, b, basis === 4 || european, ctx) : b - a;
|
|
4988
|
+
const daysSincePrevious = dayCount(previous, s, false);
|
|
4989
|
+
const daysInPeriod = basis === 1 ? next - previous : basis === 3 ? 365 / frequency2 : 360 / frequency2;
|
|
4990
|
+
const daysToNext = basis === 0 ? daysInPeriod - daysSincePrevious : basis === 4 ? days360(s, next, true, ctx) : next - s;
|
|
4991
|
+
return { previous, next, count: count2, daysSincePrevious, daysInPeriod, daysToNext };
|
|
4992
|
+
}
|
|
4993
|
+
var security = (name, description, pick2) => spec(
|
|
4994
|
+
name,
|
|
4995
|
+
C8,
|
|
4996
|
+
`${name}(settlement, maturity, frequency, [basis])`,
|
|
4997
|
+
description,
|
|
4998
|
+
3,
|
|
4999
|
+
4,
|
|
5000
|
+
(args, ctx) => pick2(
|
|
5001
|
+
couponFacts(
|
|
5002
|
+
serialArg(args[0]),
|
|
5003
|
+
serialArg(args[1]),
|
|
5004
|
+
int(args[2]),
|
|
5005
|
+
args.length > 3 && args[3] !== null ? int(args[3]) : 0,
|
|
5006
|
+
ctx
|
|
5007
|
+
)
|
|
5008
|
+
)
|
|
5009
|
+
);
|
|
5010
|
+
var COUPON_FUNCTIONS = [
|
|
5011
|
+
security("COUPPCD", "The coupon date before the settlement date.", (f) => f.previous),
|
|
5012
|
+
security("COUPNCD", "The coupon date after the settlement date.", (f) => f.next),
|
|
5013
|
+
security("COUPNUM", "The number of coupons between settlement and maturity.", (f) => f.count),
|
|
5014
|
+
security(
|
|
5015
|
+
"COUPDAYBS",
|
|
5016
|
+
"The days from the start of the coupon period to settlement.",
|
|
5017
|
+
(f) => f.daysSincePrevious
|
|
5018
|
+
),
|
|
5019
|
+
security(
|
|
5020
|
+
"COUPDAYS",
|
|
5021
|
+
"The days in the coupon period that contains the settlement date.",
|
|
5022
|
+
(f) => f.daysInPeriod
|
|
5023
|
+
),
|
|
5024
|
+
security("COUPDAYSNC", "The days from settlement to the next coupon date.", (f) => f.daysToNext)
|
|
5025
|
+
];
|
|
5026
|
+
|
|
4966
5027
|
// src/xlsx/formula/functions/financial-core.ts
|
|
4967
5028
|
function pmt(rate, nper, pv2, fv2 = 0, type = 0) {
|
|
4968
5029
|
if (nper === 0) fail(ERR.NUM);
|
|
@@ -5032,12 +5093,185 @@ function cumulative(args, principal) {
|
|
|
5032
5093
|
return total2;
|
|
5033
5094
|
}
|
|
5034
5095
|
|
|
5096
|
+
// src/xlsx/formula/functions/bonds.ts
|
|
5097
|
+
var C9 = "Financial";
|
|
5098
|
+
var basisOf = (args, index2) => {
|
|
5099
|
+
const basis = args.length > index2 && args[index2] !== null ? int(args[index2]) : 0;
|
|
5100
|
+
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
5101
|
+
return basis;
|
|
5102
|
+
};
|
|
5103
|
+
function pricePerHundred(facts, rate, yld, redemption, frequency2) {
|
|
5104
|
+
const { count: n2, daysSincePrevious: a, daysInPeriod: e, daysToNext: dsc } = facts;
|
|
5105
|
+
const coupon = 100 * rate / frequency2;
|
|
5106
|
+
const accrued = coupon * (a / e);
|
|
5107
|
+
if (n2 === 1) return (redemption + coupon) / (1 + dsc / e * yld / frequency2) - accrued;
|
|
5108
|
+
let price = redemption / (1 + yld / frequency2) ** (n2 - 1 + dsc / e);
|
|
5109
|
+
for (let k = 1; k <= n2; k++) price += coupon / (1 + yld / frequency2) ** (k - 1 + dsc / e);
|
|
5110
|
+
return price - accrued;
|
|
5111
|
+
}
|
|
5112
|
+
function bondOf(args, ctx, redemptionAt, basisAt) {
|
|
5113
|
+
const frequency2 = int(args[5]);
|
|
5114
|
+
const facts = couponFacts(
|
|
5115
|
+
serialArg(args[0]),
|
|
5116
|
+
serialArg(args[1]),
|
|
5117
|
+
frequency2,
|
|
5118
|
+
basisOf(args, basisAt),
|
|
5119
|
+
ctx
|
|
5120
|
+
);
|
|
5121
|
+
return { facts, rate: num(args[2]), redemption: num(args[redemptionAt]), frequency: frequency2 };
|
|
5122
|
+
}
|
|
5123
|
+
function duration(bond, yld) {
|
|
5124
|
+
const { facts, rate, frequency: frequency2 } = bond;
|
|
5125
|
+
const { count: n2, daysInPeriod: e, daysToNext: dsc } = facts;
|
|
5126
|
+
const coupon = 100 * rate / frequency2;
|
|
5127
|
+
let weighted = 0;
|
|
5128
|
+
let total2 = 0;
|
|
5129
|
+
for (let k = 1; k <= n2; k++) {
|
|
5130
|
+
const periods = k - 1 + dsc / e;
|
|
5131
|
+
const flow = k === n2 ? coupon + 100 : coupon;
|
|
5132
|
+
const value = flow / (1 + yld / frequency2) ** periods;
|
|
5133
|
+
weighted += periods / frequency2 * value;
|
|
5134
|
+
total2 += value;
|
|
5135
|
+
}
|
|
5136
|
+
return weighted / total2;
|
|
5137
|
+
}
|
|
5138
|
+
function quasiPeriods(anchor, from, to, frequency2, ctx) {
|
|
5139
|
+
const months = 12 / frequency2;
|
|
5140
|
+
const { year, month, day } = serialToYmd(anchor, ctx.date1904);
|
|
5141
|
+
const monthEnd = day === daysInMonth(year, month);
|
|
5142
|
+
const at = (k) => addMonths(anchor, k * months, ctx, monthEnd);
|
|
5143
|
+
let back = 0;
|
|
5144
|
+
while (at(back) > from) back -= 1;
|
|
5145
|
+
const dates = [];
|
|
5146
|
+
for (let k = back; ; k++) {
|
|
5147
|
+
dates.push(at(k));
|
|
5148
|
+
if (at(k) >= to) break;
|
|
5149
|
+
}
|
|
5150
|
+
return dates;
|
|
5151
|
+
}
|
|
5152
|
+
function accruedInterest(args, ctx) {
|
|
5153
|
+
const issue = serialArg(args[0]);
|
|
5154
|
+
const first3 = serialArg(args[1]);
|
|
5155
|
+
const settlement = serialArg(args[2]);
|
|
5156
|
+
const [rate, par] = [num(args[3]), optNum(args, 4, 1e3)];
|
|
5157
|
+
const frequency2 = int(args[5]);
|
|
5158
|
+
const basis = basisOf(args, 6);
|
|
5159
|
+
const fromIssue = args.length > 7 && args[7] !== null ? bool(args[7]) : true;
|
|
5160
|
+
if (rate <= 0 || par <= 0 || ![1, 2, 4].includes(frequency2) || issue >= settlement) fail(ERR.NUM);
|
|
5161
|
+
const start = fromIssue ? issue : Math.max(issue, first3);
|
|
5162
|
+
if (start >= settlement) return 0;
|
|
5163
|
+
const dates = quasiPeriods(first3, start, settlement, frequency2, ctx);
|
|
5164
|
+
const count2 = (a, b) => basis === 0 || basis === 4 ? days360(a, b, basis === 4, ctx) : b - a;
|
|
5165
|
+
let sum2 = 0;
|
|
5166
|
+
for (let i = 0; i + 1 < dates.length; i++) {
|
|
5167
|
+
const [p, q] = [dates[i], dates[i + 1]];
|
|
5168
|
+
const a = count2(Math.max(start, p), Math.min(settlement, q));
|
|
5169
|
+
if (a <= 0) continue;
|
|
5170
|
+
const length = basis === 1 ? q - p : basis === 3 ? 365 / frequency2 : 360 / frequency2;
|
|
5171
|
+
sum2 += a / length;
|
|
5172
|
+
}
|
|
5173
|
+
return par * rate / frequency2 * sum2;
|
|
5174
|
+
}
|
|
5175
|
+
var BOND_ARGS = (name, third, fourth, fifth) => `${name}(settlement, maturity, ${third}, ${fourth}, ${fifth}, frequency, [basis])`;
|
|
5176
|
+
var BOND_FUNCTIONS = [
|
|
5177
|
+
spec(
|
|
5178
|
+
"PRICE",
|
|
5179
|
+
C9,
|
|
5180
|
+
BOND_ARGS("PRICE", "rate", "yld", "redemption"),
|
|
5181
|
+
"The price per 100 face value of a security that pays periodic interest.",
|
|
5182
|
+
6,
|
|
5183
|
+
7,
|
|
5184
|
+
(args, ctx) => {
|
|
5185
|
+
const bond = bondOf(args, ctx, 4, 6);
|
|
5186
|
+
const yld = num(args[3]);
|
|
5187
|
+
if (bond.rate < 0 || yld < 0 || bond.redemption <= 0) fail(ERR.NUM);
|
|
5188
|
+
return pricePerHundred(bond.facts, bond.rate, yld, bond.redemption, bond.frequency);
|
|
5189
|
+
}
|
|
5190
|
+
),
|
|
5191
|
+
spec(
|
|
5192
|
+
"YIELD",
|
|
5193
|
+
C9,
|
|
5194
|
+
BOND_ARGS("YIELD", "rate", "pr", "redemption"),
|
|
5195
|
+
"The yield of a security that pays periodic interest.",
|
|
5196
|
+
6,
|
|
5197
|
+
7,
|
|
5198
|
+
(args, ctx) => {
|
|
5199
|
+
const bond = bondOf(args, ctx, 4, 6);
|
|
5200
|
+
const price = num(args[3]);
|
|
5201
|
+
if (bond.rate < 0 || price <= 0 || bond.redemption <= 0) fail(ERR.NUM);
|
|
5202
|
+
const f = (y) => pricePerHundred(bond.facts, bond.rate, y, bond.redemption, bond.frequency) - price;
|
|
5203
|
+
return solve(f, bond.rate || 0.05);
|
|
5204
|
+
}
|
|
5205
|
+
),
|
|
5206
|
+
...["DURATION", "MDURATION"].map(
|
|
5207
|
+
(name) => spec(
|
|
5208
|
+
name,
|
|
5209
|
+
C9,
|
|
5210
|
+
`${name}(settlement, maturity, coupon, yld, frequency, [basis])`,
|
|
5211
|
+
name === "DURATION" ? "The Macaulay duration of a security with periodic interest." : "The modified Macaulay duration of a security.",
|
|
5212
|
+
5,
|
|
5213
|
+
6,
|
|
5214
|
+
(args, ctx) => {
|
|
5215
|
+
const frequency2 = int(args[4]);
|
|
5216
|
+
const facts = couponFacts(
|
|
5217
|
+
serialArg(args[0]),
|
|
5218
|
+
serialArg(args[1]),
|
|
5219
|
+
frequency2,
|
|
5220
|
+
basisOf(args, 5),
|
|
5221
|
+
ctx
|
|
5222
|
+
);
|
|
5223
|
+
const [rate, yld] = [num(args[2]), num(args[3])];
|
|
5224
|
+
if (rate < 0 || yld < 0) fail(ERR.NUM);
|
|
5225
|
+
const macaulay = duration({ facts, rate, frequency: frequency2 }, yld);
|
|
5226
|
+
return name === "DURATION" ? macaulay : macaulay / (1 + yld / frequency2);
|
|
5227
|
+
}
|
|
5228
|
+
)
|
|
5229
|
+
),
|
|
5230
|
+
spec(
|
|
5231
|
+
"ACCRINT",
|
|
5232
|
+
C9,
|
|
5233
|
+
"ACCRINT(issue, first_interest, settlement, rate, par, frequency, [basis], [calc_method])",
|
|
5234
|
+
"The accrued interest of a security that pays periodic interest.",
|
|
5235
|
+
6,
|
|
5236
|
+
8,
|
|
5237
|
+
(args, ctx) => accruedInterest(args, ctx)
|
|
5238
|
+
),
|
|
5239
|
+
spec(
|
|
5240
|
+
"ACCRINTM",
|
|
5241
|
+
C9,
|
|
5242
|
+
"ACCRINTM(issue, settlement, rate, [par], [basis])",
|
|
5243
|
+
"The accrued interest of a security that pays interest at maturity.",
|
|
5244
|
+
3,
|
|
5245
|
+
5,
|
|
5246
|
+
(args, ctx) => {
|
|
5247
|
+
const [issue, settlement] = [serialArg(args[0]), serialArg(args[1])];
|
|
5248
|
+
const [rate, par] = [num(args[2]), optNum(args, 3, 1e3)];
|
|
5249
|
+
if (rate <= 0 || par <= 0 || issue >= settlement) fail(ERR.NUM);
|
|
5250
|
+
return par * rate * yearFrac(issue, settlement, basisOf(args, 4), ctx);
|
|
5251
|
+
}
|
|
5252
|
+
)
|
|
5253
|
+
];
|
|
5254
|
+
|
|
5035
5255
|
// src/xlsx/formula/functions/depreciation.ts
|
|
5036
|
-
var
|
|
5256
|
+
var C10 = "Financial";
|
|
5257
|
+
function variableDeclining(cost, salvage, life, start, end, factor, noSwitch) {
|
|
5258
|
+
let book = cost;
|
|
5259
|
+
let total2 = 0;
|
|
5260
|
+
for (let period = 1; period - 1 < end; period++) {
|
|
5261
|
+
const declining = book * factor / life;
|
|
5262
|
+
const straight = (book - salvage) / Math.max(life - (period - 1), 1);
|
|
5263
|
+
const wanted = noSwitch ? declining : Math.max(declining, straight);
|
|
5264
|
+
const dep = Math.max(0, Math.min(wanted, book - salvage));
|
|
5265
|
+
const covered = Math.min(end, period) - Math.max(start, period - 1);
|
|
5266
|
+
if (covered > 0) total2 += dep * Math.min(covered, 1);
|
|
5267
|
+
book -= dep;
|
|
5268
|
+
}
|
|
5269
|
+
return total2;
|
|
5270
|
+
}
|
|
5037
5271
|
var DEPRECIATION_FUNCTIONS = [
|
|
5038
5272
|
numeric(
|
|
5039
5273
|
"SLN",
|
|
5040
|
-
|
|
5274
|
+
C10,
|
|
5041
5275
|
"SLN(cost, salvage, life)",
|
|
5042
5276
|
"Straight-line depreciation.",
|
|
5043
5277
|
3,
|
|
@@ -5046,7 +5280,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5046
5280
|
),
|
|
5047
5281
|
numeric(
|
|
5048
5282
|
"SYD",
|
|
5049
|
-
|
|
5283
|
+
C10,
|
|
5050
5284
|
"SYD(cost, salvage, life, per)",
|
|
5051
5285
|
"Sum-of-years' digits depreciation.",
|
|
5052
5286
|
4,
|
|
@@ -5058,7 +5292,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5058
5292
|
),
|
|
5059
5293
|
numeric(
|
|
5060
5294
|
"DDB",
|
|
5061
|
-
|
|
5295
|
+
C10,
|
|
5062
5296
|
"DDB(cost, salvage, life, period, [factor])",
|
|
5063
5297
|
"Double-declining balance depreciation.",
|
|
5064
5298
|
4,
|
|
@@ -5074,9 +5308,33 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5074
5308
|
return dep;
|
|
5075
5309
|
}
|
|
5076
5310
|
),
|
|
5311
|
+
spec(
|
|
5312
|
+
"VDB",
|
|
5313
|
+
C10,
|
|
5314
|
+
"VDB(cost, salvage, life, start_period, end_period, [factor], [no_switch])",
|
|
5315
|
+
"Depreciation over any span of periods, switching to straight-line when that is larger.",
|
|
5316
|
+
5,
|
|
5317
|
+
7,
|
|
5318
|
+
(args) => {
|
|
5319
|
+
const [cost, salvage, life, start, end] = [0, 1, 2, 3, 4].map((i) => num(args[i]));
|
|
5320
|
+
const factor = args.length > 5 && args[5] !== null ? num(args[5]) : 2;
|
|
5321
|
+
const noSwitch = args.length > 6 && args[6] !== null ? bool(args[6]) : false;
|
|
5322
|
+
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)
|
|
5323
|
+
fail(ERR.NUM);
|
|
5324
|
+
return variableDeclining(
|
|
5325
|
+
cost,
|
|
5326
|
+
salvage,
|
|
5327
|
+
life,
|
|
5328
|
+
start,
|
|
5329
|
+
end,
|
|
5330
|
+
factor,
|
|
5331
|
+
noSwitch
|
|
5332
|
+
);
|
|
5333
|
+
}
|
|
5334
|
+
),
|
|
5077
5335
|
numeric(
|
|
5078
5336
|
"DB",
|
|
5079
|
-
|
|
5337
|
+
C10,
|
|
5080
5338
|
"DB(cost, salvage, life, period, [month])",
|
|
5081
5339
|
"Fixed-declining balance depreciation.",
|
|
5082
5340
|
4,
|
|
@@ -5099,7 +5357,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5099
5357
|
),
|
|
5100
5358
|
numeric(
|
|
5101
5359
|
"EFFECT",
|
|
5102
|
-
|
|
5360
|
+
C10,
|
|
5103
5361
|
"EFFECT(nominal_rate, npery)",
|
|
5104
5362
|
"The effective annual interest rate.",
|
|
5105
5363
|
2,
|
|
@@ -5112,7 +5370,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5112
5370
|
),
|
|
5113
5371
|
numeric(
|
|
5114
5372
|
"NOMINAL",
|
|
5115
|
-
|
|
5373
|
+
C10,
|
|
5116
5374
|
"NOMINAL(effect_rate, npery)",
|
|
5117
5375
|
"The nominal annual interest rate.",
|
|
5118
5376
|
2,
|
|
@@ -5125,7 +5383,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5125
5383
|
),
|
|
5126
5384
|
numeric(
|
|
5127
5385
|
"CUMIPMT",
|
|
5128
|
-
|
|
5386
|
+
C10,
|
|
5129
5387
|
"CUMIPMT(rate, nper, pv, start_period, end_period, type)",
|
|
5130
5388
|
"Cumulative interest paid between periods.",
|
|
5131
5389
|
6,
|
|
@@ -5134,7 +5392,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5134
5392
|
),
|
|
5135
5393
|
numeric(
|
|
5136
5394
|
"CUMPRINC",
|
|
5137
|
-
|
|
5395
|
+
C10,
|
|
5138
5396
|
"CUMPRINC(rate, nper, pv, start_period, end_period, type)",
|
|
5139
5397
|
"Cumulative principal paid between periods.",
|
|
5140
5398
|
6,
|
|
@@ -5143,7 +5401,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5143
5401
|
),
|
|
5144
5402
|
numeric(
|
|
5145
5403
|
"ISPMT",
|
|
5146
|
-
|
|
5404
|
+
C10,
|
|
5147
5405
|
"ISPMT(rate, per, nper, pv)",
|
|
5148
5406
|
"Interest paid in a period of a straight-line loan.",
|
|
5149
5407
|
4,
|
|
@@ -5155,7 +5413,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5155
5413
|
),
|
|
5156
5414
|
numeric(
|
|
5157
5415
|
"PDURATION",
|
|
5158
|
-
|
|
5416
|
+
C10,
|
|
5159
5417
|
"PDURATION(rate, pv, fv)",
|
|
5160
5418
|
"Periods required to reach a value.",
|
|
5161
5419
|
3,
|
|
@@ -5167,7 +5425,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5167
5425
|
),
|
|
5168
5426
|
numeric(
|
|
5169
5427
|
"RRI",
|
|
5170
|
-
|
|
5428
|
+
C10,
|
|
5171
5429
|
"RRI(nper, pv, fv)",
|
|
5172
5430
|
"An equivalent interest rate for growth.",
|
|
5173
5431
|
3,
|
|
@@ -5179,7 +5437,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5179
5437
|
),
|
|
5180
5438
|
spec(
|
|
5181
5439
|
"FVSCHEDULE",
|
|
5182
|
-
|
|
5440
|
+
C10,
|
|
5183
5441
|
"FVSCHEDULE(principal, schedule)",
|
|
5184
5442
|
"Future value with a schedule of rates.",
|
|
5185
5443
|
2,
|
|
@@ -5189,7 +5447,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5189
5447
|
),
|
|
5190
5448
|
numeric(
|
|
5191
5449
|
"DOLLARDE",
|
|
5192
|
-
|
|
5450
|
+
C10,
|
|
5193
5451
|
"DOLLARDE(fractional_dollar, fraction)",
|
|
5194
5452
|
"Converts a fractional price to a decimal.",
|
|
5195
5453
|
2,
|
|
@@ -5205,7 +5463,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5205
5463
|
),
|
|
5206
5464
|
numeric(
|
|
5207
5465
|
"DOLLARFR",
|
|
5208
|
-
|
|
5466
|
+
C10,
|
|
5209
5467
|
"DOLLARFR(decimal_dollar, fraction)",
|
|
5210
5468
|
"Converts a decimal price to a fraction.",
|
|
5211
5469
|
2,
|
|
@@ -5221,8 +5479,141 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5221
5479
|
)
|
|
5222
5480
|
];
|
|
5223
5481
|
|
|
5482
|
+
// src/xlsx/formula/functions/securities.ts
|
|
5483
|
+
var C11 = "Financial";
|
|
5484
|
+
var basisOf2 = (args, index2) => {
|
|
5485
|
+
const basis = args.length > index2 && args[index2] !== null ? int(args[index2]) : 0;
|
|
5486
|
+
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
5487
|
+
return basis;
|
|
5488
|
+
};
|
|
5489
|
+
function span(args) {
|
|
5490
|
+
const [s, m] = [Math.floor(serialArg(args[0])), Math.floor(serialArg(args[1]))];
|
|
5491
|
+
if (s >= m) fail(ERR.NUM);
|
|
5492
|
+
return { s, m };
|
|
5493
|
+
}
|
|
5494
|
+
var positive = (...values2) => {
|
|
5495
|
+
for (const v of values2) if (!(v > 0)) fail(ERR.NUM);
|
|
5496
|
+
};
|
|
5497
|
+
var discount = (name, description, syntax, fn) => spec(name, C11, syntax, description, 4, 5, (args, ctx) => {
|
|
5498
|
+
const { s, m } = span(args);
|
|
5499
|
+
const [a, b] = [num(args[2]), num(args[3])];
|
|
5500
|
+
positive(a, b);
|
|
5501
|
+
return fn(a, b, yearFrac(s, m, basisOf2(args, 4), ctx));
|
|
5502
|
+
});
|
|
5503
|
+
var atMaturity = (name, description, syntax, fn) => spec(name, C11, syntax, description, 5, 6, (args, ctx) => {
|
|
5504
|
+
const { s, m } = span(args);
|
|
5505
|
+
const issue = Math.floor(serialArg(args[2]));
|
|
5506
|
+
const [rate, other] = [num(args[3]), num(args[4])];
|
|
5507
|
+
const basis = basisOf2(args, 5);
|
|
5508
|
+
if (issue > s || rate < 0 || other < 0) fail(ERR.NUM);
|
|
5509
|
+
return fn(
|
|
5510
|
+
rate,
|
|
5511
|
+
other,
|
|
5512
|
+
yearFrac(issue, m, basis, ctx),
|
|
5513
|
+
yearFrac(issue, s, basis, ctx),
|
|
5514
|
+
yearFrac(s, m, basis, ctx)
|
|
5515
|
+
);
|
|
5516
|
+
});
|
|
5517
|
+
function billDays(args) {
|
|
5518
|
+
const { s, m } = span(args);
|
|
5519
|
+
const days = m - s;
|
|
5520
|
+
if (days > 365) fail(ERR.NUM);
|
|
5521
|
+
return days;
|
|
5522
|
+
}
|
|
5523
|
+
var SECURITY_FUNCTIONS = [
|
|
5524
|
+
discount(
|
|
5525
|
+
"DISC",
|
|
5526
|
+
"The discount rate of a security.",
|
|
5527
|
+
"DISC(settlement, maturity, pr, redemption, [basis])",
|
|
5528
|
+
(pr, redemption, f) => (redemption - pr) / redemption / f
|
|
5529
|
+
),
|
|
5530
|
+
discount(
|
|
5531
|
+
"PRICEDISC",
|
|
5532
|
+
"The price per 100 face value of a discounted security.",
|
|
5533
|
+
"PRICEDISC(settlement, maturity, discount, redemption, [basis])",
|
|
5534
|
+
(rate, redemption, f) => redemption - rate * redemption * f
|
|
5535
|
+
),
|
|
5536
|
+
discount(
|
|
5537
|
+
"YIELDDISC",
|
|
5538
|
+
"The annual yield of a discounted security.",
|
|
5539
|
+
"YIELDDISC(settlement, maturity, pr, redemption, [basis])",
|
|
5540
|
+
(pr, redemption, f) => (redemption - pr) / pr / f
|
|
5541
|
+
),
|
|
5542
|
+
discount(
|
|
5543
|
+
"INTRATE",
|
|
5544
|
+
"The interest rate of a fully invested security.",
|
|
5545
|
+
"INTRATE(settlement, maturity, investment, redemption, [basis])",
|
|
5546
|
+
(investment, redemption, f) => (redemption - investment) / investment / f
|
|
5547
|
+
),
|
|
5548
|
+
discount(
|
|
5549
|
+
"RECEIVED",
|
|
5550
|
+
"The amount received at maturity for a fully invested security.",
|
|
5551
|
+
"RECEIVED(settlement, maturity, investment, discount, [basis])",
|
|
5552
|
+
(investment, rate, f) => investment / (1 - rate * f)
|
|
5553
|
+
),
|
|
5554
|
+
atMaturity(
|
|
5555
|
+
"PRICEMAT",
|
|
5556
|
+
"The price per 100 face value of a security that pays interest at maturity.",
|
|
5557
|
+
"PRICEMAT(settlement, maturity, issue, rate, yld, [basis])",
|
|
5558
|
+
(rate, yld, dim, a, dsm) => (100 + dim * rate * 100) / (1 + dsm * yld) - a * rate * 100
|
|
5559
|
+
),
|
|
5560
|
+
atMaturity(
|
|
5561
|
+
"YIELDMAT",
|
|
5562
|
+
"The annual yield of a security that pays interest at maturity.",
|
|
5563
|
+
"YIELDMAT(settlement, maturity, issue, rate, pr, [basis])",
|
|
5564
|
+
(rate, price, dim, a, dsm) => (1 + dim * rate - (price / 100 + a * rate)) / (price / 100 + a * rate) / dsm
|
|
5565
|
+
),
|
|
5566
|
+
spec(
|
|
5567
|
+
"TBILLPRICE",
|
|
5568
|
+
C11,
|
|
5569
|
+
"TBILLPRICE(settlement, maturity, discount)",
|
|
5570
|
+
"The price per 100 face value of a Treasury bill.",
|
|
5571
|
+
3,
|
|
5572
|
+
3,
|
|
5573
|
+
(args) => {
|
|
5574
|
+
const days = billDays(args);
|
|
5575
|
+
const rate = num(args[2]);
|
|
5576
|
+
positive(rate);
|
|
5577
|
+
const price = 100 * (1 - rate * days / 360);
|
|
5578
|
+
return price > 0 ? price : fail(ERR.NUM);
|
|
5579
|
+
}
|
|
5580
|
+
),
|
|
5581
|
+
spec(
|
|
5582
|
+
"TBILLYIELD",
|
|
5583
|
+
C11,
|
|
5584
|
+
"TBILLYIELD(settlement, maturity, pr)",
|
|
5585
|
+
"The yield of a Treasury bill.",
|
|
5586
|
+
3,
|
|
5587
|
+
3,
|
|
5588
|
+
(args) => {
|
|
5589
|
+
const days = billDays(args);
|
|
5590
|
+
const price = num(args[2]);
|
|
5591
|
+
positive(price);
|
|
5592
|
+
return (100 - price) / price * (360 / days);
|
|
5593
|
+
}
|
|
5594
|
+
),
|
|
5595
|
+
spec(
|
|
5596
|
+
"TBILLEQ",
|
|
5597
|
+
C11,
|
|
5598
|
+
"TBILLEQ(settlement, maturity, discount)",
|
|
5599
|
+
"The bond-equivalent yield of a Treasury bill.",
|
|
5600
|
+
3,
|
|
5601
|
+
3,
|
|
5602
|
+
(args) => {
|
|
5603
|
+
const days = billDays(args);
|
|
5604
|
+
const rate = num(args[2]);
|
|
5605
|
+
positive(rate);
|
|
5606
|
+
if (days <= 182) return 365 * rate / (360 - rate * days);
|
|
5607
|
+
const price = 100 - rate * 100 * (days / 360);
|
|
5608
|
+
const t = days / 365;
|
|
5609
|
+
const root = Math.sqrt(t * t - (2 * t - 1) * (1 - 100 / price));
|
|
5610
|
+
return (-t + root) / (t - 0.5);
|
|
5611
|
+
}
|
|
5612
|
+
)
|
|
5613
|
+
];
|
|
5614
|
+
|
|
5224
5615
|
// src/xlsx/formula/functions/financial.ts
|
|
5225
|
-
var
|
|
5616
|
+
var C12 = "Financial";
|
|
5226
5617
|
var npv = (rate, values2) => values2.reduce((acc, v, i) => acc + v / Math.pow(1 + rate, i + 1), 0);
|
|
5227
5618
|
function datedFlows(ctx, args) {
|
|
5228
5619
|
const values2 = collectNumbers(ctx, [args[0] ?? null]);
|
|
@@ -5238,9 +5629,12 @@ var xnpv = (rate, values2, dates) => values2.reduce(
|
|
|
5238
5629
|
);
|
|
5239
5630
|
var FINANCIAL_FUNCTIONS = [
|
|
5240
5631
|
...DEPRECIATION_FUNCTIONS,
|
|
5632
|
+
...COUPON_FUNCTIONS,
|
|
5633
|
+
...BOND_FUNCTIONS,
|
|
5634
|
+
...SECURITY_FUNCTIONS,
|
|
5241
5635
|
numeric(
|
|
5242
5636
|
"PMT",
|
|
5243
|
-
|
|
5637
|
+
C12,
|
|
5244
5638
|
"PMT(rate, nper, pv, [fv], [type])",
|
|
5245
5639
|
"The payment for a loan.",
|
|
5246
5640
|
3,
|
|
@@ -5249,7 +5643,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5249
5643
|
),
|
|
5250
5644
|
numeric(
|
|
5251
5645
|
"FV",
|
|
5252
|
-
|
|
5646
|
+
C12,
|
|
5253
5647
|
"FV(rate, nper, pmt, [pv], [type])",
|
|
5254
5648
|
"The future value of an investment.",
|
|
5255
5649
|
3,
|
|
@@ -5258,7 +5652,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5258
5652
|
),
|
|
5259
5653
|
numeric(
|
|
5260
5654
|
"PV",
|
|
5261
|
-
|
|
5655
|
+
C12,
|
|
5262
5656
|
"PV(rate, nper, pmt, [fv], [type])",
|
|
5263
5657
|
"The present value of an investment.",
|
|
5264
5658
|
3,
|
|
@@ -5267,7 +5661,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5267
5661
|
),
|
|
5268
5662
|
numeric(
|
|
5269
5663
|
"NPER",
|
|
5270
|
-
|
|
5664
|
+
C12,
|
|
5271
5665
|
"NPER(rate, pmt, pv, [fv], [type])",
|
|
5272
5666
|
"The number of periods for an investment.",
|
|
5273
5667
|
3,
|
|
@@ -5284,7 +5678,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5284
5678
|
),
|
|
5285
5679
|
numeric(
|
|
5286
5680
|
"IPMT",
|
|
5287
|
-
|
|
5681
|
+
C12,
|
|
5288
5682
|
"IPMT(rate, per, nper, pv, [fv], [type])",
|
|
5289
5683
|
"The interest part of a payment.",
|
|
5290
5684
|
4,
|
|
@@ -5293,7 +5687,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5293
5687
|
),
|
|
5294
5688
|
numeric(
|
|
5295
5689
|
"PPMT",
|
|
5296
|
-
|
|
5690
|
+
C12,
|
|
5297
5691
|
"PPMT(rate, per, nper, pv, [fv], [type])",
|
|
5298
5692
|
"The principal part of a payment.",
|
|
5299
5693
|
4,
|
|
@@ -5302,7 +5696,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5302
5696
|
),
|
|
5303
5697
|
numeric(
|
|
5304
5698
|
"RATE",
|
|
5305
|
-
|
|
5699
|
+
C12,
|
|
5306
5700
|
"RATE(nper, pmt, pv, [fv], [type], [guess])",
|
|
5307
5701
|
"The interest rate per period.",
|
|
5308
5702
|
3,
|
|
@@ -5315,7 +5709,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5315
5709
|
),
|
|
5316
5710
|
spec(
|
|
5317
5711
|
"NPV",
|
|
5318
|
-
|
|
5712
|
+
C12,
|
|
5319
5713
|
"NPV(rate, value1, [value2], ...)",
|
|
5320
5714
|
"The net present value of cash flows.",
|
|
5321
5715
|
2,
|
|
@@ -5325,7 +5719,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5325
5719
|
),
|
|
5326
5720
|
spec(
|
|
5327
5721
|
"IRR",
|
|
5328
|
-
|
|
5722
|
+
C12,
|
|
5329
5723
|
"IRR(values, [guess])",
|
|
5330
5724
|
"The internal rate of return.",
|
|
5331
5725
|
1,
|
|
@@ -5342,7 +5736,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5342
5736
|
),
|
|
5343
5737
|
spec(
|
|
5344
5738
|
"XNPV",
|
|
5345
|
-
|
|
5739
|
+
C12,
|
|
5346
5740
|
"XNPV(rate, values, dates)",
|
|
5347
5741
|
"The net present value of dated cash flows.",
|
|
5348
5742
|
3,
|
|
@@ -5355,7 +5749,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5355
5749
|
),
|
|
5356
5750
|
spec(
|
|
5357
5751
|
"XIRR",
|
|
5358
|
-
|
|
5752
|
+
C12,
|
|
5359
5753
|
"XIRR(values, dates, [guess])",
|
|
5360
5754
|
"The internal rate of return of dated cash flows.",
|
|
5361
5755
|
2,
|
|
@@ -5369,7 +5763,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5369
5763
|
),
|
|
5370
5764
|
spec(
|
|
5371
5765
|
"MIRR",
|
|
5372
|
-
|
|
5766
|
+
C12,
|
|
5373
5767
|
"MIRR(values, finance_rate, reinvest_rate)",
|
|
5374
5768
|
"The modified internal rate of return.",
|
|
5375
5769
|
3,
|
|
@@ -5379,9 +5773,9 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5379
5773
|
const finance = num(args[1]);
|
|
5380
5774
|
const reinvest = num(args[2]);
|
|
5381
5775
|
const n2 = values2.length;
|
|
5382
|
-
const
|
|
5776
|
+
const positive3 = values2.map((v) => v > 0 ? v : 0);
|
|
5383
5777
|
const negative = values2.map((v) => v < 0 ? v : 0);
|
|
5384
|
-
const fvPos =
|
|
5778
|
+
const fvPos = positive3.reduce((acc, v, i) => acc + v * Math.pow(1 + reinvest, n2 - 1 - i), 0);
|
|
5385
5779
|
const pvNeg = negative.reduce((acc, v, i) => acc + v / Math.pow(1 + finance, i), 0);
|
|
5386
5780
|
if (fvPos === 0 || pvNeg === 0) fail(ERR.DIV0);
|
|
5387
5781
|
return Math.pow(-fvPos / pvNeg, 1 / (n2 - 1)) - 1;
|
|
@@ -5586,7 +5980,7 @@ function implicitIntersection(value, frame) {
|
|
|
5586
5980
|
}
|
|
5587
5981
|
|
|
5588
5982
|
// src/xlsx/formula/functions/info.ts
|
|
5589
|
-
var
|
|
5983
|
+
var C13 = "Information";
|
|
5590
5984
|
var ERROR_NUMBERS = {
|
|
5591
5985
|
"#NULL!": 1,
|
|
5592
5986
|
"#DIV/0!": 2,
|
|
@@ -5599,7 +5993,7 @@ var ERROR_NUMBERS = {
|
|
|
5599
5993
|
"#SPILL!": 9,
|
|
5600
5994
|
"#CALC!": 14
|
|
5601
5995
|
};
|
|
5602
|
-
var is = (name, syntax, description, test) => spec(name,
|
|
5996
|
+
var is = (name, syntax, description, test) => spec(name, C13, syntax, description, 1, 1, (args) => test(scalar(args[0])));
|
|
5603
5997
|
var parity = (v, odd) => {
|
|
5604
5998
|
if (isError(v)) fail(v);
|
|
5605
5999
|
if (typeof v === "boolean") fail(ERR.VALUE);
|
|
@@ -5636,7 +6030,7 @@ var INFO_FUNCTIONS = [
|
|
|
5636
6030
|
is("ISODD", "ISODD(number)", "TRUE for odd numbers.", (v) => parity(v, true)),
|
|
5637
6031
|
spec(
|
|
5638
6032
|
"ISREF",
|
|
5639
|
-
|
|
6033
|
+
C13,
|
|
5640
6034
|
"ISREF(value)",
|
|
5641
6035
|
"TRUE for references.",
|
|
5642
6036
|
1,
|
|
@@ -5646,7 +6040,7 @@ var INFO_FUNCTIONS = [
|
|
|
5646
6040
|
),
|
|
5647
6041
|
spec(
|
|
5648
6042
|
"ISFORMULA",
|
|
5649
|
-
|
|
6043
|
+
C13,
|
|
5650
6044
|
"ISFORMULA(reference)",
|
|
5651
6045
|
"TRUE when a cell holds a formula.",
|
|
5652
6046
|
1,
|
|
@@ -5660,17 +6054,17 @@ var INFO_FUNCTIONS = [
|
|
|
5660
6054
|
},
|
|
5661
6055
|
["any"]
|
|
5662
6056
|
),
|
|
5663
|
-
spec("N",
|
|
6057
|
+
spec("N", C13, "N(value)", "A value converted to a number (text is 0).", 1, 1, (args) => {
|
|
5664
6058
|
const v = scalar(args[0]);
|
|
5665
6059
|
if (isError(v)) return v;
|
|
5666
6060
|
if (typeof v === "number") return v;
|
|
5667
6061
|
if (typeof v === "boolean") return v ? 1 : 0;
|
|
5668
6062
|
return 0;
|
|
5669
6063
|
}),
|
|
5670
|
-
spec("NA",
|
|
6064
|
+
spec("NA", C13, "NA()", "The #N/A error value.", 0, 0, () => ERR.NA),
|
|
5671
6065
|
spec(
|
|
5672
6066
|
"TYPE",
|
|
5673
|
-
|
|
6067
|
+
C13,
|
|
5674
6068
|
"TYPE(value)",
|
|
5675
6069
|
"The type of a value: 1 number, 2 text, 4 logical, 16 error, 64 array.",
|
|
5676
6070
|
1,
|
|
@@ -5682,13 +6076,13 @@ var INFO_FUNCTIONS = [
|
|
|
5682
6076
|
},
|
|
5683
6077
|
["any"]
|
|
5684
6078
|
),
|
|
5685
|
-
spec("ERROR.TYPE",
|
|
6079
|
+
spec("ERROR.TYPE", C13, "ERROR.TYPE(error_val)", "The number of an error value.", 1, 1, (args) => {
|
|
5686
6080
|
const v = scalar(args[0]);
|
|
5687
6081
|
return isError(v) ? ERROR_NUMBERS[v.error] ?? ERR.NA : ERR.NA;
|
|
5688
6082
|
}),
|
|
5689
6083
|
spec(
|
|
5690
6084
|
"SHEET",
|
|
5691
|
-
|
|
6085
|
+
C13,
|
|
5692
6086
|
"SHEET([value])",
|
|
5693
6087
|
"The sheet number of a reference or sheet name.",
|
|
5694
6088
|
0,
|
|
@@ -5704,7 +6098,7 @@ var INFO_FUNCTIONS = [
|
|
|
5704
6098
|
),
|
|
5705
6099
|
spec(
|
|
5706
6100
|
"SHEETS",
|
|
5707
|
-
|
|
6101
|
+
C13,
|
|
5708
6102
|
"SHEETS([reference])",
|
|
5709
6103
|
"The number of sheets in a reference (or the workbook).",
|
|
5710
6104
|
0,
|
|
@@ -5719,7 +6113,7 @@ var INFO_FUNCTIONS = [
|
|
|
5719
6113
|
),
|
|
5720
6114
|
spec(
|
|
5721
6115
|
"CELL",
|
|
5722
|
-
|
|
6116
|
+
C13,
|
|
5723
6117
|
"CELL(info_type, [reference])",
|
|
5724
6118
|
"Information about a cell (address, row, col, contents, type, filename, sheet).",
|
|
5725
6119
|
1,
|
|
@@ -5894,7 +6288,7 @@ function broadcast1(a, fn) {
|
|
|
5894
6288
|
}
|
|
5895
6289
|
|
|
5896
6290
|
// src/xlsx/formula/functions/lambda.ts
|
|
5897
|
-
var
|
|
6291
|
+
var C14 = "Logical";
|
|
5898
6292
|
function lambdaArg(value) {
|
|
5899
6293
|
if (!(value instanceof LambdaValue)) fail(ERR.VALUE);
|
|
5900
6294
|
return value;
|
|
@@ -5911,7 +6305,7 @@ function element(ctx, value) {
|
|
|
5911
6305
|
var LAMBDA_HELPERS = [
|
|
5912
6306
|
spec(
|
|
5913
6307
|
"MAP",
|
|
5914
|
-
|
|
6308
|
+
C14,
|
|
5915
6309
|
"MAP(array1, ..., lambda)",
|
|
5916
6310
|
"Applies a LAMBDA to each value of arrays.",
|
|
5917
6311
|
2,
|
|
@@ -5937,7 +6331,7 @@ var LAMBDA_HELPERS = [
|
|
|
5937
6331
|
),
|
|
5938
6332
|
spec(
|
|
5939
6333
|
"REDUCE",
|
|
5940
|
-
|
|
6334
|
+
C14,
|
|
5941
6335
|
"REDUCE([initial_value], array, lambda)",
|
|
5942
6336
|
"Reduces an array to an accumulated value.",
|
|
5943
6337
|
2,
|
|
@@ -5953,7 +6347,7 @@ var LAMBDA_HELPERS = [
|
|
|
5953
6347
|
),
|
|
5954
6348
|
spec(
|
|
5955
6349
|
"SCAN",
|
|
5956
|
-
|
|
6350
|
+
C14,
|
|
5957
6351
|
"SCAN([initial_value], array, lambda)",
|
|
5958
6352
|
"The intermediate values of a reduction, as an array.",
|
|
5959
6353
|
2,
|
|
@@ -5971,7 +6365,7 @@ var LAMBDA_HELPERS = [
|
|
|
5971
6365
|
),
|
|
5972
6366
|
spec(
|
|
5973
6367
|
"BYROW",
|
|
5974
|
-
|
|
6368
|
+
C14,
|
|
5975
6369
|
"BYROW(array, lambda)",
|
|
5976
6370
|
"Applies a LAMBDA to each row, returning a column.",
|
|
5977
6371
|
2,
|
|
@@ -5987,7 +6381,7 @@ var LAMBDA_HELPERS = [
|
|
|
5987
6381
|
),
|
|
5988
6382
|
spec(
|
|
5989
6383
|
"BYCOL",
|
|
5990
|
-
|
|
6384
|
+
C14,
|
|
5991
6385
|
"BYCOL(array, lambda)",
|
|
5992
6386
|
"Applies a LAMBDA to each column, returning a row.",
|
|
5993
6387
|
2,
|
|
@@ -6006,7 +6400,7 @@ var LAMBDA_HELPERS = [
|
|
|
6006
6400
|
),
|
|
6007
6401
|
spec(
|
|
6008
6402
|
"MAKEARRAY",
|
|
6009
|
-
|
|
6403
|
+
C14,
|
|
6010
6404
|
"MAKEARRAY(rows, columns, lambda)",
|
|
6011
6405
|
"An array built by calling a LAMBDA for each position.",
|
|
6012
6406
|
3,
|
|
@@ -6023,7 +6417,7 @@ var LAMBDA_HELPERS = [
|
|
|
6023
6417
|
];
|
|
6024
6418
|
|
|
6025
6419
|
// src/xlsx/formula/functions/logical.ts
|
|
6026
|
-
var
|
|
6420
|
+
var C15 = "Logical";
|
|
6027
6421
|
function deref(ctx, value) {
|
|
6028
6422
|
if (value instanceof RefValue) {
|
|
6029
6423
|
if (value.isCell()) {
|
|
@@ -6093,7 +6487,7 @@ function logicalValues(ctx, args) {
|
|
|
6093
6487
|
if (out.length === 0) fail(ERR.VALUE);
|
|
6094
6488
|
return out;
|
|
6095
6489
|
}
|
|
6096
|
-
var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category =
|
|
6490
|
+
var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category = C15) => ({ name, category, syntax, description, minArgs, maxArgs, lazy });
|
|
6097
6491
|
function localName(arg) {
|
|
6098
6492
|
const node = arg?.node;
|
|
6099
6493
|
if (!node || node.type !== "name" || node.prefix) fail(ERR.VALUE);
|
|
@@ -6187,7 +6581,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6187
6581
|
),
|
|
6188
6582
|
{
|
|
6189
6583
|
name: "NOT",
|
|
6190
|
-
category:
|
|
6584
|
+
category: C15,
|
|
6191
6585
|
syntax: "NOT(logical)",
|
|
6192
6586
|
description: "Reverses a logical value.",
|
|
6193
6587
|
minArgs: 1,
|
|
@@ -6196,7 +6590,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6196
6590
|
},
|
|
6197
6591
|
{
|
|
6198
6592
|
name: "TRUE",
|
|
6199
|
-
category:
|
|
6593
|
+
category: C15,
|
|
6200
6594
|
syntax: "TRUE()",
|
|
6201
6595
|
description: "The logical value TRUE.",
|
|
6202
6596
|
minArgs: 0,
|
|
@@ -6205,7 +6599,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6205
6599
|
},
|
|
6206
6600
|
{
|
|
6207
6601
|
name: "FALSE",
|
|
6208
|
-
category:
|
|
6602
|
+
category: C15,
|
|
6209
6603
|
syntax: "FALSE()",
|
|
6210
6604
|
description: "The logical value FALSE.",
|
|
6211
6605
|
minArgs: 0,
|
|
@@ -6403,7 +6797,7 @@ function xsearch(vector, lookup2, matchMode, searchMode) {
|
|
|
6403
6797
|
}
|
|
6404
6798
|
|
|
6405
6799
|
// src/xlsx/formula/functions/reference.ts
|
|
6406
|
-
var
|
|
6800
|
+
var C16 = "Lookup & Reference";
|
|
6407
6801
|
function refArg(value) {
|
|
6408
6802
|
if (value instanceof RefValue) return value;
|
|
6409
6803
|
if (isError(value)) fail(value);
|
|
@@ -6492,7 +6886,7 @@ function rowsOrCols(value, ctx, axis) {
|
|
|
6492
6886
|
var REFERENCE_FUNCTIONS = [
|
|
6493
6887
|
spec(
|
|
6494
6888
|
"OFFSET",
|
|
6495
|
-
|
|
6889
|
+
C16,
|
|
6496
6890
|
"OFFSET(reference, rows, cols, [height], [width])",
|
|
6497
6891
|
"A reference offset from a starting reference.",
|
|
6498
6892
|
3,
|
|
@@ -6503,7 +6897,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6503
6897
|
),
|
|
6504
6898
|
spec(
|
|
6505
6899
|
"INDIRECT",
|
|
6506
|
-
|
|
6900
|
+
C16,
|
|
6507
6901
|
"INDIRECT(ref_text, [a1])",
|
|
6508
6902
|
"The reference named by a text.",
|
|
6509
6903
|
1,
|
|
@@ -6519,7 +6913,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6519
6913
|
),
|
|
6520
6914
|
spec(
|
|
6521
6915
|
"ROW",
|
|
6522
|
-
|
|
6916
|
+
C16,
|
|
6523
6917
|
"ROW([reference])",
|
|
6524
6918
|
"The row number of a reference.",
|
|
6525
6919
|
0,
|
|
@@ -6529,7 +6923,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6529
6923
|
),
|
|
6530
6924
|
spec(
|
|
6531
6925
|
"COLUMN",
|
|
6532
|
-
|
|
6926
|
+
C16,
|
|
6533
6927
|
"COLUMN([reference])",
|
|
6534
6928
|
"The column number of a reference.",
|
|
6535
6929
|
0,
|
|
@@ -6539,7 +6933,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6539
6933
|
),
|
|
6540
6934
|
spec(
|
|
6541
6935
|
"ROWS",
|
|
6542
|
-
|
|
6936
|
+
C16,
|
|
6543
6937
|
"ROWS(array)",
|
|
6544
6938
|
"The number of rows in a reference or array.",
|
|
6545
6939
|
1,
|
|
@@ -6552,7 +6946,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6552
6946
|
),
|
|
6553
6947
|
spec(
|
|
6554
6948
|
"COLUMNS",
|
|
6555
|
-
|
|
6949
|
+
C16,
|
|
6556
6950
|
"COLUMNS(array)",
|
|
6557
6951
|
"The number of columns in a reference or array.",
|
|
6558
6952
|
1,
|
|
@@ -6565,7 +6959,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6565
6959
|
),
|
|
6566
6960
|
spec(
|
|
6567
6961
|
"AREAS",
|
|
6568
|
-
|
|
6962
|
+
C16,
|
|
6569
6963
|
"AREAS(reference)",
|
|
6570
6964
|
"The number of areas in a reference.",
|
|
6571
6965
|
1,
|
|
@@ -6575,7 +6969,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6575
6969
|
),
|
|
6576
6970
|
spec(
|
|
6577
6971
|
"ADDRESS",
|
|
6578
|
-
|
|
6972
|
+
C16,
|
|
6579
6973
|
"ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])",
|
|
6580
6974
|
"A cell address as text.",
|
|
6581
6975
|
2,
|
|
@@ -6584,7 +6978,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6584
6978
|
),
|
|
6585
6979
|
spec(
|
|
6586
6980
|
"HYPERLINK",
|
|
6587
|
-
|
|
6981
|
+
C16,
|
|
6588
6982
|
"HYPERLINK(link_location, [friendly_name])",
|
|
6589
6983
|
"A link; the cell shows the friendly name.",
|
|
6590
6984
|
1,
|
|
@@ -6593,7 +6987,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6593
6987
|
),
|
|
6594
6988
|
spec(
|
|
6595
6989
|
"ANCHORARRAY",
|
|
6596
|
-
|
|
6990
|
+
C16,
|
|
6597
6991
|
"ANCHORARRAY(reference)",
|
|
6598
6992
|
"The spill range of a dynamic array formula (A1#).",
|
|
6599
6993
|
1,
|
|
@@ -6613,7 +7007,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6613
7007
|
),
|
|
6614
7008
|
spec(
|
|
6615
7009
|
"SINGLE",
|
|
6616
|
-
|
|
7010
|
+
C16,
|
|
6617
7011
|
"SINGLE(value)",
|
|
6618
7012
|
"Implicit intersection (the @ operator).",
|
|
6619
7013
|
1,
|
|
@@ -6623,7 +7017,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6623
7017
|
),
|
|
6624
7018
|
spec(
|
|
6625
7019
|
"FORMULATEXT",
|
|
6626
|
-
|
|
7020
|
+
C16,
|
|
6627
7021
|
"FORMULATEXT(reference)",
|
|
6628
7022
|
"The formula of a cell as text.",
|
|
6629
7023
|
1,
|
|
@@ -6643,7 +7037,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
6643
7037
|
];
|
|
6644
7038
|
|
|
6645
7039
|
// src/xlsx/formula/functions/lookup.ts
|
|
6646
|
-
var
|
|
7040
|
+
var C17 = "Lookup & Reference";
|
|
6647
7041
|
function cellOf(value, row2, col) {
|
|
6648
7042
|
if (value instanceof RefValue) {
|
|
6649
7043
|
const area = value.areas[0];
|
|
@@ -6770,7 +7164,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6770
7164
|
...REFERENCE_FUNCTIONS,
|
|
6771
7165
|
spec(
|
|
6772
7166
|
"VLOOKUP",
|
|
6773
|
-
|
|
7167
|
+
C17,
|
|
6774
7168
|
"VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])",
|
|
6775
7169
|
"Looks up a value in the first column of a table.",
|
|
6776
7170
|
3,
|
|
@@ -6780,7 +7174,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6780
7174
|
),
|
|
6781
7175
|
spec(
|
|
6782
7176
|
"HLOOKUP",
|
|
6783
|
-
|
|
7177
|
+
C17,
|
|
6784
7178
|
"HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])",
|
|
6785
7179
|
"Looks up a value in the first row of a table.",
|
|
6786
7180
|
3,
|
|
@@ -6790,7 +7184,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6790
7184
|
),
|
|
6791
7185
|
spec(
|
|
6792
7186
|
"LOOKUP",
|
|
6793
|
-
|
|
7187
|
+
C17,
|
|
6794
7188
|
"LOOKUP(lookup_value, lookup_vector, [result_vector])",
|
|
6795
7189
|
"Looks up a value in a sorted vector or array.",
|
|
6796
7190
|
2,
|
|
@@ -6800,7 +7194,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6800
7194
|
),
|
|
6801
7195
|
spec(
|
|
6802
7196
|
"MATCH",
|
|
6803
|
-
|
|
7197
|
+
C17,
|
|
6804
7198
|
"MATCH(lookup_value, lookup_array, [match_type])",
|
|
6805
7199
|
"The position of a value in a range.",
|
|
6806
7200
|
2,
|
|
@@ -6810,7 +7204,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6810
7204
|
),
|
|
6811
7205
|
spec(
|
|
6812
7206
|
"XMATCH",
|
|
6813
|
-
|
|
7207
|
+
C17,
|
|
6814
7208
|
"XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])",
|
|
6815
7209
|
"The position of a value with flexible matching.",
|
|
6816
7210
|
2,
|
|
@@ -6830,7 +7224,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6830
7224
|
),
|
|
6831
7225
|
spec(
|
|
6832
7226
|
"XLOOKUP",
|
|
6833
|
-
|
|
7227
|
+
C17,
|
|
6834
7228
|
"XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])",
|
|
6835
7229
|
"Searches a range and returns the matching item from another.",
|
|
6836
7230
|
3,
|
|
@@ -6840,7 +7234,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6840
7234
|
),
|
|
6841
7235
|
spec(
|
|
6842
7236
|
"INDEX",
|
|
6843
|
-
|
|
7237
|
+
C17,
|
|
6844
7238
|
"INDEX(array, row_num, [column_num], [area_num])",
|
|
6845
7239
|
"The value or reference at a position.",
|
|
6846
7240
|
1,
|
|
@@ -6850,7 +7244,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
6850
7244
|
),
|
|
6851
7245
|
spec(
|
|
6852
7246
|
"CHOOSE",
|
|
6853
|
-
|
|
7247
|
+
C17,
|
|
6854
7248
|
"CHOOSE(index_num, value1, [value2], ...)",
|
|
6855
7249
|
"Chooses a value from a list by index.",
|
|
6856
7250
|
2,
|
|
@@ -7054,7 +7448,7 @@ function liftCriteria(ctx, pairs, fn) {
|
|
|
7054
7448
|
}
|
|
7055
7449
|
|
|
7056
7450
|
// src/xlsx/formula/functions/math-sum.ts
|
|
7057
|
-
var
|
|
7451
|
+
var C18 = "Math & Trig";
|
|
7058
7452
|
var numbersOf = (values2) => values2.filter((v) => typeof v === "number");
|
|
7059
7453
|
function sumProduct(ctx, args) {
|
|
7060
7454
|
const matrices = args.map((a) => ctx.toMatrix(a));
|
|
@@ -7159,7 +7553,7 @@ function aggregate(code, values2, k) {
|
|
|
7159
7553
|
var SUM_FUNCTIONS = [
|
|
7160
7554
|
spec(
|
|
7161
7555
|
"SUM",
|
|
7162
|
-
|
|
7556
|
+
C18,
|
|
7163
7557
|
"SUM(number1, [number2], ...)",
|
|
7164
7558
|
"Adds its arguments.",
|
|
7165
7559
|
0,
|
|
@@ -7169,7 +7563,7 @@ var SUM_FUNCTIONS = [
|
|
|
7169
7563
|
),
|
|
7170
7564
|
spec(
|
|
7171
7565
|
"PRODUCT",
|
|
7172
|
-
|
|
7566
|
+
C18,
|
|
7173
7567
|
"PRODUCT(number1, [number2], ...)",
|
|
7174
7568
|
"Multiplies its arguments.",
|
|
7175
7569
|
1,
|
|
@@ -7182,7 +7576,7 @@ var SUM_FUNCTIONS = [
|
|
|
7182
7576
|
),
|
|
7183
7577
|
spec(
|
|
7184
7578
|
"SUMSQ",
|
|
7185
|
-
|
|
7579
|
+
C18,
|
|
7186
7580
|
"SUMSQ(number1, [number2], ...)",
|
|
7187
7581
|
"The sum of the squares of the arguments.",
|
|
7188
7582
|
1,
|
|
@@ -7192,7 +7586,7 @@ var SUM_FUNCTIONS = [
|
|
|
7192
7586
|
),
|
|
7193
7587
|
spec(
|
|
7194
7588
|
"SUMPRODUCT",
|
|
7195
|
-
|
|
7589
|
+
C18,
|
|
7196
7590
|
"SUMPRODUCT(array1, [array2], ...)",
|
|
7197
7591
|
"The sum of the products of corresponding array elements.",
|
|
7198
7592
|
1,
|
|
@@ -7202,7 +7596,7 @@ var SUM_FUNCTIONS = [
|
|
|
7202
7596
|
),
|
|
7203
7597
|
spec(
|
|
7204
7598
|
"SUMX2MY2",
|
|
7205
|
-
|
|
7599
|
+
C18,
|
|
7206
7600
|
"SUMX2MY2(array_x, array_y)",
|
|
7207
7601
|
"Sum of the differences of squares.",
|
|
7208
7602
|
2,
|
|
@@ -7212,7 +7606,7 @@ var SUM_FUNCTIONS = [
|
|
|
7212
7606
|
),
|
|
7213
7607
|
spec(
|
|
7214
7608
|
"SUMX2PY2",
|
|
7215
|
-
|
|
7609
|
+
C18,
|
|
7216
7610
|
"SUMX2PY2(array_x, array_y)",
|
|
7217
7611
|
"Sum of the sums of squares.",
|
|
7218
7612
|
2,
|
|
@@ -7222,7 +7616,7 @@ var SUM_FUNCTIONS = [
|
|
|
7222
7616
|
),
|
|
7223
7617
|
spec(
|
|
7224
7618
|
"SUMXMY2",
|
|
7225
|
-
|
|
7619
|
+
C18,
|
|
7226
7620
|
"SUMXMY2(array_x, array_y)",
|
|
7227
7621
|
"Sum of the squares of differences.",
|
|
7228
7622
|
2,
|
|
@@ -7232,7 +7626,7 @@ var SUM_FUNCTIONS = [
|
|
|
7232
7626
|
),
|
|
7233
7627
|
spec(
|
|
7234
7628
|
"SUMIF",
|
|
7235
|
-
|
|
7629
|
+
C18,
|
|
7236
7630
|
"SUMIF(range, criteria, [sum_range])",
|
|
7237
7631
|
"Adds the cells that meet a criterion.",
|
|
7238
7632
|
2,
|
|
@@ -7245,7 +7639,7 @@ var SUM_FUNCTIONS = [
|
|
|
7245
7639
|
),
|
|
7246
7640
|
spec(
|
|
7247
7641
|
"SUMIFS",
|
|
7248
|
-
|
|
7642
|
+
C18,
|
|
7249
7643
|
"SUMIFS(sum_range, criteria_range1, criteria1, ...)",
|
|
7250
7644
|
"Adds the cells that meet several criteria.",
|
|
7251
7645
|
3,
|
|
@@ -7259,7 +7653,7 @@ var SUM_FUNCTIONS = [
|
|
|
7259
7653
|
),
|
|
7260
7654
|
spec(
|
|
7261
7655
|
"SUBTOTAL",
|
|
7262
|
-
|
|
7656
|
+
C18,
|
|
7263
7657
|
"SUBTOTAL(function_num, ref1, ...)",
|
|
7264
7658
|
"A subtotal (1-11 include hidden rows, 101-111 ignore them).",
|
|
7265
7659
|
2,
|
|
@@ -7274,7 +7668,7 @@ var SUM_FUNCTIONS = [
|
|
|
7274
7668
|
),
|
|
7275
7669
|
spec(
|
|
7276
7670
|
"AGGREGATE",
|
|
7277
|
-
|
|
7671
|
+
C18,
|
|
7278
7672
|
"AGGREGATE(function_num, options, ref1, ...)",
|
|
7279
7673
|
"An aggregate that can ignore hidden rows and errors.",
|
|
7280
7674
|
3,
|
|
@@ -7314,14 +7708,14 @@ var SUM_FUNCTIONS = [
|
|
|
7314
7708
|
];
|
|
7315
7709
|
|
|
7316
7710
|
// src/xlsx/formula/functions/math-more.ts
|
|
7317
|
-
var
|
|
7711
|
+
var C19 = "Math & Trig";
|
|
7318
7712
|
var MATH_MORE = [
|
|
7319
|
-
numeric("SIN",
|
|
7320
|
-
numeric("COS",
|
|
7321
|
-
numeric("TAN",
|
|
7713
|
+
numeric("SIN", C19, "SIN(number)", "The sine of an angle in radians.", 1, 1, Math.sin),
|
|
7714
|
+
numeric("COS", C19, "COS(number)", "The cosine of an angle in radians.", 1, 1, Math.cos),
|
|
7715
|
+
numeric("TAN", C19, "TAN(number)", "The tangent of an angle in radians.", 1, 1, Math.tan),
|
|
7322
7716
|
numeric(
|
|
7323
7717
|
"ASIN",
|
|
7324
|
-
|
|
7718
|
+
C19,
|
|
7325
7719
|
"ASIN(number)",
|
|
7326
7720
|
"The arcsine in radians.",
|
|
7327
7721
|
1,
|
|
@@ -7330,17 +7724,17 @@ var MATH_MORE = [
|
|
|
7330
7724
|
),
|
|
7331
7725
|
numeric(
|
|
7332
7726
|
"ACOS",
|
|
7333
|
-
|
|
7727
|
+
C19,
|
|
7334
7728
|
"ACOS(number)",
|
|
7335
7729
|
"The arccosine in radians.",
|
|
7336
7730
|
1,
|
|
7337
7731
|
1,
|
|
7338
7732
|
(x) => domain(Math.abs(x) <= 1, Math.acos(x))
|
|
7339
7733
|
),
|
|
7340
|
-
numeric("ATAN",
|
|
7734
|
+
numeric("ATAN", C19, "ATAN(number)", "The arctangent in radians.", 1, 1, Math.atan),
|
|
7341
7735
|
numeric(
|
|
7342
7736
|
"ATAN2",
|
|
7343
|
-
|
|
7737
|
+
C19,
|
|
7344
7738
|
"ATAN2(x_num, y_num)",
|
|
7345
7739
|
"The arctangent of x and y coordinates.",
|
|
7346
7740
|
2,
|
|
@@ -7350,13 +7744,13 @@ var MATH_MORE = [
|
|
|
7350
7744
|
return Math.atan2(y ?? 0, x);
|
|
7351
7745
|
}
|
|
7352
7746
|
),
|
|
7353
|
-
numeric("SINH",
|
|
7354
|
-
numeric("COSH",
|
|
7355
|
-
numeric("TANH",
|
|
7356
|
-
numeric("ASINH",
|
|
7747
|
+
numeric("SINH", C19, "SINH(number)", "The hyperbolic sine.", 1, 1, Math.sinh),
|
|
7748
|
+
numeric("COSH", C19, "COSH(number)", "The hyperbolic cosine.", 1, 1, Math.cosh),
|
|
7749
|
+
numeric("TANH", C19, "TANH(number)", "The hyperbolic tangent.", 1, 1, Math.tanh),
|
|
7750
|
+
numeric("ASINH", C19, "ASINH(number)", "The inverse hyperbolic sine.", 1, 1, Math.asinh),
|
|
7357
7751
|
numeric(
|
|
7358
7752
|
"ACOSH",
|
|
7359
|
-
|
|
7753
|
+
C19,
|
|
7360
7754
|
"ACOSH(number)",
|
|
7361
7755
|
"The inverse hyperbolic cosine.",
|
|
7362
7756
|
1,
|
|
@@ -7365,7 +7759,7 @@ var MATH_MORE = [
|
|
|
7365
7759
|
),
|
|
7366
7760
|
numeric(
|
|
7367
7761
|
"ATANH",
|
|
7368
|
-
|
|
7762
|
+
C19,
|
|
7369
7763
|
"ATANH(number)",
|
|
7370
7764
|
"The inverse hyperbolic tangent.",
|
|
7371
7765
|
1,
|
|
@@ -7374,7 +7768,7 @@ var MATH_MORE = [
|
|
|
7374
7768
|
),
|
|
7375
7769
|
numeric(
|
|
7376
7770
|
"COT",
|
|
7377
|
-
|
|
7771
|
+
C19,
|
|
7378
7772
|
"COT(number)",
|
|
7379
7773
|
"The cotangent of an angle.",
|
|
7380
7774
|
1,
|
|
@@ -7383,7 +7777,7 @@ var MATH_MORE = [
|
|
|
7383
7777
|
),
|
|
7384
7778
|
numeric(
|
|
7385
7779
|
"COTH",
|
|
7386
|
-
|
|
7780
|
+
C19,
|
|
7387
7781
|
"COTH(number)",
|
|
7388
7782
|
"The hyperbolic cotangent.",
|
|
7389
7783
|
1,
|
|
@@ -7392,7 +7786,7 @@ var MATH_MORE = [
|
|
|
7392
7786
|
),
|
|
7393
7787
|
numeric(
|
|
7394
7788
|
"CSC",
|
|
7395
|
-
|
|
7789
|
+
C19,
|
|
7396
7790
|
"CSC(number)",
|
|
7397
7791
|
"The cosecant of an angle.",
|
|
7398
7792
|
1,
|
|
@@ -7401,19 +7795,19 @@ var MATH_MORE = [
|
|
|
7401
7795
|
),
|
|
7402
7796
|
numeric(
|
|
7403
7797
|
"CSCH",
|
|
7404
|
-
|
|
7798
|
+
C19,
|
|
7405
7799
|
"CSCH(number)",
|
|
7406
7800
|
"The hyperbolic cosecant.",
|
|
7407
7801
|
1,
|
|
7408
7802
|
1,
|
|
7409
7803
|
(x) => x === 0 ? fail(ERR.DIV0) : 1 / Math.sinh(x)
|
|
7410
7804
|
),
|
|
7411
|
-
numeric("SEC",
|
|
7412
|
-
numeric("SECH",
|
|
7413
|
-
numeric("ACOT",
|
|
7805
|
+
numeric("SEC", C19, "SEC(number)", "The secant of an angle.", 1, 1, (x) => 1 / Math.cos(x)),
|
|
7806
|
+
numeric("SECH", C19, "SECH(number)", "The hyperbolic secant.", 1, 1, (x) => 1 / Math.cosh(x)),
|
|
7807
|
+
numeric("ACOT", C19, "ACOT(number)", "The arccotangent.", 1, 1, (x) => Math.PI / 2 - Math.atan(x)),
|
|
7414
7808
|
numeric(
|
|
7415
7809
|
"ACOTH",
|
|
7416
|
-
|
|
7810
|
+
C19,
|
|
7417
7811
|
"ACOTH(number)",
|
|
7418
7812
|
"The inverse hyperbolic cotangent.",
|
|
7419
7813
|
1,
|
|
@@ -7422,7 +7816,7 @@ var MATH_MORE = [
|
|
|
7422
7816
|
),
|
|
7423
7817
|
numeric(
|
|
7424
7818
|
"DEGREES",
|
|
7425
|
-
|
|
7819
|
+
C19,
|
|
7426
7820
|
"DEGREES(angle)",
|
|
7427
7821
|
"Converts radians to degrees.",
|
|
7428
7822
|
1,
|
|
@@ -7431,7 +7825,7 @@ var MATH_MORE = [
|
|
|
7431
7825
|
),
|
|
7432
7826
|
numeric(
|
|
7433
7827
|
"RADIANS",
|
|
7434
|
-
|
|
7828
|
+
C19,
|
|
7435
7829
|
"RADIANS(angle)",
|
|
7436
7830
|
"Converts degrees to radians.",
|
|
7437
7831
|
1,
|
|
@@ -7440,7 +7834,7 @@ var MATH_MORE = [
|
|
|
7440
7834
|
),
|
|
7441
7835
|
spec(
|
|
7442
7836
|
"RAND",
|
|
7443
|
-
|
|
7837
|
+
C19,
|
|
7444
7838
|
"RAND()",
|
|
7445
7839
|
"A random number between 0 and 1.",
|
|
7446
7840
|
0,
|
|
@@ -7451,7 +7845,7 @@ var MATH_MORE = [
|
|
|
7451
7845
|
),
|
|
7452
7846
|
spec(
|
|
7453
7847
|
"RANDBETWEEN",
|
|
7454
|
-
|
|
7848
|
+
C19,
|
|
7455
7849
|
"RANDBETWEEN(bottom, top)",
|
|
7456
7850
|
"A random integer between two numbers.",
|
|
7457
7851
|
2,
|
|
@@ -7467,7 +7861,7 @@ var MATH_MORE = [
|
|
|
7467
7861
|
),
|
|
7468
7862
|
spec(
|
|
7469
7863
|
"SERIESSUM",
|
|
7470
|
-
|
|
7864
|
+
C19,
|
|
7471
7865
|
"SERIESSUM(x, n, m, coefficients)",
|
|
7472
7866
|
"The sum of a power series.",
|
|
7473
7867
|
4,
|
|
@@ -7486,7 +7880,7 @@ var MATH_MORE = [
|
|
|
7486
7880
|
];
|
|
7487
7881
|
|
|
7488
7882
|
// src/xlsx/formula/functions/math-combin.ts
|
|
7489
|
-
var
|
|
7883
|
+
var C20 = "Math & Trig";
|
|
7490
7884
|
var fact = (n2) => {
|
|
7491
7885
|
if (n2 < 0) fail(ERR.NUM);
|
|
7492
7886
|
let out = 1;
|
|
@@ -7510,8 +7904,8 @@ function integers(args, ctx) {
|
|
|
7510
7904
|
});
|
|
7511
7905
|
}
|
|
7512
7906
|
var COMBINATORIC_FUNCTIONS = [
|
|
7513
|
-
numeric("FACT",
|
|
7514
|
-
numeric("FACTDOUBLE",
|
|
7907
|
+
numeric("FACT", C20, "FACT(number)", "The factorial of a number.", 1, 1, fact),
|
|
7908
|
+
numeric("FACTDOUBLE", C20, "FACTDOUBLE(number)", "The double factorial of a number.", 1, 1, (n2) => {
|
|
7515
7909
|
if (n2 < -1) fail(ERR.NUM);
|
|
7516
7910
|
let out = 1;
|
|
7517
7911
|
for (let i = Math.trunc(n2); i > 1; i -= 2) out *= i;
|
|
@@ -7519,7 +7913,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7519
7913
|
}),
|
|
7520
7914
|
numeric(
|
|
7521
7915
|
"COMBIN",
|
|
7522
|
-
|
|
7916
|
+
C20,
|
|
7523
7917
|
"COMBIN(number, number_chosen)",
|
|
7524
7918
|
"The number of combinations.",
|
|
7525
7919
|
2,
|
|
@@ -7528,7 +7922,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7528
7922
|
),
|
|
7529
7923
|
numeric(
|
|
7530
7924
|
"COMBINA",
|
|
7531
|
-
|
|
7925
|
+
C20,
|
|
7532
7926
|
"COMBINA(number, number_chosen)",
|
|
7533
7927
|
"Combinations with repetitions.",
|
|
7534
7928
|
2,
|
|
@@ -7540,7 +7934,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7540
7934
|
),
|
|
7541
7935
|
spec(
|
|
7542
7936
|
"MULTINOMIAL",
|
|
7543
|
-
|
|
7937
|
+
C20,
|
|
7544
7938
|
"MULTINOMIAL(number1, ...)",
|
|
7545
7939
|
"The multinomial of a set of numbers.",
|
|
7546
7940
|
1,
|
|
@@ -7554,7 +7948,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7554
7948
|
),
|
|
7555
7949
|
spec(
|
|
7556
7950
|
"GCD",
|
|
7557
|
-
|
|
7951
|
+
C20,
|
|
7558
7952
|
"GCD(number1, ...)",
|
|
7559
7953
|
"The greatest common divisor.",
|
|
7560
7954
|
1,
|
|
@@ -7564,7 +7958,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7564
7958
|
),
|
|
7565
7959
|
spec(
|
|
7566
7960
|
"LCM",
|
|
7567
|
-
|
|
7961
|
+
C20,
|
|
7568
7962
|
"LCM(number1, ...)",
|
|
7569
7963
|
"The least common multiple.",
|
|
7570
7964
|
1,
|
|
@@ -7612,7 +8006,7 @@ function mround(x, m) {
|
|
|
7612
8006
|
}
|
|
7613
8007
|
|
|
7614
8008
|
// src/xlsx/formula/functions/math.ts
|
|
7615
|
-
var
|
|
8009
|
+
var C21 = "Math & Trig";
|
|
7616
8010
|
function roundTo(x, digits2, mode) {
|
|
7617
8011
|
if (!Number.isFinite(x)) return x;
|
|
7618
8012
|
const d = Math.trunc(digits2);
|
|
@@ -7631,10 +8025,10 @@ var quotientMultiple = (x, sig, op) => {
|
|
|
7631
8025
|
var MATH_FUNCTIONS = [
|
|
7632
8026
|
...MATH_MORE,
|
|
7633
8027
|
...SUM_FUNCTIONS,
|
|
7634
|
-
numeric("ABS",
|
|
8028
|
+
numeric("ABS", C21, "ABS(number)", "The absolute value of a number.", 1, 1, Math.abs),
|
|
7635
8029
|
numeric(
|
|
7636
8030
|
"SIGN",
|
|
7637
|
-
|
|
8031
|
+
C21,
|
|
7638
8032
|
"SIGN(number)",
|
|
7639
8033
|
"The sign of a number: 1, 0 or -1.",
|
|
7640
8034
|
1,
|
|
@@ -7643,7 +8037,7 @@ var MATH_FUNCTIONS = [
|
|
|
7643
8037
|
),
|
|
7644
8038
|
numeric(
|
|
7645
8039
|
"INT",
|
|
7646
|
-
|
|
8040
|
+
C21,
|
|
7647
8041
|
"INT(number)",
|
|
7648
8042
|
"Rounds a number down to the nearest integer.",
|
|
7649
8043
|
1,
|
|
@@ -7652,7 +8046,7 @@ var MATH_FUNCTIONS = [
|
|
|
7652
8046
|
),
|
|
7653
8047
|
numeric(
|
|
7654
8048
|
"TRUNC",
|
|
7655
|
-
|
|
8049
|
+
C21,
|
|
7656
8050
|
"TRUNC(number, [num_digits])",
|
|
7657
8051
|
"Truncates a number toward zero.",
|
|
7658
8052
|
1,
|
|
@@ -7661,7 +8055,7 @@ var MATH_FUNCTIONS = [
|
|
|
7661
8055
|
),
|
|
7662
8056
|
numeric(
|
|
7663
8057
|
"ROUND",
|
|
7664
|
-
|
|
8058
|
+
C21,
|
|
7665
8059
|
"ROUND(number, num_digits)",
|
|
7666
8060
|
"Rounds a number to a number of digits.",
|
|
7667
8061
|
2,
|
|
@@ -7670,7 +8064,7 @@ var MATH_FUNCTIONS = [
|
|
|
7670
8064
|
),
|
|
7671
8065
|
numeric(
|
|
7672
8066
|
"ROUNDUP",
|
|
7673
|
-
|
|
8067
|
+
C21,
|
|
7674
8068
|
"ROUNDUP(number, num_digits)",
|
|
7675
8069
|
"Rounds a number away from zero.",
|
|
7676
8070
|
2,
|
|
@@ -7679,7 +8073,7 @@ var MATH_FUNCTIONS = [
|
|
|
7679
8073
|
),
|
|
7680
8074
|
numeric(
|
|
7681
8075
|
"ROUNDDOWN",
|
|
7682
|
-
|
|
8076
|
+
C21,
|
|
7683
8077
|
"ROUNDDOWN(number, num_digits)",
|
|
7684
8078
|
"Rounds a number toward zero.",
|
|
7685
8079
|
2,
|
|
@@ -7688,7 +8082,7 @@ var MATH_FUNCTIONS = [
|
|
|
7688
8082
|
),
|
|
7689
8083
|
numeric(
|
|
7690
8084
|
"MROUND",
|
|
7691
|
-
|
|
8085
|
+
C21,
|
|
7692
8086
|
"MROUND(number, multiple)",
|
|
7693
8087
|
"Rounds a number to the nearest multiple.",
|
|
7694
8088
|
2,
|
|
@@ -7697,7 +8091,7 @@ var MATH_FUNCTIONS = [
|
|
|
7697
8091
|
),
|
|
7698
8092
|
numeric(
|
|
7699
8093
|
"CEILING",
|
|
7700
|
-
|
|
8094
|
+
C21,
|
|
7701
8095
|
"CEILING(number, significance)",
|
|
7702
8096
|
"Rounds a number up to a multiple of significance.",
|
|
7703
8097
|
2,
|
|
@@ -7709,7 +8103,7 @@ var MATH_FUNCTIONS = [
|
|
|
7709
8103
|
),
|
|
7710
8104
|
numeric(
|
|
7711
8105
|
"FLOOR",
|
|
7712
|
-
|
|
8106
|
+
C21,
|
|
7713
8107
|
"FLOOR(number, significance)",
|
|
7714
8108
|
"Rounds a number down to a multiple of significance.",
|
|
7715
8109
|
2,
|
|
@@ -7722,7 +8116,7 @@ var MATH_FUNCTIONS = [
|
|
|
7722
8116
|
),
|
|
7723
8117
|
numeric(
|
|
7724
8118
|
"CEILING.MATH",
|
|
7725
|
-
|
|
8119
|
+
C21,
|
|
7726
8120
|
"CEILING.MATH(number, [significance], [mode])",
|
|
7727
8121
|
"Rounds a number up to an integer or multiple.",
|
|
7728
8122
|
1,
|
|
@@ -7735,7 +8129,7 @@ var MATH_FUNCTIONS = [
|
|
|
7735
8129
|
),
|
|
7736
8130
|
numeric(
|
|
7737
8131
|
"FLOOR.MATH",
|
|
7738
|
-
|
|
8132
|
+
C21,
|
|
7739
8133
|
"FLOOR.MATH(number, [significance], [mode])",
|
|
7740
8134
|
"Rounds a number down to an integer or multiple.",
|
|
7741
8135
|
1,
|
|
@@ -7748,7 +8142,7 @@ var MATH_FUNCTIONS = [
|
|
|
7748
8142
|
),
|
|
7749
8143
|
numeric(
|
|
7750
8144
|
"CEILING.PRECISE",
|
|
7751
|
-
|
|
8145
|
+
C21,
|
|
7752
8146
|
"CEILING.PRECISE(number, [significance])",
|
|
7753
8147
|
"Rounds a number up regardless of sign.",
|
|
7754
8148
|
1,
|
|
@@ -7757,7 +8151,7 @@ var MATH_FUNCTIONS = [
|
|
|
7757
8151
|
),
|
|
7758
8152
|
numeric(
|
|
7759
8153
|
"ISO.CEILING",
|
|
7760
|
-
|
|
8154
|
+
C21,
|
|
7761
8155
|
"ISO.CEILING(number, [significance])",
|
|
7762
8156
|
"Rounds a number up regardless of sign.",
|
|
7763
8157
|
1,
|
|
@@ -7766,7 +8160,7 @@ var MATH_FUNCTIONS = [
|
|
|
7766
8160
|
),
|
|
7767
8161
|
numeric(
|
|
7768
8162
|
"FLOOR.PRECISE",
|
|
7769
|
-
|
|
8163
|
+
C21,
|
|
7770
8164
|
"FLOOR.PRECISE(number, [significance])",
|
|
7771
8165
|
"Rounds a number down regardless of sign.",
|
|
7772
8166
|
1,
|
|
@@ -7775,7 +8169,7 @@ var MATH_FUNCTIONS = [
|
|
|
7775
8169
|
),
|
|
7776
8170
|
numeric(
|
|
7777
8171
|
"EVEN",
|
|
7778
|
-
|
|
8172
|
+
C21,
|
|
7779
8173
|
"EVEN(number)",
|
|
7780
8174
|
"Rounds a number away from zero to an even integer.",
|
|
7781
8175
|
1,
|
|
@@ -7784,7 +8178,7 @@ var MATH_FUNCTIONS = [
|
|
|
7784
8178
|
),
|
|
7785
8179
|
numeric(
|
|
7786
8180
|
"ODD",
|
|
7787
|
-
|
|
8181
|
+
C21,
|
|
7788
8182
|
"ODD(number)",
|
|
7789
8183
|
"Rounds a number away from zero to an odd integer.",
|
|
7790
8184
|
1,
|
|
@@ -7796,7 +8190,7 @@ var MATH_FUNCTIONS = [
|
|
|
7796
8190
|
),
|
|
7797
8191
|
numeric(
|
|
7798
8192
|
"MOD",
|
|
7799
|
-
|
|
8193
|
+
C21,
|
|
7800
8194
|
"MOD(number, divisor)",
|
|
7801
8195
|
"The remainder after division (sign of the divisor).",
|
|
7802
8196
|
2,
|
|
@@ -7805,7 +8199,7 @@ var MATH_FUNCTIONS = [
|
|
|
7805
8199
|
),
|
|
7806
8200
|
numeric(
|
|
7807
8201
|
"QUOTIENT",
|
|
7808
|
-
|
|
8202
|
+
C21,
|
|
7809
8203
|
"QUOTIENT(numerator, denominator)",
|
|
7810
8204
|
"The integer part of a division.",
|
|
7811
8205
|
2,
|
|
@@ -7817,7 +8211,7 @@ var MATH_FUNCTIONS = [
|
|
|
7817
8211
|
),
|
|
7818
8212
|
numeric(
|
|
7819
8213
|
"SQRT",
|
|
7820
|
-
|
|
8214
|
+
C21,
|
|
7821
8215
|
"SQRT(number)",
|
|
7822
8216
|
"The positive square root.",
|
|
7823
8217
|
1,
|
|
@@ -7826,7 +8220,7 @@ var MATH_FUNCTIONS = [
|
|
|
7826
8220
|
),
|
|
7827
8221
|
numeric(
|
|
7828
8222
|
"SQRTPI",
|
|
7829
|
-
|
|
8223
|
+
C21,
|
|
7830
8224
|
"SQRTPI(number)",
|
|
7831
8225
|
"The square root of number * pi.",
|
|
7832
8226
|
1,
|
|
@@ -7835,18 +8229,18 @@ var MATH_FUNCTIONS = [
|
|
|
7835
8229
|
),
|
|
7836
8230
|
numeric(
|
|
7837
8231
|
"POWER",
|
|
7838
|
-
|
|
8232
|
+
C21,
|
|
7839
8233
|
"POWER(number, power)",
|
|
7840
8234
|
"A number raised to a power.",
|
|
7841
8235
|
2,
|
|
7842
8236
|
2,
|
|
7843
8237
|
(b, e) => power(b, e ?? 1)
|
|
7844
8238
|
),
|
|
7845
|
-
numeric("EXP",
|
|
7846
|
-
numeric("LN",
|
|
8239
|
+
numeric("EXP", C21, "EXP(number)", "e raised to a power.", 1, 1, Math.exp),
|
|
8240
|
+
numeric("LN", C21, "LN(number)", "The natural logarithm.", 1, 1, (x) => domain(x > 0, Math.log(x))),
|
|
7847
8241
|
numeric(
|
|
7848
8242
|
"LOG10",
|
|
7849
|
-
|
|
8243
|
+
C21,
|
|
7850
8244
|
"LOG10(number)",
|
|
7851
8245
|
"The base-10 logarithm.",
|
|
7852
8246
|
1,
|
|
@@ -7855,7 +8249,7 @@ var MATH_FUNCTIONS = [
|
|
|
7855
8249
|
),
|
|
7856
8250
|
numeric(
|
|
7857
8251
|
"LOG",
|
|
7858
|
-
|
|
8252
|
+
C21,
|
|
7859
8253
|
"LOG(number, [base])",
|
|
7860
8254
|
"The logarithm to a base (10 by default).",
|
|
7861
8255
|
1,
|
|
@@ -7867,12 +8261,12 @@ var MATH_FUNCTIONS = [
|
|
|
7867
8261
|
return base === 10 ? Math.log10(x) : Math.log(x) / Math.log(base);
|
|
7868
8262
|
}
|
|
7869
8263
|
),
|
|
7870
|
-
numeric("PI",
|
|
8264
|
+
numeric("PI", C21, "PI()", "The value of pi.", 0, 0, () => Math.PI),
|
|
7871
8265
|
...COMBINATORIC_FUNCTIONS
|
|
7872
8266
|
];
|
|
7873
8267
|
|
|
7874
8268
|
// src/xlsx/formula/functions/matrix.ts
|
|
7875
|
-
var
|
|
8269
|
+
var C22 = "Math & Trig";
|
|
7876
8270
|
function numbers2(ctx, value) {
|
|
7877
8271
|
return ctx.toMatrix(value ?? null).data.map(
|
|
7878
8272
|
(row2) => row2.map((v) => {
|
|
@@ -7931,7 +8325,7 @@ function eliminate(input, invert2) {
|
|
|
7931
8325
|
var MATRIX_FUNCTIONS = [
|
|
7932
8326
|
spec(
|
|
7933
8327
|
"MMULT",
|
|
7934
|
-
|
|
8328
|
+
C22,
|
|
7935
8329
|
"MMULT(array1, array2)",
|
|
7936
8330
|
"The matrix product of two arrays.",
|
|
7937
8331
|
2,
|
|
@@ -7952,7 +8346,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
7952
8346
|
),
|
|
7953
8347
|
spec(
|
|
7954
8348
|
"MDETERM",
|
|
7955
|
-
|
|
8349
|
+
C22,
|
|
7956
8350
|
"MDETERM(array)",
|
|
7957
8351
|
"The determinant of a square matrix.",
|
|
7958
8352
|
1,
|
|
@@ -7962,7 +8356,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
7962
8356
|
),
|
|
7963
8357
|
spec(
|
|
7964
8358
|
"MINVERSE",
|
|
7965
|
-
|
|
8359
|
+
C22,
|
|
7966
8360
|
"MINVERSE(array)",
|
|
7967
8361
|
"The inverse of a square matrix.",
|
|
7968
8362
|
1,
|
|
@@ -7974,7 +8368,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
7974
8368
|
},
|
|
7975
8369
|
["any"]
|
|
7976
8370
|
),
|
|
7977
|
-
spec("MUNIT",
|
|
8371
|
+
spec("MUNIT", C22, "MUNIT(dimension)", "The identity matrix.", 1, 1, (args) => {
|
|
7978
8372
|
const n2 = int(args[0]);
|
|
7979
8373
|
if (n2 < 1) fail(ERR.VALUE);
|
|
7980
8374
|
return Matrix.build(n2, n2, (r, c2) => r === c2 ? 1 : 0);
|
|
@@ -8041,7 +8435,7 @@ function fitStatistics(fit2) {
|
|
|
8041
8435
|
}
|
|
8042
8436
|
|
|
8043
8437
|
// src/xlsx/formula/functions/regression.ts
|
|
8044
|
-
var
|
|
8438
|
+
var C23 = "Statistical";
|
|
8045
8439
|
function numbersOf2(ctx, value) {
|
|
8046
8440
|
return ctx.toMatrix(value ?? null).data.map(
|
|
8047
8441
|
(row2) => row2.map((v) => {
|
|
@@ -8110,7 +8504,7 @@ var ARGS = ["any"];
|
|
|
8110
8504
|
var REGRESSION_FUNCTIONS = [
|
|
8111
8505
|
spec(
|
|
8112
8506
|
"LINEST",
|
|
8113
|
-
|
|
8507
|
+
C23,
|
|
8114
8508
|
"LINEST(known_y, [known_x], [const], [stats])",
|
|
8115
8509
|
"The statistics of a straight-line (or multiple linear) least-squares fit.",
|
|
8116
8510
|
1,
|
|
@@ -8124,7 +8518,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
8124
8518
|
),
|
|
8125
8519
|
spec(
|
|
8126
8520
|
"LOGEST",
|
|
8127
|
-
|
|
8521
|
+
C23,
|
|
8128
8522
|
"LOGEST(known_y, [known_x], [const], [stats])",
|
|
8129
8523
|
"The statistics of an exponential-curve fit.",
|
|
8130
8524
|
1,
|
|
@@ -8142,7 +8536,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
8142
8536
|
),
|
|
8143
8537
|
spec(
|
|
8144
8538
|
"TREND",
|
|
8145
|
-
|
|
8539
|
+
C23,
|
|
8146
8540
|
"TREND(known_y, [known_x], [new_x], [const])",
|
|
8147
8541
|
"Values along a linear trend.",
|
|
8148
8542
|
1,
|
|
@@ -8156,7 +8550,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
8156
8550
|
),
|
|
8157
8551
|
spec(
|
|
8158
8552
|
"GROWTH",
|
|
8159
|
-
|
|
8553
|
+
C23,
|
|
8160
8554
|
"GROWTH(known_y, [known_x], [new_x], [const])",
|
|
8161
8555
|
"Values along an exponential trend.",
|
|
8162
8556
|
1,
|
|
@@ -8310,7 +8704,7 @@ var tPdf = (t, df) => Math.exp(
|
|
|
8310
8704
|
gammaLn((df + 1) / 2) - gammaLn(df / 2) - 0.5 * Math.log(df * Math.PI) - (df + 1) / 2 * Math.log(1 + t * t / df)
|
|
8311
8705
|
);
|
|
8312
8706
|
var chiCdf = (x, df) => gammaP(df / 2, x / 2);
|
|
8313
|
-
var
|
|
8707
|
+
var positive2 = (...values2) => {
|
|
8314
8708
|
for (const v of values2) if (v === void 0 || v <= 0) fail(ERR.NUM);
|
|
8315
8709
|
};
|
|
8316
8710
|
var probability = (p) => {
|
|
@@ -8335,13 +8729,13 @@ function poisson(k, mean2, cumulative2) {
|
|
|
8335
8729
|
return Math.exp(kk * Math.log(mean2) - mean2 - gammaLn(kk + 1));
|
|
8336
8730
|
}
|
|
8337
8731
|
var normDist = (x, m, s, cumulative2) => {
|
|
8338
|
-
|
|
8732
|
+
positive2(s);
|
|
8339
8733
|
const z = (x - m) / s;
|
|
8340
8734
|
return cumulative2 ? normCdf(z) : normPdf(z) / s;
|
|
8341
8735
|
};
|
|
8342
8736
|
|
|
8343
8737
|
// src/xlsx/formula/functions/distributions-f.ts
|
|
8344
|
-
var
|
|
8738
|
+
var C24 = "Statistical";
|
|
8345
8739
|
var degrees = (...values2) => {
|
|
8346
8740
|
for (const v of values2) if (v === void 0 || v < 1) fail(ERR.NUM);
|
|
8347
8741
|
};
|
|
@@ -8362,13 +8756,13 @@ var betaScaled = (x, a, b, lo, hi) => {
|
|
|
8362
8756
|
return betaI((x - lo) / (hi - lo), a, b);
|
|
8363
8757
|
};
|
|
8364
8758
|
var betaInverse = (p, a, b, lo, hi) => {
|
|
8365
|
-
|
|
8759
|
+
positive2(a, b);
|
|
8366
8760
|
if (p <= 0 || p > 1 || lo >= hi) fail(ERR.NUM);
|
|
8367
8761
|
return lo + (hi - lo) * invert((t) => betaI(t, a, b), p, 0, 1);
|
|
8368
8762
|
};
|
|
8369
8763
|
var gammaInverse = (p, a, b) => {
|
|
8370
8764
|
prob(p);
|
|
8371
|
-
|
|
8765
|
+
positive2(a, b);
|
|
8372
8766
|
return p === 0 ? 0 : invert((x) => gammaP(a, x / b), p, 0, a * b + 1);
|
|
8373
8767
|
};
|
|
8374
8768
|
function binomInverse(trials, p, alpha) {
|
|
@@ -8400,7 +8794,7 @@ var negbinomPmf = (f, s, p) => {
|
|
|
8400
8794
|
var DISTRIBUTION_F = [
|
|
8401
8795
|
numeric(
|
|
8402
8796
|
"F.DIST",
|
|
8403
|
-
|
|
8797
|
+
C24,
|
|
8404
8798
|
"F.DIST(x, deg_freedom1, deg_freedom2, cumulative)",
|
|
8405
8799
|
"The left-tailed F probability distribution.",
|
|
8406
8800
|
4,
|
|
@@ -8416,7 +8810,7 @@ var DISTRIBUTION_F = [
|
|
|
8416
8810
|
...["F.DIST.RT", "FDIST"].map(
|
|
8417
8811
|
(name) => numeric(
|
|
8418
8812
|
name,
|
|
8419
|
-
|
|
8813
|
+
C24,
|
|
8420
8814
|
`${name}(x, deg_freedom1, deg_freedom2)`,
|
|
8421
8815
|
"The right-tailed F probability distribution.",
|
|
8422
8816
|
3,
|
|
@@ -8430,7 +8824,7 @@ var DISTRIBUTION_F = [
|
|
|
8430
8824
|
),
|
|
8431
8825
|
numeric(
|
|
8432
8826
|
"F.INV",
|
|
8433
|
-
|
|
8827
|
+
C24,
|
|
8434
8828
|
"F.INV(probability, deg_freedom1, deg_freedom2)",
|
|
8435
8829
|
"The inverse of the left-tailed F distribution.",
|
|
8436
8830
|
3,
|
|
@@ -8444,7 +8838,7 @@ var DISTRIBUTION_F = [
|
|
|
8444
8838
|
...["F.INV.RT", "FINV"].map(
|
|
8445
8839
|
(name) => numeric(
|
|
8446
8840
|
name,
|
|
8447
|
-
|
|
8841
|
+
C24,
|
|
8448
8842
|
`${name}(probability, deg_freedom1, deg_freedom2)`,
|
|
8449
8843
|
"The inverse of the right-tailed F distribution.",
|
|
8450
8844
|
3,
|
|
@@ -8459,7 +8853,7 @@ var DISTRIBUTION_F = [
|
|
|
8459
8853
|
...["BETA.INV", "BETAINV"].map(
|
|
8460
8854
|
(name) => numeric(
|
|
8461
8855
|
name,
|
|
8462
|
-
|
|
8856
|
+
C24,
|
|
8463
8857
|
`${name}(probability, alpha, beta, [A], [B])`,
|
|
8464
8858
|
"The inverse of the cumulative beta distribution.",
|
|
8465
8859
|
3,
|
|
@@ -8470,13 +8864,13 @@ var DISTRIBUTION_F = [
|
|
|
8470
8864
|
),
|
|
8471
8865
|
numeric(
|
|
8472
8866
|
"BETADIST",
|
|
8473
|
-
|
|
8867
|
+
C24,
|
|
8474
8868
|
"BETADIST(x, alpha, beta, [A], [B])",
|
|
8475
8869
|
"The cumulative beta distribution.",
|
|
8476
8870
|
3,
|
|
8477
8871
|
5,
|
|
8478
8872
|
(x, a, b, lo, hi) => {
|
|
8479
|
-
|
|
8873
|
+
positive2(a, b);
|
|
8480
8874
|
return betaScaled(x, a ?? 1, b ?? 1, lo ?? 0, hi ?? 1);
|
|
8481
8875
|
},
|
|
8482
8876
|
[0, 0, 0, 0, 1]
|
|
@@ -8484,7 +8878,7 @@ var DISTRIBUTION_F = [
|
|
|
8484
8878
|
...["GAMMA.INV", "GAMMAINV"].map(
|
|
8485
8879
|
(name) => numeric(
|
|
8486
8880
|
name,
|
|
8487
|
-
|
|
8881
|
+
C24,
|
|
8488
8882
|
`${name}(probability, alpha, beta)`,
|
|
8489
8883
|
"The inverse of the gamma cumulative distribution.",
|
|
8490
8884
|
3,
|
|
@@ -8494,14 +8888,14 @@ var DISTRIBUTION_F = [
|
|
|
8494
8888
|
),
|
|
8495
8889
|
numeric(
|
|
8496
8890
|
"GAMMADIST",
|
|
8497
|
-
|
|
8891
|
+
C24,
|
|
8498
8892
|
"GAMMADIST(x, alpha, beta, cumulative)",
|
|
8499
8893
|
"The gamma distribution.",
|
|
8500
8894
|
4,
|
|
8501
8895
|
4,
|
|
8502
8896
|
(x, a, b, c2) => {
|
|
8503
8897
|
if (x < 0) fail(ERR.NUM);
|
|
8504
|
-
|
|
8898
|
+
positive2(a, b);
|
|
8505
8899
|
const al = a ?? 1;
|
|
8506
8900
|
const be = b ?? 1;
|
|
8507
8901
|
return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
|
|
@@ -8509,33 +8903,33 @@ var DISTRIBUTION_F = [
|
|
|
8509
8903
|
),
|
|
8510
8904
|
numeric(
|
|
8511
8905
|
"LOGINV",
|
|
8512
|
-
|
|
8906
|
+
C24,
|
|
8513
8907
|
"LOGINV(probability, mean, standard_dev)",
|
|
8514
8908
|
"The inverse of the lognormal cumulative distribution.",
|
|
8515
8909
|
3,
|
|
8516
8910
|
3,
|
|
8517
8911
|
(p, m, s) => {
|
|
8518
|
-
|
|
8912
|
+
positive2(s);
|
|
8519
8913
|
if (p <= 0 || p >= 1) fail(ERR.NUM);
|
|
8520
8914
|
return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
|
|
8521
8915
|
}
|
|
8522
8916
|
),
|
|
8523
8917
|
numeric(
|
|
8524
8918
|
"LOGNORMDIST",
|
|
8525
|
-
|
|
8919
|
+
C24,
|
|
8526
8920
|
"LOGNORMDIST(x, mean, standard_dev)",
|
|
8527
8921
|
"The cumulative lognormal distribution.",
|
|
8528
8922
|
3,
|
|
8529
8923
|
3,
|
|
8530
8924
|
(x, m, s) => {
|
|
8531
|
-
|
|
8925
|
+
positive2(x, s);
|
|
8532
8926
|
return normCdf((Math.log(x) - (m ?? 0)) / (s ?? 1));
|
|
8533
8927
|
}
|
|
8534
8928
|
),
|
|
8535
8929
|
...["BINOM.INV", "CRITBINOM"].map(
|
|
8536
8930
|
(name) => numeric(
|
|
8537
8931
|
name,
|
|
8538
|
-
|
|
8932
|
+
C24,
|
|
8539
8933
|
`${name}(trials, probability_s, alpha)`,
|
|
8540
8934
|
"The smallest value whose cumulative binomial distribution reaches the criterion.",
|
|
8541
8935
|
3,
|
|
@@ -8545,7 +8939,7 @@ var DISTRIBUTION_F = [
|
|
|
8545
8939
|
),
|
|
8546
8940
|
numeric(
|
|
8547
8941
|
"BINOM.DIST.RANGE",
|
|
8548
|
-
|
|
8942
|
+
C24,
|
|
8549
8943
|
"BINOM.DIST.RANGE(trials, probability_s, number_s, [number_s2])",
|
|
8550
8944
|
"The probability of a trial result within a range, from the binomial distribution.",
|
|
8551
8945
|
3,
|
|
@@ -8563,7 +8957,7 @@ var DISTRIBUTION_F = [
|
|
|
8563
8957
|
),
|
|
8564
8958
|
numeric(
|
|
8565
8959
|
"HYPGEOMDIST",
|
|
8566
|
-
|
|
8960
|
+
C24,
|
|
8567
8961
|
"HYPGEOMDIST(sample_s, number_sample, population_s, number_pop)",
|
|
8568
8962
|
"The hypergeometric distribution.",
|
|
8569
8963
|
4,
|
|
@@ -8572,7 +8966,7 @@ var DISTRIBUTION_F = [
|
|
|
8572
8966
|
),
|
|
8573
8967
|
numeric(
|
|
8574
8968
|
"NEGBINOMDIST",
|
|
8575
|
-
|
|
8969
|
+
C24,
|
|
8576
8970
|
"NEGBINOMDIST(number_f, number_s, probability_s)",
|
|
8577
8971
|
"The negative binomial distribution.",
|
|
8578
8972
|
3,
|
|
@@ -8582,7 +8976,7 @@ var DISTRIBUTION_F = [
|
|
|
8582
8976
|
];
|
|
8583
8977
|
|
|
8584
8978
|
// src/xlsx/formula/functions/statistical-shape.ts
|
|
8585
|
-
var
|
|
8979
|
+
var C25 = "Statistical";
|
|
8586
8980
|
function moments(values2) {
|
|
8587
8981
|
const n2 = values2.length;
|
|
8588
8982
|
return { n: n2, m: mean(values2), s: stdev(values2, true) };
|
|
@@ -8599,7 +8993,7 @@ function frequency(data, bins) {
|
|
|
8599
8993
|
var STATISTICAL_SHAPE = [
|
|
8600
8994
|
spec(
|
|
8601
8995
|
"GEOMEAN",
|
|
8602
|
-
|
|
8996
|
+
C25,
|
|
8603
8997
|
"GEOMEAN(number1, ...)",
|
|
8604
8998
|
"The geometric mean.",
|
|
8605
8999
|
1,
|
|
@@ -8613,7 +9007,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8613
9007
|
),
|
|
8614
9008
|
spec(
|
|
8615
9009
|
"HARMEAN",
|
|
8616
|
-
|
|
9010
|
+
C25,
|
|
8617
9011
|
"HARMEAN(number1, ...)",
|
|
8618
9012
|
"The harmonic mean.",
|
|
8619
9013
|
1,
|
|
@@ -8627,7 +9021,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8627
9021
|
),
|
|
8628
9022
|
spec(
|
|
8629
9023
|
"AVEDEV",
|
|
8630
|
-
|
|
9024
|
+
C25,
|
|
8631
9025
|
"AVEDEV(number1, ...)",
|
|
8632
9026
|
"The mean absolute deviation from the mean.",
|
|
8633
9027
|
1,
|
|
@@ -8642,7 +9036,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8642
9036
|
),
|
|
8643
9037
|
spec(
|
|
8644
9038
|
"DEVSQ",
|
|
8645
|
-
|
|
9039
|
+
C25,
|
|
8646
9040
|
"DEVSQ(number1, ...)",
|
|
8647
9041
|
"The sum of squared deviations from the mean.",
|
|
8648
9042
|
1,
|
|
@@ -8655,7 +9049,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8655
9049
|
),
|
|
8656
9050
|
spec(
|
|
8657
9051
|
"KURT",
|
|
8658
|
-
|
|
9052
|
+
C25,
|
|
8659
9053
|
"KURT(number1, ...)",
|
|
8660
9054
|
"The kurtosis of a data set.",
|
|
8661
9055
|
1,
|
|
@@ -8671,7 +9065,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8671
9065
|
),
|
|
8672
9066
|
spec(
|
|
8673
9067
|
"SKEW",
|
|
8674
|
-
|
|
9068
|
+
C25,
|
|
8675
9069
|
"SKEW(number1, ...)",
|
|
8676
9070
|
"The skewness of a distribution.",
|
|
8677
9071
|
1,
|
|
@@ -8686,7 +9080,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8686
9080
|
),
|
|
8687
9081
|
spec(
|
|
8688
9082
|
"SKEW.P",
|
|
8689
|
-
|
|
9083
|
+
C25,
|
|
8690
9084
|
"SKEW.P(number1, ...)",
|
|
8691
9085
|
"The population skewness.",
|
|
8692
9086
|
1,
|
|
@@ -8702,7 +9096,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8702
9096
|
),
|
|
8703
9097
|
numeric(
|
|
8704
9098
|
"STANDARDIZE",
|
|
8705
|
-
|
|
9099
|
+
C25,
|
|
8706
9100
|
"STANDARDIZE(x, mean, standard_dev)",
|
|
8707
9101
|
"A normalized value.",
|
|
8708
9102
|
3,
|
|
@@ -8714,7 +9108,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8714
9108
|
),
|
|
8715
9109
|
spec(
|
|
8716
9110
|
"TRIMMEAN",
|
|
8717
|
-
|
|
9111
|
+
C25,
|
|
8718
9112
|
"TRIMMEAN(array, percent)",
|
|
8719
9113
|
"The mean of the interior of a data set.",
|
|
8720
9114
|
2,
|
|
@@ -8730,7 +9124,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8730
9124
|
),
|
|
8731
9125
|
spec(
|
|
8732
9126
|
"FREQUENCY",
|
|
8733
|
-
|
|
9127
|
+
C25,
|
|
8734
9128
|
"FREQUENCY(data_array, bins_array)",
|
|
8735
9129
|
"How often values occur within ranges, as a vertical array.",
|
|
8736
9130
|
2,
|
|
@@ -8740,7 +9134,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8740
9134
|
),
|
|
8741
9135
|
numeric(
|
|
8742
9136
|
"PERMUT",
|
|
8743
|
-
|
|
9137
|
+
C25,
|
|
8744
9138
|
"PERMUT(number, number_chosen)",
|
|
8745
9139
|
"The number of permutations.",
|
|
8746
9140
|
2,
|
|
@@ -8756,7 +9150,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8756
9150
|
),
|
|
8757
9151
|
numeric(
|
|
8758
9152
|
"PERMUTATIONA",
|
|
8759
|
-
|
|
9153
|
+
C25,
|
|
8760
9154
|
"PERMUTATIONA(number, number_chosen)",
|
|
8761
9155
|
"Permutations with repetitions.",
|
|
8762
9156
|
2,
|
|
@@ -8766,26 +9160,26 @@ var STATISTICAL_SHAPE = [
|
|
|
8766
9160
|
return Math.pow(Math.trunc(n2), Math.trunc(k ?? 0));
|
|
8767
9161
|
}
|
|
8768
9162
|
),
|
|
8769
|
-
numeric("FISHER",
|
|
9163
|
+
numeric("FISHER", C25, "FISHER(x)", "The Fisher transformation.", 1, 1, (x) => {
|
|
8770
9164
|
if (x <= -1 || x >= 1) fail(ERR.NUM);
|
|
8771
9165
|
return 0.5 * Math.log((1 + x) / (1 - x));
|
|
8772
9166
|
}),
|
|
8773
9167
|
numeric(
|
|
8774
9168
|
"FISHERINV",
|
|
8775
|
-
|
|
9169
|
+
C25,
|
|
8776
9170
|
"FISHERINV(y)",
|
|
8777
9171
|
"The inverse of the Fisher transformation.",
|
|
8778
9172
|
1,
|
|
8779
9173
|
1,
|
|
8780
9174
|
(y) => Math.tanh(y)
|
|
8781
9175
|
),
|
|
8782
|
-
numeric("GAMMA",
|
|
9176
|
+
numeric("GAMMA", C25, "GAMMA(number)", "The gamma function value.", 1, 1, (x) => {
|
|
8783
9177
|
if (x <= 0 && Number.isInteger(x)) fail(ERR.NUM);
|
|
8784
9178
|
return gamma(x);
|
|
8785
9179
|
}),
|
|
8786
9180
|
numeric(
|
|
8787
9181
|
"GAMMALN",
|
|
8788
|
-
|
|
9182
|
+
C25,
|
|
8789
9183
|
"GAMMALN(x)",
|
|
8790
9184
|
"The natural logarithm of the gamma function.",
|
|
8791
9185
|
1,
|
|
@@ -8794,7 +9188,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8794
9188
|
),
|
|
8795
9189
|
numeric(
|
|
8796
9190
|
"GAMMALN.PRECISE",
|
|
8797
|
-
|
|
9191
|
+
C25,
|
|
8798
9192
|
"GAMMALN.PRECISE(x)",
|
|
8799
9193
|
"The natural logarithm of the gamma function.",
|
|
8800
9194
|
1,
|
|
@@ -8804,7 +9198,7 @@ var STATISTICAL_SHAPE = [
|
|
|
8804
9198
|
];
|
|
8805
9199
|
|
|
8806
9200
|
// src/xlsx/formula/functions/statistical-more.ts
|
|
8807
|
-
var
|
|
9201
|
+
var C26 = "Statistical";
|
|
8808
9202
|
function pairedNumbers(ctx, a, b) {
|
|
8809
9203
|
const ma = ctx.toMatrix(a).flat();
|
|
8810
9204
|
const mb = ctx.toMatrix(b).flat();
|
|
@@ -8825,7 +9219,7 @@ function pairedNumbers(ctx, a, b) {
|
|
|
8825
9219
|
}
|
|
8826
9220
|
var pairFn = (name, description, syntax, fn) => spec(
|
|
8827
9221
|
name,
|
|
8828
|
-
|
|
9222
|
+
C26,
|
|
8829
9223
|
syntax,
|
|
8830
9224
|
description,
|
|
8831
9225
|
2,
|
|
@@ -8840,7 +9234,7 @@ var STATISTICAL_MORE = [
|
|
|
8840
9234
|
...STATISTICAL_SHAPE,
|
|
8841
9235
|
spec(
|
|
8842
9236
|
"MODE.MULT",
|
|
8843
|
-
|
|
9237
|
+
C26,
|
|
8844
9238
|
"MODE.MULT(number1, [number2], ...)",
|
|
8845
9239
|
"A vertical array of the most frequent values.",
|
|
8846
9240
|
1,
|
|
@@ -8922,7 +9316,7 @@ var STATISTICAL_MORE = [
|
|
|
8922
9316
|
...["FORECAST", "FORECAST.LINEAR"].map(
|
|
8923
9317
|
(name) => spec(
|
|
8924
9318
|
name,
|
|
8925
|
-
|
|
9319
|
+
C26,
|
|
8926
9320
|
`${name}(x, known_ys, known_xs)`,
|
|
8927
9321
|
"Predicts a value along a linear trend.",
|
|
8928
9322
|
3,
|
|
@@ -8939,7 +9333,7 @@ var STATISTICAL_MORE = [
|
|
|
8939
9333
|
];
|
|
8940
9334
|
|
|
8941
9335
|
// src/xlsx/formula/functions/hypothesis-tests.ts
|
|
8942
|
-
var
|
|
9336
|
+
var C27 = "Statistical";
|
|
8943
9337
|
var ARRAYS = ["any"];
|
|
8944
9338
|
var numbersOf3 = (ctx, value) => collectNumbers(ctx, [value ?? null]);
|
|
8945
9339
|
function tStatistic(a, b, type) {
|
|
@@ -9024,7 +9418,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9024
9418
|
["Z.TEST", "ZTEST"],
|
|
9025
9419
|
(name) => spec(
|
|
9026
9420
|
name,
|
|
9027
|
-
|
|
9421
|
+
C27,
|
|
9028
9422
|
`${name}(array, x, [sigma])`,
|
|
9029
9423
|
"The one-tailed P-value of a z-test.",
|
|
9030
9424
|
2,
|
|
@@ -9043,7 +9437,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9043
9437
|
["T.TEST", "TTEST"],
|
|
9044
9438
|
(name) => spec(
|
|
9045
9439
|
name,
|
|
9046
|
-
|
|
9440
|
+
C27,
|
|
9047
9441
|
`${name}(array1, array2, tails, type)`,
|
|
9048
9442
|
"The probability associated with a Student's t-test.",
|
|
9049
9443
|
4,
|
|
@@ -9064,7 +9458,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9064
9458
|
["F.TEST", "FTEST"],
|
|
9065
9459
|
(name) => spec(
|
|
9066
9460
|
name,
|
|
9067
|
-
|
|
9461
|
+
C27,
|
|
9068
9462
|
`${name}(array1, array2)`,
|
|
9069
9463
|
"The two-tailed probability that the variances of two arrays are not different.",
|
|
9070
9464
|
2,
|
|
@@ -9077,7 +9471,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9077
9471
|
["CHISQ.TEST", "CHITEST"],
|
|
9078
9472
|
(name) => spec(
|
|
9079
9473
|
name,
|
|
9080
|
-
|
|
9474
|
+
C27,
|
|
9081
9475
|
`${name}(actual_range, expected_range)`,
|
|
9082
9476
|
"The chi-squared test of independence.",
|
|
9083
9477
|
2,
|
|
@@ -9088,7 +9482,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9088
9482
|
),
|
|
9089
9483
|
spec(
|
|
9090
9484
|
"PROB",
|
|
9091
|
-
|
|
9485
|
+
C27,
|
|
9092
9486
|
"PROB(x_range, prob_range, lower_limit, [upper_limit])",
|
|
9093
9487
|
"The probability that values in a range are between two limits.",
|
|
9094
9488
|
3,
|
|
@@ -9099,7 +9493,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
9099
9493
|
];
|
|
9100
9494
|
|
|
9101
9495
|
// src/xlsx/formula/functions/statistical-spread.ts
|
|
9102
|
-
var
|
|
9496
|
+
var C28 = "Statistical";
|
|
9103
9497
|
var STATISTICAL_SPREAD = [
|
|
9104
9498
|
...[
|
|
9105
9499
|
["STDEV", true, false],
|
|
@@ -9111,7 +9505,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9111
9505
|
].map(
|
|
9112
9506
|
([name, sample, a]) => spec(
|
|
9113
9507
|
name,
|
|
9114
|
-
|
|
9508
|
+
C28,
|
|
9115
9509
|
`${name}(number1, [number2], ...)`,
|
|
9116
9510
|
`The ${sample ? "sample" : "population"} standard deviation${a ? " counting logicals and text" : ""}.`,
|
|
9117
9511
|
1,
|
|
@@ -9130,7 +9524,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9130
9524
|
].map(
|
|
9131
9525
|
([name, sample, a]) => spec(
|
|
9132
9526
|
name,
|
|
9133
|
-
|
|
9527
|
+
C28,
|
|
9134
9528
|
`${name}(number1, [number2], ...)`,
|
|
9135
9529
|
`The ${sample ? "sample" : "population"} variance${a ? " counting logicals and text" : ""}.`,
|
|
9136
9530
|
1,
|
|
@@ -9142,7 +9536,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9142
9536
|
...["PERCENTILE", "PERCENTILE.INC", "PERCENTILE.EXC"].map(
|
|
9143
9537
|
(name) => spec(
|
|
9144
9538
|
name,
|
|
9145
|
-
|
|
9539
|
+
C28,
|
|
9146
9540
|
`${name}(array, k)`,
|
|
9147
9541
|
"The k-th percentile.",
|
|
9148
9542
|
2,
|
|
@@ -9158,7 +9552,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9158
9552
|
...["QUARTILE", "QUARTILE.INC", "QUARTILE.EXC"].map(
|
|
9159
9553
|
(name) => spec(
|
|
9160
9554
|
name,
|
|
9161
|
-
|
|
9555
|
+
C28,
|
|
9162
9556
|
`${name}(array, quart)`,
|
|
9163
9557
|
"A quartile of a data set.",
|
|
9164
9558
|
2,
|
|
@@ -9170,7 +9564,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9170
9564
|
...["PERCENTRANK", "PERCENTRANK.INC", "PERCENTRANK.EXC"].map(
|
|
9171
9565
|
(name) => spec(
|
|
9172
9566
|
name,
|
|
9173
|
-
|
|
9567
|
+
C28,
|
|
9174
9568
|
`${name}(array, x, [significance])`,
|
|
9175
9569
|
"The rank of a value as a percentage of the data set.",
|
|
9176
9570
|
2,
|
|
@@ -9187,7 +9581,7 @@ var STATISTICAL_SPREAD = [
|
|
|
9187
9581
|
];
|
|
9188
9582
|
|
|
9189
9583
|
// src/xlsx/formula/functions/statistical-count.ts
|
|
9190
|
-
var
|
|
9584
|
+
var C29 = "Statistical";
|
|
9191
9585
|
function count(ctx, args) {
|
|
9192
9586
|
let n2 = 0;
|
|
9193
9587
|
for (const arg of args) {
|
|
@@ -9253,7 +9647,7 @@ function countIf(ctx, range, criteria) {
|
|
|
9253
9647
|
var COUNT_FUNCTIONS = [
|
|
9254
9648
|
spec(
|
|
9255
9649
|
"COUNT",
|
|
9256
|
-
|
|
9650
|
+
C29,
|
|
9257
9651
|
"COUNT(value1, [value2], ...)",
|
|
9258
9652
|
"Counts the numbers in the arguments.",
|
|
9259
9653
|
0,
|
|
@@ -9263,7 +9657,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9263
9657
|
),
|
|
9264
9658
|
spec(
|
|
9265
9659
|
"COUNTA",
|
|
9266
|
-
|
|
9660
|
+
C29,
|
|
9267
9661
|
"COUNTA(value1, [value2], ...)",
|
|
9268
9662
|
"Counts the non-empty values.",
|
|
9269
9663
|
1,
|
|
@@ -9273,7 +9667,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9273
9667
|
),
|
|
9274
9668
|
spec(
|
|
9275
9669
|
"COUNTBLANK",
|
|
9276
|
-
|
|
9670
|
+
C29,
|
|
9277
9671
|
"COUNTBLANK(range)",
|
|
9278
9672
|
"Counts the empty cells in a range.",
|
|
9279
9673
|
1,
|
|
@@ -9283,7 +9677,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9283
9677
|
),
|
|
9284
9678
|
spec(
|
|
9285
9679
|
"COUNTIF",
|
|
9286
|
-
|
|
9680
|
+
C29,
|
|
9287
9681
|
"COUNTIF(range, criteria)",
|
|
9288
9682
|
"Counts the cells that meet a criterion.",
|
|
9289
9683
|
2,
|
|
@@ -9293,7 +9687,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9293
9687
|
),
|
|
9294
9688
|
spec(
|
|
9295
9689
|
"COUNTIFS",
|
|
9296
|
-
|
|
9690
|
+
C29,
|
|
9297
9691
|
"COUNTIFS(criteria_range1, criteria1, ...)",
|
|
9298
9692
|
"Counts the cells that meet several criteria.",
|
|
9299
9693
|
2,
|
|
@@ -9306,7 +9700,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9306
9700
|
),
|
|
9307
9701
|
spec(
|
|
9308
9702
|
"AVERAGE",
|
|
9309
|
-
|
|
9703
|
+
C29,
|
|
9310
9704
|
"AVERAGE(number1, [number2], ...)",
|
|
9311
9705
|
"The arithmetic mean.",
|
|
9312
9706
|
1,
|
|
@@ -9317,7 +9711,7 @@ var COUNT_FUNCTIONS = [
|
|
|
9317
9711
|
];
|
|
9318
9712
|
|
|
9319
9713
|
// src/xlsx/formula/functions/statistical.ts
|
|
9320
|
-
var
|
|
9714
|
+
var C30 = "Statistical";
|
|
9321
9715
|
var numbersOf4 = (values2) => values2.filter((v) => typeof v === "number");
|
|
9322
9716
|
var extreme2 = extreme;
|
|
9323
9717
|
var STATISTICAL_FUNCTIONS = [
|
|
@@ -9328,7 +9722,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9328
9722
|
...COUNT_FUNCTIONS,
|
|
9329
9723
|
spec(
|
|
9330
9724
|
"AVERAGEA",
|
|
9331
|
-
|
|
9725
|
+
C30,
|
|
9332
9726
|
"AVERAGEA(value1, [value2], ...)",
|
|
9333
9727
|
"The mean counting text as 0 and logicals.",
|
|
9334
9728
|
1,
|
|
@@ -9338,7 +9732,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9338
9732
|
),
|
|
9339
9733
|
spec(
|
|
9340
9734
|
"AVERAGEIF",
|
|
9341
|
-
|
|
9735
|
+
C30,
|
|
9342
9736
|
"AVERAGEIF(range, criteria, [average_range])",
|
|
9343
9737
|
"The mean of the cells that meet a criterion.",
|
|
9344
9738
|
2,
|
|
@@ -9357,7 +9751,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9357
9751
|
),
|
|
9358
9752
|
spec(
|
|
9359
9753
|
"AVERAGEIFS",
|
|
9360
|
-
|
|
9754
|
+
C30,
|
|
9361
9755
|
"AVERAGEIFS(average_range, criteria_range1, criteria1, ...)",
|
|
9362
9756
|
"The mean of the cells that meet several criteria.",
|
|
9363
9757
|
3,
|
|
@@ -9371,7 +9765,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9371
9765
|
),
|
|
9372
9766
|
spec(
|
|
9373
9767
|
"MAX",
|
|
9374
|
-
|
|
9768
|
+
C30,
|
|
9375
9769
|
"MAX(number1, [number2], ...)",
|
|
9376
9770
|
"The largest value.",
|
|
9377
9771
|
1,
|
|
@@ -9381,7 +9775,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9381
9775
|
),
|
|
9382
9776
|
spec(
|
|
9383
9777
|
"MIN",
|
|
9384
|
-
|
|
9778
|
+
C30,
|
|
9385
9779
|
"MIN(number1, [number2], ...)",
|
|
9386
9780
|
"The smallest value.",
|
|
9387
9781
|
1,
|
|
@@ -9391,7 +9785,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9391
9785
|
),
|
|
9392
9786
|
spec(
|
|
9393
9787
|
"MAXA",
|
|
9394
|
-
|
|
9788
|
+
C30,
|
|
9395
9789
|
"MAXA(value1, [value2], ...)",
|
|
9396
9790
|
"The largest value counting logicals and text.",
|
|
9397
9791
|
1,
|
|
@@ -9401,7 +9795,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9401
9795
|
),
|
|
9402
9796
|
spec(
|
|
9403
9797
|
"MINA",
|
|
9404
|
-
|
|
9798
|
+
C30,
|
|
9405
9799
|
"MINA(value1, [value2], ...)",
|
|
9406
9800
|
"The smallest value counting logicals and text.",
|
|
9407
9801
|
1,
|
|
@@ -9411,7 +9805,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9411
9805
|
),
|
|
9412
9806
|
spec(
|
|
9413
9807
|
"MAXIFS",
|
|
9414
|
-
|
|
9808
|
+
C30,
|
|
9415
9809
|
"MAXIFS(max_range, criteria_range1, criteria1, ...)",
|
|
9416
9810
|
"The largest value meeting criteria.",
|
|
9417
9811
|
3,
|
|
@@ -9425,7 +9819,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9425
9819
|
),
|
|
9426
9820
|
spec(
|
|
9427
9821
|
"MINIFS",
|
|
9428
|
-
|
|
9822
|
+
C30,
|
|
9429
9823
|
"MINIFS(min_range, criteria_range1, criteria1, ...)",
|
|
9430
9824
|
"The smallest value meeting criteria.",
|
|
9431
9825
|
3,
|
|
@@ -9439,7 +9833,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9439
9833
|
),
|
|
9440
9834
|
spec(
|
|
9441
9835
|
"MEDIAN",
|
|
9442
|
-
|
|
9836
|
+
C30,
|
|
9443
9837
|
"MEDIAN(number1, [number2], ...)",
|
|
9444
9838
|
"The median.",
|
|
9445
9839
|
1,
|
|
@@ -9449,7 +9843,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9449
9843
|
),
|
|
9450
9844
|
spec(
|
|
9451
9845
|
"MODE",
|
|
9452
|
-
|
|
9846
|
+
C30,
|
|
9453
9847
|
"MODE(number1, [number2], ...)",
|
|
9454
9848
|
"The most frequent value.",
|
|
9455
9849
|
1,
|
|
@@ -9459,7 +9853,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9459
9853
|
),
|
|
9460
9854
|
spec(
|
|
9461
9855
|
"MODE.SNGL",
|
|
9462
|
-
|
|
9856
|
+
C30,
|
|
9463
9857
|
"MODE.SNGL(number1, [number2], ...)",
|
|
9464
9858
|
"The most frequent value.",
|
|
9465
9859
|
1,
|
|
@@ -9469,7 +9863,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9469
9863
|
),
|
|
9470
9864
|
spec(
|
|
9471
9865
|
"LARGE",
|
|
9472
|
-
|
|
9866
|
+
C30,
|
|
9473
9867
|
"LARGE(array, k)",
|
|
9474
9868
|
"The k-th largest value.",
|
|
9475
9869
|
2,
|
|
@@ -9479,7 +9873,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9479
9873
|
),
|
|
9480
9874
|
spec(
|
|
9481
9875
|
"SMALL",
|
|
9482
|
-
|
|
9876
|
+
C30,
|
|
9483
9877
|
"SMALL(array, k)",
|
|
9484
9878
|
"The k-th smallest value.",
|
|
9485
9879
|
2,
|
|
@@ -9490,7 +9884,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9490
9884
|
...["RANK", "RANK.EQ", "RANK.AVG"].map(
|
|
9491
9885
|
(name) => spec(
|
|
9492
9886
|
name,
|
|
9493
|
-
|
|
9887
|
+
C30,
|
|
9494
9888
|
`${name}(number, ref, [order])`,
|
|
9495
9889
|
"The rank of a number in a list.",
|
|
9496
9890
|
2,
|
|
@@ -9507,11 +9901,11 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
9507
9901
|
];
|
|
9508
9902
|
|
|
9509
9903
|
// src/xlsx/formula/functions/distributions-more.ts
|
|
9510
|
-
var
|
|
9904
|
+
var C31 = "Statistical";
|
|
9511
9905
|
var DISTRIBUTION_MORE = [
|
|
9512
9906
|
numeric(
|
|
9513
9907
|
"T.DIST",
|
|
9514
|
-
|
|
9908
|
+
C31,
|
|
9515
9909
|
"T.DIST(x, deg_freedom, cumulative)",
|
|
9516
9910
|
"Student's left-tailed t-distribution.",
|
|
9517
9911
|
3,
|
|
@@ -9523,7 +9917,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9523
9917
|
),
|
|
9524
9918
|
numeric(
|
|
9525
9919
|
"T.DIST.RT",
|
|
9526
|
-
|
|
9920
|
+
C31,
|
|
9527
9921
|
"T.DIST.RT(x, deg_freedom)",
|
|
9528
9922
|
"Student's right-tailed t-distribution.",
|
|
9529
9923
|
2,
|
|
@@ -9535,7 +9929,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9535
9929
|
),
|
|
9536
9930
|
numeric(
|
|
9537
9931
|
"T.DIST.2T",
|
|
9538
|
-
|
|
9932
|
+
C31,
|
|
9539
9933
|
"T.DIST.2T(x, deg_freedom)",
|
|
9540
9934
|
"Student's two-tailed t-distribution.",
|
|
9541
9935
|
2,
|
|
@@ -9547,7 +9941,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9547
9941
|
),
|
|
9548
9942
|
numeric(
|
|
9549
9943
|
"TDIST",
|
|
9550
|
-
|
|
9944
|
+
C31,
|
|
9551
9945
|
"TDIST(x, deg_freedom, tails)",
|
|
9552
9946
|
"Student's t-distribution.",
|
|
9553
9947
|
3,
|
|
@@ -9559,7 +9953,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9559
9953
|
),
|
|
9560
9954
|
numeric(
|
|
9561
9955
|
"T.INV",
|
|
9562
|
-
|
|
9956
|
+
C31,
|
|
9563
9957
|
"T.INV(probability, deg_freedom)",
|
|
9564
9958
|
"The left-tailed inverse of Student's t-distribution.",
|
|
9565
9959
|
2,
|
|
@@ -9574,7 +9968,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9574
9968
|
...["T.INV.2T", "TINV"].map(
|
|
9575
9969
|
(name) => numeric(
|
|
9576
9970
|
name,
|
|
9577
|
-
|
|
9971
|
+
C31,
|
|
9578
9972
|
`${name}(probability, deg_freedom)`,
|
|
9579
9973
|
"The two-tailed inverse of Student's t-distribution.",
|
|
9580
9974
|
2,
|
|
@@ -9587,7 +9981,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9587
9981
|
),
|
|
9588
9982
|
numeric(
|
|
9589
9983
|
"CHISQ.DIST",
|
|
9590
|
-
|
|
9984
|
+
C31,
|
|
9591
9985
|
"CHISQ.DIST(x, deg_freedom, cumulative)",
|
|
9592
9986
|
"The chi-squared distribution.",
|
|
9593
9987
|
3,
|
|
@@ -9601,7 +9995,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9601
9995
|
...["CHISQ.DIST.RT", "CHIDIST"].map(
|
|
9602
9996
|
(name) => numeric(
|
|
9603
9997
|
name,
|
|
9604
|
-
|
|
9998
|
+
C31,
|
|
9605
9999
|
`${name}(x, deg_freedom)`,
|
|
9606
10000
|
"The right-tailed chi-squared probability.",
|
|
9607
10001
|
2,
|
|
@@ -9614,7 +10008,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9614
10008
|
),
|
|
9615
10009
|
numeric(
|
|
9616
10010
|
"CHISQ.INV",
|
|
9617
|
-
|
|
10011
|
+
C31,
|
|
9618
10012
|
"CHISQ.INV(probability, deg_freedom)",
|
|
9619
10013
|
"The inverse of the left-tailed chi-squared distribution.",
|
|
9620
10014
|
2,
|
|
@@ -9627,7 +10021,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9627
10021
|
...["CHISQ.INV.RT", "CHIINV"].map(
|
|
9628
10022
|
(name) => numeric(
|
|
9629
10023
|
name,
|
|
9630
|
-
|
|
10024
|
+
C31,
|
|
9631
10025
|
`${name}(probability, deg_freedom)`,
|
|
9632
10026
|
"The inverse of the right-tailed chi-squared distribution.",
|
|
9633
10027
|
2,
|
|
@@ -9640,7 +10034,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9640
10034
|
),
|
|
9641
10035
|
numeric(
|
|
9642
10036
|
"BETA.DIST",
|
|
9643
|
-
|
|
10037
|
+
C31,
|
|
9644
10038
|
"BETA.DIST(x, alpha, beta, cumulative, [A], [B])",
|
|
9645
10039
|
"The beta distribution.",
|
|
9646
10040
|
4,
|
|
@@ -9648,7 +10042,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9648
10042
|
(x, a, b, c2, lo, hi) => {
|
|
9649
10043
|
const A = lo ?? 0;
|
|
9650
10044
|
const B = hi ?? 1;
|
|
9651
|
-
|
|
10045
|
+
positive2(a, b);
|
|
9652
10046
|
if (x < A || x > B || A === B) fail(ERR.NUM);
|
|
9653
10047
|
const t = (x - A) / (B - A);
|
|
9654
10048
|
const al = a ?? 1;
|
|
@@ -9660,7 +10054,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9660
10054
|
),
|
|
9661
10055
|
numeric(
|
|
9662
10056
|
"NEGBINOM.DIST",
|
|
9663
|
-
|
|
10057
|
+
C31,
|
|
9664
10058
|
"NEGBINOM.DIST(number_f, number_s, probability_s, cumulative)",
|
|
9665
10059
|
"The negative binomial distribution.",
|
|
9666
10060
|
4,
|
|
@@ -9679,7 +10073,7 @@ var DISTRIBUTION_MORE = [
|
|
|
9679
10073
|
),
|
|
9680
10074
|
numeric(
|
|
9681
10075
|
"HYPGEOM.DIST",
|
|
9682
|
-
|
|
10076
|
+
C31,
|
|
9683
10077
|
"HYPGEOM.DIST(sample_s, number_sample, population_s, number_pop, cumulative)",
|
|
9684
10078
|
"The hypergeometric distribution.",
|
|
9685
10079
|
5,
|
|
@@ -9700,13 +10094,13 @@ var DISTRIBUTION_MORE = [
|
|
|
9700
10094
|
];
|
|
9701
10095
|
|
|
9702
10096
|
// src/xlsx/formula/functions/distributions.ts
|
|
9703
|
-
var
|
|
10097
|
+
var C32 = "Statistical";
|
|
9704
10098
|
var DISTRIBUTION_FUNCTIONS = [
|
|
9705
10099
|
...DISTRIBUTION_MORE,
|
|
9706
10100
|
...DISTRIBUTION_F,
|
|
9707
10101
|
numeric(
|
|
9708
10102
|
"NORM.DIST",
|
|
9709
|
-
|
|
10103
|
+
C32,
|
|
9710
10104
|
"NORM.DIST(x, mean, standard_dev, cumulative)",
|
|
9711
10105
|
"The normal distribution.",
|
|
9712
10106
|
4,
|
|
@@ -9715,7 +10109,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9715
10109
|
),
|
|
9716
10110
|
numeric(
|
|
9717
10111
|
"NORMDIST",
|
|
9718
|
-
|
|
10112
|
+
C32,
|
|
9719
10113
|
"NORMDIST(x, mean, standard_dev, cumulative)",
|
|
9720
10114
|
"The normal distribution.",
|
|
9721
10115
|
4,
|
|
@@ -9724,7 +10118,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9724
10118
|
),
|
|
9725
10119
|
numeric(
|
|
9726
10120
|
"NORM.S.DIST",
|
|
9727
|
-
|
|
10121
|
+
C32,
|
|
9728
10122
|
"NORM.S.DIST(z, cumulative)",
|
|
9729
10123
|
"The standard normal distribution.",
|
|
9730
10124
|
2,
|
|
@@ -9733,7 +10127,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9733
10127
|
),
|
|
9734
10128
|
numeric(
|
|
9735
10129
|
"NORMSDIST",
|
|
9736
|
-
|
|
10130
|
+
C32,
|
|
9737
10131
|
"NORMSDIST(z)",
|
|
9738
10132
|
"The standard normal cumulative distribution.",
|
|
9739
10133
|
1,
|
|
@@ -9742,31 +10136,31 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9742
10136
|
),
|
|
9743
10137
|
numeric(
|
|
9744
10138
|
"NORM.INV",
|
|
9745
|
-
|
|
10139
|
+
C32,
|
|
9746
10140
|
"NORM.INV(probability, mean, standard_dev)",
|
|
9747
10141
|
"The inverse of the normal cumulative distribution.",
|
|
9748
10142
|
3,
|
|
9749
10143
|
3,
|
|
9750
10144
|
(p, m, s) => {
|
|
9751
|
-
|
|
10145
|
+
positive2(s);
|
|
9752
10146
|
return (m ?? 0) + (s ?? 1) * normInv(p);
|
|
9753
10147
|
}
|
|
9754
10148
|
),
|
|
9755
10149
|
numeric(
|
|
9756
10150
|
"NORMINV",
|
|
9757
|
-
|
|
10151
|
+
C32,
|
|
9758
10152
|
"NORMINV(probability, mean, standard_dev)",
|
|
9759
10153
|
"The inverse of the normal cumulative distribution.",
|
|
9760
10154
|
3,
|
|
9761
10155
|
3,
|
|
9762
10156
|
(p, m, s) => {
|
|
9763
|
-
|
|
10157
|
+
positive2(s);
|
|
9764
10158
|
return (m ?? 0) + (s ?? 1) * normInv(p);
|
|
9765
10159
|
}
|
|
9766
10160
|
),
|
|
9767
10161
|
numeric(
|
|
9768
10162
|
"NORM.S.INV",
|
|
9769
|
-
|
|
10163
|
+
C32,
|
|
9770
10164
|
"NORM.S.INV(probability)",
|
|
9771
10165
|
"The inverse of the standard normal distribution.",
|
|
9772
10166
|
1,
|
|
@@ -9775,17 +10169,17 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9775
10169
|
),
|
|
9776
10170
|
numeric(
|
|
9777
10171
|
"NORMSINV",
|
|
9778
|
-
|
|
10172
|
+
C32,
|
|
9779
10173
|
"NORMSINV(probability)",
|
|
9780
10174
|
"The inverse of the standard normal distribution.",
|
|
9781
10175
|
1,
|
|
9782
10176
|
1,
|
|
9783
10177
|
normInv
|
|
9784
10178
|
),
|
|
9785
|
-
numeric("PHI",
|
|
10179
|
+
numeric("PHI", C32, "PHI(x)", "The standard normal density.", 1, 1, normPdf),
|
|
9786
10180
|
numeric(
|
|
9787
10181
|
"GAUSS",
|
|
9788
|
-
|
|
10182
|
+
C32,
|
|
9789
10183
|
"GAUSS(z)",
|
|
9790
10184
|
"The probability between the mean and z standard deviations.",
|
|
9791
10185
|
1,
|
|
@@ -9823,14 +10217,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9823
10217
|
...["CONFIDENCE", "CONFIDENCE.NORM"].map(
|
|
9824
10218
|
(name) => numeric(
|
|
9825
10219
|
name,
|
|
9826
|
-
|
|
10220
|
+
C32,
|
|
9827
10221
|
`${name}(alpha, standard_dev, size)`,
|
|
9828
10222
|
"The confidence interval for a population mean (normal).",
|
|
9829
10223
|
3,
|
|
9830
10224
|
3,
|
|
9831
10225
|
(a, s, n2) => {
|
|
9832
10226
|
probability(a);
|
|
9833
|
-
|
|
10227
|
+
positive2(s);
|
|
9834
10228
|
if ((n2 ?? 0) < 1) fail(ERR.NUM);
|
|
9835
10229
|
return normInv(1 - a / 2) * (s ?? 1) / Math.sqrt(Math.trunc(n2 ?? 1));
|
|
9836
10230
|
}
|
|
@@ -9838,14 +10232,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9838
10232
|
),
|
|
9839
10233
|
numeric(
|
|
9840
10234
|
"CONFIDENCE.T",
|
|
9841
|
-
|
|
10235
|
+
C32,
|
|
9842
10236
|
"CONFIDENCE.T(alpha, standard_dev, size)",
|
|
9843
10237
|
"The confidence interval for a population mean (Student's t).",
|
|
9844
10238
|
3,
|
|
9845
10239
|
3,
|
|
9846
10240
|
(a, s, n2) => {
|
|
9847
10241
|
probability(a);
|
|
9848
|
-
|
|
10242
|
+
positive2(s);
|
|
9849
10243
|
const size = Math.trunc(n2 ?? 1);
|
|
9850
10244
|
if (size < 2) fail(ERR.DIV0);
|
|
9851
10245
|
return invert((t) => tCdf(t, size - 1), 1 - a / 2, 0, 10) * (s ?? 1) / Math.sqrt(size);
|
|
@@ -9854,7 +10248,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9854
10248
|
...["BINOM.DIST", "BINOMDIST"].map(
|
|
9855
10249
|
(name) => numeric(
|
|
9856
10250
|
name,
|
|
9857
|
-
|
|
10251
|
+
C32,
|
|
9858
10252
|
`${name}(number_s, trials, probability_s, cumulative)`,
|
|
9859
10253
|
"The binomial distribution probability.",
|
|
9860
10254
|
4,
|
|
@@ -9865,7 +10259,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9865
10259
|
...["POISSON.DIST", "POISSON"].map(
|
|
9866
10260
|
(name) => numeric(
|
|
9867
10261
|
name,
|
|
9868
|
-
|
|
10262
|
+
C32,
|
|
9869
10263
|
`${name}(x, mean, cumulative)`,
|
|
9870
10264
|
"The Poisson distribution.",
|
|
9871
10265
|
3,
|
|
@@ -9876,54 +10270,54 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9876
10270
|
...["EXPON.DIST", "EXPONDIST"].map(
|
|
9877
10271
|
(name) => numeric(
|
|
9878
10272
|
name,
|
|
9879
|
-
|
|
10273
|
+
C32,
|
|
9880
10274
|
`${name}(x, lambda, cumulative)`,
|
|
9881
10275
|
"The exponential distribution.",
|
|
9882
10276
|
3,
|
|
9883
10277
|
3,
|
|
9884
10278
|
(x, l, c2) => {
|
|
9885
10279
|
if (x < 0) fail(ERR.NUM);
|
|
9886
|
-
|
|
10280
|
+
positive2(l);
|
|
9887
10281
|
return c2 ? 1 - Math.exp(-(l ?? 1) * x) : (l ?? 1) * Math.exp(-(l ?? 1) * x);
|
|
9888
10282
|
}
|
|
9889
10283
|
)
|
|
9890
10284
|
),
|
|
9891
10285
|
numeric(
|
|
9892
10286
|
"LOGNORM.DIST",
|
|
9893
|
-
|
|
10287
|
+
C32,
|
|
9894
10288
|
"LOGNORM.DIST(x, mean, standard_dev, cumulative)",
|
|
9895
10289
|
"The lognormal distribution.",
|
|
9896
10290
|
4,
|
|
9897
10291
|
4,
|
|
9898
10292
|
(x, m, s, c2) => {
|
|
9899
|
-
|
|
10293
|
+
positive2(x, s);
|
|
9900
10294
|
const z = (Math.log(x) - (m ?? 0)) / (s ?? 1);
|
|
9901
10295
|
return c2 ? normCdf(z) : normPdf(z) / (x * (s ?? 1));
|
|
9902
10296
|
}
|
|
9903
10297
|
),
|
|
9904
10298
|
numeric(
|
|
9905
10299
|
"LOGNORM.INV",
|
|
9906
|
-
|
|
10300
|
+
C32,
|
|
9907
10301
|
"LOGNORM.INV(probability, mean, standard_dev)",
|
|
9908
10302
|
"The inverse of the lognormal distribution.",
|
|
9909
10303
|
3,
|
|
9910
10304
|
3,
|
|
9911
10305
|
(p, m, s) => {
|
|
9912
|
-
|
|
10306
|
+
positive2(s);
|
|
9913
10307
|
return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
|
|
9914
10308
|
}
|
|
9915
10309
|
),
|
|
9916
10310
|
...["WEIBULL.DIST", "WEIBULL"].map(
|
|
9917
10311
|
(name) => numeric(
|
|
9918
10312
|
name,
|
|
9919
|
-
|
|
10313
|
+
C32,
|
|
9920
10314
|
`${name}(x, alpha, beta, cumulative)`,
|
|
9921
10315
|
"The Weibull distribution.",
|
|
9922
10316
|
4,
|
|
9923
10317
|
4,
|
|
9924
10318
|
(x, a, b, c2) => {
|
|
9925
10319
|
if (x < 0) fail(ERR.NUM);
|
|
9926
|
-
|
|
10320
|
+
positive2(a, b);
|
|
9927
10321
|
const al = a ?? 1;
|
|
9928
10322
|
const be = b ?? 1;
|
|
9929
10323
|
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));
|
|
@@ -9932,14 +10326,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9932
10326
|
),
|
|
9933
10327
|
numeric(
|
|
9934
10328
|
"GAMMA.DIST",
|
|
9935
|
-
|
|
10329
|
+
C32,
|
|
9936
10330
|
"GAMMA.DIST(x, alpha, beta, cumulative)",
|
|
9937
10331
|
"The gamma distribution.",
|
|
9938
10332
|
4,
|
|
9939
10333
|
4,
|
|
9940
10334
|
(x, a, b, c2) => {
|
|
9941
10335
|
if (x < 0) fail(ERR.NUM);
|
|
9942
|
-
|
|
10336
|
+
positive2(a, b);
|
|
9943
10337
|
const al = a ?? 1;
|
|
9944
10338
|
const be = b ?? 1;
|
|
9945
10339
|
return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
|
|
@@ -9948,7 +10342,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
9948
10342
|
];
|
|
9949
10343
|
|
|
9950
10344
|
// src/xlsx/formula/functions/text-convert.ts
|
|
9951
|
-
var
|
|
10345
|
+
var C33 = "Text";
|
|
9952
10346
|
var CP1252 = {
|
|
9953
10347
|
128: 8364,
|
|
9954
10348
|
130: 8218,
|
|
@@ -9993,7 +10387,7 @@ function fixed(value, decimals, commas) {
|
|
|
9993
10387
|
var TEXT_CONVERT = [
|
|
9994
10388
|
spec(
|
|
9995
10389
|
"TEXT",
|
|
9996
|
-
|
|
10390
|
+
C33,
|
|
9997
10391
|
"TEXT(value, format_text)",
|
|
9998
10392
|
"Formats a value with a number format.",
|
|
9999
10393
|
2,
|
|
@@ -10006,7 +10400,7 @@ var TEXT_CONVERT = [
|
|
|
10006
10400
|
return formatValue(value, str(args[1]), { date1904: ctx.date1904 }).text;
|
|
10007
10401
|
}
|
|
10008
10402
|
),
|
|
10009
|
-
spec("VALUE",
|
|
10403
|
+
spec("VALUE", C33, "VALUE(text)", "Converts text to a number.", 1, 1, (args) => {
|
|
10010
10404
|
const v = scalar(args[0]);
|
|
10011
10405
|
if (typeof v === "number") return v;
|
|
10012
10406
|
if (v === null) return 0;
|
|
@@ -10016,7 +10410,7 @@ var TEXT_CONVERT = [
|
|
|
10016
10410
|
}),
|
|
10017
10411
|
spec(
|
|
10018
10412
|
"NUMBERVALUE",
|
|
10019
|
-
|
|
10413
|
+
C33,
|
|
10020
10414
|
"NUMBERVALUE(text, [decimal_separator], [group_separator])",
|
|
10021
10415
|
"Converts text to a number with given separators.",
|
|
10022
10416
|
1,
|
|
@@ -10043,7 +10437,7 @@ var TEXT_CONVERT = [
|
|
|
10043
10437
|
),
|
|
10044
10438
|
spec(
|
|
10045
10439
|
"FIXED",
|
|
10046
|
-
|
|
10440
|
+
C33,
|
|
10047
10441
|
"FIXED(number, [decimals], [no_commas])",
|
|
10048
10442
|
"Formats a number as text with fixed decimals.",
|
|
10049
10443
|
1,
|
|
@@ -10052,7 +10446,7 @@ var TEXT_CONVERT = [
|
|
|
10052
10446
|
),
|
|
10053
10447
|
spec(
|
|
10054
10448
|
"DOLLAR",
|
|
10055
|
-
|
|
10449
|
+
C33,
|
|
10056
10450
|
"DOLLAR(number, [decimals])",
|
|
10057
10451
|
"Formats a number as currency text.",
|
|
10058
10452
|
1,
|
|
@@ -10063,28 +10457,28 @@ var TEXT_CONVERT = [
|
|
|
10063
10457
|
return value < 0 && text2.replace(/[0.,]/g, "") !== "" ? `($${text2})` : `$${text2}`;
|
|
10064
10458
|
}
|
|
10065
10459
|
),
|
|
10066
|
-
spec("CHAR",
|
|
10460
|
+
spec("CHAR", C33, "CHAR(number)", "The character for a code (Windows-1252).", 1, 1, (args) => {
|
|
10067
10461
|
const n2 = int(args[0]);
|
|
10068
10462
|
if (n2 < 1 || n2 > 255) fail(ERR.VALUE);
|
|
10069
10463
|
return String.fromCharCode(CP1252[n2] ?? n2);
|
|
10070
10464
|
}),
|
|
10071
|
-
spec("CODE",
|
|
10465
|
+
spec("CODE", C33, "CODE(text)", "The code of the first character (Windows-1252).", 1, 1, (args) => {
|
|
10072
10466
|
const text2 = str(args[0]);
|
|
10073
10467
|
if (text2 === "") fail(ERR.VALUE);
|
|
10074
10468
|
const code = text2.charCodeAt(0);
|
|
10075
10469
|
return CP1252_REVERSE.get(code) ?? (code <= 255 ? code : 63);
|
|
10076
10470
|
}),
|
|
10077
|
-
spec("UNICHAR",
|
|
10471
|
+
spec("UNICHAR", C33, "UNICHAR(number)", "The Unicode character for a code point.", 1, 1, (args) => {
|
|
10078
10472
|
const n2 = int(args[0]);
|
|
10079
10473
|
if (n2 < 1 || n2 > 1114111) fail(ERR.VALUE);
|
|
10080
10474
|
return String.fromCodePoint(n2);
|
|
10081
10475
|
}),
|
|
10082
|
-
spec("UNICODE",
|
|
10476
|
+
spec("UNICODE", C33, "UNICODE(text)", "The code point of the first character.", 1, 1, (args) => {
|
|
10083
10477
|
const text2 = str(args[0]);
|
|
10084
10478
|
if (text2 === "") fail(ERR.VALUE);
|
|
10085
10479
|
return text2.codePointAt(0) ?? fail(ERR.VALUE);
|
|
10086
10480
|
}),
|
|
10087
|
-
spec("T",
|
|
10481
|
+
spec("T", C33, "T(value)", "The text of a value, or empty text.", 1, 1, (args) => {
|
|
10088
10482
|
const v = scalar(args[0]);
|
|
10089
10483
|
if (isError(v)) return v;
|
|
10090
10484
|
return typeof v === "string" ? v : "";
|
|
@@ -10134,7 +10528,7 @@ function right(text2, n2) {
|
|
|
10134
10528
|
}
|
|
10135
10529
|
|
|
10136
10530
|
// src/xlsx/formula/functions/text.ts
|
|
10137
|
-
var
|
|
10531
|
+
var C34 = "Text";
|
|
10138
10532
|
var MAX_TEXT = 32767;
|
|
10139
10533
|
var limit = (text2) => text2.length > MAX_TEXT ? fail(ERR.VALUE) : text2;
|
|
10140
10534
|
function find(args, insensitive) {
|
|
@@ -10167,7 +10561,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10167
10561
|
...TEXT_CONVERT,
|
|
10168
10562
|
spec(
|
|
10169
10563
|
"CONCATENATE",
|
|
10170
|
-
|
|
10564
|
+
C34,
|
|
10171
10565
|
"CONCATENATE(text1, [text2], ...)",
|
|
10172
10566
|
"Joins text items.",
|
|
10173
10567
|
1,
|
|
@@ -10176,7 +10570,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10176
10570
|
),
|
|
10177
10571
|
spec(
|
|
10178
10572
|
"CONCAT",
|
|
10179
|
-
|
|
10573
|
+
C34,
|
|
10180
10574
|
"CONCAT(text1, [text2], ...)",
|
|
10181
10575
|
"Joins text from items and ranges.",
|
|
10182
10576
|
1,
|
|
@@ -10186,7 +10580,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10186
10580
|
),
|
|
10187
10581
|
spec(
|
|
10188
10582
|
"TEXTJOIN",
|
|
10189
|
-
|
|
10583
|
+
C34,
|
|
10190
10584
|
"TEXTJOIN(delimiter, ignore_empty, text1, ...)",
|
|
10191
10585
|
"Joins text with a delimiter.",
|
|
10192
10586
|
3,
|
|
@@ -10205,14 +10599,14 @@ var TEXT_FUNCTIONS = [
|
|
|
10205
10599
|
["any"]
|
|
10206
10600
|
),
|
|
10207
10601
|
...["LEFT", "LEFTB"].map(
|
|
10208
|
-
(name) => spec(name,
|
|
10602
|
+
(name) => spec(name, C34, `${name}(text, [num_chars])`, "The first characters of a text.", 1, 2, (args) => {
|
|
10209
10603
|
const n2 = optNum(args, 1, 1);
|
|
10210
10604
|
if (n2 < 0) fail(ERR.VALUE);
|
|
10211
10605
|
return left(str(args[0]), Math.trunc(n2));
|
|
10212
10606
|
})
|
|
10213
10607
|
),
|
|
10214
10608
|
...["RIGHT", "RIGHTB"].map(
|
|
10215
|
-
(name) => spec(name,
|
|
10609
|
+
(name) => spec(name, C34, `${name}(text, [num_chars])`, "The last characters of a text.", 1, 2, (args) => {
|
|
10216
10610
|
const n2 = Math.trunc(optNum(args, 1, 1));
|
|
10217
10611
|
if (n2 < 0) fail(ERR.VALUE);
|
|
10218
10612
|
return right(str(args[0]), n2);
|
|
@@ -10221,7 +10615,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10221
10615
|
...["MID", "MIDB"].map(
|
|
10222
10616
|
(name) => spec(
|
|
10223
10617
|
name,
|
|
10224
|
-
|
|
10618
|
+
C34,
|
|
10225
10619
|
`${name}(text, start_num, num_chars)`,
|
|
10226
10620
|
"Characters from the middle of a text.",
|
|
10227
10621
|
3,
|
|
@@ -10237,7 +10631,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10237
10631
|
...["LEN", "LENB"].map(
|
|
10238
10632
|
(name) => spec(
|
|
10239
10633
|
name,
|
|
10240
|
-
|
|
10634
|
+
C34,
|
|
10241
10635
|
`${name}(text)`,
|
|
10242
10636
|
"The number of characters in a text.",
|
|
10243
10637
|
1,
|
|
@@ -10247,7 +10641,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10247
10641
|
),
|
|
10248
10642
|
spec(
|
|
10249
10643
|
"LOWER",
|
|
10250
|
-
|
|
10644
|
+
C34,
|
|
10251
10645
|
"LOWER(text)",
|
|
10252
10646
|
"Converts text to lower case.",
|
|
10253
10647
|
1,
|
|
@@ -10256,7 +10650,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10256
10650
|
),
|
|
10257
10651
|
spec(
|
|
10258
10652
|
"UPPER",
|
|
10259
|
-
|
|
10653
|
+
C34,
|
|
10260
10654
|
"UPPER(text)",
|
|
10261
10655
|
"Converts text to upper case.",
|
|
10262
10656
|
1,
|
|
@@ -10265,7 +10659,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10265
10659
|
),
|
|
10266
10660
|
spec(
|
|
10267
10661
|
"PROPER",
|
|
10268
|
-
|
|
10662
|
+
C34,
|
|
10269
10663
|
"PROPER(text)",
|
|
10270
10664
|
"Capitalizes the first letter of each word.",
|
|
10271
10665
|
1,
|
|
@@ -10274,7 +10668,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10274
10668
|
),
|
|
10275
10669
|
spec(
|
|
10276
10670
|
"TRIM",
|
|
10277
|
-
|
|
10671
|
+
C34,
|
|
10278
10672
|
"TRIM(text)",
|
|
10279
10673
|
"Removes extra spaces.",
|
|
10280
10674
|
1,
|
|
@@ -10283,7 +10677,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10283
10677
|
),
|
|
10284
10678
|
spec(
|
|
10285
10679
|
"CLEAN",
|
|
10286
|
-
|
|
10680
|
+
C34,
|
|
10287
10681
|
"CLEAN(text)",
|
|
10288
10682
|
"Removes non-printable characters.",
|
|
10289
10683
|
1,
|
|
@@ -10295,7 +10689,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10295
10689
|
),
|
|
10296
10690
|
spec(
|
|
10297
10691
|
"SUBSTITUTE",
|
|
10298
|
-
|
|
10692
|
+
C34,
|
|
10299
10693
|
"SUBSTITUTE(text, old_text, new_text, [instance_num])",
|
|
10300
10694
|
"Replaces occurrences of a text.",
|
|
10301
10695
|
3,
|
|
@@ -10319,7 +10713,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10319
10713
|
...["REPLACE", "REPLACEB"].map(
|
|
10320
10714
|
(name) => spec(
|
|
10321
10715
|
name,
|
|
10322
|
-
|
|
10716
|
+
C34,
|
|
10323
10717
|
`${name}(old_text, start_num, num_chars, new_text)`,
|
|
10324
10718
|
"Replaces part of a text.",
|
|
10325
10719
|
4,
|
|
@@ -10336,7 +10730,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10336
10730
|
...["FIND", "FINDB"].map(
|
|
10337
10731
|
(name) => spec(
|
|
10338
10732
|
name,
|
|
10339
|
-
|
|
10733
|
+
C34,
|
|
10340
10734
|
`${name}(find_text, within_text, [start_num])`,
|
|
10341
10735
|
"The position of a text (case-sensitive).",
|
|
10342
10736
|
2,
|
|
@@ -10347,7 +10741,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10347
10741
|
...["SEARCH", "SEARCHB"].map(
|
|
10348
10742
|
(name) => spec(
|
|
10349
10743
|
name,
|
|
10350
|
-
|
|
10744
|
+
C34,
|
|
10351
10745
|
`${name}(find_text, within_text, [start_num])`,
|
|
10352
10746
|
"The position of a text (wildcards, any case).",
|
|
10353
10747
|
2,
|
|
@@ -10355,7 +10749,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10355
10749
|
(args) => find(args, true)
|
|
10356
10750
|
)
|
|
10357
10751
|
),
|
|
10358
|
-
spec("REPT",
|
|
10752
|
+
spec("REPT", C34, "REPT(text, number_times)", "Repeats a text.", 2, 2, (args) => {
|
|
10359
10753
|
const n2 = Math.trunc(num(args[1]));
|
|
10360
10754
|
const text2 = str(args[0]);
|
|
10361
10755
|
if (n2 < 0 || text2.length * n2 > MAX_TEXT) fail(ERR.VALUE);
|
|
@@ -10363,7 +10757,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10363
10757
|
}),
|
|
10364
10758
|
spec(
|
|
10365
10759
|
"EXACT",
|
|
10366
|
-
|
|
10760
|
+
C34,
|
|
10367
10761
|
"EXACT(text1, text2)",
|
|
10368
10762
|
"Whether two texts are identical (case-sensitive).",
|
|
10369
10763
|
2,
|
|
@@ -10372,8 +10766,78 @@ var TEXT_FUNCTIONS = [
|
|
|
10372
10766
|
)
|
|
10373
10767
|
];
|
|
10374
10768
|
|
|
10769
|
+
// src/xlsx/formula/functions/text-regex.ts
|
|
10770
|
+
var C35 = "Text";
|
|
10771
|
+
function compile(pattern, caseMode2, global) {
|
|
10772
|
+
if (caseMode2 !== 0 && caseMode2 !== 1) fail(ERR.VALUE);
|
|
10773
|
+
try {
|
|
10774
|
+
return new RegExp(pattern, `${global ? "g" : ""}${caseMode2 === 1 ? "i" : ""}u`);
|
|
10775
|
+
} catch {
|
|
10776
|
+
return fail(ERR.VALUE);
|
|
10777
|
+
}
|
|
10778
|
+
}
|
|
10779
|
+
var caseMode = (args, index2) => optNum(args, index2, 0);
|
|
10780
|
+
function encodeUrl(text2) {
|
|
10781
|
+
return encodeURIComponent(text2).replace(
|
|
10782
|
+
/[!'()*]/g,
|
|
10783
|
+
(c2) => `%${c2.charCodeAt(0).toString(16).toUpperCase()}`
|
|
10784
|
+
);
|
|
10785
|
+
}
|
|
10786
|
+
var TEXT_REGEX_FUNCTIONS = [
|
|
10787
|
+
spec(
|
|
10788
|
+
"ENCODEURL",
|
|
10789
|
+
C35,
|
|
10790
|
+
"ENCODEURL(text)",
|
|
10791
|
+
"Percent-encodes text for use in a URL.",
|
|
10792
|
+
1,
|
|
10793
|
+
1,
|
|
10794
|
+
(args) => encodeUrl(str(args[0]))
|
|
10795
|
+
),
|
|
10796
|
+
spec(
|
|
10797
|
+
"REGEXTEST",
|
|
10798
|
+
C35,
|
|
10799
|
+
"REGEXTEST(text, pattern, [case_sensitivity])",
|
|
10800
|
+
"Whether any part of the text matches the pattern.",
|
|
10801
|
+
2,
|
|
10802
|
+
3,
|
|
10803
|
+
(args) => compile(str(args[1]), caseMode(args, 2), false).test(str(args[0]))
|
|
10804
|
+
),
|
|
10805
|
+
spec(
|
|
10806
|
+
"REGEXEXTRACT",
|
|
10807
|
+
C35,
|
|
10808
|
+
"REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])",
|
|
10809
|
+
"The first part of the text that matches the pattern.",
|
|
10810
|
+
2,
|
|
10811
|
+
4,
|
|
10812
|
+
(args) => {
|
|
10813
|
+
if (optNum(args, 2, 0) !== 0) fail(ERR.VALUE);
|
|
10814
|
+
const match2 = compile(str(args[1]), caseMode(args, 3), false).exec(str(args[0]));
|
|
10815
|
+
return match2 ? match2[0] : fail(ERR.NA);
|
|
10816
|
+
}
|
|
10817
|
+
),
|
|
10818
|
+
spec(
|
|
10819
|
+
"REGEXREPLACE",
|
|
10820
|
+
C35,
|
|
10821
|
+
"REGEXREPLACE(text, pattern, replacement, [occurrence], [case_sensitivity])",
|
|
10822
|
+
"Replaces the parts of the text that match the pattern.",
|
|
10823
|
+
3,
|
|
10824
|
+
5,
|
|
10825
|
+
(args) => {
|
|
10826
|
+
const text2 = str(args[0]);
|
|
10827
|
+
const regex = compile(str(args[1]), caseMode(args, 4), true);
|
|
10828
|
+
const replacement = str(args[2]);
|
|
10829
|
+
const occurrence = args.length > 3 && args[3] !== null ? int(args[3]) : 0;
|
|
10830
|
+
if (occurrence === 0) return text2.replace(regex, replacement);
|
|
10831
|
+
const matches2 = [...text2.matchAll(regex)];
|
|
10832
|
+
const picked = occurrence > 0 ? matches2[occurrence - 1] : matches2.at(occurrence);
|
|
10833
|
+
if (!picked || picked.index === void 0) return text2;
|
|
10834
|
+
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);
|
|
10835
|
+
}
|
|
10836
|
+
)
|
|
10837
|
+
];
|
|
10838
|
+
|
|
10375
10839
|
// src/xlsx/formula/functions/text-extra.ts
|
|
10376
|
-
var
|
|
10840
|
+
var C36 = "Text";
|
|
10377
10841
|
function delimitersOf(ctx, value) {
|
|
10378
10842
|
if (value === void 0 || value === null) return [];
|
|
10379
10843
|
return ctx.toMatrix(value).flat().map((v) => {
|
|
@@ -10439,9 +10903,10 @@ function valueToText(value, strict) {
|
|
|
10439
10903
|
return toText(value);
|
|
10440
10904
|
}
|
|
10441
10905
|
var TEXT_EXTRA_FUNCTIONS = [
|
|
10906
|
+
...TEXT_REGEX_FUNCTIONS,
|
|
10442
10907
|
spec(
|
|
10443
10908
|
"TEXTBEFORE",
|
|
10444
|
-
|
|
10909
|
+
C36,
|
|
10445
10910
|
"TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
|
|
10446
10911
|
"The text before a delimiter.",
|
|
10447
10912
|
2,
|
|
@@ -10451,7 +10916,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
10451
10916
|
),
|
|
10452
10917
|
spec(
|
|
10453
10918
|
"TEXTAFTER",
|
|
10454
|
-
|
|
10919
|
+
C36,
|
|
10455
10920
|
"TEXTAFTER(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
|
|
10456
10921
|
"The text after a delimiter.",
|
|
10457
10922
|
2,
|
|
@@ -10461,7 +10926,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
10461
10926
|
),
|
|
10462
10927
|
spec(
|
|
10463
10928
|
"TEXTSPLIT",
|
|
10464
|
-
|
|
10929
|
+
C36,
|
|
10465
10930
|
"TEXTSPLIT(text, col_delimiter, [row_delimiter], [ignore_empty], [match_mode], [pad_with])",
|
|
10466
10931
|
"Splits text into an array.",
|
|
10467
10932
|
2,
|
|
@@ -10484,7 +10949,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
10484
10949
|
),
|
|
10485
10950
|
spec(
|
|
10486
10951
|
"VALUETOTEXT",
|
|
10487
|
-
|
|
10952
|
+
C36,
|
|
10488
10953
|
"VALUETOTEXT(value, [format])",
|
|
10489
10954
|
"Text for any value.",
|
|
10490
10955
|
1,
|
|
@@ -10493,7 +10958,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
10493
10958
|
),
|
|
10494
10959
|
spec(
|
|
10495
10960
|
"ARRAYTOTEXT",
|
|
10496
|
-
|
|
10961
|
+
C36,
|
|
10497
10962
|
"ARRAYTOTEXT(array, [format])",
|
|
10498
10963
|
"Text for an array.",
|
|
10499
10964
|
1,
|
|
@@ -11259,6 +11724,8 @@ var EngineHost = class {
|
|
|
11259
11724
|
inProgress = /* @__PURE__ */ new Set();
|
|
11260
11725
|
cycles = /* @__PURE__ */ new Set();
|
|
11261
11726
|
dynamicCycleHits = /* @__PURE__ */ new Set();
|
|
11727
|
+
/** Set while a circular group is iterated: reads of a formula in progress see its stored value. */
|
|
11728
|
+
iterating = false;
|
|
11262
11729
|
pending;
|
|
11263
11730
|
columnIndex;
|
|
11264
11731
|
reverseIndex;
|
|
@@ -11298,6 +11765,7 @@ var EngineHost = class {
|
|
|
11298
11765
|
const node = this.nodes.get(sheet)?.get(cellKey(row2, col));
|
|
11299
11766
|
if (!node) return;
|
|
11300
11767
|
if (this.inProgress.has(node)) {
|
|
11768
|
+
if (this.iterating) return;
|
|
11301
11769
|
this.dynamicCycleHits.add(node);
|
|
11302
11770
|
this.dynamicCycleHit = true;
|
|
11303
11771
|
this.cycleReads++;
|
|
@@ -11616,6 +12084,10 @@ function storeResult(sheet, node, cell, result2, claims) {
|
|
|
11616
12084
|
|
|
11617
12085
|
// src/xlsx/formula/engine-core.ts
|
|
11618
12086
|
var MAX_ROUNDS = 8;
|
|
12087
|
+
function valueChange(before, after) {
|
|
12088
|
+
if (typeof before === "number" && typeof after === "number") return Math.abs(after - before);
|
|
12089
|
+
return before === after ? 0 : Number.POSITIVE_INFINITY;
|
|
12090
|
+
}
|
|
11619
12091
|
var EngineCore = class extends EngineHost {
|
|
11620
12092
|
releaseAllSpills() {
|
|
11621
12093
|
for (const sheet of this.workbook.sheets) {
|
|
@@ -11701,7 +12173,9 @@ var EngineCore = class extends EngineHost {
|
|
|
11701
12173
|
for (const component of order.components) {
|
|
11702
12174
|
const first3 = component.nodes[0];
|
|
11703
12175
|
if (component.cyclic) {
|
|
11704
|
-
|
|
12176
|
+
const iterate = this.workbook.iterate;
|
|
12177
|
+
if (iterate) this.iterateGroup(component.nodes, iterate);
|
|
12178
|
+
else for (const node of component.nodes) this.markCycle(node);
|
|
11705
12179
|
} else if (this.pending.has(first3)) {
|
|
11706
12180
|
this.computeFrom(first3);
|
|
11707
12181
|
}
|
|
@@ -11743,6 +12217,30 @@ var EngineCore = class extends EngineHost {
|
|
|
11743
12217
|
}
|
|
11744
12218
|
}
|
|
11745
12219
|
}
|
|
12220
|
+
/**
|
|
12221
|
+
* Iterative calculation of a circular group (`calcPr iterate`): every member is recomputed in
|
|
12222
|
+
* turn, reading the others' values from the previous step, until the largest change is within
|
|
12223
|
+
* `delta` or `count` passes have run. The group starts from the values the cells hold.
|
|
12224
|
+
*/
|
|
12225
|
+
iterateGroup(nodes, limits) {
|
|
12226
|
+
for (const node of nodes) this.pending?.delete(node);
|
|
12227
|
+
const cellOf2 = (node) => this.workbook.sheets[node.sheet]?.rows.get(node.row)?.get(node.col);
|
|
12228
|
+
this.iterating = true;
|
|
12229
|
+
try {
|
|
12230
|
+
for (let pass = 0; pass < limits.count; pass++) {
|
|
12231
|
+
let change = 0;
|
|
12232
|
+
for (const node of nodes) {
|
|
12233
|
+
const before = cellOf2(node)?.value ?? null;
|
|
12234
|
+
this.compute(node);
|
|
12235
|
+
const after = cellOf2(node)?.value ?? null;
|
|
12236
|
+
change = Math.max(change, valueChange(before, after));
|
|
12237
|
+
}
|
|
12238
|
+
if (change <= limits.delta) break;
|
|
12239
|
+
}
|
|
12240
|
+
} finally {
|
|
12241
|
+
this.iterating = false;
|
|
12242
|
+
}
|
|
12243
|
+
}
|
|
11746
12244
|
markCycle(node) {
|
|
11747
12245
|
this.pending?.delete(node);
|
|
11748
12246
|
this.cycles.add(node);
|
|
@@ -12389,6 +12887,163 @@ function needsArrayEvaluation(formula) {
|
|
|
12389
12887
|
return result2.needs || result2.multi;
|
|
12390
12888
|
}
|
|
12391
12889
|
|
|
12890
|
+
// src/xlsx/formula/editor-text.ts
|
|
12891
|
+
var REFERENCE_COLORS = [
|
|
12892
|
+
"#2a6ad8",
|
|
12893
|
+
"#d24726",
|
|
12894
|
+
"#7d3fbf",
|
|
12895
|
+
"#0f8a3b",
|
|
12896
|
+
"#c0399f",
|
|
12897
|
+
"#946d00",
|
|
12898
|
+
"#d1102b",
|
|
12899
|
+
"#00788a"
|
|
12900
|
+
];
|
|
12901
|
+
var isFormulaText = (text2) => text2.startsWith("=") || text2.startsWith("+");
|
|
12902
|
+
function coloredReferences(text2) {
|
|
12903
|
+
if (!isFormulaText(text2)) return [];
|
|
12904
|
+
const seen = /* @__PURE__ */ new Map();
|
|
12905
|
+
return referenceSpans(text2.slice(1), "").map((span3) => {
|
|
12906
|
+
const key = span3.text.replace(/\$/g, "").toUpperCase();
|
|
12907
|
+
let index2 = seen.get(key);
|
|
12908
|
+
if (index2 === void 0) {
|
|
12909
|
+
index2 = seen.size;
|
|
12910
|
+
seen.set(key, index2);
|
|
12911
|
+
}
|
|
12912
|
+
return {
|
|
12913
|
+
start: span3.start + 1,
|
|
12914
|
+
end: span3.end + 1,
|
|
12915
|
+
text: span3.text,
|
|
12916
|
+
index: index2,
|
|
12917
|
+
color: REFERENCE_COLORS[index2 % REFERENCE_COLORS.length] ?? REFERENCE_COLORS[0]
|
|
12918
|
+
};
|
|
12919
|
+
});
|
|
12920
|
+
}
|
|
12921
|
+
var POINT_AFTER = /* @__PURE__ */ new Set(["=", "(", ",", "+", "-", "*", "/", "^", "&", "<", ">", ":", ";", "%"]);
|
|
12922
|
+
function acceptsReference(text2, caret) {
|
|
12923
|
+
if (!isFormulaText(text2)) return false;
|
|
12924
|
+
if (text2.slice(caret).trimStart() !== "" && !/^[\s),;&+\-*/^<>=]/.test(text2.slice(caret)))
|
|
12925
|
+
return false;
|
|
12926
|
+
const before = text2.slice(0, caret).trimEnd();
|
|
12927
|
+
const last = before[before.length - 1];
|
|
12928
|
+
return last !== void 0 && POINT_AFTER.has(last) && !insideString(text2, caret);
|
|
12929
|
+
}
|
|
12930
|
+
function insideString(text2, caret) {
|
|
12931
|
+
let open = false;
|
|
12932
|
+
for (let i = 0; i < caret && i < text2.length; i++) if (text2[i] === '"') open = !open;
|
|
12933
|
+
return open;
|
|
12934
|
+
}
|
|
12935
|
+
function nameAtCaret(text2, caret) {
|
|
12936
|
+
if (!isFormulaText(text2) || insideString(text2, caret)) return void 0;
|
|
12937
|
+
const match2 = /[A-Za-z_][A-Za-z0-9_.]*$/.exec(text2.slice(0, caret));
|
|
12938
|
+
if (!match2) return void 0;
|
|
12939
|
+
const start = caret - match2[0].length;
|
|
12940
|
+
const prev = text2[start - 1] ?? "";
|
|
12941
|
+
if (start === 0 || /[A-Za-z0-9_$!'".:]/.test(prev)) return void 0;
|
|
12942
|
+
if (/^[A-Za-z0-9_.]/.test(text2.slice(caret))) return void 0;
|
|
12943
|
+
return { start, prefix: match2[0] };
|
|
12944
|
+
}
|
|
12945
|
+
function functionMatches(prefix, limit2 = 12, catalog = FUNCTION_CATALOG) {
|
|
12946
|
+
const upper2 = prefix.toUpperCase();
|
|
12947
|
+
if (!upper2) return [];
|
|
12948
|
+
const out = [];
|
|
12949
|
+
for (const info of catalog) {
|
|
12950
|
+
if (info.name.startsWith(upper2)) out.push(info);
|
|
12951
|
+
if (out.length >= limit2) break;
|
|
12952
|
+
}
|
|
12953
|
+
return out;
|
|
12954
|
+
}
|
|
12955
|
+
function callAtCaret(text2, caret) {
|
|
12956
|
+
if (!isFormulaText(text2)) return void 0;
|
|
12957
|
+
const stack2 = [];
|
|
12958
|
+
let inString = false;
|
|
12959
|
+
for (let i = 1; i < caret && i < text2.length; i++) {
|
|
12960
|
+
const ch = text2[i];
|
|
12961
|
+
if (ch === '"') inString = !inString;
|
|
12962
|
+
if (inString) continue;
|
|
12963
|
+
if (ch === "(") {
|
|
12964
|
+
const name = /([A-Za-z_][A-Za-z0-9_.]*)\s*$/.exec(text2.slice(0, i))?.[1];
|
|
12965
|
+
stack2.push({ name: (name ?? "").toUpperCase(), argIndex: 0 });
|
|
12966
|
+
} else if (ch === ")") stack2.pop();
|
|
12967
|
+
else if (ch === "," || ch === ";") {
|
|
12968
|
+
const top = stack2[stack2.length - 1];
|
|
12969
|
+
if (top) top.argIndex++;
|
|
12970
|
+
} else if (ch === "{") stack2.push({ name: "", argIndex: 0 });
|
|
12971
|
+
else if (ch === "}") stack2.pop();
|
|
12972
|
+
}
|
|
12973
|
+
for (let i = stack2.length - 1; i >= 0; i--) {
|
|
12974
|
+
const entry = stack2[i];
|
|
12975
|
+
if (entry?.name) return entry;
|
|
12976
|
+
if (entry && !entry.name) return void 0;
|
|
12977
|
+
}
|
|
12978
|
+
return void 0;
|
|
12979
|
+
}
|
|
12980
|
+
function syntaxParams(syntax) {
|
|
12981
|
+
const open = syntax.indexOf("(");
|
|
12982
|
+
const close = syntax.lastIndexOf(")");
|
|
12983
|
+
if (open < 0) return { name: syntax, params: [] };
|
|
12984
|
+
const inner2 = syntax.slice(open + 1, close < 0 ? void 0 : close).trim();
|
|
12985
|
+
const params = inner2 ? inner2.split(",").map((p) => p.trim()) : [];
|
|
12986
|
+
return { name: syntax.slice(0, open), params };
|
|
12987
|
+
}
|
|
12988
|
+
function activeParam(params, argIndex) {
|
|
12989
|
+
if (argIndex < params.length) {
|
|
12990
|
+
if (params[argIndex] === "...") return Math.max(0, argIndex - 1);
|
|
12991
|
+
return argIndex;
|
|
12992
|
+
}
|
|
12993
|
+
return params[params.length - 1] === "..." ? params.length - 2 : params.length - 1;
|
|
12994
|
+
}
|
|
12995
|
+
function splice(text2, start, end, insert) {
|
|
12996
|
+
return { text: text2.slice(0, start) + insert + text2.slice(end), caret: start + insert.length };
|
|
12997
|
+
}
|
|
12998
|
+
function referenceTarget(text2) {
|
|
12999
|
+
const bang = text2.lastIndexOf("!");
|
|
13000
|
+
const sheet = bang >= 0 ? text2.slice(0, bang).replace(/^'|'$/g, "").replace(/''/g, "'") : void 0;
|
|
13001
|
+
const body = text2.slice(bang + 1).replace(/\$/g, "").toUpperCase();
|
|
13002
|
+
let range;
|
|
13003
|
+
const cols = /^([A-Z]{1,3}):([A-Z]{1,3})$/.exec(body);
|
|
13004
|
+
const rows = /^(\d+):(\d+)$/.exec(body);
|
|
13005
|
+
if (cols) {
|
|
13006
|
+
const a = columnIndex(cols[1] ?? "A");
|
|
13007
|
+
const b = columnIndex(cols[2] ?? "A");
|
|
13008
|
+
range = { start: { row: 0, col: Math.min(a, b) }, end: { row: MAX_ROW, col: Math.max(a, b) } };
|
|
13009
|
+
} else if (rows) {
|
|
13010
|
+
const a = Number(rows[1]) - 1;
|
|
13011
|
+
const b = Number(rows[2]) - 1;
|
|
13012
|
+
range = { start: { row: Math.min(a, b), col: 0 }, end: { row: Math.max(a, b), col: MAX_COL } };
|
|
13013
|
+
} else range = parseRange(body);
|
|
13014
|
+
if (!range) return void 0;
|
|
13015
|
+
return sheet === void 0 ? { range } : { sheet, range };
|
|
13016
|
+
}
|
|
13017
|
+
var cycleCell = (cell) => {
|
|
13018
|
+
const m = /^(\$?)([A-Za-z]{1,3})(\$?)(\d+)$/.exec(cell);
|
|
13019
|
+
if (!m) return cell;
|
|
13020
|
+
const [, c2, col, r, row2] = m;
|
|
13021
|
+
if (!c2 && !r) return `$${col}$${row2}`;
|
|
13022
|
+
if (c2 && r) return `${col}$${row2}`;
|
|
13023
|
+
if (!c2 && r) return `$${col}${row2}`;
|
|
13024
|
+
return `${col}${row2}`;
|
|
13025
|
+
};
|
|
13026
|
+
function toggleAbsolute(text2, caret) {
|
|
13027
|
+
const ref = coloredReferences(text2).find((r) => caret >= r.start && caret <= r.end);
|
|
13028
|
+
if (!ref) return void 0;
|
|
13029
|
+
const bang = ref.text.lastIndexOf("!");
|
|
13030
|
+
const prefix = ref.text.slice(0, bang + 1);
|
|
13031
|
+
const body = ref.text.slice(bang + 1).split(":").map(cycleCell).join(":");
|
|
13032
|
+
const next = splice(text2, ref.start, ref.end, prefix + body);
|
|
13033
|
+
return next;
|
|
13034
|
+
}
|
|
13035
|
+
function closeParens(text2) {
|
|
13036
|
+
if (!isFormulaText(text2)) return text2;
|
|
13037
|
+
let depth = 0;
|
|
13038
|
+
let inString = false;
|
|
13039
|
+
for (const ch of text2) {
|
|
13040
|
+
if (ch === '"') inString = !inString;
|
|
13041
|
+
else if (!inString && ch === "(") depth++;
|
|
13042
|
+
else if (!inString && ch === ")") depth = Math.max(0, depth - 1);
|
|
13043
|
+
}
|
|
13044
|
+
return depth > 0 && !inString ? text2 + ")".repeat(depth) : text2;
|
|
13045
|
+
}
|
|
13046
|
+
|
|
12392
13047
|
// src/opc/relationship-types.ts
|
|
12393
13048
|
var BASE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
12394
13049
|
var RELATIONSHIP_TYPES = {
|
|
@@ -13756,8 +14411,14 @@ function parseWorkbookPart(xml) {
|
|
|
13756
14411
|
const protection = xFirst(root, "workbookProtection");
|
|
13757
14412
|
const password = att(protection, "workbookPassword");
|
|
13758
14413
|
const modernHash = readModernHash(protection, "workbook");
|
|
13759
|
-
const
|
|
14414
|
+
const calcPr = xFirst(root, "calcPr");
|
|
14415
|
+
const calcMode = att(calcPr, "calcMode");
|
|
14416
|
+
const iterate = boolAttr(calcPr, "iterate", false) ? {
|
|
14417
|
+
count: numAttr(calcPr, "iterateCount") ?? 100,
|
|
14418
|
+
delta: numAttr(calcPr, "iterateDelta") ?? 1e-3
|
|
14419
|
+
} : void 0;
|
|
13760
14420
|
return {
|
|
14421
|
+
...iterate ? { iterate } : {},
|
|
13761
14422
|
...password ? { workbookPasswordHash: password } : {},
|
|
13762
14423
|
...modernHash ? { workbookModernHash: modernHash } : {},
|
|
13763
14424
|
...calcMode === "manual" ? { calcMode: "manual" } : {},
|
|
@@ -15905,6 +16566,7 @@ async function loadXlsx(input) {
|
|
|
15905
16566
|
if (book.workbookPasswordHash) workbook.workbookPasswordHash = book.workbookPasswordHash;
|
|
15906
16567
|
if (book.workbookModernHash) workbook.workbookModernHash = book.workbookModernHash;
|
|
15907
16568
|
if (book.calcMode) workbook.calcMode = book.calcMode;
|
|
16569
|
+
if (book.iterate) workbook.iterate = book.iterate;
|
|
15908
16570
|
if (signatures.hasSignatures)
|
|
15909
16571
|
workbook.signatures = { count: signatures.signatureCount, parts: signatures.signaturePaths };
|
|
15910
16572
|
if (!sheets.length) throw new Error("XLSX workbook has no sheets");
|
|
@@ -16580,16 +17242,16 @@ function shiftIndexClamped(index2, shift2) {
|
|
|
16580
17242
|
}
|
|
16581
17243
|
function shiftRange(range, shift2) {
|
|
16582
17244
|
if (shift2.axis === "row") {
|
|
16583
|
-
const
|
|
16584
|
-
return
|
|
16585
|
-
start: { row:
|
|
16586
|
-
end: { row:
|
|
17245
|
+
const span4 = shiftSpan(range.start.row, range.end.row, shift2);
|
|
17246
|
+
return span4 && {
|
|
17247
|
+
start: { row: span4.start, col: range.start.col },
|
|
17248
|
+
end: { row: span4.end, col: range.end.col }
|
|
16587
17249
|
};
|
|
16588
17250
|
}
|
|
16589
|
-
const
|
|
16590
|
-
return
|
|
16591
|
-
start: { row: range.start.row, col:
|
|
16592
|
-
end: { row: range.end.row, col:
|
|
17251
|
+
const span3 = shiftSpan(range.start.col, range.end.col, shift2);
|
|
17252
|
+
return span3 && {
|
|
17253
|
+
start: { row: range.start.row, col: span3.start },
|
|
17254
|
+
end: { row: range.end.row, col: span3.end }
|
|
16593
17255
|
};
|
|
16594
17256
|
}
|
|
16595
17257
|
function shiftRangeInBand(range, shift2, lo, hi) {
|
|
@@ -17401,7 +18063,9 @@ function workbookXml(workbook, sheets, activeTab, sourceXml) {
|
|
|
17401
18063
|
).join("")}</definedNames>`;
|
|
17402
18064
|
const calc = kept.get("calcPr");
|
|
17403
18065
|
const mode = workbook.calcMode === "manual" ? ' calcMode="manual"' : "";
|
|
17404
|
-
|
|
18066
|
+
const iterate = workbook.iterate ? ` iterate="1" iterateCount="${workbook.iterate.count}" iterateDelta="${workbook.iterate.delta}"` : "";
|
|
18067
|
+
const owned = ["fullCalcOnLoad", "calcId", "calcMode", "iterate", "iterateCount", "iterateDelta"];
|
|
18068
|
+
out += `<calcPr${copyAttrs(calc, owned)} calcId="191029"${mode}${iterate} fullCalcOnLoad="1"/>`;
|
|
17405
18069
|
out += raw(KEPT_TAIL);
|
|
17406
18070
|
return `${out}</workbook>`;
|
|
17407
18071
|
}
|
|
@@ -19591,8 +20255,8 @@ function shiftAxisFormats(sheet, shift2) {
|
|
|
19591
20255
|
}
|
|
19592
20256
|
sheet.columns = normalizeColumns(
|
|
19593
20257
|
sheet.columns.flatMap((info) => {
|
|
19594
|
-
const
|
|
19595
|
-
return
|
|
20258
|
+
const span3 = shiftSpan(info.min, info.max, shift2);
|
|
20259
|
+
return span3 ? [{ ...info, min: span3.start, max: span3.end }] : [];
|
|
19596
20260
|
})
|
|
19597
20261
|
);
|
|
19598
20262
|
}
|
|
@@ -19769,11 +20433,11 @@ function toHtml(cells, theme2) {
|
|
|
19769
20433
|
if (covered.has(`${r},${c2}`)) continue;
|
|
19770
20434
|
const cell = cells.data[r]?.[c2] ?? null;
|
|
19771
20435
|
const attrs2 = [];
|
|
19772
|
-
const
|
|
19773
|
-
if (
|
|
19774
|
-
attrs2.push(`rowspan="${
|
|
19775
|
-
if (
|
|
19776
|
-
attrs2.push(`colspan="${
|
|
20436
|
+
const span3 = spans2.get(`${r},${c2}`);
|
|
20437
|
+
if (span3 && span3.end.row > span3.start.row)
|
|
20438
|
+
attrs2.push(`rowspan="${span3.end.row - span3.start.row + 1}"`);
|
|
20439
|
+
if (span3 && span3.end.col > span3.start.col)
|
|
20440
|
+
attrs2.push(`colspan="${span3.end.col - span3.start.col + 1}"`);
|
|
19777
20441
|
if (cell && typeof cell.value === "number") attrs2.push(`x:num="${cell.value}"`);
|
|
19778
20442
|
const css = cssFor(cell?.style, theme2);
|
|
19779
20443
|
if (css) attrs2.push(`style="${escapeHtml(css)}"`);
|
|
@@ -21991,7 +22655,7 @@ var MAX_OUTLINE_LEVEL = 7;
|
|
|
21991
22655
|
function nextLevel(level, delta) {
|
|
21992
22656
|
return Math.max(0, Math.min(MAX_OUTLINE_LEVEL, (level ?? 0) + delta));
|
|
21993
22657
|
}
|
|
21994
|
-
function
|
|
22658
|
+
function span2(from, to) {
|
|
21995
22659
|
const lo = Math.max(0, Math.min(from, to));
|
|
21996
22660
|
const hi = Math.max(from, to);
|
|
21997
22661
|
return Array.from({ length: hi - lo + 1 }, (_v, i) => lo + i);
|
|
@@ -22003,7 +22667,7 @@ function outlineRows(ctx, s, from, to, delta) {
|
|
|
22003
22667
|
"structure",
|
|
22004
22668
|
[{ kind: "sheet", sheet: s }],
|
|
22005
22669
|
() => {
|
|
22006
|
-
for (const row2 of
|
|
22670
|
+
for (const row2 of span2(from, to)) {
|
|
22007
22671
|
const info = { ...sheet.rowInfo.get(row2) };
|
|
22008
22672
|
const level = nextLevel(info.outlineLevel, delta);
|
|
22009
22673
|
if (level) info.outlineLevel = level;
|
|
@@ -22024,7 +22688,7 @@ function outlineColumns(ctx, s, from, to, delta) {
|
|
|
22024
22688
|
delta > 0 ? "Group columns" : "Ungroup columns",
|
|
22025
22689
|
"structure",
|
|
22026
22690
|
[{ kind: "sheet", sheet: s }],
|
|
22027
|
-
() => editColumns(sheet,
|
|
22691
|
+
() => editColumns(sheet, span2(from, to), (info) => {
|
|
22028
22692
|
const level = nextLevel(info.outlineLevel, delta);
|
|
22029
22693
|
if (level) info.outlineLevel = level;
|
|
22030
22694
|
else {
|
|
@@ -25145,8 +25809,8 @@ function axes2(model, area, out) {
|
|
|
25145
25809
|
w: Math.max(1, area.w - labelW - 4),
|
|
25146
25810
|
h: Math.max(1, area.h - 20)
|
|
25147
25811
|
};
|
|
25148
|
-
const
|
|
25149
|
-
const value = horizontal ? (v) => plot.x + (v - scale2.min) /
|
|
25812
|
+
const span3 = scale2.max - scale2.min || 1;
|
|
25813
|
+
const value = horizontal ? (v) => plot.x + (v - scale2.min) / span3 * plot.w : (v) => plot.y + plot.h - (v - scale2.min) / span3 * plot.h;
|
|
25150
25814
|
const bandSize = (horizontal ? plot.h : plot.w) / cats;
|
|
25151
25815
|
const band = horizontal ? (i) => plot.y + plot.h - bandSize * (i + 0.5) : (i) => plot.x + bandSize * (i + 0.5);
|
|
25152
25816
|
scale2.ticks.forEach((t, i) => {
|
|
@@ -25516,4 +26180,4 @@ function createRefEvaluator(workbook, calc, options = {}) {
|
|
|
25516
26180
|
};
|
|
25517
26181
|
}
|
|
25518
26182
|
|
|
25519
|
-
export { AxisMetrics, BORDER_STYLES, BUILTIN_CELL_STYLES, BUILTIN_NUMBER_FORMATS, CIRCULAR_REFERENCE_WARNING, COLUMN_PADDING_PX, DEFAULT_ANCHOR_EXTENT_EMU, DEFAULT_BASE_COL_WIDTH, DEFAULT_COL_WIDTH, DEFAULT_MAX_DIGIT_WIDTH, DEFAULT_ROW_HEIGHT, DEFAULT_THEME, DEFAULT_VALIDATION_MESSAGE, ERROR_CODES, FORMAT_PRESETS, FUNCTION_CATALOG, FormulaError, IMAGE_EXTENSIONS, INDENT_PX_PER_LEVEL, INDEXED_COLORS, MAX_COL, MAX_DATE_SERIAL, MAX_OUTLINE_LEVEL, MAX_ROW, MIN_TWO_CELL_PIXELS, OVERFLOW_TEXT, PERCENT_SCALE, THEME_SLOTS, TIME_PERIODS, addFuturePrefixes, anchorKind, anchorToPixelBox, applyBuiltinStyle, applyStylePatch, applyTint, approximateMeasure, autoFitColumnWidth, autoFitRowHeight, autoGrowRows, autoSeriesColor, bordersView, builtinCellStyle, builtinFormatId, calcModeOf, categoryTotals, cellError, cellInputText, cellKey, cellView, cellsFromText, charactersToColumnWidth, charactersToPixels, chartView, columnIndex, columnLabel, columnWidthToPixels, compareCellValues, compareValues, createCalcEngine, createConditionalFormatEvaluator, createEditSession, createGridMetrics, createRefEvaluator, createWorkbook, createWorksheet, currentRegion, dateToSerial, defaultCellStyle, defaultColumnPixels, deleteCell, deleteSheetInFormula, detectSeries, edgeView, effectiveStyleId, fillView, fontView, forEachCell, forEachCellInRange, formatAddress, formatAxisValue, formatGeneral, formatRange, formatRefSpec, formatValue, formulaBarText, generalAlignment, getCell, getCellAt, getValue, hls240ToRgb, inTimePeriod, internStyle, isCellError, isDateFormat, isEmptyCell, isErrorCode, isOverflowTarget, isSpilledCell, keyToAddress, legacyPasswordHash, lineHeightPoints, listValidationOptions, loadXlsx, mergeAt, mergeFont, mergeView, mergeWouldDiscard, mixColors, modernPasswordHash, modulateLuminance, moveReferencesInFormula, navigate, needsArrayEvaluation, newMediaPart, nextSheetId, nextSheetName, niceScale, normalizeRange, numberInputText, numberToText, overflowExtent, parseAddress, parseCellInput, parseFormula, parseHex, parseHtmlTable, parseNumberText, parseRange, parseTsv, patchStyle, percentile, pictureAnchorAt, pixelBoxToAnchor, pixelSizeToExtent, pixelsToCharacters, pixelsToColumnWidth, pixelsToPoints, pointsToPixels, presetEdges, putCell, queryPattern, quoteSheetName, rangeContains, rangeSize, rangesIntersect, referenceSpans, referencedRanges, renameSheetInFormula, renameTableInFormula, renderChartSvg, replaceText, resolveColor, rgbToHls240, rotationDegrees, rowsToRefit, saveXlsx, scaleColor, selectionStats, serialToDate, sheetByName, shiftFormula, shiftRange, shiftSpan, spillAnchorOf, stepDecimals, stripFuturePrefixes, structuredToA1, styleAt, styleKey, subtractRange, themeColor, timePeriodFormula, toHexColor, toHtml, toTsv, tokenize, translateFormula, translateReferences, uniqueHeaders, usedRange, validateCellInput, validateDefinedName, validateSheetName, validateTableName, validationAt, verifySheetPassword, verifySheetPasswordAsync, verifyWorkbookPassword, visibleCells, wrappedLineCount, zoomPercent };
|
|
26183
|
+
export { AxisMetrics, BORDER_STYLES, BUILTIN_CELL_STYLES, BUILTIN_NUMBER_FORMATS, CIRCULAR_REFERENCE_WARNING, COLUMN_PADDING_PX, DEFAULT_ANCHOR_EXTENT_EMU, DEFAULT_BASE_COL_WIDTH, DEFAULT_COL_WIDTH, DEFAULT_MAX_DIGIT_WIDTH, DEFAULT_ROW_HEIGHT, DEFAULT_THEME, DEFAULT_VALIDATION_MESSAGE, ERROR_CODES, FORMAT_PRESETS, FUNCTION_CATALOG, FormulaError, IMAGE_EXTENSIONS, INDENT_PX_PER_LEVEL, INDEXED_COLORS, MAX_COL, MAX_DATE_SERIAL, MAX_OUTLINE_LEVEL, MAX_ROW, MIN_TWO_CELL_PIXELS, OVERFLOW_TEXT, PERCENT_SCALE, REFERENCE_COLORS, THEME_SLOTS, TIME_PERIODS, acceptsReference, activeParam, addFuturePrefixes, anchorKind, anchorToPixelBox, applyBuiltinStyle, applyStylePatch, applyTint, approximateMeasure, autoFitColumnWidth, autoFitRowHeight, autoGrowRows, autoSeriesColor, bordersView, builtinCellStyle, builtinFormatId, calcModeOf, callAtCaret, categoryTotals, cellError, cellInputText, cellKey, cellView, cellsFromText, charactersToColumnWidth, charactersToPixels, chartView, closeParens, coloredReferences, columnIndex, columnLabel, columnWidthToPixels, compareCellValues, compareValues, createCalcEngine, createConditionalFormatEvaluator, createEditSession, createGridMetrics, createRefEvaluator, createWorkbook, createWorksheet, currentRegion, dateToSerial, defaultCellStyle, defaultColumnPixels, deleteCell, deleteSheetInFormula, detectSeries, edgeView, effectiveStyleId, fillView, fontView, forEachCell, forEachCellInRange, formatAddress, formatAxisValue, formatGeneral, formatRange, formatRefSpec, formatValue, formulaBarText, functionMatches, generalAlignment, getCell, getCellAt, getValue, hls240ToRgb, inTimePeriod, insideString, internStyle, isCellError, isDateFormat, isEmptyCell, isErrorCode, isFormulaText, isOverflowTarget, isSpilledCell, keyToAddress, legacyPasswordHash, lineHeightPoints, listValidationOptions, loadXlsx, mergeAt, mergeFont, mergeView, mergeWouldDiscard, mixColors, modernPasswordHash, modulateLuminance, moveReferencesInFormula, nameAtCaret, navigate, needsArrayEvaluation, newMediaPart, nextSheetId, nextSheetName, niceScale, normalizeRange, numberInputText, numberToText, overflowExtent, parseAddress, parseCellInput, parseFormula, parseHex, parseHtmlTable, parseNumberText, parseRange, parseTsv, patchStyle, percentile, pictureAnchorAt, pixelBoxToAnchor, pixelSizeToExtent, pixelsToCharacters, pixelsToColumnWidth, pixelsToPoints, pointsToPixels, presetEdges, putCell, queryPattern, quoteSheetName, rangeContains, rangeSize, rangesIntersect, referenceSpans, referenceTarget, referencedRanges, renameSheetInFormula, renameTableInFormula, renderChartSvg, replaceText, resolveColor, rgbToHls240, rotationDegrees, rowsToRefit, saveXlsx, scaleColor, selectionStats, serialToDate, sheetByName, shiftFormula, shiftRange, shiftSpan, spillAnchorOf, splice, stepDecimals, stripFuturePrefixes, structuredToA1, styleAt, styleKey, subtractRange, syntaxParams, themeColor, timePeriodFormula, toHexColor, toHtml, toTsv, toggleAbsolute, tokenize, translateFormula, translateReferences, uniqueHeaders, usedRange, validateCellInput, validateDefinedName, validateSheetName, validateTableName, validationAt, verifySheetPassword, verifySheetPasswordAsync, verifyWorkbookPassword, visibleCells, wrappedLineCount, zoomPercent };
|