ooxml-core 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automation/index.cjs +867 -360
- package/dist/automation/index.mjs +867 -360
- package/dist/xlsx/formula/engine-core.d.ts +9 -0
- package/dist/xlsx/formula/engine-core.d.ts.map +1 -1
- package/dist/xlsx/formula/engine-host.d.ts +2 -0
- package/dist/xlsx/formula/engine-host.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/bonds.d.ts +3 -0
- package/dist/xlsx/formula/functions/bonds.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/coupons.d.ts +21 -0
- package/dist/xlsx/formula/functions/coupons.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/depreciation.d.ts +0 -1
- package/dist/xlsx/formula/functions/depreciation.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/financial.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/securities.d.ts +3 -0
- package/dist/xlsx/formula/functions/securities.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/text-extra.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/text-regex.d.ts +5 -0
- package/dist/xlsx/formula/functions/text-regex.d.ts.map +1 -0
- package/dist/xlsx/index.cjs +850 -343
- package/dist/xlsx/index.mjs +850 -343
- package/dist/xlsx/load/index.cjs +804 -330
- package/dist/xlsx/load/index.mjs +804 -330
- package/dist/xlsx/model.d.ts +9 -0
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/load.d.ts.map +1 -1
- package/dist/xlsx/read/workbook-part.d.ts +5 -0
- package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
- package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/xlsx/load/index.mjs
CHANGED
|
@@ -3982,8 +3982,14 @@ function parseWorkbookPart(xml) {
|
|
|
3982
3982
|
const protection = xFirst(root, "workbookProtection");
|
|
3983
3983
|
const password = att(protection, "workbookPassword");
|
|
3984
3984
|
const modernHash = readModernHash(protection, "workbook");
|
|
3985
|
-
const
|
|
3985
|
+
const calcPr = xFirst(root, "calcPr");
|
|
3986
|
+
const calcMode = att(calcPr, "calcMode");
|
|
3987
|
+
const iterate = boolAttr(calcPr, "iterate", false) ? {
|
|
3988
|
+
count: numAttr(calcPr, "iterateCount") ?? 100,
|
|
3989
|
+
delta: numAttr(calcPr, "iterateDelta") ?? 1e-3
|
|
3990
|
+
} : void 0;
|
|
3986
3991
|
return {
|
|
3992
|
+
...iterate ? { iterate } : {},
|
|
3987
3993
|
...password ? { workbookPasswordHash: password } : {},
|
|
3988
3994
|
...modernHash ? { workbookModernHash: modernHash } : {},
|
|
3989
3995
|
...calcMode === "manual" ? { calcMode: "manual" } : {},
|
|
@@ -6210,6 +6216,7 @@ async function loadXlsx(input) {
|
|
|
6210
6216
|
if (book.workbookPasswordHash) workbook.workbookPasswordHash = book.workbookPasswordHash;
|
|
6211
6217
|
if (book.workbookModernHash) workbook.workbookModernHash = book.workbookModernHash;
|
|
6212
6218
|
if (book.calcMode) workbook.calcMode = book.calcMode;
|
|
6219
|
+
if (book.iterate) workbook.iterate = book.iterate;
|
|
6213
6220
|
if (signatures.hasSignatures)
|
|
6214
6221
|
workbook.signatures = { count: signatures.signatureCount, parts: signatures.signaturePaths };
|
|
6215
6222
|
if (!sheets.length) throw new Error("XLSX workbook has no sheets");
|
|
@@ -10578,6 +10585,67 @@ var ENGINEERING_FUNCTIONS = [
|
|
|
10578
10585
|
)
|
|
10579
10586
|
];
|
|
10580
10587
|
|
|
10588
|
+
// src/xlsx/formula/functions/coupons.ts
|
|
10589
|
+
var C8 = "Financial";
|
|
10590
|
+
function checkSecurity(settlement, maturity, frequency2, basis) {
|
|
10591
|
+
if (![1, 2, 4].includes(frequency2) || basis < 0 || basis > 4 || settlement >= maturity)
|
|
10592
|
+
fail(ERR.NUM);
|
|
10593
|
+
}
|
|
10594
|
+
function couponFacts(settlement, maturity, frequency2, basis, ctx) {
|
|
10595
|
+
const [s, m] = [Math.floor(settlement), Math.floor(maturity)];
|
|
10596
|
+
checkSecurity(s, m, frequency2, basis);
|
|
10597
|
+
const months = 12 / frequency2;
|
|
10598
|
+
const { year, month, day } = serialToYmd(m, ctx.date1904);
|
|
10599
|
+
const monthEnd = day === daysInMonth(year, month);
|
|
10600
|
+
let count2 = 0;
|
|
10601
|
+
let next = m;
|
|
10602
|
+
let previous = addMonths(m, -months, ctx, monthEnd);
|
|
10603
|
+
while (previous > s) {
|
|
10604
|
+
count2 += 1;
|
|
10605
|
+
next = previous;
|
|
10606
|
+
previous = addMonths(m, -months * (count2 + 1), ctx, monthEnd);
|
|
10607
|
+
}
|
|
10608
|
+
count2 += 1;
|
|
10609
|
+
const dayCount = (a, b, european) => basis === 0 || basis === 4 ? days360(a, b, basis === 4 || european, ctx) : b - a;
|
|
10610
|
+
const daysSincePrevious = dayCount(previous, s, false);
|
|
10611
|
+
const daysInPeriod = basis === 1 ? next - previous : basis === 3 ? 365 / frequency2 : 360 / frequency2;
|
|
10612
|
+
const daysToNext = basis === 0 ? daysInPeriod - daysSincePrevious : basis === 4 ? days360(s, next, true, ctx) : next - s;
|
|
10613
|
+
return { previous, next, count: count2, daysSincePrevious, daysInPeriod, daysToNext };
|
|
10614
|
+
}
|
|
10615
|
+
var security = (name, description, pick2) => spec(
|
|
10616
|
+
name,
|
|
10617
|
+
C8,
|
|
10618
|
+
`${name}(settlement, maturity, frequency, [basis])`,
|
|
10619
|
+
description,
|
|
10620
|
+
3,
|
|
10621
|
+
4,
|
|
10622
|
+
(args, ctx) => pick2(
|
|
10623
|
+
couponFacts(
|
|
10624
|
+
serialArg(args[0]),
|
|
10625
|
+
serialArg(args[1]),
|
|
10626
|
+
int3(args[2]),
|
|
10627
|
+
args.length > 3 && args[3] !== null ? int3(args[3]) : 0,
|
|
10628
|
+
ctx
|
|
10629
|
+
)
|
|
10630
|
+
)
|
|
10631
|
+
);
|
|
10632
|
+
var COUPON_FUNCTIONS = [
|
|
10633
|
+
security("COUPPCD", "The coupon date before the settlement date.", (f) => f.previous),
|
|
10634
|
+
security("COUPNCD", "The coupon date after the settlement date.", (f) => f.next),
|
|
10635
|
+
security("COUPNUM", "The number of coupons between settlement and maturity.", (f) => f.count),
|
|
10636
|
+
security(
|
|
10637
|
+
"COUPDAYBS",
|
|
10638
|
+
"The days from the start of the coupon period to settlement.",
|
|
10639
|
+
(f) => f.daysSincePrevious
|
|
10640
|
+
),
|
|
10641
|
+
security(
|
|
10642
|
+
"COUPDAYS",
|
|
10643
|
+
"The days in the coupon period that contains the settlement date.",
|
|
10644
|
+
(f) => f.daysInPeriod
|
|
10645
|
+
),
|
|
10646
|
+
security("COUPDAYSNC", "The days from settlement to the next coupon date.", (f) => f.daysToNext)
|
|
10647
|
+
];
|
|
10648
|
+
|
|
10581
10649
|
// src/xlsx/formula/functions/financial-core.ts
|
|
10582
10650
|
function pmt(rate, nper, pv2, fv2 = 0, type = 0) {
|
|
10583
10651
|
if (nper === 0) fail(ERR.NUM);
|
|
@@ -10647,12 +10715,185 @@ function cumulative(args, principal) {
|
|
|
10647
10715
|
return total2;
|
|
10648
10716
|
}
|
|
10649
10717
|
|
|
10718
|
+
// src/xlsx/formula/functions/bonds.ts
|
|
10719
|
+
var C9 = "Financial";
|
|
10720
|
+
var basisOf = (args, index2) => {
|
|
10721
|
+
const basis = args.length > index2 && args[index2] !== null ? int3(args[index2]) : 0;
|
|
10722
|
+
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
10723
|
+
return basis;
|
|
10724
|
+
};
|
|
10725
|
+
function pricePerHundred(facts, rate, yld, redemption, frequency2) {
|
|
10726
|
+
const { count: n, daysSincePrevious: a, daysInPeriod: e, daysToNext: dsc } = facts;
|
|
10727
|
+
const coupon = 100 * rate / frequency2;
|
|
10728
|
+
const accrued = coupon * (a / e);
|
|
10729
|
+
if (n === 1) return (redemption + coupon) / (1 + dsc / e * yld / frequency2) - accrued;
|
|
10730
|
+
let price = redemption / (1 + yld / frequency2) ** (n - 1 + dsc / e);
|
|
10731
|
+
for (let k = 1; k <= n; k++) price += coupon / (1 + yld / frequency2) ** (k - 1 + dsc / e);
|
|
10732
|
+
return price - accrued;
|
|
10733
|
+
}
|
|
10734
|
+
function bondOf(args, ctx, redemptionAt, basisAt) {
|
|
10735
|
+
const frequency2 = int3(args[5]);
|
|
10736
|
+
const facts = couponFacts(
|
|
10737
|
+
serialArg(args[0]),
|
|
10738
|
+
serialArg(args[1]),
|
|
10739
|
+
frequency2,
|
|
10740
|
+
basisOf(args, basisAt),
|
|
10741
|
+
ctx
|
|
10742
|
+
);
|
|
10743
|
+
return { facts, rate: num2(args[2]), redemption: num2(args[redemptionAt]), frequency: frequency2 };
|
|
10744
|
+
}
|
|
10745
|
+
function duration(bond, yld) {
|
|
10746
|
+
const { facts, rate, frequency: frequency2 } = bond;
|
|
10747
|
+
const { count: n, daysInPeriod: e, daysToNext: dsc } = facts;
|
|
10748
|
+
const coupon = 100 * rate / frequency2;
|
|
10749
|
+
let weighted = 0;
|
|
10750
|
+
let total2 = 0;
|
|
10751
|
+
for (let k = 1; k <= n; k++) {
|
|
10752
|
+
const periods = k - 1 + dsc / e;
|
|
10753
|
+
const flow = k === n ? coupon + 100 : coupon;
|
|
10754
|
+
const value = flow / (1 + yld / frequency2) ** periods;
|
|
10755
|
+
weighted += periods / frequency2 * value;
|
|
10756
|
+
total2 += value;
|
|
10757
|
+
}
|
|
10758
|
+
return weighted / total2;
|
|
10759
|
+
}
|
|
10760
|
+
function quasiPeriods(anchor, from, to, frequency2, ctx) {
|
|
10761
|
+
const months = 12 / frequency2;
|
|
10762
|
+
const { year, month, day } = serialToYmd(anchor, ctx.date1904);
|
|
10763
|
+
const monthEnd = day === daysInMonth(year, month);
|
|
10764
|
+
const at = (k) => addMonths(anchor, k * months, ctx, monthEnd);
|
|
10765
|
+
let back = 0;
|
|
10766
|
+
while (at(back) > from) back -= 1;
|
|
10767
|
+
const dates = [];
|
|
10768
|
+
for (let k = back; ; k++) {
|
|
10769
|
+
dates.push(at(k));
|
|
10770
|
+
if (at(k) >= to) break;
|
|
10771
|
+
}
|
|
10772
|
+
return dates;
|
|
10773
|
+
}
|
|
10774
|
+
function accruedInterest(args, ctx) {
|
|
10775
|
+
const issue = serialArg(args[0]);
|
|
10776
|
+
const first3 = serialArg(args[1]);
|
|
10777
|
+
const settlement = serialArg(args[2]);
|
|
10778
|
+
const [rate, par] = [num2(args[3]), optNum(args, 4, 1e3)];
|
|
10779
|
+
const frequency2 = int3(args[5]);
|
|
10780
|
+
const basis = basisOf(args, 6);
|
|
10781
|
+
const fromIssue = args.length > 7 && args[7] !== null ? bool(args[7]) : true;
|
|
10782
|
+
if (rate <= 0 || par <= 0 || ![1, 2, 4].includes(frequency2) || issue >= settlement) fail(ERR.NUM);
|
|
10783
|
+
const start = fromIssue ? issue : Math.max(issue, first3);
|
|
10784
|
+
if (start >= settlement) return 0;
|
|
10785
|
+
const dates = quasiPeriods(first3, start, settlement, frequency2, ctx);
|
|
10786
|
+
const count2 = (a, b) => basis === 0 || basis === 4 ? days360(a, b, basis === 4, ctx) : b - a;
|
|
10787
|
+
let sum2 = 0;
|
|
10788
|
+
for (let i = 0; i + 1 < dates.length; i++) {
|
|
10789
|
+
const [p, q] = [dates[i], dates[i + 1]];
|
|
10790
|
+
const a = count2(Math.max(start, p), Math.min(settlement, q));
|
|
10791
|
+
if (a <= 0) continue;
|
|
10792
|
+
const length = basis === 1 ? q - p : basis === 3 ? 365 / frequency2 : 360 / frequency2;
|
|
10793
|
+
sum2 += a / length;
|
|
10794
|
+
}
|
|
10795
|
+
return par * rate / frequency2 * sum2;
|
|
10796
|
+
}
|
|
10797
|
+
var BOND_ARGS = (name, third, fourth, fifth) => `${name}(settlement, maturity, ${third}, ${fourth}, ${fifth}, frequency, [basis])`;
|
|
10798
|
+
var BOND_FUNCTIONS = [
|
|
10799
|
+
spec(
|
|
10800
|
+
"PRICE",
|
|
10801
|
+
C9,
|
|
10802
|
+
BOND_ARGS("PRICE", "rate", "yld", "redemption"),
|
|
10803
|
+
"The price per 100 face value of a security that pays periodic interest.",
|
|
10804
|
+
6,
|
|
10805
|
+
7,
|
|
10806
|
+
(args, ctx) => {
|
|
10807
|
+
const bond = bondOf(args, ctx, 4, 6);
|
|
10808
|
+
const yld = num2(args[3]);
|
|
10809
|
+
if (bond.rate < 0 || yld < 0 || bond.redemption <= 0) fail(ERR.NUM);
|
|
10810
|
+
return pricePerHundred(bond.facts, bond.rate, yld, bond.redemption, bond.frequency);
|
|
10811
|
+
}
|
|
10812
|
+
),
|
|
10813
|
+
spec(
|
|
10814
|
+
"YIELD",
|
|
10815
|
+
C9,
|
|
10816
|
+
BOND_ARGS("YIELD", "rate", "pr", "redemption"),
|
|
10817
|
+
"The yield of a security that pays periodic interest.",
|
|
10818
|
+
6,
|
|
10819
|
+
7,
|
|
10820
|
+
(args, ctx) => {
|
|
10821
|
+
const bond = bondOf(args, ctx, 4, 6);
|
|
10822
|
+
const price = num2(args[3]);
|
|
10823
|
+
if (bond.rate < 0 || price <= 0 || bond.redemption <= 0) fail(ERR.NUM);
|
|
10824
|
+
const f = (y) => pricePerHundred(bond.facts, bond.rate, y, bond.redemption, bond.frequency) - price;
|
|
10825
|
+
return solve(f, bond.rate || 0.05);
|
|
10826
|
+
}
|
|
10827
|
+
),
|
|
10828
|
+
...["DURATION", "MDURATION"].map(
|
|
10829
|
+
(name) => spec(
|
|
10830
|
+
name,
|
|
10831
|
+
C9,
|
|
10832
|
+
`${name}(settlement, maturity, coupon, yld, frequency, [basis])`,
|
|
10833
|
+
name === "DURATION" ? "The Macaulay duration of a security with periodic interest." : "The modified Macaulay duration of a security.",
|
|
10834
|
+
5,
|
|
10835
|
+
6,
|
|
10836
|
+
(args, ctx) => {
|
|
10837
|
+
const frequency2 = int3(args[4]);
|
|
10838
|
+
const facts = couponFacts(
|
|
10839
|
+
serialArg(args[0]),
|
|
10840
|
+
serialArg(args[1]),
|
|
10841
|
+
frequency2,
|
|
10842
|
+
basisOf(args, 5),
|
|
10843
|
+
ctx
|
|
10844
|
+
);
|
|
10845
|
+
const [rate, yld] = [num2(args[2]), num2(args[3])];
|
|
10846
|
+
if (rate < 0 || yld < 0) fail(ERR.NUM);
|
|
10847
|
+
const macaulay = duration({ facts, rate, frequency: frequency2 }, yld);
|
|
10848
|
+
return name === "DURATION" ? macaulay : macaulay / (1 + yld / frequency2);
|
|
10849
|
+
}
|
|
10850
|
+
)
|
|
10851
|
+
),
|
|
10852
|
+
spec(
|
|
10853
|
+
"ACCRINT",
|
|
10854
|
+
C9,
|
|
10855
|
+
"ACCRINT(issue, first_interest, settlement, rate, par, frequency, [basis], [calc_method])",
|
|
10856
|
+
"The accrued interest of a security that pays periodic interest.",
|
|
10857
|
+
6,
|
|
10858
|
+
8,
|
|
10859
|
+
(args, ctx) => accruedInterest(args, ctx)
|
|
10860
|
+
),
|
|
10861
|
+
spec(
|
|
10862
|
+
"ACCRINTM",
|
|
10863
|
+
C9,
|
|
10864
|
+
"ACCRINTM(issue, settlement, rate, [par], [basis])",
|
|
10865
|
+
"The accrued interest of a security that pays interest at maturity.",
|
|
10866
|
+
3,
|
|
10867
|
+
5,
|
|
10868
|
+
(args, ctx) => {
|
|
10869
|
+
const [issue, settlement] = [serialArg(args[0]), serialArg(args[1])];
|
|
10870
|
+
const [rate, par] = [num2(args[2]), optNum(args, 3, 1e3)];
|
|
10871
|
+
if (rate <= 0 || par <= 0 || issue >= settlement) fail(ERR.NUM);
|
|
10872
|
+
return par * rate * yearFrac(issue, settlement, basisOf(args, 4), ctx);
|
|
10873
|
+
}
|
|
10874
|
+
)
|
|
10875
|
+
];
|
|
10876
|
+
|
|
10650
10877
|
// src/xlsx/formula/functions/depreciation.ts
|
|
10651
|
-
var
|
|
10878
|
+
var C10 = "Financial";
|
|
10879
|
+
function variableDeclining(cost, salvage, life, start, end, factor, noSwitch) {
|
|
10880
|
+
let book = cost;
|
|
10881
|
+
let total2 = 0;
|
|
10882
|
+
for (let period = 1; period - 1 < end; period++) {
|
|
10883
|
+
const declining = book * factor / life;
|
|
10884
|
+
const straight = (book - salvage) / Math.max(life - (period - 1), 1);
|
|
10885
|
+
const wanted = noSwitch ? declining : Math.max(declining, straight);
|
|
10886
|
+
const dep = Math.max(0, Math.min(wanted, book - salvage));
|
|
10887
|
+
const covered = Math.min(end, period) - Math.max(start, period - 1);
|
|
10888
|
+
if (covered > 0) total2 += dep * Math.min(covered, 1);
|
|
10889
|
+
book -= dep;
|
|
10890
|
+
}
|
|
10891
|
+
return total2;
|
|
10892
|
+
}
|
|
10652
10893
|
var DEPRECIATION_FUNCTIONS = [
|
|
10653
10894
|
numeric(
|
|
10654
10895
|
"SLN",
|
|
10655
|
-
|
|
10896
|
+
C10,
|
|
10656
10897
|
"SLN(cost, salvage, life)",
|
|
10657
10898
|
"Straight-line depreciation.",
|
|
10658
10899
|
3,
|
|
@@ -10661,7 +10902,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10661
10902
|
),
|
|
10662
10903
|
numeric(
|
|
10663
10904
|
"SYD",
|
|
10664
|
-
|
|
10905
|
+
C10,
|
|
10665
10906
|
"SYD(cost, salvage, life, per)",
|
|
10666
10907
|
"Sum-of-years' digits depreciation.",
|
|
10667
10908
|
4,
|
|
@@ -10673,7 +10914,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10673
10914
|
),
|
|
10674
10915
|
numeric(
|
|
10675
10916
|
"DDB",
|
|
10676
|
-
|
|
10917
|
+
C10,
|
|
10677
10918
|
"DDB(cost, salvage, life, period, [factor])",
|
|
10678
10919
|
"Double-declining balance depreciation.",
|
|
10679
10920
|
4,
|
|
@@ -10689,9 +10930,33 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10689
10930
|
return dep;
|
|
10690
10931
|
}
|
|
10691
10932
|
),
|
|
10933
|
+
spec(
|
|
10934
|
+
"VDB",
|
|
10935
|
+
C10,
|
|
10936
|
+
"VDB(cost, salvage, life, start_period, end_period, [factor], [no_switch])",
|
|
10937
|
+
"Depreciation over any span of periods, switching to straight-line when that is larger.",
|
|
10938
|
+
5,
|
|
10939
|
+
7,
|
|
10940
|
+
(args) => {
|
|
10941
|
+
const [cost, salvage, life, start, end] = [0, 1, 2, 3, 4].map((i) => num2(args[i]));
|
|
10942
|
+
const factor = args.length > 5 && args[5] !== null ? num2(args[5]) : 2;
|
|
10943
|
+
const noSwitch = args.length > 6 && args[6] !== null ? bool(args[6]) : false;
|
|
10944
|
+
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)
|
|
10945
|
+
fail(ERR.NUM);
|
|
10946
|
+
return variableDeclining(
|
|
10947
|
+
cost,
|
|
10948
|
+
salvage,
|
|
10949
|
+
life,
|
|
10950
|
+
start,
|
|
10951
|
+
end,
|
|
10952
|
+
factor,
|
|
10953
|
+
noSwitch
|
|
10954
|
+
);
|
|
10955
|
+
}
|
|
10956
|
+
),
|
|
10692
10957
|
numeric(
|
|
10693
10958
|
"DB",
|
|
10694
|
-
|
|
10959
|
+
C10,
|
|
10695
10960
|
"DB(cost, salvage, life, period, [month])",
|
|
10696
10961
|
"Fixed-declining balance depreciation.",
|
|
10697
10962
|
4,
|
|
@@ -10714,7 +10979,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10714
10979
|
),
|
|
10715
10980
|
numeric(
|
|
10716
10981
|
"EFFECT",
|
|
10717
|
-
|
|
10982
|
+
C10,
|
|
10718
10983
|
"EFFECT(nominal_rate, npery)",
|
|
10719
10984
|
"The effective annual interest rate.",
|
|
10720
10985
|
2,
|
|
@@ -10727,7 +10992,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10727
10992
|
),
|
|
10728
10993
|
numeric(
|
|
10729
10994
|
"NOMINAL",
|
|
10730
|
-
|
|
10995
|
+
C10,
|
|
10731
10996
|
"NOMINAL(effect_rate, npery)",
|
|
10732
10997
|
"The nominal annual interest rate.",
|
|
10733
10998
|
2,
|
|
@@ -10740,7 +11005,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10740
11005
|
),
|
|
10741
11006
|
numeric(
|
|
10742
11007
|
"CUMIPMT",
|
|
10743
|
-
|
|
11008
|
+
C10,
|
|
10744
11009
|
"CUMIPMT(rate, nper, pv, start_period, end_period, type)",
|
|
10745
11010
|
"Cumulative interest paid between periods.",
|
|
10746
11011
|
6,
|
|
@@ -10749,7 +11014,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10749
11014
|
),
|
|
10750
11015
|
numeric(
|
|
10751
11016
|
"CUMPRINC",
|
|
10752
|
-
|
|
11017
|
+
C10,
|
|
10753
11018
|
"CUMPRINC(rate, nper, pv, start_period, end_period, type)",
|
|
10754
11019
|
"Cumulative principal paid between periods.",
|
|
10755
11020
|
6,
|
|
@@ -10758,7 +11023,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10758
11023
|
),
|
|
10759
11024
|
numeric(
|
|
10760
11025
|
"ISPMT",
|
|
10761
|
-
|
|
11026
|
+
C10,
|
|
10762
11027
|
"ISPMT(rate, per, nper, pv)",
|
|
10763
11028
|
"Interest paid in a period of a straight-line loan.",
|
|
10764
11029
|
4,
|
|
@@ -10770,7 +11035,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10770
11035
|
),
|
|
10771
11036
|
numeric(
|
|
10772
11037
|
"PDURATION",
|
|
10773
|
-
|
|
11038
|
+
C10,
|
|
10774
11039
|
"PDURATION(rate, pv, fv)",
|
|
10775
11040
|
"Periods required to reach a value.",
|
|
10776
11041
|
3,
|
|
@@ -10782,7 +11047,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10782
11047
|
),
|
|
10783
11048
|
numeric(
|
|
10784
11049
|
"RRI",
|
|
10785
|
-
|
|
11050
|
+
C10,
|
|
10786
11051
|
"RRI(nper, pv, fv)",
|
|
10787
11052
|
"An equivalent interest rate for growth.",
|
|
10788
11053
|
3,
|
|
@@ -10794,7 +11059,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10794
11059
|
),
|
|
10795
11060
|
spec(
|
|
10796
11061
|
"FVSCHEDULE",
|
|
10797
|
-
|
|
11062
|
+
C10,
|
|
10798
11063
|
"FVSCHEDULE(principal, schedule)",
|
|
10799
11064
|
"Future value with a schedule of rates.",
|
|
10800
11065
|
2,
|
|
@@ -10804,7 +11069,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10804
11069
|
),
|
|
10805
11070
|
numeric(
|
|
10806
11071
|
"DOLLARDE",
|
|
10807
|
-
|
|
11072
|
+
C10,
|
|
10808
11073
|
"DOLLARDE(fractional_dollar, fraction)",
|
|
10809
11074
|
"Converts a fractional price to a decimal.",
|
|
10810
11075
|
2,
|
|
@@ -10820,7 +11085,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10820
11085
|
),
|
|
10821
11086
|
numeric(
|
|
10822
11087
|
"DOLLARFR",
|
|
10823
|
-
|
|
11088
|
+
C10,
|
|
10824
11089
|
"DOLLARFR(decimal_dollar, fraction)",
|
|
10825
11090
|
"Converts a decimal price to a fraction.",
|
|
10826
11091
|
2,
|
|
@@ -10836,8 +11101,141 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
10836
11101
|
)
|
|
10837
11102
|
];
|
|
10838
11103
|
|
|
11104
|
+
// src/xlsx/formula/functions/securities.ts
|
|
11105
|
+
var C11 = "Financial";
|
|
11106
|
+
var basisOf2 = (args, index2) => {
|
|
11107
|
+
const basis = args.length > index2 && args[index2] !== null ? int3(args[index2]) : 0;
|
|
11108
|
+
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
11109
|
+
return basis;
|
|
11110
|
+
};
|
|
11111
|
+
function span(args) {
|
|
11112
|
+
const [s, m] = [Math.floor(serialArg(args[0])), Math.floor(serialArg(args[1]))];
|
|
11113
|
+
if (s >= m) fail(ERR.NUM);
|
|
11114
|
+
return { s, m };
|
|
11115
|
+
}
|
|
11116
|
+
var positive = (...values2) => {
|
|
11117
|
+
for (const v of values2) if (!(v > 0)) fail(ERR.NUM);
|
|
11118
|
+
};
|
|
11119
|
+
var discount = (name, description, syntax, fn) => spec(name, C11, syntax, description, 4, 5, (args, ctx) => {
|
|
11120
|
+
const { s, m } = span(args);
|
|
11121
|
+
const [a, b] = [num2(args[2]), num2(args[3])];
|
|
11122
|
+
positive(a, b);
|
|
11123
|
+
return fn(a, b, yearFrac(s, m, basisOf2(args, 4), ctx));
|
|
11124
|
+
});
|
|
11125
|
+
var atMaturity = (name, description, syntax, fn) => spec(name, C11, syntax, description, 5, 6, (args, ctx) => {
|
|
11126
|
+
const { s, m } = span(args);
|
|
11127
|
+
const issue = Math.floor(serialArg(args[2]));
|
|
11128
|
+
const [rate, other] = [num2(args[3]), num2(args[4])];
|
|
11129
|
+
const basis = basisOf2(args, 5);
|
|
11130
|
+
if (issue > s || rate < 0 || other < 0) fail(ERR.NUM);
|
|
11131
|
+
return fn(
|
|
11132
|
+
rate,
|
|
11133
|
+
other,
|
|
11134
|
+
yearFrac(issue, m, basis, ctx),
|
|
11135
|
+
yearFrac(issue, s, basis, ctx),
|
|
11136
|
+
yearFrac(s, m, basis, ctx)
|
|
11137
|
+
);
|
|
11138
|
+
});
|
|
11139
|
+
function billDays(args) {
|
|
11140
|
+
const { s, m } = span(args);
|
|
11141
|
+
const days = m - s;
|
|
11142
|
+
if (days > 365) fail(ERR.NUM);
|
|
11143
|
+
return days;
|
|
11144
|
+
}
|
|
11145
|
+
var SECURITY_FUNCTIONS = [
|
|
11146
|
+
discount(
|
|
11147
|
+
"DISC",
|
|
11148
|
+
"The discount rate of a security.",
|
|
11149
|
+
"DISC(settlement, maturity, pr, redemption, [basis])",
|
|
11150
|
+
(pr, redemption, f) => (redemption - pr) / redemption / f
|
|
11151
|
+
),
|
|
11152
|
+
discount(
|
|
11153
|
+
"PRICEDISC",
|
|
11154
|
+
"The price per 100 face value of a discounted security.",
|
|
11155
|
+
"PRICEDISC(settlement, maturity, discount, redemption, [basis])",
|
|
11156
|
+
(rate, redemption, f) => redemption - rate * redemption * f
|
|
11157
|
+
),
|
|
11158
|
+
discount(
|
|
11159
|
+
"YIELDDISC",
|
|
11160
|
+
"The annual yield of a discounted security.",
|
|
11161
|
+
"YIELDDISC(settlement, maturity, pr, redemption, [basis])",
|
|
11162
|
+
(pr, redemption, f) => (redemption - pr) / pr / f
|
|
11163
|
+
),
|
|
11164
|
+
discount(
|
|
11165
|
+
"INTRATE",
|
|
11166
|
+
"The interest rate of a fully invested security.",
|
|
11167
|
+
"INTRATE(settlement, maturity, investment, redemption, [basis])",
|
|
11168
|
+
(investment, redemption, f) => (redemption - investment) / investment / f
|
|
11169
|
+
),
|
|
11170
|
+
discount(
|
|
11171
|
+
"RECEIVED",
|
|
11172
|
+
"The amount received at maturity for a fully invested security.",
|
|
11173
|
+
"RECEIVED(settlement, maturity, investment, discount, [basis])",
|
|
11174
|
+
(investment, rate, f) => investment / (1 - rate * f)
|
|
11175
|
+
),
|
|
11176
|
+
atMaturity(
|
|
11177
|
+
"PRICEMAT",
|
|
11178
|
+
"The price per 100 face value of a security that pays interest at maturity.",
|
|
11179
|
+
"PRICEMAT(settlement, maturity, issue, rate, yld, [basis])",
|
|
11180
|
+
(rate, yld, dim, a, dsm) => (100 + dim * rate * 100) / (1 + dsm * yld) - a * rate * 100
|
|
11181
|
+
),
|
|
11182
|
+
atMaturity(
|
|
11183
|
+
"YIELDMAT",
|
|
11184
|
+
"The annual yield of a security that pays interest at maturity.",
|
|
11185
|
+
"YIELDMAT(settlement, maturity, issue, rate, pr, [basis])",
|
|
11186
|
+
(rate, price, dim, a, dsm) => (1 + dim * rate - (price / 100 + a * rate)) / (price / 100 + a * rate) / dsm
|
|
11187
|
+
),
|
|
11188
|
+
spec(
|
|
11189
|
+
"TBILLPRICE",
|
|
11190
|
+
C11,
|
|
11191
|
+
"TBILLPRICE(settlement, maturity, discount)",
|
|
11192
|
+
"The price per 100 face value of a Treasury bill.",
|
|
11193
|
+
3,
|
|
11194
|
+
3,
|
|
11195
|
+
(args) => {
|
|
11196
|
+
const days = billDays(args);
|
|
11197
|
+
const rate = num2(args[2]);
|
|
11198
|
+
positive(rate);
|
|
11199
|
+
const price = 100 * (1 - rate * days / 360);
|
|
11200
|
+
return price > 0 ? price : fail(ERR.NUM);
|
|
11201
|
+
}
|
|
11202
|
+
),
|
|
11203
|
+
spec(
|
|
11204
|
+
"TBILLYIELD",
|
|
11205
|
+
C11,
|
|
11206
|
+
"TBILLYIELD(settlement, maturity, pr)",
|
|
11207
|
+
"The yield of a Treasury bill.",
|
|
11208
|
+
3,
|
|
11209
|
+
3,
|
|
11210
|
+
(args) => {
|
|
11211
|
+
const days = billDays(args);
|
|
11212
|
+
const price = num2(args[2]);
|
|
11213
|
+
positive(price);
|
|
11214
|
+
return (100 - price) / price * (360 / days);
|
|
11215
|
+
}
|
|
11216
|
+
),
|
|
11217
|
+
spec(
|
|
11218
|
+
"TBILLEQ",
|
|
11219
|
+
C11,
|
|
11220
|
+
"TBILLEQ(settlement, maturity, discount)",
|
|
11221
|
+
"The bond-equivalent yield of a Treasury bill.",
|
|
11222
|
+
3,
|
|
11223
|
+
3,
|
|
11224
|
+
(args) => {
|
|
11225
|
+
const days = billDays(args);
|
|
11226
|
+
const rate = num2(args[2]);
|
|
11227
|
+
positive(rate);
|
|
11228
|
+
if (days <= 182) return 365 * rate / (360 - rate * days);
|
|
11229
|
+
const price = 100 - rate * 100 * (days / 360);
|
|
11230
|
+
const t = days / 365;
|
|
11231
|
+
const root = Math.sqrt(t * t - (2 * t - 1) * (1 - 100 / price));
|
|
11232
|
+
return (-t + root) / (t - 0.5);
|
|
11233
|
+
}
|
|
11234
|
+
)
|
|
11235
|
+
];
|
|
11236
|
+
|
|
10839
11237
|
// src/xlsx/formula/functions/financial.ts
|
|
10840
|
-
var
|
|
11238
|
+
var C12 = "Financial";
|
|
10841
11239
|
var npv = (rate, values2) => values2.reduce((acc, v, i) => acc + v / Math.pow(1 + rate, i + 1), 0);
|
|
10842
11240
|
function datedFlows(ctx, args) {
|
|
10843
11241
|
const values2 = collectNumbers(ctx, [args[0] ?? null]);
|
|
@@ -10853,9 +11251,12 @@ var xnpv = (rate, values2, dates) => values2.reduce(
|
|
|
10853
11251
|
);
|
|
10854
11252
|
var FINANCIAL_FUNCTIONS = [
|
|
10855
11253
|
...DEPRECIATION_FUNCTIONS,
|
|
11254
|
+
...COUPON_FUNCTIONS,
|
|
11255
|
+
...BOND_FUNCTIONS,
|
|
11256
|
+
...SECURITY_FUNCTIONS,
|
|
10856
11257
|
numeric(
|
|
10857
11258
|
"PMT",
|
|
10858
|
-
|
|
11259
|
+
C12,
|
|
10859
11260
|
"PMT(rate, nper, pv, [fv], [type])",
|
|
10860
11261
|
"The payment for a loan.",
|
|
10861
11262
|
3,
|
|
@@ -10864,7 +11265,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10864
11265
|
),
|
|
10865
11266
|
numeric(
|
|
10866
11267
|
"FV",
|
|
10867
|
-
|
|
11268
|
+
C12,
|
|
10868
11269
|
"FV(rate, nper, pmt, [pv], [type])",
|
|
10869
11270
|
"The future value of an investment.",
|
|
10870
11271
|
3,
|
|
@@ -10873,7 +11274,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10873
11274
|
),
|
|
10874
11275
|
numeric(
|
|
10875
11276
|
"PV",
|
|
10876
|
-
|
|
11277
|
+
C12,
|
|
10877
11278
|
"PV(rate, nper, pmt, [fv], [type])",
|
|
10878
11279
|
"The present value of an investment.",
|
|
10879
11280
|
3,
|
|
@@ -10882,7 +11283,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10882
11283
|
),
|
|
10883
11284
|
numeric(
|
|
10884
11285
|
"NPER",
|
|
10885
|
-
|
|
11286
|
+
C12,
|
|
10886
11287
|
"NPER(rate, pmt, pv, [fv], [type])",
|
|
10887
11288
|
"The number of periods for an investment.",
|
|
10888
11289
|
3,
|
|
@@ -10899,7 +11300,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10899
11300
|
),
|
|
10900
11301
|
numeric(
|
|
10901
11302
|
"IPMT",
|
|
10902
|
-
|
|
11303
|
+
C12,
|
|
10903
11304
|
"IPMT(rate, per, nper, pv, [fv], [type])",
|
|
10904
11305
|
"The interest part of a payment.",
|
|
10905
11306
|
4,
|
|
@@ -10908,7 +11309,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10908
11309
|
),
|
|
10909
11310
|
numeric(
|
|
10910
11311
|
"PPMT",
|
|
10911
|
-
|
|
11312
|
+
C12,
|
|
10912
11313
|
"PPMT(rate, per, nper, pv, [fv], [type])",
|
|
10913
11314
|
"The principal part of a payment.",
|
|
10914
11315
|
4,
|
|
@@ -10917,7 +11318,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10917
11318
|
),
|
|
10918
11319
|
numeric(
|
|
10919
11320
|
"RATE",
|
|
10920
|
-
|
|
11321
|
+
C12,
|
|
10921
11322
|
"RATE(nper, pmt, pv, [fv], [type], [guess])",
|
|
10922
11323
|
"The interest rate per period.",
|
|
10923
11324
|
3,
|
|
@@ -10930,7 +11331,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10930
11331
|
),
|
|
10931
11332
|
spec(
|
|
10932
11333
|
"NPV",
|
|
10933
|
-
|
|
11334
|
+
C12,
|
|
10934
11335
|
"NPV(rate, value1, [value2], ...)",
|
|
10935
11336
|
"The net present value of cash flows.",
|
|
10936
11337
|
2,
|
|
@@ -10940,7 +11341,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10940
11341
|
),
|
|
10941
11342
|
spec(
|
|
10942
11343
|
"IRR",
|
|
10943
|
-
|
|
11344
|
+
C12,
|
|
10944
11345
|
"IRR(values, [guess])",
|
|
10945
11346
|
"The internal rate of return.",
|
|
10946
11347
|
1,
|
|
@@ -10957,7 +11358,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10957
11358
|
),
|
|
10958
11359
|
spec(
|
|
10959
11360
|
"XNPV",
|
|
10960
|
-
|
|
11361
|
+
C12,
|
|
10961
11362
|
"XNPV(rate, values, dates)",
|
|
10962
11363
|
"The net present value of dated cash flows.",
|
|
10963
11364
|
3,
|
|
@@ -10970,7 +11371,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10970
11371
|
),
|
|
10971
11372
|
spec(
|
|
10972
11373
|
"XIRR",
|
|
10973
|
-
|
|
11374
|
+
C12,
|
|
10974
11375
|
"XIRR(values, dates, [guess])",
|
|
10975
11376
|
"The internal rate of return of dated cash flows.",
|
|
10976
11377
|
2,
|
|
@@ -10984,7 +11385,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10984
11385
|
),
|
|
10985
11386
|
spec(
|
|
10986
11387
|
"MIRR",
|
|
10987
|
-
|
|
11388
|
+
C12,
|
|
10988
11389
|
"MIRR(values, finance_rate, reinvest_rate)",
|
|
10989
11390
|
"The modified internal rate of return.",
|
|
10990
11391
|
3,
|
|
@@ -10994,9 +11395,9 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
10994
11395
|
const finance = num2(args[1]);
|
|
10995
11396
|
const reinvest = num2(args[2]);
|
|
10996
11397
|
const n = values2.length;
|
|
10997
|
-
const
|
|
11398
|
+
const positive3 = values2.map((v) => v > 0 ? v : 0);
|
|
10998
11399
|
const negative = values2.map((v) => v < 0 ? v : 0);
|
|
10999
|
-
const fvPos =
|
|
11400
|
+
const fvPos = positive3.reduce((acc, v, i) => acc + v * Math.pow(1 + reinvest, n - 1 - i), 0);
|
|
11000
11401
|
const pvNeg = negative.reduce((acc, v, i) => acc + v / Math.pow(1 + finance, i), 0);
|
|
11001
11402
|
if (fvPos === 0 || pvNeg === 0) fail(ERR.DIV0);
|
|
11002
11403
|
return Math.pow(-fvPos / pvNeg, 1 / (n - 1)) - 1;
|
|
@@ -11012,7 +11413,7 @@ function sheetIndex(host, name) {
|
|
|
11012
11413
|
}
|
|
11013
11414
|
|
|
11014
11415
|
// src/xlsx/formula/functions/info.ts
|
|
11015
|
-
var
|
|
11416
|
+
var C13 = "Information";
|
|
11016
11417
|
var ERROR_NUMBERS = {
|
|
11017
11418
|
"#NULL!": 1,
|
|
11018
11419
|
"#DIV/0!": 2,
|
|
@@ -11025,7 +11426,7 @@ var ERROR_NUMBERS = {
|
|
|
11025
11426
|
"#SPILL!": 9,
|
|
11026
11427
|
"#CALC!": 14
|
|
11027
11428
|
};
|
|
11028
|
-
var is = (name, syntax, description, test) => spec(name,
|
|
11429
|
+
var is = (name, syntax, description, test) => spec(name, C13, syntax, description, 1, 1, (args) => test(scalar(args[0])));
|
|
11029
11430
|
var parity = (v, odd) => {
|
|
11030
11431
|
if (isError(v)) fail(v);
|
|
11031
11432
|
if (typeof v === "boolean") fail(ERR.VALUE);
|
|
@@ -11062,7 +11463,7 @@ var INFO_FUNCTIONS = [
|
|
|
11062
11463
|
is("ISODD", "ISODD(number)", "TRUE for odd numbers.", (v) => parity(v, true)),
|
|
11063
11464
|
spec(
|
|
11064
11465
|
"ISREF",
|
|
11065
|
-
|
|
11466
|
+
C13,
|
|
11066
11467
|
"ISREF(value)",
|
|
11067
11468
|
"TRUE for references.",
|
|
11068
11469
|
1,
|
|
@@ -11072,7 +11473,7 @@ var INFO_FUNCTIONS = [
|
|
|
11072
11473
|
),
|
|
11073
11474
|
spec(
|
|
11074
11475
|
"ISFORMULA",
|
|
11075
|
-
|
|
11476
|
+
C13,
|
|
11076
11477
|
"ISFORMULA(reference)",
|
|
11077
11478
|
"TRUE when a cell holds a formula.",
|
|
11078
11479
|
1,
|
|
@@ -11086,17 +11487,17 @@ var INFO_FUNCTIONS = [
|
|
|
11086
11487
|
},
|
|
11087
11488
|
["any"]
|
|
11088
11489
|
),
|
|
11089
|
-
spec("N",
|
|
11490
|
+
spec("N", C13, "N(value)", "A value converted to a number (text is 0).", 1, 1, (args) => {
|
|
11090
11491
|
const v = scalar(args[0]);
|
|
11091
11492
|
if (isError(v)) return v;
|
|
11092
11493
|
if (typeof v === "number") return v;
|
|
11093
11494
|
if (typeof v === "boolean") return v ? 1 : 0;
|
|
11094
11495
|
return 0;
|
|
11095
11496
|
}),
|
|
11096
|
-
spec("NA",
|
|
11497
|
+
spec("NA", C13, "NA()", "The #N/A error value.", 0, 0, () => ERR.NA),
|
|
11097
11498
|
spec(
|
|
11098
11499
|
"TYPE",
|
|
11099
|
-
|
|
11500
|
+
C13,
|
|
11100
11501
|
"TYPE(value)",
|
|
11101
11502
|
"The type of a value: 1 number, 2 text, 4 logical, 16 error, 64 array.",
|
|
11102
11503
|
1,
|
|
@@ -11108,13 +11509,13 @@ var INFO_FUNCTIONS = [
|
|
|
11108
11509
|
},
|
|
11109
11510
|
["any"]
|
|
11110
11511
|
),
|
|
11111
|
-
spec("ERROR.TYPE",
|
|
11512
|
+
spec("ERROR.TYPE", C13, "ERROR.TYPE(error_val)", "The number of an error value.", 1, 1, (args) => {
|
|
11112
11513
|
const v = scalar(args[0]);
|
|
11113
11514
|
return isError(v) ? ERROR_NUMBERS[v.error] ?? ERR.NA : ERR.NA;
|
|
11114
11515
|
}),
|
|
11115
11516
|
spec(
|
|
11116
11517
|
"SHEET",
|
|
11117
|
-
|
|
11518
|
+
C13,
|
|
11118
11519
|
"SHEET([value])",
|
|
11119
11520
|
"The sheet number of a reference or sheet name.",
|
|
11120
11521
|
0,
|
|
@@ -11130,7 +11531,7 @@ var INFO_FUNCTIONS = [
|
|
|
11130
11531
|
),
|
|
11131
11532
|
spec(
|
|
11132
11533
|
"SHEETS",
|
|
11133
|
-
|
|
11534
|
+
C13,
|
|
11134
11535
|
"SHEETS([reference])",
|
|
11135
11536
|
"The number of sheets in a reference (or the workbook).",
|
|
11136
11537
|
0,
|
|
@@ -11145,7 +11546,7 @@ var INFO_FUNCTIONS = [
|
|
|
11145
11546
|
),
|
|
11146
11547
|
spec(
|
|
11147
11548
|
"CELL",
|
|
11148
|
-
|
|
11549
|
+
C13,
|
|
11149
11550
|
"CELL(info_type, [reference])",
|
|
11150
11551
|
"Information about a cell (address, row, col, contents, type, filename, sheet).",
|
|
11151
11552
|
1,
|
|
@@ -11231,7 +11632,7 @@ function broadcastShape(operands, at) {
|
|
|
11231
11632
|
}
|
|
11232
11633
|
|
|
11233
11634
|
// src/xlsx/formula/functions/lambda.ts
|
|
11234
|
-
var
|
|
11635
|
+
var C14 = "Logical";
|
|
11235
11636
|
function lambdaArg(value) {
|
|
11236
11637
|
if (!(value instanceof LambdaValue)) fail(ERR.VALUE);
|
|
11237
11638
|
return value;
|
|
@@ -11248,7 +11649,7 @@ function element(ctx, value) {
|
|
|
11248
11649
|
var LAMBDA_HELPERS = [
|
|
11249
11650
|
spec(
|
|
11250
11651
|
"MAP",
|
|
11251
|
-
|
|
11652
|
+
C14,
|
|
11252
11653
|
"MAP(array1, ..., lambda)",
|
|
11253
11654
|
"Applies a LAMBDA to each value of arrays.",
|
|
11254
11655
|
2,
|
|
@@ -11274,7 +11675,7 @@ var LAMBDA_HELPERS = [
|
|
|
11274
11675
|
),
|
|
11275
11676
|
spec(
|
|
11276
11677
|
"REDUCE",
|
|
11277
|
-
|
|
11678
|
+
C14,
|
|
11278
11679
|
"REDUCE([initial_value], array, lambda)",
|
|
11279
11680
|
"Reduces an array to an accumulated value.",
|
|
11280
11681
|
2,
|
|
@@ -11290,7 +11691,7 @@ var LAMBDA_HELPERS = [
|
|
|
11290
11691
|
),
|
|
11291
11692
|
spec(
|
|
11292
11693
|
"SCAN",
|
|
11293
|
-
|
|
11694
|
+
C14,
|
|
11294
11695
|
"SCAN([initial_value], array, lambda)",
|
|
11295
11696
|
"The intermediate values of a reduction, as an array.",
|
|
11296
11697
|
2,
|
|
@@ -11308,7 +11709,7 @@ var LAMBDA_HELPERS = [
|
|
|
11308
11709
|
),
|
|
11309
11710
|
spec(
|
|
11310
11711
|
"BYROW",
|
|
11311
|
-
|
|
11712
|
+
C14,
|
|
11312
11713
|
"BYROW(array, lambda)",
|
|
11313
11714
|
"Applies a LAMBDA to each row, returning a column.",
|
|
11314
11715
|
2,
|
|
@@ -11324,7 +11725,7 @@ var LAMBDA_HELPERS = [
|
|
|
11324
11725
|
),
|
|
11325
11726
|
spec(
|
|
11326
11727
|
"BYCOL",
|
|
11327
|
-
|
|
11728
|
+
C14,
|
|
11328
11729
|
"BYCOL(array, lambda)",
|
|
11329
11730
|
"Applies a LAMBDA to each column, returning a row.",
|
|
11330
11731
|
2,
|
|
@@ -11343,7 +11744,7 @@ var LAMBDA_HELPERS = [
|
|
|
11343
11744
|
),
|
|
11344
11745
|
spec(
|
|
11345
11746
|
"MAKEARRAY",
|
|
11346
|
-
|
|
11747
|
+
C14,
|
|
11347
11748
|
"MAKEARRAY(rows, columns, lambda)",
|
|
11348
11749
|
"An array built by calling a LAMBDA for each position.",
|
|
11349
11750
|
3,
|
|
@@ -11360,7 +11761,7 @@ var LAMBDA_HELPERS = [
|
|
|
11360
11761
|
];
|
|
11361
11762
|
|
|
11362
11763
|
// src/xlsx/formula/functions/logical.ts
|
|
11363
|
-
var
|
|
11764
|
+
var C15 = "Logical";
|
|
11364
11765
|
function deref(ctx, value) {
|
|
11365
11766
|
if (value instanceof RefValue) {
|
|
11366
11767
|
if (value.isCell()) {
|
|
@@ -11430,7 +11831,7 @@ function logicalValues(ctx, args) {
|
|
|
11430
11831
|
if (out.length === 0) fail(ERR.VALUE);
|
|
11431
11832
|
return out;
|
|
11432
11833
|
}
|
|
11433
|
-
var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category =
|
|
11834
|
+
var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category = C15) => ({ name, category, syntax, description, minArgs, maxArgs, lazy });
|
|
11434
11835
|
function localName(arg) {
|
|
11435
11836
|
const node = arg?.node;
|
|
11436
11837
|
if (!node || node.type !== "name" || node.prefix) fail(ERR.VALUE);
|
|
@@ -11524,7 +11925,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
11524
11925
|
),
|
|
11525
11926
|
{
|
|
11526
11927
|
name: "NOT",
|
|
11527
|
-
category:
|
|
11928
|
+
category: C15,
|
|
11528
11929
|
syntax: "NOT(logical)",
|
|
11529
11930
|
description: "Reverses a logical value.",
|
|
11530
11931
|
minArgs: 1,
|
|
@@ -11533,7 +11934,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
11533
11934
|
},
|
|
11534
11935
|
{
|
|
11535
11936
|
name: "TRUE",
|
|
11536
|
-
category:
|
|
11937
|
+
category: C15,
|
|
11537
11938
|
syntax: "TRUE()",
|
|
11538
11939
|
description: "The logical value TRUE.",
|
|
11539
11940
|
minArgs: 0,
|
|
@@ -11542,7 +11943,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
11542
11943
|
},
|
|
11543
11944
|
{
|
|
11544
11945
|
name: "FALSE",
|
|
11545
|
-
category:
|
|
11946
|
+
category: C15,
|
|
11546
11947
|
syntax: "FALSE()",
|
|
11547
11948
|
description: "The logical value FALSE.",
|
|
11548
11949
|
minArgs: 0,
|
|
@@ -11740,7 +12141,7 @@ function xsearch(vector, lookup2, matchMode, searchMode) {
|
|
|
11740
12141
|
}
|
|
11741
12142
|
|
|
11742
12143
|
// src/xlsx/formula/functions/reference.ts
|
|
11743
|
-
var
|
|
12144
|
+
var C16 = "Lookup & Reference";
|
|
11744
12145
|
function refArg(value) {
|
|
11745
12146
|
if (value instanceof RefValue) return value;
|
|
11746
12147
|
if (isError(value)) fail(value);
|
|
@@ -11829,7 +12230,7 @@ function rowsOrCols(value, ctx, axis) {
|
|
|
11829
12230
|
var REFERENCE_FUNCTIONS = [
|
|
11830
12231
|
spec(
|
|
11831
12232
|
"OFFSET",
|
|
11832
|
-
|
|
12233
|
+
C16,
|
|
11833
12234
|
"OFFSET(reference, rows, cols, [height], [width])",
|
|
11834
12235
|
"A reference offset from a starting reference.",
|
|
11835
12236
|
3,
|
|
@@ -11840,7 +12241,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11840
12241
|
),
|
|
11841
12242
|
spec(
|
|
11842
12243
|
"INDIRECT",
|
|
11843
|
-
|
|
12244
|
+
C16,
|
|
11844
12245
|
"INDIRECT(ref_text, [a1])",
|
|
11845
12246
|
"The reference named by a text.",
|
|
11846
12247
|
1,
|
|
@@ -11856,7 +12257,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11856
12257
|
),
|
|
11857
12258
|
spec(
|
|
11858
12259
|
"ROW",
|
|
11859
|
-
|
|
12260
|
+
C16,
|
|
11860
12261
|
"ROW([reference])",
|
|
11861
12262
|
"The row number of a reference.",
|
|
11862
12263
|
0,
|
|
@@ -11866,7 +12267,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11866
12267
|
),
|
|
11867
12268
|
spec(
|
|
11868
12269
|
"COLUMN",
|
|
11869
|
-
|
|
12270
|
+
C16,
|
|
11870
12271
|
"COLUMN([reference])",
|
|
11871
12272
|
"The column number of a reference.",
|
|
11872
12273
|
0,
|
|
@@ -11876,7 +12277,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11876
12277
|
),
|
|
11877
12278
|
spec(
|
|
11878
12279
|
"ROWS",
|
|
11879
|
-
|
|
12280
|
+
C16,
|
|
11880
12281
|
"ROWS(array)",
|
|
11881
12282
|
"The number of rows in a reference or array.",
|
|
11882
12283
|
1,
|
|
@@ -11889,7 +12290,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11889
12290
|
),
|
|
11890
12291
|
spec(
|
|
11891
12292
|
"COLUMNS",
|
|
11892
|
-
|
|
12293
|
+
C16,
|
|
11893
12294
|
"COLUMNS(array)",
|
|
11894
12295
|
"The number of columns in a reference or array.",
|
|
11895
12296
|
1,
|
|
@@ -11902,7 +12303,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11902
12303
|
),
|
|
11903
12304
|
spec(
|
|
11904
12305
|
"AREAS",
|
|
11905
|
-
|
|
12306
|
+
C16,
|
|
11906
12307
|
"AREAS(reference)",
|
|
11907
12308
|
"The number of areas in a reference.",
|
|
11908
12309
|
1,
|
|
@@ -11912,7 +12313,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11912
12313
|
),
|
|
11913
12314
|
spec(
|
|
11914
12315
|
"ADDRESS",
|
|
11915
|
-
|
|
12316
|
+
C16,
|
|
11916
12317
|
"ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])",
|
|
11917
12318
|
"A cell address as text.",
|
|
11918
12319
|
2,
|
|
@@ -11921,7 +12322,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11921
12322
|
),
|
|
11922
12323
|
spec(
|
|
11923
12324
|
"HYPERLINK",
|
|
11924
|
-
|
|
12325
|
+
C16,
|
|
11925
12326
|
"HYPERLINK(link_location, [friendly_name])",
|
|
11926
12327
|
"A link; the cell shows the friendly name.",
|
|
11927
12328
|
1,
|
|
@@ -11930,7 +12331,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11930
12331
|
),
|
|
11931
12332
|
spec(
|
|
11932
12333
|
"ANCHORARRAY",
|
|
11933
|
-
|
|
12334
|
+
C16,
|
|
11934
12335
|
"ANCHORARRAY(reference)",
|
|
11935
12336
|
"The spill range of a dynamic array formula (A1#).",
|
|
11936
12337
|
1,
|
|
@@ -11950,7 +12351,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11950
12351
|
),
|
|
11951
12352
|
spec(
|
|
11952
12353
|
"SINGLE",
|
|
11953
|
-
|
|
12354
|
+
C16,
|
|
11954
12355
|
"SINGLE(value)",
|
|
11955
12356
|
"Implicit intersection (the @ operator).",
|
|
11956
12357
|
1,
|
|
@@ -11960,7 +12361,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11960
12361
|
),
|
|
11961
12362
|
spec(
|
|
11962
12363
|
"FORMULATEXT",
|
|
11963
|
-
|
|
12364
|
+
C16,
|
|
11964
12365
|
"FORMULATEXT(reference)",
|
|
11965
12366
|
"The formula of a cell as text.",
|
|
11966
12367
|
1,
|
|
@@ -11980,7 +12381,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
11980
12381
|
];
|
|
11981
12382
|
|
|
11982
12383
|
// src/xlsx/formula/functions/lookup.ts
|
|
11983
|
-
var
|
|
12384
|
+
var C17 = "Lookup & Reference";
|
|
11984
12385
|
function cellOf(value, row2, col) {
|
|
11985
12386
|
if (value instanceof RefValue) {
|
|
11986
12387
|
const area = value.areas[0];
|
|
@@ -12107,7 +12508,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
12107
12508
|
...REFERENCE_FUNCTIONS,
|
|
12108
12509
|
spec(
|
|
12109
12510
|
"VLOOKUP",
|
|
12110
|
-
|
|
12511
|
+
C17,
|
|
12111
12512
|
"VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])",
|
|
12112
12513
|
"Looks up a value in the first column of a table.",
|
|
12113
12514
|
3,
|
|
@@ -12117,7 +12518,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
12117
12518
|
),
|
|
12118
12519
|
spec(
|
|
12119
12520
|
"HLOOKUP",
|
|
12120
|
-
|
|
12521
|
+
C17,
|
|
12121
12522
|
"HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])",
|
|
12122
12523
|
"Looks up a value in the first row of a table.",
|
|
12123
12524
|
3,
|
|
@@ -12127,7 +12528,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
12127
12528
|
),
|
|
12128
12529
|
spec(
|
|
12129
12530
|
"LOOKUP",
|
|
12130
|
-
|
|
12531
|
+
C17,
|
|
12131
12532
|
"LOOKUP(lookup_value, lookup_vector, [result_vector])",
|
|
12132
12533
|
"Looks up a value in a sorted vector or array.",
|
|
12133
12534
|
2,
|
|
@@ -12137,7 +12538,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
12137
12538
|
),
|
|
12138
12539
|
spec(
|
|
12139
12540
|
"MATCH",
|
|
12140
|
-
|
|
12541
|
+
C17,
|
|
12141
12542
|
"MATCH(lookup_value, lookup_array, [match_type])",
|
|
12142
12543
|
"The position of a value in a range.",
|
|
12143
12544
|
2,
|
|
@@ -12147,7 +12548,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
12147
12548
|
),
|
|
12148
12549
|
spec(
|
|
12149
12550
|
"XMATCH",
|
|
12150
|
-
|
|
12551
|
+
C17,
|
|
12151
12552
|
"XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])",
|
|
12152
12553
|
"The position of a value with flexible matching.",
|
|
12153
12554
|
2,
|
|
@@ -12167,7 +12568,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
12167
12568
|
),
|
|
12168
12569
|
spec(
|
|
12169
12570
|
"XLOOKUP",
|
|
12170
|
-
|
|
12571
|
+
C17,
|
|
12171
12572
|
"XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])",
|
|
12172
12573
|
"Searches a range and returns the matching item from another.",
|
|
12173
12574
|
3,
|
|
@@ -12177,7 +12578,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
12177
12578
|
),
|
|
12178
12579
|
spec(
|
|
12179
12580
|
"INDEX",
|
|
12180
|
-
|
|
12581
|
+
C17,
|
|
12181
12582
|
"INDEX(array, row_num, [column_num], [area_num])",
|
|
12182
12583
|
"The value or reference at a position.",
|
|
12183
12584
|
1,
|
|
@@ -12187,7 +12588,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
12187
12588
|
),
|
|
12188
12589
|
spec(
|
|
12189
12590
|
"CHOOSE",
|
|
12190
|
-
|
|
12591
|
+
C17,
|
|
12191
12592
|
"CHOOSE(index_num, value1, [value2], ...)",
|
|
12192
12593
|
"Chooses a value from a list by index.",
|
|
12193
12594
|
2,
|
|
@@ -12391,7 +12792,7 @@ function liftCriteria(ctx, pairs, fn) {
|
|
|
12391
12792
|
}
|
|
12392
12793
|
|
|
12393
12794
|
// src/xlsx/formula/functions/math-sum.ts
|
|
12394
|
-
var
|
|
12795
|
+
var C18 = "Math & Trig";
|
|
12395
12796
|
var numbersOf = (values2) => values2.filter((v) => typeof v === "number");
|
|
12396
12797
|
function sumProduct(ctx, args) {
|
|
12397
12798
|
const matrices = args.map((a) => ctx.toMatrix(a));
|
|
@@ -12496,7 +12897,7 @@ function aggregate(code, values2, k) {
|
|
|
12496
12897
|
var SUM_FUNCTIONS = [
|
|
12497
12898
|
spec(
|
|
12498
12899
|
"SUM",
|
|
12499
|
-
|
|
12900
|
+
C18,
|
|
12500
12901
|
"SUM(number1, [number2], ...)",
|
|
12501
12902
|
"Adds its arguments.",
|
|
12502
12903
|
0,
|
|
@@ -12506,7 +12907,7 @@ var SUM_FUNCTIONS = [
|
|
|
12506
12907
|
),
|
|
12507
12908
|
spec(
|
|
12508
12909
|
"PRODUCT",
|
|
12509
|
-
|
|
12910
|
+
C18,
|
|
12510
12911
|
"PRODUCT(number1, [number2], ...)",
|
|
12511
12912
|
"Multiplies its arguments.",
|
|
12512
12913
|
1,
|
|
@@ -12519,7 +12920,7 @@ var SUM_FUNCTIONS = [
|
|
|
12519
12920
|
),
|
|
12520
12921
|
spec(
|
|
12521
12922
|
"SUMSQ",
|
|
12522
|
-
|
|
12923
|
+
C18,
|
|
12523
12924
|
"SUMSQ(number1, [number2], ...)",
|
|
12524
12925
|
"The sum of the squares of the arguments.",
|
|
12525
12926
|
1,
|
|
@@ -12529,7 +12930,7 @@ var SUM_FUNCTIONS = [
|
|
|
12529
12930
|
),
|
|
12530
12931
|
spec(
|
|
12531
12932
|
"SUMPRODUCT",
|
|
12532
|
-
|
|
12933
|
+
C18,
|
|
12533
12934
|
"SUMPRODUCT(array1, [array2], ...)",
|
|
12534
12935
|
"The sum of the products of corresponding array elements.",
|
|
12535
12936
|
1,
|
|
@@ -12539,7 +12940,7 @@ var SUM_FUNCTIONS = [
|
|
|
12539
12940
|
),
|
|
12540
12941
|
spec(
|
|
12541
12942
|
"SUMX2MY2",
|
|
12542
|
-
|
|
12943
|
+
C18,
|
|
12543
12944
|
"SUMX2MY2(array_x, array_y)",
|
|
12544
12945
|
"Sum of the differences of squares.",
|
|
12545
12946
|
2,
|
|
@@ -12549,7 +12950,7 @@ var SUM_FUNCTIONS = [
|
|
|
12549
12950
|
),
|
|
12550
12951
|
spec(
|
|
12551
12952
|
"SUMX2PY2",
|
|
12552
|
-
|
|
12953
|
+
C18,
|
|
12553
12954
|
"SUMX2PY2(array_x, array_y)",
|
|
12554
12955
|
"Sum of the sums of squares.",
|
|
12555
12956
|
2,
|
|
@@ -12559,7 +12960,7 @@ var SUM_FUNCTIONS = [
|
|
|
12559
12960
|
),
|
|
12560
12961
|
spec(
|
|
12561
12962
|
"SUMXMY2",
|
|
12562
|
-
|
|
12963
|
+
C18,
|
|
12563
12964
|
"SUMXMY2(array_x, array_y)",
|
|
12564
12965
|
"Sum of the squares of differences.",
|
|
12565
12966
|
2,
|
|
@@ -12569,7 +12970,7 @@ var SUM_FUNCTIONS = [
|
|
|
12569
12970
|
),
|
|
12570
12971
|
spec(
|
|
12571
12972
|
"SUMIF",
|
|
12572
|
-
|
|
12973
|
+
C18,
|
|
12573
12974
|
"SUMIF(range, criteria, [sum_range])",
|
|
12574
12975
|
"Adds the cells that meet a criterion.",
|
|
12575
12976
|
2,
|
|
@@ -12582,7 +12983,7 @@ var SUM_FUNCTIONS = [
|
|
|
12582
12983
|
),
|
|
12583
12984
|
spec(
|
|
12584
12985
|
"SUMIFS",
|
|
12585
|
-
|
|
12986
|
+
C18,
|
|
12586
12987
|
"SUMIFS(sum_range, criteria_range1, criteria1, ...)",
|
|
12587
12988
|
"Adds the cells that meet several criteria.",
|
|
12588
12989
|
3,
|
|
@@ -12596,7 +12997,7 @@ var SUM_FUNCTIONS = [
|
|
|
12596
12997
|
),
|
|
12597
12998
|
spec(
|
|
12598
12999
|
"SUBTOTAL",
|
|
12599
|
-
|
|
13000
|
+
C18,
|
|
12600
13001
|
"SUBTOTAL(function_num, ref1, ...)",
|
|
12601
13002
|
"A subtotal (1-11 include hidden rows, 101-111 ignore them).",
|
|
12602
13003
|
2,
|
|
@@ -12611,7 +13012,7 @@ var SUM_FUNCTIONS = [
|
|
|
12611
13012
|
),
|
|
12612
13013
|
spec(
|
|
12613
13014
|
"AGGREGATE",
|
|
12614
|
-
|
|
13015
|
+
C18,
|
|
12615
13016
|
"AGGREGATE(function_num, options, ref1, ...)",
|
|
12616
13017
|
"An aggregate that can ignore hidden rows and errors.",
|
|
12617
13018
|
3,
|
|
@@ -12651,14 +13052,14 @@ var SUM_FUNCTIONS = [
|
|
|
12651
13052
|
];
|
|
12652
13053
|
|
|
12653
13054
|
// src/xlsx/formula/functions/math-more.ts
|
|
12654
|
-
var
|
|
13055
|
+
var C19 = "Math & Trig";
|
|
12655
13056
|
var MATH_MORE = [
|
|
12656
|
-
numeric("SIN",
|
|
12657
|
-
numeric("COS",
|
|
12658
|
-
numeric("TAN",
|
|
13057
|
+
numeric("SIN", C19, "SIN(number)", "The sine of an angle in radians.", 1, 1, Math.sin),
|
|
13058
|
+
numeric("COS", C19, "COS(number)", "The cosine of an angle in radians.", 1, 1, Math.cos),
|
|
13059
|
+
numeric("TAN", C19, "TAN(number)", "The tangent of an angle in radians.", 1, 1, Math.tan),
|
|
12659
13060
|
numeric(
|
|
12660
13061
|
"ASIN",
|
|
12661
|
-
|
|
13062
|
+
C19,
|
|
12662
13063
|
"ASIN(number)",
|
|
12663
13064
|
"The arcsine in radians.",
|
|
12664
13065
|
1,
|
|
@@ -12667,17 +13068,17 @@ var MATH_MORE = [
|
|
|
12667
13068
|
),
|
|
12668
13069
|
numeric(
|
|
12669
13070
|
"ACOS",
|
|
12670
|
-
|
|
13071
|
+
C19,
|
|
12671
13072
|
"ACOS(number)",
|
|
12672
13073
|
"The arccosine in radians.",
|
|
12673
13074
|
1,
|
|
12674
13075
|
1,
|
|
12675
13076
|
(x) => domain(Math.abs(x) <= 1, Math.acos(x))
|
|
12676
13077
|
),
|
|
12677
|
-
numeric("ATAN",
|
|
13078
|
+
numeric("ATAN", C19, "ATAN(number)", "The arctangent in radians.", 1, 1, Math.atan),
|
|
12678
13079
|
numeric(
|
|
12679
13080
|
"ATAN2",
|
|
12680
|
-
|
|
13081
|
+
C19,
|
|
12681
13082
|
"ATAN2(x_num, y_num)",
|
|
12682
13083
|
"The arctangent of x and y coordinates.",
|
|
12683
13084
|
2,
|
|
@@ -12687,13 +13088,13 @@ var MATH_MORE = [
|
|
|
12687
13088
|
return Math.atan2(y ?? 0, x);
|
|
12688
13089
|
}
|
|
12689
13090
|
),
|
|
12690
|
-
numeric("SINH",
|
|
12691
|
-
numeric("COSH",
|
|
12692
|
-
numeric("TANH",
|
|
12693
|
-
numeric("ASINH",
|
|
13091
|
+
numeric("SINH", C19, "SINH(number)", "The hyperbolic sine.", 1, 1, Math.sinh),
|
|
13092
|
+
numeric("COSH", C19, "COSH(number)", "The hyperbolic cosine.", 1, 1, Math.cosh),
|
|
13093
|
+
numeric("TANH", C19, "TANH(number)", "The hyperbolic tangent.", 1, 1, Math.tanh),
|
|
13094
|
+
numeric("ASINH", C19, "ASINH(number)", "The inverse hyperbolic sine.", 1, 1, Math.asinh),
|
|
12694
13095
|
numeric(
|
|
12695
13096
|
"ACOSH",
|
|
12696
|
-
|
|
13097
|
+
C19,
|
|
12697
13098
|
"ACOSH(number)",
|
|
12698
13099
|
"The inverse hyperbolic cosine.",
|
|
12699
13100
|
1,
|
|
@@ -12702,7 +13103,7 @@ var MATH_MORE = [
|
|
|
12702
13103
|
),
|
|
12703
13104
|
numeric(
|
|
12704
13105
|
"ATANH",
|
|
12705
|
-
|
|
13106
|
+
C19,
|
|
12706
13107
|
"ATANH(number)",
|
|
12707
13108
|
"The inverse hyperbolic tangent.",
|
|
12708
13109
|
1,
|
|
@@ -12711,7 +13112,7 @@ var MATH_MORE = [
|
|
|
12711
13112
|
),
|
|
12712
13113
|
numeric(
|
|
12713
13114
|
"COT",
|
|
12714
|
-
|
|
13115
|
+
C19,
|
|
12715
13116
|
"COT(number)",
|
|
12716
13117
|
"The cotangent of an angle.",
|
|
12717
13118
|
1,
|
|
@@ -12720,7 +13121,7 @@ var MATH_MORE = [
|
|
|
12720
13121
|
),
|
|
12721
13122
|
numeric(
|
|
12722
13123
|
"COTH",
|
|
12723
|
-
|
|
13124
|
+
C19,
|
|
12724
13125
|
"COTH(number)",
|
|
12725
13126
|
"The hyperbolic cotangent.",
|
|
12726
13127
|
1,
|
|
@@ -12729,7 +13130,7 @@ var MATH_MORE = [
|
|
|
12729
13130
|
),
|
|
12730
13131
|
numeric(
|
|
12731
13132
|
"CSC",
|
|
12732
|
-
|
|
13133
|
+
C19,
|
|
12733
13134
|
"CSC(number)",
|
|
12734
13135
|
"The cosecant of an angle.",
|
|
12735
13136
|
1,
|
|
@@ -12738,19 +13139,19 @@ var MATH_MORE = [
|
|
|
12738
13139
|
),
|
|
12739
13140
|
numeric(
|
|
12740
13141
|
"CSCH",
|
|
12741
|
-
|
|
13142
|
+
C19,
|
|
12742
13143
|
"CSCH(number)",
|
|
12743
13144
|
"The hyperbolic cosecant.",
|
|
12744
13145
|
1,
|
|
12745
13146
|
1,
|
|
12746
13147
|
(x) => x === 0 ? fail(ERR.DIV0) : 1 / Math.sinh(x)
|
|
12747
13148
|
),
|
|
12748
|
-
numeric("SEC",
|
|
12749
|
-
numeric("SECH",
|
|
12750
|
-
numeric("ACOT",
|
|
13149
|
+
numeric("SEC", C19, "SEC(number)", "The secant of an angle.", 1, 1, (x) => 1 / Math.cos(x)),
|
|
13150
|
+
numeric("SECH", C19, "SECH(number)", "The hyperbolic secant.", 1, 1, (x) => 1 / Math.cosh(x)),
|
|
13151
|
+
numeric("ACOT", C19, "ACOT(number)", "The arccotangent.", 1, 1, (x) => Math.PI / 2 - Math.atan(x)),
|
|
12751
13152
|
numeric(
|
|
12752
13153
|
"ACOTH",
|
|
12753
|
-
|
|
13154
|
+
C19,
|
|
12754
13155
|
"ACOTH(number)",
|
|
12755
13156
|
"The inverse hyperbolic cotangent.",
|
|
12756
13157
|
1,
|
|
@@ -12759,7 +13160,7 @@ var MATH_MORE = [
|
|
|
12759
13160
|
),
|
|
12760
13161
|
numeric(
|
|
12761
13162
|
"DEGREES",
|
|
12762
|
-
|
|
13163
|
+
C19,
|
|
12763
13164
|
"DEGREES(angle)",
|
|
12764
13165
|
"Converts radians to degrees.",
|
|
12765
13166
|
1,
|
|
@@ -12768,7 +13169,7 @@ var MATH_MORE = [
|
|
|
12768
13169
|
),
|
|
12769
13170
|
numeric(
|
|
12770
13171
|
"RADIANS",
|
|
12771
|
-
|
|
13172
|
+
C19,
|
|
12772
13173
|
"RADIANS(angle)",
|
|
12773
13174
|
"Converts degrees to radians.",
|
|
12774
13175
|
1,
|
|
@@ -12777,7 +13178,7 @@ var MATH_MORE = [
|
|
|
12777
13178
|
),
|
|
12778
13179
|
spec(
|
|
12779
13180
|
"RAND",
|
|
12780
|
-
|
|
13181
|
+
C19,
|
|
12781
13182
|
"RAND()",
|
|
12782
13183
|
"A random number between 0 and 1.",
|
|
12783
13184
|
0,
|
|
@@ -12788,7 +13189,7 @@ var MATH_MORE = [
|
|
|
12788
13189
|
),
|
|
12789
13190
|
spec(
|
|
12790
13191
|
"RANDBETWEEN",
|
|
12791
|
-
|
|
13192
|
+
C19,
|
|
12792
13193
|
"RANDBETWEEN(bottom, top)",
|
|
12793
13194
|
"A random integer between two numbers.",
|
|
12794
13195
|
2,
|
|
@@ -12804,7 +13205,7 @@ var MATH_MORE = [
|
|
|
12804
13205
|
),
|
|
12805
13206
|
spec(
|
|
12806
13207
|
"SERIESSUM",
|
|
12807
|
-
|
|
13208
|
+
C19,
|
|
12808
13209
|
"SERIESSUM(x, n, m, coefficients)",
|
|
12809
13210
|
"The sum of a power series.",
|
|
12810
13211
|
4,
|
|
@@ -12823,7 +13224,7 @@ var MATH_MORE = [
|
|
|
12823
13224
|
];
|
|
12824
13225
|
|
|
12825
13226
|
// src/xlsx/formula/functions/math-combin.ts
|
|
12826
|
-
var
|
|
13227
|
+
var C20 = "Math & Trig";
|
|
12827
13228
|
var fact = (n) => {
|
|
12828
13229
|
if (n < 0) fail(ERR.NUM);
|
|
12829
13230
|
let out = 1;
|
|
@@ -12847,8 +13248,8 @@ function integers(args, ctx) {
|
|
|
12847
13248
|
});
|
|
12848
13249
|
}
|
|
12849
13250
|
var COMBINATORIC_FUNCTIONS = [
|
|
12850
|
-
numeric("FACT",
|
|
12851
|
-
numeric("FACTDOUBLE",
|
|
13251
|
+
numeric("FACT", C20, "FACT(number)", "The factorial of a number.", 1, 1, fact),
|
|
13252
|
+
numeric("FACTDOUBLE", C20, "FACTDOUBLE(number)", "The double factorial of a number.", 1, 1, (n) => {
|
|
12852
13253
|
if (n < -1) fail(ERR.NUM);
|
|
12853
13254
|
let out = 1;
|
|
12854
13255
|
for (let i = Math.trunc(n); i > 1; i -= 2) out *= i;
|
|
@@ -12856,7 +13257,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
12856
13257
|
}),
|
|
12857
13258
|
numeric(
|
|
12858
13259
|
"COMBIN",
|
|
12859
|
-
|
|
13260
|
+
C20,
|
|
12860
13261
|
"COMBIN(number, number_chosen)",
|
|
12861
13262
|
"The number of combinations.",
|
|
12862
13263
|
2,
|
|
@@ -12865,7 +13266,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
12865
13266
|
),
|
|
12866
13267
|
numeric(
|
|
12867
13268
|
"COMBINA",
|
|
12868
|
-
|
|
13269
|
+
C20,
|
|
12869
13270
|
"COMBINA(number, number_chosen)",
|
|
12870
13271
|
"Combinations with repetitions.",
|
|
12871
13272
|
2,
|
|
@@ -12877,7 +13278,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
12877
13278
|
),
|
|
12878
13279
|
spec(
|
|
12879
13280
|
"MULTINOMIAL",
|
|
12880
|
-
|
|
13281
|
+
C20,
|
|
12881
13282
|
"MULTINOMIAL(number1, ...)",
|
|
12882
13283
|
"The multinomial of a set of numbers.",
|
|
12883
13284
|
1,
|
|
@@ -12891,7 +13292,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
12891
13292
|
),
|
|
12892
13293
|
spec(
|
|
12893
13294
|
"GCD",
|
|
12894
|
-
|
|
13295
|
+
C20,
|
|
12895
13296
|
"GCD(number1, ...)",
|
|
12896
13297
|
"The greatest common divisor.",
|
|
12897
13298
|
1,
|
|
@@ -12901,7 +13302,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
12901
13302
|
),
|
|
12902
13303
|
spec(
|
|
12903
13304
|
"LCM",
|
|
12904
|
-
|
|
13305
|
+
C20,
|
|
12905
13306
|
"LCM(number1, ...)",
|
|
12906
13307
|
"The least common multiple.",
|
|
12907
13308
|
1,
|
|
@@ -12949,7 +13350,7 @@ function mround(x, m) {
|
|
|
12949
13350
|
}
|
|
12950
13351
|
|
|
12951
13352
|
// src/xlsx/formula/functions/math.ts
|
|
12952
|
-
var
|
|
13353
|
+
var C21 = "Math & Trig";
|
|
12953
13354
|
function roundTo(x, digits2, mode) {
|
|
12954
13355
|
if (!Number.isFinite(x)) return x;
|
|
12955
13356
|
const d = Math.trunc(digits2);
|
|
@@ -12968,10 +13369,10 @@ var quotientMultiple = (x, sig, op) => {
|
|
|
12968
13369
|
var MATH_FUNCTIONS = [
|
|
12969
13370
|
...MATH_MORE,
|
|
12970
13371
|
...SUM_FUNCTIONS,
|
|
12971
|
-
numeric("ABS",
|
|
13372
|
+
numeric("ABS", C21, "ABS(number)", "The absolute value of a number.", 1, 1, Math.abs),
|
|
12972
13373
|
numeric(
|
|
12973
13374
|
"SIGN",
|
|
12974
|
-
|
|
13375
|
+
C21,
|
|
12975
13376
|
"SIGN(number)",
|
|
12976
13377
|
"The sign of a number: 1, 0 or -1.",
|
|
12977
13378
|
1,
|
|
@@ -12980,7 +13381,7 @@ var MATH_FUNCTIONS = [
|
|
|
12980
13381
|
),
|
|
12981
13382
|
numeric(
|
|
12982
13383
|
"INT",
|
|
12983
|
-
|
|
13384
|
+
C21,
|
|
12984
13385
|
"INT(number)",
|
|
12985
13386
|
"Rounds a number down to the nearest integer.",
|
|
12986
13387
|
1,
|
|
@@ -12989,7 +13390,7 @@ var MATH_FUNCTIONS = [
|
|
|
12989
13390
|
),
|
|
12990
13391
|
numeric(
|
|
12991
13392
|
"TRUNC",
|
|
12992
|
-
|
|
13393
|
+
C21,
|
|
12993
13394
|
"TRUNC(number, [num_digits])",
|
|
12994
13395
|
"Truncates a number toward zero.",
|
|
12995
13396
|
1,
|
|
@@ -12998,7 +13399,7 @@ var MATH_FUNCTIONS = [
|
|
|
12998
13399
|
),
|
|
12999
13400
|
numeric(
|
|
13000
13401
|
"ROUND",
|
|
13001
|
-
|
|
13402
|
+
C21,
|
|
13002
13403
|
"ROUND(number, num_digits)",
|
|
13003
13404
|
"Rounds a number to a number of digits.",
|
|
13004
13405
|
2,
|
|
@@ -13007,7 +13408,7 @@ var MATH_FUNCTIONS = [
|
|
|
13007
13408
|
),
|
|
13008
13409
|
numeric(
|
|
13009
13410
|
"ROUNDUP",
|
|
13010
|
-
|
|
13411
|
+
C21,
|
|
13011
13412
|
"ROUNDUP(number, num_digits)",
|
|
13012
13413
|
"Rounds a number away from zero.",
|
|
13013
13414
|
2,
|
|
@@ -13016,7 +13417,7 @@ var MATH_FUNCTIONS = [
|
|
|
13016
13417
|
),
|
|
13017
13418
|
numeric(
|
|
13018
13419
|
"ROUNDDOWN",
|
|
13019
|
-
|
|
13420
|
+
C21,
|
|
13020
13421
|
"ROUNDDOWN(number, num_digits)",
|
|
13021
13422
|
"Rounds a number toward zero.",
|
|
13022
13423
|
2,
|
|
@@ -13025,7 +13426,7 @@ var MATH_FUNCTIONS = [
|
|
|
13025
13426
|
),
|
|
13026
13427
|
numeric(
|
|
13027
13428
|
"MROUND",
|
|
13028
|
-
|
|
13429
|
+
C21,
|
|
13029
13430
|
"MROUND(number, multiple)",
|
|
13030
13431
|
"Rounds a number to the nearest multiple.",
|
|
13031
13432
|
2,
|
|
@@ -13034,7 +13435,7 @@ var MATH_FUNCTIONS = [
|
|
|
13034
13435
|
),
|
|
13035
13436
|
numeric(
|
|
13036
13437
|
"CEILING",
|
|
13037
|
-
|
|
13438
|
+
C21,
|
|
13038
13439
|
"CEILING(number, significance)",
|
|
13039
13440
|
"Rounds a number up to a multiple of significance.",
|
|
13040
13441
|
2,
|
|
@@ -13046,7 +13447,7 @@ var MATH_FUNCTIONS = [
|
|
|
13046
13447
|
),
|
|
13047
13448
|
numeric(
|
|
13048
13449
|
"FLOOR",
|
|
13049
|
-
|
|
13450
|
+
C21,
|
|
13050
13451
|
"FLOOR(number, significance)",
|
|
13051
13452
|
"Rounds a number down to a multiple of significance.",
|
|
13052
13453
|
2,
|
|
@@ -13059,7 +13460,7 @@ var MATH_FUNCTIONS = [
|
|
|
13059
13460
|
),
|
|
13060
13461
|
numeric(
|
|
13061
13462
|
"CEILING.MATH",
|
|
13062
|
-
|
|
13463
|
+
C21,
|
|
13063
13464
|
"CEILING.MATH(number, [significance], [mode])",
|
|
13064
13465
|
"Rounds a number up to an integer or multiple.",
|
|
13065
13466
|
1,
|
|
@@ -13072,7 +13473,7 @@ var MATH_FUNCTIONS = [
|
|
|
13072
13473
|
),
|
|
13073
13474
|
numeric(
|
|
13074
13475
|
"FLOOR.MATH",
|
|
13075
|
-
|
|
13476
|
+
C21,
|
|
13076
13477
|
"FLOOR.MATH(number, [significance], [mode])",
|
|
13077
13478
|
"Rounds a number down to an integer or multiple.",
|
|
13078
13479
|
1,
|
|
@@ -13085,7 +13486,7 @@ var MATH_FUNCTIONS = [
|
|
|
13085
13486
|
),
|
|
13086
13487
|
numeric(
|
|
13087
13488
|
"CEILING.PRECISE",
|
|
13088
|
-
|
|
13489
|
+
C21,
|
|
13089
13490
|
"CEILING.PRECISE(number, [significance])",
|
|
13090
13491
|
"Rounds a number up regardless of sign.",
|
|
13091
13492
|
1,
|
|
@@ -13094,7 +13495,7 @@ var MATH_FUNCTIONS = [
|
|
|
13094
13495
|
),
|
|
13095
13496
|
numeric(
|
|
13096
13497
|
"ISO.CEILING",
|
|
13097
|
-
|
|
13498
|
+
C21,
|
|
13098
13499
|
"ISO.CEILING(number, [significance])",
|
|
13099
13500
|
"Rounds a number up regardless of sign.",
|
|
13100
13501
|
1,
|
|
@@ -13103,7 +13504,7 @@ var MATH_FUNCTIONS = [
|
|
|
13103
13504
|
),
|
|
13104
13505
|
numeric(
|
|
13105
13506
|
"FLOOR.PRECISE",
|
|
13106
|
-
|
|
13507
|
+
C21,
|
|
13107
13508
|
"FLOOR.PRECISE(number, [significance])",
|
|
13108
13509
|
"Rounds a number down regardless of sign.",
|
|
13109
13510
|
1,
|
|
@@ -13112,7 +13513,7 @@ var MATH_FUNCTIONS = [
|
|
|
13112
13513
|
),
|
|
13113
13514
|
numeric(
|
|
13114
13515
|
"EVEN",
|
|
13115
|
-
|
|
13516
|
+
C21,
|
|
13116
13517
|
"EVEN(number)",
|
|
13117
13518
|
"Rounds a number away from zero to an even integer.",
|
|
13118
13519
|
1,
|
|
@@ -13121,7 +13522,7 @@ var MATH_FUNCTIONS = [
|
|
|
13121
13522
|
),
|
|
13122
13523
|
numeric(
|
|
13123
13524
|
"ODD",
|
|
13124
|
-
|
|
13525
|
+
C21,
|
|
13125
13526
|
"ODD(number)",
|
|
13126
13527
|
"Rounds a number away from zero to an odd integer.",
|
|
13127
13528
|
1,
|
|
@@ -13133,7 +13534,7 @@ var MATH_FUNCTIONS = [
|
|
|
13133
13534
|
),
|
|
13134
13535
|
numeric(
|
|
13135
13536
|
"MOD",
|
|
13136
|
-
|
|
13537
|
+
C21,
|
|
13137
13538
|
"MOD(number, divisor)",
|
|
13138
13539
|
"The remainder after division (sign of the divisor).",
|
|
13139
13540
|
2,
|
|
@@ -13142,7 +13543,7 @@ var MATH_FUNCTIONS = [
|
|
|
13142
13543
|
),
|
|
13143
13544
|
numeric(
|
|
13144
13545
|
"QUOTIENT",
|
|
13145
|
-
|
|
13546
|
+
C21,
|
|
13146
13547
|
"QUOTIENT(numerator, denominator)",
|
|
13147
13548
|
"The integer part of a division.",
|
|
13148
13549
|
2,
|
|
@@ -13154,7 +13555,7 @@ var MATH_FUNCTIONS = [
|
|
|
13154
13555
|
),
|
|
13155
13556
|
numeric(
|
|
13156
13557
|
"SQRT",
|
|
13157
|
-
|
|
13558
|
+
C21,
|
|
13158
13559
|
"SQRT(number)",
|
|
13159
13560
|
"The positive square root.",
|
|
13160
13561
|
1,
|
|
@@ -13163,7 +13564,7 @@ var MATH_FUNCTIONS = [
|
|
|
13163
13564
|
),
|
|
13164
13565
|
numeric(
|
|
13165
13566
|
"SQRTPI",
|
|
13166
|
-
|
|
13567
|
+
C21,
|
|
13167
13568
|
"SQRTPI(number)",
|
|
13168
13569
|
"The square root of number * pi.",
|
|
13169
13570
|
1,
|
|
@@ -13172,18 +13573,18 @@ var MATH_FUNCTIONS = [
|
|
|
13172
13573
|
),
|
|
13173
13574
|
numeric(
|
|
13174
13575
|
"POWER",
|
|
13175
|
-
|
|
13576
|
+
C21,
|
|
13176
13577
|
"POWER(number, power)",
|
|
13177
13578
|
"A number raised to a power.",
|
|
13178
13579
|
2,
|
|
13179
13580
|
2,
|
|
13180
13581
|
(b, e) => power(b, e ?? 1)
|
|
13181
13582
|
),
|
|
13182
|
-
numeric("EXP",
|
|
13183
|
-
numeric("LN",
|
|
13583
|
+
numeric("EXP", C21, "EXP(number)", "e raised to a power.", 1, 1, Math.exp),
|
|
13584
|
+
numeric("LN", C21, "LN(number)", "The natural logarithm.", 1, 1, (x) => domain(x > 0, Math.log(x))),
|
|
13184
13585
|
numeric(
|
|
13185
13586
|
"LOG10",
|
|
13186
|
-
|
|
13587
|
+
C21,
|
|
13187
13588
|
"LOG10(number)",
|
|
13188
13589
|
"The base-10 logarithm.",
|
|
13189
13590
|
1,
|
|
@@ -13192,7 +13593,7 @@ var MATH_FUNCTIONS = [
|
|
|
13192
13593
|
),
|
|
13193
13594
|
numeric(
|
|
13194
13595
|
"LOG",
|
|
13195
|
-
|
|
13596
|
+
C21,
|
|
13196
13597
|
"LOG(number, [base])",
|
|
13197
13598
|
"The logarithm to a base (10 by default).",
|
|
13198
13599
|
1,
|
|
@@ -13204,12 +13605,12 @@ var MATH_FUNCTIONS = [
|
|
|
13204
13605
|
return base === 10 ? Math.log10(x) : Math.log(x) / Math.log(base);
|
|
13205
13606
|
}
|
|
13206
13607
|
),
|
|
13207
|
-
numeric("PI",
|
|
13608
|
+
numeric("PI", C21, "PI()", "The value of pi.", 0, 0, () => Math.PI),
|
|
13208
13609
|
...COMBINATORIC_FUNCTIONS
|
|
13209
13610
|
];
|
|
13210
13611
|
|
|
13211
13612
|
// src/xlsx/formula/functions/matrix.ts
|
|
13212
|
-
var
|
|
13613
|
+
var C22 = "Math & Trig";
|
|
13213
13614
|
function numbers2(ctx, value) {
|
|
13214
13615
|
return ctx.toMatrix(value ?? null).data.map(
|
|
13215
13616
|
(row2) => row2.map((v) => {
|
|
@@ -13268,7 +13669,7 @@ function eliminate(input, invert2) {
|
|
|
13268
13669
|
var MATRIX_FUNCTIONS = [
|
|
13269
13670
|
spec(
|
|
13270
13671
|
"MMULT",
|
|
13271
|
-
|
|
13672
|
+
C22,
|
|
13272
13673
|
"MMULT(array1, array2)",
|
|
13273
13674
|
"The matrix product of two arrays.",
|
|
13274
13675
|
2,
|
|
@@ -13289,7 +13690,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
13289
13690
|
),
|
|
13290
13691
|
spec(
|
|
13291
13692
|
"MDETERM",
|
|
13292
|
-
|
|
13693
|
+
C22,
|
|
13293
13694
|
"MDETERM(array)",
|
|
13294
13695
|
"The determinant of a square matrix.",
|
|
13295
13696
|
1,
|
|
@@ -13299,7 +13700,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
13299
13700
|
),
|
|
13300
13701
|
spec(
|
|
13301
13702
|
"MINVERSE",
|
|
13302
|
-
|
|
13703
|
+
C22,
|
|
13303
13704
|
"MINVERSE(array)",
|
|
13304
13705
|
"The inverse of a square matrix.",
|
|
13305
13706
|
1,
|
|
@@ -13311,7 +13712,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
13311
13712
|
},
|
|
13312
13713
|
["any"]
|
|
13313
13714
|
),
|
|
13314
|
-
spec("MUNIT",
|
|
13715
|
+
spec("MUNIT", C22, "MUNIT(dimension)", "The identity matrix.", 1, 1, (args) => {
|
|
13315
13716
|
const n = int3(args[0]);
|
|
13316
13717
|
if (n < 1) fail(ERR.VALUE);
|
|
13317
13718
|
return Matrix.build(n, n, (r, c2) => r === c2 ? 1 : 0);
|
|
@@ -13378,7 +13779,7 @@ function fitStatistics(fit) {
|
|
|
13378
13779
|
}
|
|
13379
13780
|
|
|
13380
13781
|
// src/xlsx/formula/functions/regression.ts
|
|
13381
|
-
var
|
|
13782
|
+
var C23 = "Statistical";
|
|
13382
13783
|
function numbersOf2(ctx, value) {
|
|
13383
13784
|
return ctx.toMatrix(value ?? null).data.map(
|
|
13384
13785
|
(row2) => row2.map((v) => {
|
|
@@ -13447,7 +13848,7 @@ var ARGS = ["any"];
|
|
|
13447
13848
|
var REGRESSION_FUNCTIONS = [
|
|
13448
13849
|
spec(
|
|
13449
13850
|
"LINEST",
|
|
13450
|
-
|
|
13851
|
+
C23,
|
|
13451
13852
|
"LINEST(known_y, [known_x], [const], [stats])",
|
|
13452
13853
|
"The statistics of a straight-line (or multiple linear) least-squares fit.",
|
|
13453
13854
|
1,
|
|
@@ -13461,7 +13862,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
13461
13862
|
),
|
|
13462
13863
|
spec(
|
|
13463
13864
|
"LOGEST",
|
|
13464
|
-
|
|
13865
|
+
C23,
|
|
13465
13866
|
"LOGEST(known_y, [known_x], [const], [stats])",
|
|
13466
13867
|
"The statistics of an exponential-curve fit.",
|
|
13467
13868
|
1,
|
|
@@ -13479,7 +13880,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
13479
13880
|
),
|
|
13480
13881
|
spec(
|
|
13481
13882
|
"TREND",
|
|
13482
|
-
|
|
13883
|
+
C23,
|
|
13483
13884
|
"TREND(known_y, [known_x], [new_x], [const])",
|
|
13484
13885
|
"Values along a linear trend.",
|
|
13485
13886
|
1,
|
|
@@ -13493,7 +13894,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
13493
13894
|
),
|
|
13494
13895
|
spec(
|
|
13495
13896
|
"GROWTH",
|
|
13496
|
-
|
|
13897
|
+
C23,
|
|
13497
13898
|
"GROWTH(known_y, [known_x], [new_x], [const])",
|
|
13498
13899
|
"Values along an exponential trend.",
|
|
13499
13900
|
1,
|
|
@@ -13647,7 +14048,7 @@ var tPdf = (t, df) => Math.exp(
|
|
|
13647
14048
|
gammaLn((df + 1) / 2) - gammaLn(df / 2) - 0.5 * Math.log(df * Math.PI) - (df + 1) / 2 * Math.log(1 + t * t / df)
|
|
13648
14049
|
);
|
|
13649
14050
|
var chiCdf = (x, df) => gammaP(df / 2, x / 2);
|
|
13650
|
-
var
|
|
14051
|
+
var positive2 = (...values2) => {
|
|
13651
14052
|
for (const v of values2) if (v === void 0 || v <= 0) fail(ERR.NUM);
|
|
13652
14053
|
};
|
|
13653
14054
|
var probability = (p) => {
|
|
@@ -13672,13 +14073,13 @@ function poisson(k, mean2, cumulative2) {
|
|
|
13672
14073
|
return Math.exp(kk * Math.log(mean2) - mean2 - gammaLn(kk + 1));
|
|
13673
14074
|
}
|
|
13674
14075
|
var normDist = (x, m, s, cumulative2) => {
|
|
13675
|
-
|
|
14076
|
+
positive2(s);
|
|
13676
14077
|
const z = (x - m) / s;
|
|
13677
14078
|
return cumulative2 ? normCdf(z) : normPdf(z) / s;
|
|
13678
14079
|
};
|
|
13679
14080
|
|
|
13680
14081
|
// src/xlsx/formula/functions/distributions-f.ts
|
|
13681
|
-
var
|
|
14082
|
+
var C24 = "Statistical";
|
|
13682
14083
|
var degrees = (...values2) => {
|
|
13683
14084
|
for (const v of values2) if (v === void 0 || v < 1) fail(ERR.NUM);
|
|
13684
14085
|
};
|
|
@@ -13699,13 +14100,13 @@ var betaScaled = (x, a, b, lo, hi) => {
|
|
|
13699
14100
|
return betaI((x - lo) / (hi - lo), a, b);
|
|
13700
14101
|
};
|
|
13701
14102
|
var betaInverse = (p, a, b, lo, hi) => {
|
|
13702
|
-
|
|
14103
|
+
positive2(a, b);
|
|
13703
14104
|
if (p <= 0 || p > 1 || lo >= hi) fail(ERR.NUM);
|
|
13704
14105
|
return lo + (hi - lo) * invert((t) => betaI(t, a, b), p, 0, 1);
|
|
13705
14106
|
};
|
|
13706
14107
|
var gammaInverse = (p, a, b) => {
|
|
13707
14108
|
prob(p);
|
|
13708
|
-
|
|
14109
|
+
positive2(a, b);
|
|
13709
14110
|
return p === 0 ? 0 : invert((x) => gammaP(a, x / b), p, 0, a * b + 1);
|
|
13710
14111
|
};
|
|
13711
14112
|
function binomInverse(trials, p, alpha) {
|
|
@@ -13737,7 +14138,7 @@ var negbinomPmf = (f, s, p) => {
|
|
|
13737
14138
|
var DISTRIBUTION_F = [
|
|
13738
14139
|
numeric(
|
|
13739
14140
|
"F.DIST",
|
|
13740
|
-
|
|
14141
|
+
C24,
|
|
13741
14142
|
"F.DIST(x, deg_freedom1, deg_freedom2, cumulative)",
|
|
13742
14143
|
"The left-tailed F probability distribution.",
|
|
13743
14144
|
4,
|
|
@@ -13753,7 +14154,7 @@ var DISTRIBUTION_F = [
|
|
|
13753
14154
|
...["F.DIST.RT", "FDIST"].map(
|
|
13754
14155
|
(name) => numeric(
|
|
13755
14156
|
name,
|
|
13756
|
-
|
|
14157
|
+
C24,
|
|
13757
14158
|
`${name}(x, deg_freedom1, deg_freedom2)`,
|
|
13758
14159
|
"The right-tailed F probability distribution.",
|
|
13759
14160
|
3,
|
|
@@ -13767,7 +14168,7 @@ var DISTRIBUTION_F = [
|
|
|
13767
14168
|
),
|
|
13768
14169
|
numeric(
|
|
13769
14170
|
"F.INV",
|
|
13770
|
-
|
|
14171
|
+
C24,
|
|
13771
14172
|
"F.INV(probability, deg_freedom1, deg_freedom2)",
|
|
13772
14173
|
"The inverse of the left-tailed F distribution.",
|
|
13773
14174
|
3,
|
|
@@ -13781,7 +14182,7 @@ var DISTRIBUTION_F = [
|
|
|
13781
14182
|
...["F.INV.RT", "FINV"].map(
|
|
13782
14183
|
(name) => numeric(
|
|
13783
14184
|
name,
|
|
13784
|
-
|
|
14185
|
+
C24,
|
|
13785
14186
|
`${name}(probability, deg_freedom1, deg_freedom2)`,
|
|
13786
14187
|
"The inverse of the right-tailed F distribution.",
|
|
13787
14188
|
3,
|
|
@@ -13796,7 +14197,7 @@ var DISTRIBUTION_F = [
|
|
|
13796
14197
|
...["BETA.INV", "BETAINV"].map(
|
|
13797
14198
|
(name) => numeric(
|
|
13798
14199
|
name,
|
|
13799
|
-
|
|
14200
|
+
C24,
|
|
13800
14201
|
`${name}(probability, alpha, beta, [A], [B])`,
|
|
13801
14202
|
"The inverse of the cumulative beta distribution.",
|
|
13802
14203
|
3,
|
|
@@ -13807,13 +14208,13 @@ var DISTRIBUTION_F = [
|
|
|
13807
14208
|
),
|
|
13808
14209
|
numeric(
|
|
13809
14210
|
"BETADIST",
|
|
13810
|
-
|
|
14211
|
+
C24,
|
|
13811
14212
|
"BETADIST(x, alpha, beta, [A], [B])",
|
|
13812
14213
|
"The cumulative beta distribution.",
|
|
13813
14214
|
3,
|
|
13814
14215
|
5,
|
|
13815
14216
|
(x, a, b, lo, hi) => {
|
|
13816
|
-
|
|
14217
|
+
positive2(a, b);
|
|
13817
14218
|
return betaScaled(x, a ?? 1, b ?? 1, lo ?? 0, hi ?? 1);
|
|
13818
14219
|
},
|
|
13819
14220
|
[0, 0, 0, 0, 1]
|
|
@@ -13821,7 +14222,7 @@ var DISTRIBUTION_F = [
|
|
|
13821
14222
|
...["GAMMA.INV", "GAMMAINV"].map(
|
|
13822
14223
|
(name) => numeric(
|
|
13823
14224
|
name,
|
|
13824
|
-
|
|
14225
|
+
C24,
|
|
13825
14226
|
`${name}(probability, alpha, beta)`,
|
|
13826
14227
|
"The inverse of the gamma cumulative distribution.",
|
|
13827
14228
|
3,
|
|
@@ -13831,14 +14232,14 @@ var DISTRIBUTION_F = [
|
|
|
13831
14232
|
),
|
|
13832
14233
|
numeric(
|
|
13833
14234
|
"GAMMADIST",
|
|
13834
|
-
|
|
14235
|
+
C24,
|
|
13835
14236
|
"GAMMADIST(x, alpha, beta, cumulative)",
|
|
13836
14237
|
"The gamma distribution.",
|
|
13837
14238
|
4,
|
|
13838
14239
|
4,
|
|
13839
14240
|
(x, a, b, c2) => {
|
|
13840
14241
|
if (x < 0) fail(ERR.NUM);
|
|
13841
|
-
|
|
14242
|
+
positive2(a, b);
|
|
13842
14243
|
const al = a ?? 1;
|
|
13843
14244
|
const be = b ?? 1;
|
|
13844
14245
|
return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
|
|
@@ -13846,33 +14247,33 @@ var DISTRIBUTION_F = [
|
|
|
13846
14247
|
),
|
|
13847
14248
|
numeric(
|
|
13848
14249
|
"LOGINV",
|
|
13849
|
-
|
|
14250
|
+
C24,
|
|
13850
14251
|
"LOGINV(probability, mean, standard_dev)",
|
|
13851
14252
|
"The inverse of the lognormal cumulative distribution.",
|
|
13852
14253
|
3,
|
|
13853
14254
|
3,
|
|
13854
14255
|
(p, m, s) => {
|
|
13855
|
-
|
|
14256
|
+
positive2(s);
|
|
13856
14257
|
if (p <= 0 || p >= 1) fail(ERR.NUM);
|
|
13857
14258
|
return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
|
|
13858
14259
|
}
|
|
13859
14260
|
),
|
|
13860
14261
|
numeric(
|
|
13861
14262
|
"LOGNORMDIST",
|
|
13862
|
-
|
|
14263
|
+
C24,
|
|
13863
14264
|
"LOGNORMDIST(x, mean, standard_dev)",
|
|
13864
14265
|
"The cumulative lognormal distribution.",
|
|
13865
14266
|
3,
|
|
13866
14267
|
3,
|
|
13867
14268
|
(x, m, s) => {
|
|
13868
|
-
|
|
14269
|
+
positive2(x, s);
|
|
13869
14270
|
return normCdf((Math.log(x) - (m ?? 0)) / (s ?? 1));
|
|
13870
14271
|
}
|
|
13871
14272
|
),
|
|
13872
14273
|
...["BINOM.INV", "CRITBINOM"].map(
|
|
13873
14274
|
(name) => numeric(
|
|
13874
14275
|
name,
|
|
13875
|
-
|
|
14276
|
+
C24,
|
|
13876
14277
|
`${name}(trials, probability_s, alpha)`,
|
|
13877
14278
|
"The smallest value whose cumulative binomial distribution reaches the criterion.",
|
|
13878
14279
|
3,
|
|
@@ -13882,7 +14283,7 @@ var DISTRIBUTION_F = [
|
|
|
13882
14283
|
),
|
|
13883
14284
|
numeric(
|
|
13884
14285
|
"BINOM.DIST.RANGE",
|
|
13885
|
-
|
|
14286
|
+
C24,
|
|
13886
14287
|
"BINOM.DIST.RANGE(trials, probability_s, number_s, [number_s2])",
|
|
13887
14288
|
"The probability of a trial result within a range, from the binomial distribution.",
|
|
13888
14289
|
3,
|
|
@@ -13900,7 +14301,7 @@ var DISTRIBUTION_F = [
|
|
|
13900
14301
|
),
|
|
13901
14302
|
numeric(
|
|
13902
14303
|
"HYPGEOMDIST",
|
|
13903
|
-
|
|
14304
|
+
C24,
|
|
13904
14305
|
"HYPGEOMDIST(sample_s, number_sample, population_s, number_pop)",
|
|
13905
14306
|
"The hypergeometric distribution.",
|
|
13906
14307
|
4,
|
|
@@ -13909,7 +14310,7 @@ var DISTRIBUTION_F = [
|
|
|
13909
14310
|
),
|
|
13910
14311
|
numeric(
|
|
13911
14312
|
"NEGBINOMDIST",
|
|
13912
|
-
|
|
14313
|
+
C24,
|
|
13913
14314
|
"NEGBINOMDIST(number_f, number_s, probability_s)",
|
|
13914
14315
|
"The negative binomial distribution.",
|
|
13915
14316
|
3,
|
|
@@ -13919,7 +14320,7 @@ var DISTRIBUTION_F = [
|
|
|
13919
14320
|
];
|
|
13920
14321
|
|
|
13921
14322
|
// src/xlsx/formula/functions/statistical-shape.ts
|
|
13922
|
-
var
|
|
14323
|
+
var C25 = "Statistical";
|
|
13923
14324
|
function moments(values2) {
|
|
13924
14325
|
const n = values2.length;
|
|
13925
14326
|
return { n, m: mean(values2), s: stdev(values2, true) };
|
|
@@ -13936,7 +14337,7 @@ function frequency(data, bins) {
|
|
|
13936
14337
|
var STATISTICAL_SHAPE = [
|
|
13937
14338
|
spec(
|
|
13938
14339
|
"GEOMEAN",
|
|
13939
|
-
|
|
14340
|
+
C25,
|
|
13940
14341
|
"GEOMEAN(number1, ...)",
|
|
13941
14342
|
"The geometric mean.",
|
|
13942
14343
|
1,
|
|
@@ -13950,7 +14351,7 @@ var STATISTICAL_SHAPE = [
|
|
|
13950
14351
|
),
|
|
13951
14352
|
spec(
|
|
13952
14353
|
"HARMEAN",
|
|
13953
|
-
|
|
14354
|
+
C25,
|
|
13954
14355
|
"HARMEAN(number1, ...)",
|
|
13955
14356
|
"The harmonic mean.",
|
|
13956
14357
|
1,
|
|
@@ -13964,7 +14365,7 @@ var STATISTICAL_SHAPE = [
|
|
|
13964
14365
|
),
|
|
13965
14366
|
spec(
|
|
13966
14367
|
"AVEDEV",
|
|
13967
|
-
|
|
14368
|
+
C25,
|
|
13968
14369
|
"AVEDEV(number1, ...)",
|
|
13969
14370
|
"The mean absolute deviation from the mean.",
|
|
13970
14371
|
1,
|
|
@@ -13979,7 +14380,7 @@ var STATISTICAL_SHAPE = [
|
|
|
13979
14380
|
),
|
|
13980
14381
|
spec(
|
|
13981
14382
|
"DEVSQ",
|
|
13982
|
-
|
|
14383
|
+
C25,
|
|
13983
14384
|
"DEVSQ(number1, ...)",
|
|
13984
14385
|
"The sum of squared deviations from the mean.",
|
|
13985
14386
|
1,
|
|
@@ -13992,7 +14393,7 @@ var STATISTICAL_SHAPE = [
|
|
|
13992
14393
|
),
|
|
13993
14394
|
spec(
|
|
13994
14395
|
"KURT",
|
|
13995
|
-
|
|
14396
|
+
C25,
|
|
13996
14397
|
"KURT(number1, ...)",
|
|
13997
14398
|
"The kurtosis of a data set.",
|
|
13998
14399
|
1,
|
|
@@ -14008,7 +14409,7 @@ var STATISTICAL_SHAPE = [
|
|
|
14008
14409
|
),
|
|
14009
14410
|
spec(
|
|
14010
14411
|
"SKEW",
|
|
14011
|
-
|
|
14412
|
+
C25,
|
|
14012
14413
|
"SKEW(number1, ...)",
|
|
14013
14414
|
"The skewness of a distribution.",
|
|
14014
14415
|
1,
|
|
@@ -14023,7 +14424,7 @@ var STATISTICAL_SHAPE = [
|
|
|
14023
14424
|
),
|
|
14024
14425
|
spec(
|
|
14025
14426
|
"SKEW.P",
|
|
14026
|
-
|
|
14427
|
+
C25,
|
|
14027
14428
|
"SKEW.P(number1, ...)",
|
|
14028
14429
|
"The population skewness.",
|
|
14029
14430
|
1,
|
|
@@ -14039,7 +14440,7 @@ var STATISTICAL_SHAPE = [
|
|
|
14039
14440
|
),
|
|
14040
14441
|
numeric(
|
|
14041
14442
|
"STANDARDIZE",
|
|
14042
|
-
|
|
14443
|
+
C25,
|
|
14043
14444
|
"STANDARDIZE(x, mean, standard_dev)",
|
|
14044
14445
|
"A normalized value.",
|
|
14045
14446
|
3,
|
|
@@ -14051,7 +14452,7 @@ var STATISTICAL_SHAPE = [
|
|
|
14051
14452
|
),
|
|
14052
14453
|
spec(
|
|
14053
14454
|
"TRIMMEAN",
|
|
14054
|
-
|
|
14455
|
+
C25,
|
|
14055
14456
|
"TRIMMEAN(array, percent)",
|
|
14056
14457
|
"The mean of the interior of a data set.",
|
|
14057
14458
|
2,
|
|
@@ -14067,7 +14468,7 @@ var STATISTICAL_SHAPE = [
|
|
|
14067
14468
|
),
|
|
14068
14469
|
spec(
|
|
14069
14470
|
"FREQUENCY",
|
|
14070
|
-
|
|
14471
|
+
C25,
|
|
14071
14472
|
"FREQUENCY(data_array, bins_array)",
|
|
14072
14473
|
"How often values occur within ranges, as a vertical array.",
|
|
14073
14474
|
2,
|
|
@@ -14077,7 +14478,7 @@ var STATISTICAL_SHAPE = [
|
|
|
14077
14478
|
),
|
|
14078
14479
|
numeric(
|
|
14079
14480
|
"PERMUT",
|
|
14080
|
-
|
|
14481
|
+
C25,
|
|
14081
14482
|
"PERMUT(number, number_chosen)",
|
|
14082
14483
|
"The number of permutations.",
|
|
14083
14484
|
2,
|
|
@@ -14093,7 +14494,7 @@ var STATISTICAL_SHAPE = [
|
|
|
14093
14494
|
),
|
|
14094
14495
|
numeric(
|
|
14095
14496
|
"PERMUTATIONA",
|
|
14096
|
-
|
|
14497
|
+
C25,
|
|
14097
14498
|
"PERMUTATIONA(number, number_chosen)",
|
|
14098
14499
|
"Permutations with repetitions.",
|
|
14099
14500
|
2,
|
|
@@ -14103,26 +14504,26 @@ var STATISTICAL_SHAPE = [
|
|
|
14103
14504
|
return Math.pow(Math.trunc(n), Math.trunc(k ?? 0));
|
|
14104
14505
|
}
|
|
14105
14506
|
),
|
|
14106
|
-
numeric("FISHER",
|
|
14507
|
+
numeric("FISHER", C25, "FISHER(x)", "The Fisher transformation.", 1, 1, (x) => {
|
|
14107
14508
|
if (x <= -1 || x >= 1) fail(ERR.NUM);
|
|
14108
14509
|
return 0.5 * Math.log((1 + x) / (1 - x));
|
|
14109
14510
|
}),
|
|
14110
14511
|
numeric(
|
|
14111
14512
|
"FISHERINV",
|
|
14112
|
-
|
|
14513
|
+
C25,
|
|
14113
14514
|
"FISHERINV(y)",
|
|
14114
14515
|
"The inverse of the Fisher transformation.",
|
|
14115
14516
|
1,
|
|
14116
14517
|
1,
|
|
14117
14518
|
(y) => Math.tanh(y)
|
|
14118
14519
|
),
|
|
14119
|
-
numeric("GAMMA",
|
|
14520
|
+
numeric("GAMMA", C25, "GAMMA(number)", "The gamma function value.", 1, 1, (x) => {
|
|
14120
14521
|
if (x <= 0 && Number.isInteger(x)) fail(ERR.NUM);
|
|
14121
14522
|
return gamma(x);
|
|
14122
14523
|
}),
|
|
14123
14524
|
numeric(
|
|
14124
14525
|
"GAMMALN",
|
|
14125
|
-
|
|
14526
|
+
C25,
|
|
14126
14527
|
"GAMMALN(x)",
|
|
14127
14528
|
"The natural logarithm of the gamma function.",
|
|
14128
14529
|
1,
|
|
@@ -14131,7 +14532,7 @@ var STATISTICAL_SHAPE = [
|
|
|
14131
14532
|
),
|
|
14132
14533
|
numeric(
|
|
14133
14534
|
"GAMMALN.PRECISE",
|
|
14134
|
-
|
|
14535
|
+
C25,
|
|
14135
14536
|
"GAMMALN.PRECISE(x)",
|
|
14136
14537
|
"The natural logarithm of the gamma function.",
|
|
14137
14538
|
1,
|
|
@@ -14141,7 +14542,7 @@ var STATISTICAL_SHAPE = [
|
|
|
14141
14542
|
];
|
|
14142
14543
|
|
|
14143
14544
|
// src/xlsx/formula/functions/statistical-more.ts
|
|
14144
|
-
var
|
|
14545
|
+
var C26 = "Statistical";
|
|
14145
14546
|
function pairedNumbers(ctx, a, b) {
|
|
14146
14547
|
const ma = ctx.toMatrix(a).flat();
|
|
14147
14548
|
const mb = ctx.toMatrix(b).flat();
|
|
@@ -14162,7 +14563,7 @@ function pairedNumbers(ctx, a, b) {
|
|
|
14162
14563
|
}
|
|
14163
14564
|
var pairFn = (name, description, syntax, fn) => spec(
|
|
14164
14565
|
name,
|
|
14165
|
-
|
|
14566
|
+
C26,
|
|
14166
14567
|
syntax,
|
|
14167
14568
|
description,
|
|
14168
14569
|
2,
|
|
@@ -14177,7 +14578,7 @@ var STATISTICAL_MORE = [
|
|
|
14177
14578
|
...STATISTICAL_SHAPE,
|
|
14178
14579
|
spec(
|
|
14179
14580
|
"MODE.MULT",
|
|
14180
|
-
|
|
14581
|
+
C26,
|
|
14181
14582
|
"MODE.MULT(number1, [number2], ...)",
|
|
14182
14583
|
"A vertical array of the most frequent values.",
|
|
14183
14584
|
1,
|
|
@@ -14259,7 +14660,7 @@ var STATISTICAL_MORE = [
|
|
|
14259
14660
|
...["FORECAST", "FORECAST.LINEAR"].map(
|
|
14260
14661
|
(name) => spec(
|
|
14261
14662
|
name,
|
|
14262
|
-
|
|
14663
|
+
C26,
|
|
14263
14664
|
`${name}(x, known_ys, known_xs)`,
|
|
14264
14665
|
"Predicts a value along a linear trend.",
|
|
14265
14666
|
3,
|
|
@@ -14276,7 +14677,7 @@ var STATISTICAL_MORE = [
|
|
|
14276
14677
|
];
|
|
14277
14678
|
|
|
14278
14679
|
// src/xlsx/formula/functions/hypothesis-tests.ts
|
|
14279
|
-
var
|
|
14680
|
+
var C27 = "Statistical";
|
|
14280
14681
|
var ARRAYS = ["any"];
|
|
14281
14682
|
var numbersOf3 = (ctx, value) => collectNumbers(ctx, [value ?? null]);
|
|
14282
14683
|
function tStatistic(a, b, type) {
|
|
@@ -14361,7 +14762,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
14361
14762
|
["Z.TEST", "ZTEST"],
|
|
14362
14763
|
(name) => spec(
|
|
14363
14764
|
name,
|
|
14364
|
-
|
|
14765
|
+
C27,
|
|
14365
14766
|
`${name}(array, x, [sigma])`,
|
|
14366
14767
|
"The one-tailed P-value of a z-test.",
|
|
14367
14768
|
2,
|
|
@@ -14380,7 +14781,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
14380
14781
|
["T.TEST", "TTEST"],
|
|
14381
14782
|
(name) => spec(
|
|
14382
14783
|
name,
|
|
14383
|
-
|
|
14784
|
+
C27,
|
|
14384
14785
|
`${name}(array1, array2, tails, type)`,
|
|
14385
14786
|
"The probability associated with a Student's t-test.",
|
|
14386
14787
|
4,
|
|
@@ -14401,7 +14802,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
14401
14802
|
["F.TEST", "FTEST"],
|
|
14402
14803
|
(name) => spec(
|
|
14403
14804
|
name,
|
|
14404
|
-
|
|
14805
|
+
C27,
|
|
14405
14806
|
`${name}(array1, array2)`,
|
|
14406
14807
|
"The two-tailed probability that the variances of two arrays are not different.",
|
|
14407
14808
|
2,
|
|
@@ -14414,7 +14815,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
14414
14815
|
["CHISQ.TEST", "CHITEST"],
|
|
14415
14816
|
(name) => spec(
|
|
14416
14817
|
name,
|
|
14417
|
-
|
|
14818
|
+
C27,
|
|
14418
14819
|
`${name}(actual_range, expected_range)`,
|
|
14419
14820
|
"The chi-squared test of independence.",
|
|
14420
14821
|
2,
|
|
@@ -14425,7 +14826,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
14425
14826
|
),
|
|
14426
14827
|
spec(
|
|
14427
14828
|
"PROB",
|
|
14428
|
-
|
|
14829
|
+
C27,
|
|
14429
14830
|
"PROB(x_range, prob_range, lower_limit, [upper_limit])",
|
|
14430
14831
|
"The probability that values in a range are between two limits.",
|
|
14431
14832
|
3,
|
|
@@ -14436,7 +14837,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
14436
14837
|
];
|
|
14437
14838
|
|
|
14438
14839
|
// src/xlsx/formula/functions/statistical-spread.ts
|
|
14439
|
-
var
|
|
14840
|
+
var C28 = "Statistical";
|
|
14440
14841
|
var STATISTICAL_SPREAD = [
|
|
14441
14842
|
...[
|
|
14442
14843
|
["STDEV", true, false],
|
|
@@ -14448,7 +14849,7 @@ var STATISTICAL_SPREAD = [
|
|
|
14448
14849
|
].map(
|
|
14449
14850
|
([name, sample, a]) => spec(
|
|
14450
14851
|
name,
|
|
14451
|
-
|
|
14852
|
+
C28,
|
|
14452
14853
|
`${name}(number1, [number2], ...)`,
|
|
14453
14854
|
`The ${sample ? "sample" : "population"} standard deviation${a ? " counting logicals and text" : ""}.`,
|
|
14454
14855
|
1,
|
|
@@ -14467,7 +14868,7 @@ var STATISTICAL_SPREAD = [
|
|
|
14467
14868
|
].map(
|
|
14468
14869
|
([name, sample, a]) => spec(
|
|
14469
14870
|
name,
|
|
14470
|
-
|
|
14871
|
+
C28,
|
|
14471
14872
|
`${name}(number1, [number2], ...)`,
|
|
14472
14873
|
`The ${sample ? "sample" : "population"} variance${a ? " counting logicals and text" : ""}.`,
|
|
14473
14874
|
1,
|
|
@@ -14479,7 +14880,7 @@ var STATISTICAL_SPREAD = [
|
|
|
14479
14880
|
...["PERCENTILE", "PERCENTILE.INC", "PERCENTILE.EXC"].map(
|
|
14480
14881
|
(name) => spec(
|
|
14481
14882
|
name,
|
|
14482
|
-
|
|
14883
|
+
C28,
|
|
14483
14884
|
`${name}(array, k)`,
|
|
14484
14885
|
"The k-th percentile.",
|
|
14485
14886
|
2,
|
|
@@ -14495,7 +14896,7 @@ var STATISTICAL_SPREAD = [
|
|
|
14495
14896
|
...["QUARTILE", "QUARTILE.INC", "QUARTILE.EXC"].map(
|
|
14496
14897
|
(name) => spec(
|
|
14497
14898
|
name,
|
|
14498
|
-
|
|
14899
|
+
C28,
|
|
14499
14900
|
`${name}(array, quart)`,
|
|
14500
14901
|
"A quartile of a data set.",
|
|
14501
14902
|
2,
|
|
@@ -14507,7 +14908,7 @@ var STATISTICAL_SPREAD = [
|
|
|
14507
14908
|
...["PERCENTRANK", "PERCENTRANK.INC", "PERCENTRANK.EXC"].map(
|
|
14508
14909
|
(name) => spec(
|
|
14509
14910
|
name,
|
|
14510
|
-
|
|
14911
|
+
C28,
|
|
14511
14912
|
`${name}(array, x, [significance])`,
|
|
14512
14913
|
"The rank of a value as a percentage of the data set.",
|
|
14513
14914
|
2,
|
|
@@ -14524,7 +14925,7 @@ var STATISTICAL_SPREAD = [
|
|
|
14524
14925
|
];
|
|
14525
14926
|
|
|
14526
14927
|
// src/xlsx/formula/functions/statistical-count.ts
|
|
14527
|
-
var
|
|
14928
|
+
var C29 = "Statistical";
|
|
14528
14929
|
function count(ctx, args) {
|
|
14529
14930
|
let n = 0;
|
|
14530
14931
|
for (const arg of args) {
|
|
@@ -14590,7 +14991,7 @@ function countIf(ctx, range, criteria) {
|
|
|
14590
14991
|
var COUNT_FUNCTIONS = [
|
|
14591
14992
|
spec(
|
|
14592
14993
|
"COUNT",
|
|
14593
|
-
|
|
14994
|
+
C29,
|
|
14594
14995
|
"COUNT(value1, [value2], ...)",
|
|
14595
14996
|
"Counts the numbers in the arguments.",
|
|
14596
14997
|
0,
|
|
@@ -14600,7 +15001,7 @@ var COUNT_FUNCTIONS = [
|
|
|
14600
15001
|
),
|
|
14601
15002
|
spec(
|
|
14602
15003
|
"COUNTA",
|
|
14603
|
-
|
|
15004
|
+
C29,
|
|
14604
15005
|
"COUNTA(value1, [value2], ...)",
|
|
14605
15006
|
"Counts the non-empty values.",
|
|
14606
15007
|
1,
|
|
@@ -14610,7 +15011,7 @@ var COUNT_FUNCTIONS = [
|
|
|
14610
15011
|
),
|
|
14611
15012
|
spec(
|
|
14612
15013
|
"COUNTBLANK",
|
|
14613
|
-
|
|
15014
|
+
C29,
|
|
14614
15015
|
"COUNTBLANK(range)",
|
|
14615
15016
|
"Counts the empty cells in a range.",
|
|
14616
15017
|
1,
|
|
@@ -14620,7 +15021,7 @@ var COUNT_FUNCTIONS = [
|
|
|
14620
15021
|
),
|
|
14621
15022
|
spec(
|
|
14622
15023
|
"COUNTIF",
|
|
14623
|
-
|
|
15024
|
+
C29,
|
|
14624
15025
|
"COUNTIF(range, criteria)",
|
|
14625
15026
|
"Counts the cells that meet a criterion.",
|
|
14626
15027
|
2,
|
|
@@ -14630,7 +15031,7 @@ var COUNT_FUNCTIONS = [
|
|
|
14630
15031
|
),
|
|
14631
15032
|
spec(
|
|
14632
15033
|
"COUNTIFS",
|
|
14633
|
-
|
|
15034
|
+
C29,
|
|
14634
15035
|
"COUNTIFS(criteria_range1, criteria1, ...)",
|
|
14635
15036
|
"Counts the cells that meet several criteria.",
|
|
14636
15037
|
2,
|
|
@@ -14643,7 +15044,7 @@ var COUNT_FUNCTIONS = [
|
|
|
14643
15044
|
),
|
|
14644
15045
|
spec(
|
|
14645
15046
|
"AVERAGE",
|
|
14646
|
-
|
|
15047
|
+
C29,
|
|
14647
15048
|
"AVERAGE(number1, [number2], ...)",
|
|
14648
15049
|
"The arithmetic mean.",
|
|
14649
15050
|
1,
|
|
@@ -14654,7 +15055,7 @@ var COUNT_FUNCTIONS = [
|
|
|
14654
15055
|
];
|
|
14655
15056
|
|
|
14656
15057
|
// src/xlsx/formula/functions/statistical.ts
|
|
14657
|
-
var
|
|
15058
|
+
var C30 = "Statistical";
|
|
14658
15059
|
var numbersOf4 = (values2) => values2.filter((v) => typeof v === "number");
|
|
14659
15060
|
var extreme2 = extreme;
|
|
14660
15061
|
var STATISTICAL_FUNCTIONS = [
|
|
@@ -14665,7 +15066,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14665
15066
|
...COUNT_FUNCTIONS,
|
|
14666
15067
|
spec(
|
|
14667
15068
|
"AVERAGEA",
|
|
14668
|
-
|
|
15069
|
+
C30,
|
|
14669
15070
|
"AVERAGEA(value1, [value2], ...)",
|
|
14670
15071
|
"The mean counting text as 0 and logicals.",
|
|
14671
15072
|
1,
|
|
@@ -14675,7 +15076,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14675
15076
|
),
|
|
14676
15077
|
spec(
|
|
14677
15078
|
"AVERAGEIF",
|
|
14678
|
-
|
|
15079
|
+
C30,
|
|
14679
15080
|
"AVERAGEIF(range, criteria, [average_range])",
|
|
14680
15081
|
"The mean of the cells that meet a criterion.",
|
|
14681
15082
|
2,
|
|
@@ -14694,7 +15095,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14694
15095
|
),
|
|
14695
15096
|
spec(
|
|
14696
15097
|
"AVERAGEIFS",
|
|
14697
|
-
|
|
15098
|
+
C30,
|
|
14698
15099
|
"AVERAGEIFS(average_range, criteria_range1, criteria1, ...)",
|
|
14699
15100
|
"The mean of the cells that meet several criteria.",
|
|
14700
15101
|
3,
|
|
@@ -14708,7 +15109,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14708
15109
|
),
|
|
14709
15110
|
spec(
|
|
14710
15111
|
"MAX",
|
|
14711
|
-
|
|
15112
|
+
C30,
|
|
14712
15113
|
"MAX(number1, [number2], ...)",
|
|
14713
15114
|
"The largest value.",
|
|
14714
15115
|
1,
|
|
@@ -14718,7 +15119,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14718
15119
|
),
|
|
14719
15120
|
spec(
|
|
14720
15121
|
"MIN",
|
|
14721
|
-
|
|
15122
|
+
C30,
|
|
14722
15123
|
"MIN(number1, [number2], ...)",
|
|
14723
15124
|
"The smallest value.",
|
|
14724
15125
|
1,
|
|
@@ -14728,7 +15129,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14728
15129
|
),
|
|
14729
15130
|
spec(
|
|
14730
15131
|
"MAXA",
|
|
14731
|
-
|
|
15132
|
+
C30,
|
|
14732
15133
|
"MAXA(value1, [value2], ...)",
|
|
14733
15134
|
"The largest value counting logicals and text.",
|
|
14734
15135
|
1,
|
|
@@ -14738,7 +15139,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14738
15139
|
),
|
|
14739
15140
|
spec(
|
|
14740
15141
|
"MINA",
|
|
14741
|
-
|
|
15142
|
+
C30,
|
|
14742
15143
|
"MINA(value1, [value2], ...)",
|
|
14743
15144
|
"The smallest value counting logicals and text.",
|
|
14744
15145
|
1,
|
|
@@ -14748,7 +15149,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14748
15149
|
),
|
|
14749
15150
|
spec(
|
|
14750
15151
|
"MAXIFS",
|
|
14751
|
-
|
|
15152
|
+
C30,
|
|
14752
15153
|
"MAXIFS(max_range, criteria_range1, criteria1, ...)",
|
|
14753
15154
|
"The largest value meeting criteria.",
|
|
14754
15155
|
3,
|
|
@@ -14762,7 +15163,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14762
15163
|
),
|
|
14763
15164
|
spec(
|
|
14764
15165
|
"MINIFS",
|
|
14765
|
-
|
|
15166
|
+
C30,
|
|
14766
15167
|
"MINIFS(min_range, criteria_range1, criteria1, ...)",
|
|
14767
15168
|
"The smallest value meeting criteria.",
|
|
14768
15169
|
3,
|
|
@@ -14776,7 +15177,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14776
15177
|
),
|
|
14777
15178
|
spec(
|
|
14778
15179
|
"MEDIAN",
|
|
14779
|
-
|
|
15180
|
+
C30,
|
|
14780
15181
|
"MEDIAN(number1, [number2], ...)",
|
|
14781
15182
|
"The median.",
|
|
14782
15183
|
1,
|
|
@@ -14786,7 +15187,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14786
15187
|
),
|
|
14787
15188
|
spec(
|
|
14788
15189
|
"MODE",
|
|
14789
|
-
|
|
15190
|
+
C30,
|
|
14790
15191
|
"MODE(number1, [number2], ...)",
|
|
14791
15192
|
"The most frequent value.",
|
|
14792
15193
|
1,
|
|
@@ -14796,7 +15197,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14796
15197
|
),
|
|
14797
15198
|
spec(
|
|
14798
15199
|
"MODE.SNGL",
|
|
14799
|
-
|
|
15200
|
+
C30,
|
|
14800
15201
|
"MODE.SNGL(number1, [number2], ...)",
|
|
14801
15202
|
"The most frequent value.",
|
|
14802
15203
|
1,
|
|
@@ -14806,7 +15207,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14806
15207
|
),
|
|
14807
15208
|
spec(
|
|
14808
15209
|
"LARGE",
|
|
14809
|
-
|
|
15210
|
+
C30,
|
|
14810
15211
|
"LARGE(array, k)",
|
|
14811
15212
|
"The k-th largest value.",
|
|
14812
15213
|
2,
|
|
@@ -14816,7 +15217,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14816
15217
|
),
|
|
14817
15218
|
spec(
|
|
14818
15219
|
"SMALL",
|
|
14819
|
-
|
|
15220
|
+
C30,
|
|
14820
15221
|
"SMALL(array, k)",
|
|
14821
15222
|
"The k-th smallest value.",
|
|
14822
15223
|
2,
|
|
@@ -14827,7 +15228,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14827
15228
|
...["RANK", "RANK.EQ", "RANK.AVG"].map(
|
|
14828
15229
|
(name) => spec(
|
|
14829
15230
|
name,
|
|
14830
|
-
|
|
15231
|
+
C30,
|
|
14831
15232
|
`${name}(number, ref, [order])`,
|
|
14832
15233
|
"The rank of a number in a list.",
|
|
14833
15234
|
2,
|
|
@@ -14844,11 +15245,11 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
14844
15245
|
];
|
|
14845
15246
|
|
|
14846
15247
|
// src/xlsx/formula/functions/distributions-more.ts
|
|
14847
|
-
var
|
|
15248
|
+
var C31 = "Statistical";
|
|
14848
15249
|
var DISTRIBUTION_MORE = [
|
|
14849
15250
|
numeric(
|
|
14850
15251
|
"T.DIST",
|
|
14851
|
-
|
|
15252
|
+
C31,
|
|
14852
15253
|
"T.DIST(x, deg_freedom, cumulative)",
|
|
14853
15254
|
"Student's left-tailed t-distribution.",
|
|
14854
15255
|
3,
|
|
@@ -14860,7 +15261,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14860
15261
|
),
|
|
14861
15262
|
numeric(
|
|
14862
15263
|
"T.DIST.RT",
|
|
14863
|
-
|
|
15264
|
+
C31,
|
|
14864
15265
|
"T.DIST.RT(x, deg_freedom)",
|
|
14865
15266
|
"Student's right-tailed t-distribution.",
|
|
14866
15267
|
2,
|
|
@@ -14872,7 +15273,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14872
15273
|
),
|
|
14873
15274
|
numeric(
|
|
14874
15275
|
"T.DIST.2T",
|
|
14875
|
-
|
|
15276
|
+
C31,
|
|
14876
15277
|
"T.DIST.2T(x, deg_freedom)",
|
|
14877
15278
|
"Student's two-tailed t-distribution.",
|
|
14878
15279
|
2,
|
|
@@ -14884,7 +15285,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14884
15285
|
),
|
|
14885
15286
|
numeric(
|
|
14886
15287
|
"TDIST",
|
|
14887
|
-
|
|
15288
|
+
C31,
|
|
14888
15289
|
"TDIST(x, deg_freedom, tails)",
|
|
14889
15290
|
"Student's t-distribution.",
|
|
14890
15291
|
3,
|
|
@@ -14896,7 +15297,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14896
15297
|
),
|
|
14897
15298
|
numeric(
|
|
14898
15299
|
"T.INV",
|
|
14899
|
-
|
|
15300
|
+
C31,
|
|
14900
15301
|
"T.INV(probability, deg_freedom)",
|
|
14901
15302
|
"The left-tailed inverse of Student's t-distribution.",
|
|
14902
15303
|
2,
|
|
@@ -14911,7 +15312,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14911
15312
|
...["T.INV.2T", "TINV"].map(
|
|
14912
15313
|
(name) => numeric(
|
|
14913
15314
|
name,
|
|
14914
|
-
|
|
15315
|
+
C31,
|
|
14915
15316
|
`${name}(probability, deg_freedom)`,
|
|
14916
15317
|
"The two-tailed inverse of Student's t-distribution.",
|
|
14917
15318
|
2,
|
|
@@ -14924,7 +15325,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14924
15325
|
),
|
|
14925
15326
|
numeric(
|
|
14926
15327
|
"CHISQ.DIST",
|
|
14927
|
-
|
|
15328
|
+
C31,
|
|
14928
15329
|
"CHISQ.DIST(x, deg_freedom, cumulative)",
|
|
14929
15330
|
"The chi-squared distribution.",
|
|
14930
15331
|
3,
|
|
@@ -14938,7 +15339,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14938
15339
|
...["CHISQ.DIST.RT", "CHIDIST"].map(
|
|
14939
15340
|
(name) => numeric(
|
|
14940
15341
|
name,
|
|
14941
|
-
|
|
15342
|
+
C31,
|
|
14942
15343
|
`${name}(x, deg_freedom)`,
|
|
14943
15344
|
"The right-tailed chi-squared probability.",
|
|
14944
15345
|
2,
|
|
@@ -14951,7 +15352,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14951
15352
|
),
|
|
14952
15353
|
numeric(
|
|
14953
15354
|
"CHISQ.INV",
|
|
14954
|
-
|
|
15355
|
+
C31,
|
|
14955
15356
|
"CHISQ.INV(probability, deg_freedom)",
|
|
14956
15357
|
"The inverse of the left-tailed chi-squared distribution.",
|
|
14957
15358
|
2,
|
|
@@ -14964,7 +15365,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14964
15365
|
...["CHISQ.INV.RT", "CHIINV"].map(
|
|
14965
15366
|
(name) => numeric(
|
|
14966
15367
|
name,
|
|
14967
|
-
|
|
15368
|
+
C31,
|
|
14968
15369
|
`${name}(probability, deg_freedom)`,
|
|
14969
15370
|
"The inverse of the right-tailed chi-squared distribution.",
|
|
14970
15371
|
2,
|
|
@@ -14977,7 +15378,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14977
15378
|
),
|
|
14978
15379
|
numeric(
|
|
14979
15380
|
"BETA.DIST",
|
|
14980
|
-
|
|
15381
|
+
C31,
|
|
14981
15382
|
"BETA.DIST(x, alpha, beta, cumulative, [A], [B])",
|
|
14982
15383
|
"The beta distribution.",
|
|
14983
15384
|
4,
|
|
@@ -14985,7 +15386,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14985
15386
|
(x, a, b, c2, lo, hi) => {
|
|
14986
15387
|
const A = lo ?? 0;
|
|
14987
15388
|
const B = hi ?? 1;
|
|
14988
|
-
|
|
15389
|
+
positive2(a, b);
|
|
14989
15390
|
if (x < A || x > B || A === B) fail(ERR.NUM);
|
|
14990
15391
|
const t = (x - A) / (B - A);
|
|
14991
15392
|
const al = a ?? 1;
|
|
@@ -14997,7 +15398,7 @@ var DISTRIBUTION_MORE = [
|
|
|
14997
15398
|
),
|
|
14998
15399
|
numeric(
|
|
14999
15400
|
"NEGBINOM.DIST",
|
|
15000
|
-
|
|
15401
|
+
C31,
|
|
15001
15402
|
"NEGBINOM.DIST(number_f, number_s, probability_s, cumulative)",
|
|
15002
15403
|
"The negative binomial distribution.",
|
|
15003
15404
|
4,
|
|
@@ -15016,7 +15417,7 @@ var DISTRIBUTION_MORE = [
|
|
|
15016
15417
|
),
|
|
15017
15418
|
numeric(
|
|
15018
15419
|
"HYPGEOM.DIST",
|
|
15019
|
-
|
|
15420
|
+
C31,
|
|
15020
15421
|
"HYPGEOM.DIST(sample_s, number_sample, population_s, number_pop, cumulative)",
|
|
15021
15422
|
"The hypergeometric distribution.",
|
|
15022
15423
|
5,
|
|
@@ -15037,13 +15438,13 @@ var DISTRIBUTION_MORE = [
|
|
|
15037
15438
|
];
|
|
15038
15439
|
|
|
15039
15440
|
// src/xlsx/formula/functions/distributions.ts
|
|
15040
|
-
var
|
|
15441
|
+
var C32 = "Statistical";
|
|
15041
15442
|
var DISTRIBUTION_FUNCTIONS = [
|
|
15042
15443
|
...DISTRIBUTION_MORE,
|
|
15043
15444
|
...DISTRIBUTION_F,
|
|
15044
15445
|
numeric(
|
|
15045
15446
|
"NORM.DIST",
|
|
15046
|
-
|
|
15447
|
+
C32,
|
|
15047
15448
|
"NORM.DIST(x, mean, standard_dev, cumulative)",
|
|
15048
15449
|
"The normal distribution.",
|
|
15049
15450
|
4,
|
|
@@ -15052,7 +15453,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15052
15453
|
),
|
|
15053
15454
|
numeric(
|
|
15054
15455
|
"NORMDIST",
|
|
15055
|
-
|
|
15456
|
+
C32,
|
|
15056
15457
|
"NORMDIST(x, mean, standard_dev, cumulative)",
|
|
15057
15458
|
"The normal distribution.",
|
|
15058
15459
|
4,
|
|
@@ -15061,7 +15462,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15061
15462
|
),
|
|
15062
15463
|
numeric(
|
|
15063
15464
|
"NORM.S.DIST",
|
|
15064
|
-
|
|
15465
|
+
C32,
|
|
15065
15466
|
"NORM.S.DIST(z, cumulative)",
|
|
15066
15467
|
"The standard normal distribution.",
|
|
15067
15468
|
2,
|
|
@@ -15070,7 +15471,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15070
15471
|
),
|
|
15071
15472
|
numeric(
|
|
15072
15473
|
"NORMSDIST",
|
|
15073
|
-
|
|
15474
|
+
C32,
|
|
15074
15475
|
"NORMSDIST(z)",
|
|
15075
15476
|
"The standard normal cumulative distribution.",
|
|
15076
15477
|
1,
|
|
@@ -15079,31 +15480,31 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15079
15480
|
),
|
|
15080
15481
|
numeric(
|
|
15081
15482
|
"NORM.INV",
|
|
15082
|
-
|
|
15483
|
+
C32,
|
|
15083
15484
|
"NORM.INV(probability, mean, standard_dev)",
|
|
15084
15485
|
"The inverse of the normal cumulative distribution.",
|
|
15085
15486
|
3,
|
|
15086
15487
|
3,
|
|
15087
15488
|
(p, m, s) => {
|
|
15088
|
-
|
|
15489
|
+
positive2(s);
|
|
15089
15490
|
return (m ?? 0) + (s ?? 1) * normInv(p);
|
|
15090
15491
|
}
|
|
15091
15492
|
),
|
|
15092
15493
|
numeric(
|
|
15093
15494
|
"NORMINV",
|
|
15094
|
-
|
|
15495
|
+
C32,
|
|
15095
15496
|
"NORMINV(probability, mean, standard_dev)",
|
|
15096
15497
|
"The inverse of the normal cumulative distribution.",
|
|
15097
15498
|
3,
|
|
15098
15499
|
3,
|
|
15099
15500
|
(p, m, s) => {
|
|
15100
|
-
|
|
15501
|
+
positive2(s);
|
|
15101
15502
|
return (m ?? 0) + (s ?? 1) * normInv(p);
|
|
15102
15503
|
}
|
|
15103
15504
|
),
|
|
15104
15505
|
numeric(
|
|
15105
15506
|
"NORM.S.INV",
|
|
15106
|
-
|
|
15507
|
+
C32,
|
|
15107
15508
|
"NORM.S.INV(probability)",
|
|
15108
15509
|
"The inverse of the standard normal distribution.",
|
|
15109
15510
|
1,
|
|
@@ -15112,17 +15513,17 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15112
15513
|
),
|
|
15113
15514
|
numeric(
|
|
15114
15515
|
"NORMSINV",
|
|
15115
|
-
|
|
15516
|
+
C32,
|
|
15116
15517
|
"NORMSINV(probability)",
|
|
15117
15518
|
"The inverse of the standard normal distribution.",
|
|
15118
15519
|
1,
|
|
15119
15520
|
1,
|
|
15120
15521
|
normInv
|
|
15121
15522
|
),
|
|
15122
|
-
numeric("PHI",
|
|
15523
|
+
numeric("PHI", C32, "PHI(x)", "The standard normal density.", 1, 1, normPdf),
|
|
15123
15524
|
numeric(
|
|
15124
15525
|
"GAUSS",
|
|
15125
|
-
|
|
15526
|
+
C32,
|
|
15126
15527
|
"GAUSS(z)",
|
|
15127
15528
|
"The probability between the mean and z standard deviations.",
|
|
15128
15529
|
1,
|
|
@@ -15160,14 +15561,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15160
15561
|
...["CONFIDENCE", "CONFIDENCE.NORM"].map(
|
|
15161
15562
|
(name) => numeric(
|
|
15162
15563
|
name,
|
|
15163
|
-
|
|
15564
|
+
C32,
|
|
15164
15565
|
`${name}(alpha, standard_dev, size)`,
|
|
15165
15566
|
"The confidence interval for a population mean (normal).",
|
|
15166
15567
|
3,
|
|
15167
15568
|
3,
|
|
15168
15569
|
(a, s, n) => {
|
|
15169
15570
|
probability(a);
|
|
15170
|
-
|
|
15571
|
+
positive2(s);
|
|
15171
15572
|
if ((n ?? 0) < 1) fail(ERR.NUM);
|
|
15172
15573
|
return normInv(1 - a / 2) * (s ?? 1) / Math.sqrt(Math.trunc(n ?? 1));
|
|
15173
15574
|
}
|
|
@@ -15175,14 +15576,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15175
15576
|
),
|
|
15176
15577
|
numeric(
|
|
15177
15578
|
"CONFIDENCE.T",
|
|
15178
|
-
|
|
15579
|
+
C32,
|
|
15179
15580
|
"CONFIDENCE.T(alpha, standard_dev, size)",
|
|
15180
15581
|
"The confidence interval for a population mean (Student's t).",
|
|
15181
15582
|
3,
|
|
15182
15583
|
3,
|
|
15183
15584
|
(a, s, n) => {
|
|
15184
15585
|
probability(a);
|
|
15185
|
-
|
|
15586
|
+
positive2(s);
|
|
15186
15587
|
const size = Math.trunc(n ?? 1);
|
|
15187
15588
|
if (size < 2) fail(ERR.DIV0);
|
|
15188
15589
|
return invert((t) => tCdf(t, size - 1), 1 - a / 2, 0, 10) * (s ?? 1) / Math.sqrt(size);
|
|
@@ -15191,7 +15592,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15191
15592
|
...["BINOM.DIST", "BINOMDIST"].map(
|
|
15192
15593
|
(name) => numeric(
|
|
15193
15594
|
name,
|
|
15194
|
-
|
|
15595
|
+
C32,
|
|
15195
15596
|
`${name}(number_s, trials, probability_s, cumulative)`,
|
|
15196
15597
|
"The binomial distribution probability.",
|
|
15197
15598
|
4,
|
|
@@ -15202,7 +15603,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15202
15603
|
...["POISSON.DIST", "POISSON"].map(
|
|
15203
15604
|
(name) => numeric(
|
|
15204
15605
|
name,
|
|
15205
|
-
|
|
15606
|
+
C32,
|
|
15206
15607
|
`${name}(x, mean, cumulative)`,
|
|
15207
15608
|
"The Poisson distribution.",
|
|
15208
15609
|
3,
|
|
@@ -15213,54 +15614,54 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15213
15614
|
...["EXPON.DIST", "EXPONDIST"].map(
|
|
15214
15615
|
(name) => numeric(
|
|
15215
15616
|
name,
|
|
15216
|
-
|
|
15617
|
+
C32,
|
|
15217
15618
|
`${name}(x, lambda, cumulative)`,
|
|
15218
15619
|
"The exponential distribution.",
|
|
15219
15620
|
3,
|
|
15220
15621
|
3,
|
|
15221
15622
|
(x, l, c2) => {
|
|
15222
15623
|
if (x < 0) fail(ERR.NUM);
|
|
15223
|
-
|
|
15624
|
+
positive2(l);
|
|
15224
15625
|
return c2 ? 1 - Math.exp(-(l ?? 1) * x) : (l ?? 1) * Math.exp(-(l ?? 1) * x);
|
|
15225
15626
|
}
|
|
15226
15627
|
)
|
|
15227
15628
|
),
|
|
15228
15629
|
numeric(
|
|
15229
15630
|
"LOGNORM.DIST",
|
|
15230
|
-
|
|
15631
|
+
C32,
|
|
15231
15632
|
"LOGNORM.DIST(x, mean, standard_dev, cumulative)",
|
|
15232
15633
|
"The lognormal distribution.",
|
|
15233
15634
|
4,
|
|
15234
15635
|
4,
|
|
15235
15636
|
(x, m, s, c2) => {
|
|
15236
|
-
|
|
15637
|
+
positive2(x, s);
|
|
15237
15638
|
const z = (Math.log(x) - (m ?? 0)) / (s ?? 1);
|
|
15238
15639
|
return c2 ? normCdf(z) : normPdf(z) / (x * (s ?? 1));
|
|
15239
15640
|
}
|
|
15240
15641
|
),
|
|
15241
15642
|
numeric(
|
|
15242
15643
|
"LOGNORM.INV",
|
|
15243
|
-
|
|
15644
|
+
C32,
|
|
15244
15645
|
"LOGNORM.INV(probability, mean, standard_dev)",
|
|
15245
15646
|
"The inverse of the lognormal distribution.",
|
|
15246
15647
|
3,
|
|
15247
15648
|
3,
|
|
15248
15649
|
(p, m, s) => {
|
|
15249
|
-
|
|
15650
|
+
positive2(s);
|
|
15250
15651
|
return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
|
|
15251
15652
|
}
|
|
15252
15653
|
),
|
|
15253
15654
|
...["WEIBULL.DIST", "WEIBULL"].map(
|
|
15254
15655
|
(name) => numeric(
|
|
15255
15656
|
name,
|
|
15256
|
-
|
|
15657
|
+
C32,
|
|
15257
15658
|
`${name}(x, alpha, beta, cumulative)`,
|
|
15258
15659
|
"The Weibull distribution.",
|
|
15259
15660
|
4,
|
|
15260
15661
|
4,
|
|
15261
15662
|
(x, a, b, c2) => {
|
|
15262
15663
|
if (x < 0) fail(ERR.NUM);
|
|
15263
|
-
|
|
15664
|
+
positive2(a, b);
|
|
15264
15665
|
const al = a ?? 1;
|
|
15265
15666
|
const be = b ?? 1;
|
|
15266
15667
|
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));
|
|
@@ -15269,14 +15670,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15269
15670
|
),
|
|
15270
15671
|
numeric(
|
|
15271
15672
|
"GAMMA.DIST",
|
|
15272
|
-
|
|
15673
|
+
C32,
|
|
15273
15674
|
"GAMMA.DIST(x, alpha, beta, cumulative)",
|
|
15274
15675
|
"The gamma distribution.",
|
|
15275
15676
|
4,
|
|
15276
15677
|
4,
|
|
15277
15678
|
(x, a, b, c2) => {
|
|
15278
15679
|
if (x < 0) fail(ERR.NUM);
|
|
15279
|
-
|
|
15680
|
+
positive2(a, b);
|
|
15280
15681
|
const al = a ?? 1;
|
|
15281
15682
|
const be = b ?? 1;
|
|
15282
15683
|
return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
|
|
@@ -15285,7 +15686,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
15285
15686
|
];
|
|
15286
15687
|
|
|
15287
15688
|
// src/xlsx/formula/functions/text-convert.ts
|
|
15288
|
-
var
|
|
15689
|
+
var C33 = "Text";
|
|
15289
15690
|
var CP1252 = {
|
|
15290
15691
|
128: 8364,
|
|
15291
15692
|
130: 8218,
|
|
@@ -15330,7 +15731,7 @@ function fixed(value, decimals, commas) {
|
|
|
15330
15731
|
var TEXT_CONVERT = [
|
|
15331
15732
|
spec(
|
|
15332
15733
|
"TEXT",
|
|
15333
|
-
|
|
15734
|
+
C33,
|
|
15334
15735
|
"TEXT(value, format_text)",
|
|
15335
15736
|
"Formats a value with a number format.",
|
|
15336
15737
|
2,
|
|
@@ -15343,7 +15744,7 @@ var TEXT_CONVERT = [
|
|
|
15343
15744
|
return formatValue(value, str(args[1]), { date1904: ctx.date1904 }).text;
|
|
15344
15745
|
}
|
|
15345
15746
|
),
|
|
15346
|
-
spec("VALUE",
|
|
15747
|
+
spec("VALUE", C33, "VALUE(text)", "Converts text to a number.", 1, 1, (args) => {
|
|
15347
15748
|
const v = scalar(args[0]);
|
|
15348
15749
|
if (typeof v === "number") return v;
|
|
15349
15750
|
if (v === null) return 0;
|
|
@@ -15353,7 +15754,7 @@ var TEXT_CONVERT = [
|
|
|
15353
15754
|
}),
|
|
15354
15755
|
spec(
|
|
15355
15756
|
"NUMBERVALUE",
|
|
15356
|
-
|
|
15757
|
+
C33,
|
|
15357
15758
|
"NUMBERVALUE(text, [decimal_separator], [group_separator])",
|
|
15358
15759
|
"Converts text to a number with given separators.",
|
|
15359
15760
|
1,
|
|
@@ -15380,7 +15781,7 @@ var TEXT_CONVERT = [
|
|
|
15380
15781
|
),
|
|
15381
15782
|
spec(
|
|
15382
15783
|
"FIXED",
|
|
15383
|
-
|
|
15784
|
+
C33,
|
|
15384
15785
|
"FIXED(number, [decimals], [no_commas])",
|
|
15385
15786
|
"Formats a number as text with fixed decimals.",
|
|
15386
15787
|
1,
|
|
@@ -15389,7 +15790,7 @@ var TEXT_CONVERT = [
|
|
|
15389
15790
|
),
|
|
15390
15791
|
spec(
|
|
15391
15792
|
"DOLLAR",
|
|
15392
|
-
|
|
15793
|
+
C33,
|
|
15393
15794
|
"DOLLAR(number, [decimals])",
|
|
15394
15795
|
"Formats a number as currency text.",
|
|
15395
15796
|
1,
|
|
@@ -15400,28 +15801,28 @@ var TEXT_CONVERT = [
|
|
|
15400
15801
|
return value < 0 && text.replace(/[0.,]/g, "") !== "" ? `($${text})` : `$${text}`;
|
|
15401
15802
|
}
|
|
15402
15803
|
),
|
|
15403
|
-
spec("CHAR",
|
|
15804
|
+
spec("CHAR", C33, "CHAR(number)", "The character for a code (Windows-1252).", 1, 1, (args) => {
|
|
15404
15805
|
const n = int3(args[0]);
|
|
15405
15806
|
if (n < 1 || n > 255) fail(ERR.VALUE);
|
|
15406
15807
|
return String.fromCharCode(CP1252[n] ?? n);
|
|
15407
15808
|
}),
|
|
15408
|
-
spec("CODE",
|
|
15809
|
+
spec("CODE", C33, "CODE(text)", "The code of the first character (Windows-1252).", 1, 1, (args) => {
|
|
15409
15810
|
const text = str(args[0]);
|
|
15410
15811
|
if (text === "") fail(ERR.VALUE);
|
|
15411
15812
|
const code = text.charCodeAt(0);
|
|
15412
15813
|
return CP1252_REVERSE.get(code) ?? (code <= 255 ? code : 63);
|
|
15413
15814
|
}),
|
|
15414
|
-
spec("UNICHAR",
|
|
15815
|
+
spec("UNICHAR", C33, "UNICHAR(number)", "The Unicode character for a code point.", 1, 1, (args) => {
|
|
15415
15816
|
const n = int3(args[0]);
|
|
15416
15817
|
if (n < 1 || n > 1114111) fail(ERR.VALUE);
|
|
15417
15818
|
return String.fromCodePoint(n);
|
|
15418
15819
|
}),
|
|
15419
|
-
spec("UNICODE",
|
|
15820
|
+
spec("UNICODE", C33, "UNICODE(text)", "The code point of the first character.", 1, 1, (args) => {
|
|
15420
15821
|
const text = str(args[0]);
|
|
15421
15822
|
if (text === "") fail(ERR.VALUE);
|
|
15422
15823
|
return text.codePointAt(0) ?? fail(ERR.VALUE);
|
|
15423
15824
|
}),
|
|
15424
|
-
spec("T",
|
|
15825
|
+
spec("T", C33, "T(value)", "The text of a value, or empty text.", 1, 1, (args) => {
|
|
15425
15826
|
const v = scalar(args[0]);
|
|
15426
15827
|
if (isError(v)) return v;
|
|
15427
15828
|
return typeof v === "string" ? v : "";
|
|
@@ -15471,7 +15872,7 @@ function right(text, n) {
|
|
|
15471
15872
|
}
|
|
15472
15873
|
|
|
15473
15874
|
// src/xlsx/formula/functions/text.ts
|
|
15474
|
-
var
|
|
15875
|
+
var C34 = "Text";
|
|
15475
15876
|
var MAX_TEXT = 32767;
|
|
15476
15877
|
var limit = (text) => text.length > MAX_TEXT ? fail(ERR.VALUE) : text;
|
|
15477
15878
|
function find(args, insensitive) {
|
|
@@ -15504,7 +15905,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15504
15905
|
...TEXT_CONVERT,
|
|
15505
15906
|
spec(
|
|
15506
15907
|
"CONCATENATE",
|
|
15507
|
-
|
|
15908
|
+
C34,
|
|
15508
15909
|
"CONCATENATE(text1, [text2], ...)",
|
|
15509
15910
|
"Joins text items.",
|
|
15510
15911
|
1,
|
|
@@ -15513,7 +15914,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15513
15914
|
),
|
|
15514
15915
|
spec(
|
|
15515
15916
|
"CONCAT",
|
|
15516
|
-
|
|
15917
|
+
C34,
|
|
15517
15918
|
"CONCAT(text1, [text2], ...)",
|
|
15518
15919
|
"Joins text from items and ranges.",
|
|
15519
15920
|
1,
|
|
@@ -15523,7 +15924,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15523
15924
|
),
|
|
15524
15925
|
spec(
|
|
15525
15926
|
"TEXTJOIN",
|
|
15526
|
-
|
|
15927
|
+
C34,
|
|
15527
15928
|
"TEXTJOIN(delimiter, ignore_empty, text1, ...)",
|
|
15528
15929
|
"Joins text with a delimiter.",
|
|
15529
15930
|
3,
|
|
@@ -15542,14 +15943,14 @@ var TEXT_FUNCTIONS = [
|
|
|
15542
15943
|
["any"]
|
|
15543
15944
|
),
|
|
15544
15945
|
...["LEFT", "LEFTB"].map(
|
|
15545
|
-
(name) => spec(name,
|
|
15946
|
+
(name) => spec(name, C34, `${name}(text, [num_chars])`, "The first characters of a text.", 1, 2, (args) => {
|
|
15546
15947
|
const n = optNum(args, 1, 1);
|
|
15547
15948
|
if (n < 0) fail(ERR.VALUE);
|
|
15548
15949
|
return left(str(args[0]), Math.trunc(n));
|
|
15549
15950
|
})
|
|
15550
15951
|
),
|
|
15551
15952
|
...["RIGHT", "RIGHTB"].map(
|
|
15552
|
-
(name) => spec(name,
|
|
15953
|
+
(name) => spec(name, C34, `${name}(text, [num_chars])`, "The last characters of a text.", 1, 2, (args) => {
|
|
15553
15954
|
const n = Math.trunc(optNum(args, 1, 1));
|
|
15554
15955
|
if (n < 0) fail(ERR.VALUE);
|
|
15555
15956
|
return right(str(args[0]), n);
|
|
@@ -15558,7 +15959,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15558
15959
|
...["MID", "MIDB"].map(
|
|
15559
15960
|
(name) => spec(
|
|
15560
15961
|
name,
|
|
15561
|
-
|
|
15962
|
+
C34,
|
|
15562
15963
|
`${name}(text, start_num, num_chars)`,
|
|
15563
15964
|
"Characters from the middle of a text.",
|
|
15564
15965
|
3,
|
|
@@ -15574,7 +15975,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15574
15975
|
...["LEN", "LENB"].map(
|
|
15575
15976
|
(name) => spec(
|
|
15576
15977
|
name,
|
|
15577
|
-
|
|
15978
|
+
C34,
|
|
15578
15979
|
`${name}(text)`,
|
|
15579
15980
|
"The number of characters in a text.",
|
|
15580
15981
|
1,
|
|
@@ -15584,7 +15985,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15584
15985
|
),
|
|
15585
15986
|
spec(
|
|
15586
15987
|
"LOWER",
|
|
15587
|
-
|
|
15988
|
+
C34,
|
|
15588
15989
|
"LOWER(text)",
|
|
15589
15990
|
"Converts text to lower case.",
|
|
15590
15991
|
1,
|
|
@@ -15593,7 +15994,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15593
15994
|
),
|
|
15594
15995
|
spec(
|
|
15595
15996
|
"UPPER",
|
|
15596
|
-
|
|
15997
|
+
C34,
|
|
15597
15998
|
"UPPER(text)",
|
|
15598
15999
|
"Converts text to upper case.",
|
|
15599
16000
|
1,
|
|
@@ -15602,7 +16003,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15602
16003
|
),
|
|
15603
16004
|
spec(
|
|
15604
16005
|
"PROPER",
|
|
15605
|
-
|
|
16006
|
+
C34,
|
|
15606
16007
|
"PROPER(text)",
|
|
15607
16008
|
"Capitalizes the first letter of each word.",
|
|
15608
16009
|
1,
|
|
@@ -15611,7 +16012,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15611
16012
|
),
|
|
15612
16013
|
spec(
|
|
15613
16014
|
"TRIM",
|
|
15614
|
-
|
|
16015
|
+
C34,
|
|
15615
16016
|
"TRIM(text)",
|
|
15616
16017
|
"Removes extra spaces.",
|
|
15617
16018
|
1,
|
|
@@ -15620,7 +16021,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15620
16021
|
),
|
|
15621
16022
|
spec(
|
|
15622
16023
|
"CLEAN",
|
|
15623
|
-
|
|
16024
|
+
C34,
|
|
15624
16025
|
"CLEAN(text)",
|
|
15625
16026
|
"Removes non-printable characters.",
|
|
15626
16027
|
1,
|
|
@@ -15632,7 +16033,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15632
16033
|
),
|
|
15633
16034
|
spec(
|
|
15634
16035
|
"SUBSTITUTE",
|
|
15635
|
-
|
|
16036
|
+
C34,
|
|
15636
16037
|
"SUBSTITUTE(text, old_text, new_text, [instance_num])",
|
|
15637
16038
|
"Replaces occurrences of a text.",
|
|
15638
16039
|
3,
|
|
@@ -15656,7 +16057,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15656
16057
|
...["REPLACE", "REPLACEB"].map(
|
|
15657
16058
|
(name) => spec(
|
|
15658
16059
|
name,
|
|
15659
|
-
|
|
16060
|
+
C34,
|
|
15660
16061
|
`${name}(old_text, start_num, num_chars, new_text)`,
|
|
15661
16062
|
"Replaces part of a text.",
|
|
15662
16063
|
4,
|
|
@@ -15673,7 +16074,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15673
16074
|
...["FIND", "FINDB"].map(
|
|
15674
16075
|
(name) => spec(
|
|
15675
16076
|
name,
|
|
15676
|
-
|
|
16077
|
+
C34,
|
|
15677
16078
|
`${name}(find_text, within_text, [start_num])`,
|
|
15678
16079
|
"The position of a text (case-sensitive).",
|
|
15679
16080
|
2,
|
|
@@ -15684,7 +16085,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15684
16085
|
...["SEARCH", "SEARCHB"].map(
|
|
15685
16086
|
(name) => spec(
|
|
15686
16087
|
name,
|
|
15687
|
-
|
|
16088
|
+
C34,
|
|
15688
16089
|
`${name}(find_text, within_text, [start_num])`,
|
|
15689
16090
|
"The position of a text (wildcards, any case).",
|
|
15690
16091
|
2,
|
|
@@ -15692,7 +16093,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15692
16093
|
(args) => find(args, true)
|
|
15693
16094
|
)
|
|
15694
16095
|
),
|
|
15695
|
-
spec("REPT",
|
|
16096
|
+
spec("REPT", C34, "REPT(text, number_times)", "Repeats a text.", 2, 2, (args) => {
|
|
15696
16097
|
const n = Math.trunc(num2(args[1]));
|
|
15697
16098
|
const text = str(args[0]);
|
|
15698
16099
|
if (n < 0 || text.length * n > MAX_TEXT) fail(ERR.VALUE);
|
|
@@ -15700,7 +16101,7 @@ var TEXT_FUNCTIONS = [
|
|
|
15700
16101
|
}),
|
|
15701
16102
|
spec(
|
|
15702
16103
|
"EXACT",
|
|
15703
|
-
|
|
16104
|
+
C34,
|
|
15704
16105
|
"EXACT(text1, text2)",
|
|
15705
16106
|
"Whether two texts are identical (case-sensitive).",
|
|
15706
16107
|
2,
|
|
@@ -15709,8 +16110,78 @@ var TEXT_FUNCTIONS = [
|
|
|
15709
16110
|
)
|
|
15710
16111
|
];
|
|
15711
16112
|
|
|
16113
|
+
// src/xlsx/formula/functions/text-regex.ts
|
|
16114
|
+
var C35 = "Text";
|
|
16115
|
+
function compile(pattern, caseMode2, global) {
|
|
16116
|
+
if (caseMode2 !== 0 && caseMode2 !== 1) fail(ERR.VALUE);
|
|
16117
|
+
try {
|
|
16118
|
+
return new RegExp(pattern, `${global ? "g" : ""}${caseMode2 === 1 ? "i" : ""}u`);
|
|
16119
|
+
} catch {
|
|
16120
|
+
return fail(ERR.VALUE);
|
|
16121
|
+
}
|
|
16122
|
+
}
|
|
16123
|
+
var caseMode = (args, index2) => optNum(args, index2, 0);
|
|
16124
|
+
function encodeUrl(text) {
|
|
16125
|
+
return encodeURIComponent(text).replace(
|
|
16126
|
+
/[!'()*]/g,
|
|
16127
|
+
(c2) => `%${c2.charCodeAt(0).toString(16).toUpperCase()}`
|
|
16128
|
+
);
|
|
16129
|
+
}
|
|
16130
|
+
var TEXT_REGEX_FUNCTIONS = [
|
|
16131
|
+
spec(
|
|
16132
|
+
"ENCODEURL",
|
|
16133
|
+
C35,
|
|
16134
|
+
"ENCODEURL(text)",
|
|
16135
|
+
"Percent-encodes text for use in a URL.",
|
|
16136
|
+
1,
|
|
16137
|
+
1,
|
|
16138
|
+
(args) => encodeUrl(str(args[0]))
|
|
16139
|
+
),
|
|
16140
|
+
spec(
|
|
16141
|
+
"REGEXTEST",
|
|
16142
|
+
C35,
|
|
16143
|
+
"REGEXTEST(text, pattern, [case_sensitivity])",
|
|
16144
|
+
"Whether any part of the text matches the pattern.",
|
|
16145
|
+
2,
|
|
16146
|
+
3,
|
|
16147
|
+
(args) => compile(str(args[1]), caseMode(args, 2), false).test(str(args[0]))
|
|
16148
|
+
),
|
|
16149
|
+
spec(
|
|
16150
|
+
"REGEXEXTRACT",
|
|
16151
|
+
C35,
|
|
16152
|
+
"REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])",
|
|
16153
|
+
"The first part of the text that matches the pattern.",
|
|
16154
|
+
2,
|
|
16155
|
+
4,
|
|
16156
|
+
(args) => {
|
|
16157
|
+
if (optNum(args, 2, 0) !== 0) fail(ERR.VALUE);
|
|
16158
|
+
const match2 = compile(str(args[1]), caseMode(args, 3), false).exec(str(args[0]));
|
|
16159
|
+
return match2 ? match2[0] : fail(ERR.NA);
|
|
16160
|
+
}
|
|
16161
|
+
),
|
|
16162
|
+
spec(
|
|
16163
|
+
"REGEXREPLACE",
|
|
16164
|
+
C35,
|
|
16165
|
+
"REGEXREPLACE(text, pattern, replacement, [occurrence], [case_sensitivity])",
|
|
16166
|
+
"Replaces the parts of the text that match the pattern.",
|
|
16167
|
+
3,
|
|
16168
|
+
5,
|
|
16169
|
+
(args) => {
|
|
16170
|
+
const text = str(args[0]);
|
|
16171
|
+
const regex = compile(str(args[1]), caseMode(args, 4), true);
|
|
16172
|
+
const replacement = str(args[2]);
|
|
16173
|
+
const occurrence = args.length > 3 && args[3] !== null ? int3(args[3]) : 0;
|
|
16174
|
+
if (occurrence === 0) return text.replace(regex, replacement);
|
|
16175
|
+
const matches2 = [...text.matchAll(regex)];
|
|
16176
|
+
const picked = occurrence > 0 ? matches2[occurrence - 1] : matches2.at(occurrence);
|
|
16177
|
+
if (!picked || picked.index === void 0) return text;
|
|
16178
|
+
return text.slice(0, picked.index) + picked[0].replace(new RegExp(regex.source, regex.flags.replace("g", "")), replacement) + text.slice(picked.index + picked[0].length);
|
|
16179
|
+
}
|
|
16180
|
+
)
|
|
16181
|
+
];
|
|
16182
|
+
|
|
15712
16183
|
// src/xlsx/formula/functions/text-extra.ts
|
|
15713
|
-
var
|
|
16184
|
+
var C36 = "Text";
|
|
15714
16185
|
function delimitersOf(ctx, value) {
|
|
15715
16186
|
if (value === void 0 || value === null) return [];
|
|
15716
16187
|
return ctx.toMatrix(value).flat().map((v) => {
|
|
@@ -15776,9 +16247,10 @@ function valueToText(value, strict) {
|
|
|
15776
16247
|
return toText(value);
|
|
15777
16248
|
}
|
|
15778
16249
|
var TEXT_EXTRA_FUNCTIONS = [
|
|
16250
|
+
...TEXT_REGEX_FUNCTIONS,
|
|
15779
16251
|
spec(
|
|
15780
16252
|
"TEXTBEFORE",
|
|
15781
|
-
|
|
16253
|
+
C36,
|
|
15782
16254
|
"TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
|
|
15783
16255
|
"The text before a delimiter.",
|
|
15784
16256
|
2,
|
|
@@ -15788,7 +16260,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
15788
16260
|
),
|
|
15789
16261
|
spec(
|
|
15790
16262
|
"TEXTAFTER",
|
|
15791
|
-
|
|
16263
|
+
C36,
|
|
15792
16264
|
"TEXTAFTER(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
|
|
15793
16265
|
"The text after a delimiter.",
|
|
15794
16266
|
2,
|
|
@@ -15798,7 +16270,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
15798
16270
|
),
|
|
15799
16271
|
spec(
|
|
15800
16272
|
"TEXTSPLIT",
|
|
15801
|
-
|
|
16273
|
+
C36,
|
|
15802
16274
|
"TEXTSPLIT(text, col_delimiter, [row_delimiter], [ignore_empty], [match_mode], [pad_with])",
|
|
15803
16275
|
"Splits text into an array.",
|
|
15804
16276
|
2,
|
|
@@ -15821,7 +16293,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
15821
16293
|
),
|
|
15822
16294
|
spec(
|
|
15823
16295
|
"VALUETOTEXT",
|
|
15824
|
-
|
|
16296
|
+
C36,
|
|
15825
16297
|
"VALUETOTEXT(value, [format])",
|
|
15826
16298
|
"Text for any value.",
|
|
15827
16299
|
1,
|
|
@@ -15830,7 +16302,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
15830
16302
|
),
|
|
15831
16303
|
spec(
|
|
15832
16304
|
"ARRAYTOTEXT",
|
|
15833
|
-
|
|
16305
|
+
C36,
|
|
15834
16306
|
"ARRAYTOTEXT(array, [format])",
|
|
15835
16307
|
"Text for an array.",
|
|
15836
16308
|
1,
|
|
@@ -15989,16 +16461,16 @@ function shiftSpan(start, end, shift2) {
|
|
|
15989
16461
|
}
|
|
15990
16462
|
function shiftRange(range, shift2) {
|
|
15991
16463
|
if (shift2.axis === "row") {
|
|
15992
|
-
const
|
|
15993
|
-
return
|
|
15994
|
-
start: { row:
|
|
15995
|
-
end: { row:
|
|
16464
|
+
const span3 = shiftSpan(range.start.row, range.end.row, shift2);
|
|
16465
|
+
return span3 && {
|
|
16466
|
+
start: { row: span3.start, col: range.start.col },
|
|
16467
|
+
end: { row: span3.end, col: range.end.col }
|
|
15996
16468
|
};
|
|
15997
16469
|
}
|
|
15998
|
-
const
|
|
15999
|
-
return
|
|
16000
|
-
start: { row: range.start.row, col:
|
|
16001
|
-
end: { row: range.end.row, col:
|
|
16470
|
+
const span2 = shiftSpan(range.start.col, range.end.col, shift2);
|
|
16471
|
+
return span2 && {
|
|
16472
|
+
start: { row: range.start.row, col: span2.start },
|
|
16473
|
+
end: { row: range.end.row, col: span2.end }
|
|
16002
16474
|
};
|
|
16003
16475
|
}
|
|
16004
16476
|
function shiftRangeInBand(range, shift2, lo, hi) {
|
|
@@ -16790,7 +17262,9 @@ function workbookXml(workbook, sheets, activeTab, sourceXml) {
|
|
|
16790
17262
|
).join("")}</definedNames>`;
|
|
16791
17263
|
const calc = kept.get("calcPr");
|
|
16792
17264
|
const mode = workbook.calcMode === "manual" ? ' calcMode="manual"' : "";
|
|
16793
|
-
|
|
17265
|
+
const iterate = workbook.iterate ? ` iterate="1" iterateCount="${workbook.iterate.count}" iterateDelta="${workbook.iterate.delta}"` : "";
|
|
17266
|
+
const owned = ["fullCalcOnLoad", "calcId", "calcMode", "iterate", "iterateCount", "iterateDelta"];
|
|
17267
|
+
out += `<calcPr${copyAttrs(calc, owned)} calcId="191029"${mode}${iterate} fullCalcOnLoad="1"/>`;
|
|
16794
17268
|
out += raw(KEPT_TAIL);
|
|
16795
17269
|
return `${out}</workbook>`;
|
|
16796
17270
|
}
|