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.
@@ -3988,8 +3988,14 @@ function parseWorkbookPart(xml) {
3988
3988
  const protection = xFirst(root, "workbookProtection");
3989
3989
  const password = att(protection, "workbookPassword");
3990
3990
  const modernHash = readModernHash(protection, "workbook");
3991
- const calcMode = att(xFirst(root, "calcPr"), "calcMode");
3991
+ const calcPr = xFirst(root, "calcPr");
3992
+ const calcMode = att(calcPr, "calcMode");
3993
+ const iterate = boolAttr(calcPr, "iterate", false) ? {
3994
+ count: numAttr(calcPr, "iterateCount") ?? 100,
3995
+ delta: numAttr(calcPr, "iterateDelta") ?? 1e-3
3996
+ } : void 0;
3992
3997
  return {
3998
+ ...iterate ? { iterate } : {},
3993
3999
  ...password ? { workbookPasswordHash: password } : {},
3994
4000
  ...modernHash ? { workbookModernHash: modernHash } : {},
3995
4001
  ...calcMode === "manual" ? { calcMode: "manual" } : {},
@@ -6216,6 +6222,7 @@ async function loadXlsx(input) {
6216
6222
  if (book.workbookPasswordHash) workbook.workbookPasswordHash = book.workbookPasswordHash;
6217
6223
  if (book.workbookModernHash) workbook.workbookModernHash = book.workbookModernHash;
6218
6224
  if (book.calcMode) workbook.calcMode = book.calcMode;
6225
+ if (book.iterate) workbook.iterate = book.iterate;
6219
6226
  if (signatures.hasSignatures)
6220
6227
  workbook.signatures = { count: signatures.signatureCount, parts: signatures.signaturePaths };
6221
6228
  if (!sheets.length) throw new Error("XLSX workbook has no sheets");
@@ -10584,6 +10591,67 @@ var ENGINEERING_FUNCTIONS = [
10584
10591
  )
10585
10592
  ];
10586
10593
 
10594
+ // src/xlsx/formula/functions/coupons.ts
10595
+ var C8 = "Financial";
10596
+ function checkSecurity(settlement, maturity, frequency2, basis) {
10597
+ if (![1, 2, 4].includes(frequency2) || basis < 0 || basis > 4 || settlement >= maturity)
10598
+ fail(ERR.NUM);
10599
+ }
10600
+ function couponFacts(settlement, maturity, frequency2, basis, ctx) {
10601
+ const [s, m] = [Math.floor(settlement), Math.floor(maturity)];
10602
+ checkSecurity(s, m, frequency2, basis);
10603
+ const months = 12 / frequency2;
10604
+ const { year, month, day } = serialToYmd(m, ctx.date1904);
10605
+ const monthEnd = day === daysInMonth(year, month);
10606
+ let count2 = 0;
10607
+ let next = m;
10608
+ let previous = addMonths(m, -months, ctx, monthEnd);
10609
+ while (previous > s) {
10610
+ count2 += 1;
10611
+ next = previous;
10612
+ previous = addMonths(m, -months * (count2 + 1), ctx, monthEnd);
10613
+ }
10614
+ count2 += 1;
10615
+ const dayCount = (a, b, european) => basis === 0 || basis === 4 ? days360(a, b, basis === 4 || european, ctx) : b - a;
10616
+ const daysSincePrevious = dayCount(previous, s, false);
10617
+ const daysInPeriod = basis === 1 ? next - previous : basis === 3 ? 365 / frequency2 : 360 / frequency2;
10618
+ const daysToNext = basis === 0 ? daysInPeriod - daysSincePrevious : basis === 4 ? days360(s, next, true, ctx) : next - s;
10619
+ return { previous, next, count: count2, daysSincePrevious, daysInPeriod, daysToNext };
10620
+ }
10621
+ var security = (name, description, pick2) => spec(
10622
+ name,
10623
+ C8,
10624
+ `${name}(settlement, maturity, frequency, [basis])`,
10625
+ description,
10626
+ 3,
10627
+ 4,
10628
+ (args, ctx) => pick2(
10629
+ couponFacts(
10630
+ serialArg(args[0]),
10631
+ serialArg(args[1]),
10632
+ int3(args[2]),
10633
+ args.length > 3 && args[3] !== null ? int3(args[3]) : 0,
10634
+ ctx
10635
+ )
10636
+ )
10637
+ );
10638
+ var COUPON_FUNCTIONS = [
10639
+ security("COUPPCD", "The coupon date before the settlement date.", (f) => f.previous),
10640
+ security("COUPNCD", "The coupon date after the settlement date.", (f) => f.next),
10641
+ security("COUPNUM", "The number of coupons between settlement and maturity.", (f) => f.count),
10642
+ security(
10643
+ "COUPDAYBS",
10644
+ "The days from the start of the coupon period to settlement.",
10645
+ (f) => f.daysSincePrevious
10646
+ ),
10647
+ security(
10648
+ "COUPDAYS",
10649
+ "The days in the coupon period that contains the settlement date.",
10650
+ (f) => f.daysInPeriod
10651
+ ),
10652
+ security("COUPDAYSNC", "The days from settlement to the next coupon date.", (f) => f.daysToNext)
10653
+ ];
10654
+
10587
10655
  // src/xlsx/formula/functions/financial-core.ts
10588
10656
  function pmt(rate, nper, pv2, fv2 = 0, type = 0) {
10589
10657
  if (nper === 0) fail(ERR.NUM);
@@ -10653,12 +10721,185 @@ function cumulative(args, principal) {
10653
10721
  return total2;
10654
10722
  }
10655
10723
 
10724
+ // src/xlsx/formula/functions/bonds.ts
10725
+ var C9 = "Financial";
10726
+ var basisOf = (args, index2) => {
10727
+ const basis = args.length > index2 && args[index2] !== null ? int3(args[index2]) : 0;
10728
+ if (basis < 0 || basis > 4) fail(ERR.NUM);
10729
+ return basis;
10730
+ };
10731
+ function pricePerHundred(facts, rate, yld, redemption, frequency2) {
10732
+ const { count: n, daysSincePrevious: a, daysInPeriod: e, daysToNext: dsc } = facts;
10733
+ const coupon = 100 * rate / frequency2;
10734
+ const accrued = coupon * (a / e);
10735
+ if (n === 1) return (redemption + coupon) / (1 + dsc / e * yld / frequency2) - accrued;
10736
+ let price = redemption / (1 + yld / frequency2) ** (n - 1 + dsc / e);
10737
+ for (let k = 1; k <= n; k++) price += coupon / (1 + yld / frequency2) ** (k - 1 + dsc / e);
10738
+ return price - accrued;
10739
+ }
10740
+ function bondOf(args, ctx, redemptionAt, basisAt) {
10741
+ const frequency2 = int3(args[5]);
10742
+ const facts = couponFacts(
10743
+ serialArg(args[0]),
10744
+ serialArg(args[1]),
10745
+ frequency2,
10746
+ basisOf(args, basisAt),
10747
+ ctx
10748
+ );
10749
+ return { facts, rate: num2(args[2]), redemption: num2(args[redemptionAt]), frequency: frequency2 };
10750
+ }
10751
+ function duration(bond, yld) {
10752
+ const { facts, rate, frequency: frequency2 } = bond;
10753
+ const { count: n, daysInPeriod: e, daysToNext: dsc } = facts;
10754
+ const coupon = 100 * rate / frequency2;
10755
+ let weighted = 0;
10756
+ let total2 = 0;
10757
+ for (let k = 1; k <= n; k++) {
10758
+ const periods = k - 1 + dsc / e;
10759
+ const flow = k === n ? coupon + 100 : coupon;
10760
+ const value = flow / (1 + yld / frequency2) ** periods;
10761
+ weighted += periods / frequency2 * value;
10762
+ total2 += value;
10763
+ }
10764
+ return weighted / total2;
10765
+ }
10766
+ function quasiPeriods(anchor, from, to, frequency2, ctx) {
10767
+ const months = 12 / frequency2;
10768
+ const { year, month, day } = serialToYmd(anchor, ctx.date1904);
10769
+ const monthEnd = day === daysInMonth(year, month);
10770
+ const at = (k) => addMonths(anchor, k * months, ctx, monthEnd);
10771
+ let back = 0;
10772
+ while (at(back) > from) back -= 1;
10773
+ const dates = [];
10774
+ for (let k = back; ; k++) {
10775
+ dates.push(at(k));
10776
+ if (at(k) >= to) break;
10777
+ }
10778
+ return dates;
10779
+ }
10780
+ function accruedInterest(args, ctx) {
10781
+ const issue = serialArg(args[0]);
10782
+ const first3 = serialArg(args[1]);
10783
+ const settlement = serialArg(args[2]);
10784
+ const [rate, par] = [num2(args[3]), optNum(args, 4, 1e3)];
10785
+ const frequency2 = int3(args[5]);
10786
+ const basis = basisOf(args, 6);
10787
+ const fromIssue = args.length > 7 && args[7] !== null ? bool(args[7]) : true;
10788
+ if (rate <= 0 || par <= 0 || ![1, 2, 4].includes(frequency2) || issue >= settlement) fail(ERR.NUM);
10789
+ const start = fromIssue ? issue : Math.max(issue, first3);
10790
+ if (start >= settlement) return 0;
10791
+ const dates = quasiPeriods(first3, start, settlement, frequency2, ctx);
10792
+ const count2 = (a, b) => basis === 0 || basis === 4 ? days360(a, b, basis === 4, ctx) : b - a;
10793
+ let sum2 = 0;
10794
+ for (let i = 0; i + 1 < dates.length; i++) {
10795
+ const [p, q] = [dates[i], dates[i + 1]];
10796
+ const a = count2(Math.max(start, p), Math.min(settlement, q));
10797
+ if (a <= 0) continue;
10798
+ const length = basis === 1 ? q - p : basis === 3 ? 365 / frequency2 : 360 / frequency2;
10799
+ sum2 += a / length;
10800
+ }
10801
+ return par * rate / frequency2 * sum2;
10802
+ }
10803
+ var BOND_ARGS = (name, third, fourth, fifth) => `${name}(settlement, maturity, ${third}, ${fourth}, ${fifth}, frequency, [basis])`;
10804
+ var BOND_FUNCTIONS = [
10805
+ spec(
10806
+ "PRICE",
10807
+ C9,
10808
+ BOND_ARGS("PRICE", "rate", "yld", "redemption"),
10809
+ "The price per 100 face value of a security that pays periodic interest.",
10810
+ 6,
10811
+ 7,
10812
+ (args, ctx) => {
10813
+ const bond = bondOf(args, ctx, 4, 6);
10814
+ const yld = num2(args[3]);
10815
+ if (bond.rate < 0 || yld < 0 || bond.redemption <= 0) fail(ERR.NUM);
10816
+ return pricePerHundred(bond.facts, bond.rate, yld, bond.redemption, bond.frequency);
10817
+ }
10818
+ ),
10819
+ spec(
10820
+ "YIELD",
10821
+ C9,
10822
+ BOND_ARGS("YIELD", "rate", "pr", "redemption"),
10823
+ "The yield of a security that pays periodic interest.",
10824
+ 6,
10825
+ 7,
10826
+ (args, ctx) => {
10827
+ const bond = bondOf(args, ctx, 4, 6);
10828
+ const price = num2(args[3]);
10829
+ if (bond.rate < 0 || price <= 0 || bond.redemption <= 0) fail(ERR.NUM);
10830
+ const f = (y) => pricePerHundred(bond.facts, bond.rate, y, bond.redemption, bond.frequency) - price;
10831
+ return solve(f, bond.rate || 0.05);
10832
+ }
10833
+ ),
10834
+ ...["DURATION", "MDURATION"].map(
10835
+ (name) => spec(
10836
+ name,
10837
+ C9,
10838
+ `${name}(settlement, maturity, coupon, yld, frequency, [basis])`,
10839
+ name === "DURATION" ? "The Macaulay duration of a security with periodic interest." : "The modified Macaulay duration of a security.",
10840
+ 5,
10841
+ 6,
10842
+ (args, ctx) => {
10843
+ const frequency2 = int3(args[4]);
10844
+ const facts = couponFacts(
10845
+ serialArg(args[0]),
10846
+ serialArg(args[1]),
10847
+ frequency2,
10848
+ basisOf(args, 5),
10849
+ ctx
10850
+ );
10851
+ const [rate, yld] = [num2(args[2]), num2(args[3])];
10852
+ if (rate < 0 || yld < 0) fail(ERR.NUM);
10853
+ const macaulay = duration({ facts, rate, frequency: frequency2 }, yld);
10854
+ return name === "DURATION" ? macaulay : macaulay / (1 + yld / frequency2);
10855
+ }
10856
+ )
10857
+ ),
10858
+ spec(
10859
+ "ACCRINT",
10860
+ C9,
10861
+ "ACCRINT(issue, first_interest, settlement, rate, par, frequency, [basis], [calc_method])",
10862
+ "The accrued interest of a security that pays periodic interest.",
10863
+ 6,
10864
+ 8,
10865
+ (args, ctx) => accruedInterest(args, ctx)
10866
+ ),
10867
+ spec(
10868
+ "ACCRINTM",
10869
+ C9,
10870
+ "ACCRINTM(issue, settlement, rate, [par], [basis])",
10871
+ "The accrued interest of a security that pays interest at maturity.",
10872
+ 3,
10873
+ 5,
10874
+ (args, ctx) => {
10875
+ const [issue, settlement] = [serialArg(args[0]), serialArg(args[1])];
10876
+ const [rate, par] = [num2(args[2]), optNum(args, 3, 1e3)];
10877
+ if (rate <= 0 || par <= 0 || issue >= settlement) fail(ERR.NUM);
10878
+ return par * rate * yearFrac(issue, settlement, basisOf(args, 4), ctx);
10879
+ }
10880
+ )
10881
+ ];
10882
+
10656
10883
  // src/xlsx/formula/functions/depreciation.ts
10657
- var C8 = "Financial";
10884
+ var C10 = "Financial";
10885
+ function variableDeclining(cost, salvage, life, start, end, factor, noSwitch) {
10886
+ let book = cost;
10887
+ let total2 = 0;
10888
+ for (let period = 1; period - 1 < end; period++) {
10889
+ const declining = book * factor / life;
10890
+ const straight = (book - salvage) / Math.max(life - (period - 1), 1);
10891
+ const wanted = noSwitch ? declining : Math.max(declining, straight);
10892
+ const dep = Math.max(0, Math.min(wanted, book - salvage));
10893
+ const covered = Math.min(end, period) - Math.max(start, period - 1);
10894
+ if (covered > 0) total2 += dep * Math.min(covered, 1);
10895
+ book -= dep;
10896
+ }
10897
+ return total2;
10898
+ }
10658
10899
  var DEPRECIATION_FUNCTIONS = [
10659
10900
  numeric(
10660
10901
  "SLN",
10661
- C8,
10902
+ C10,
10662
10903
  "SLN(cost, salvage, life)",
10663
10904
  "Straight-line depreciation.",
10664
10905
  3,
@@ -10667,7 +10908,7 @@ var DEPRECIATION_FUNCTIONS = [
10667
10908
  ),
10668
10909
  numeric(
10669
10910
  "SYD",
10670
- C8,
10911
+ C10,
10671
10912
  "SYD(cost, salvage, life, per)",
10672
10913
  "Sum-of-years' digits depreciation.",
10673
10914
  4,
@@ -10679,7 +10920,7 @@ var DEPRECIATION_FUNCTIONS = [
10679
10920
  ),
10680
10921
  numeric(
10681
10922
  "DDB",
10682
- C8,
10923
+ C10,
10683
10924
  "DDB(cost, salvage, life, period, [factor])",
10684
10925
  "Double-declining balance depreciation.",
10685
10926
  4,
@@ -10695,9 +10936,33 @@ var DEPRECIATION_FUNCTIONS = [
10695
10936
  return dep;
10696
10937
  }
10697
10938
  ),
10939
+ spec(
10940
+ "VDB",
10941
+ C10,
10942
+ "VDB(cost, salvage, life, start_period, end_period, [factor], [no_switch])",
10943
+ "Depreciation over any span of periods, switching to straight-line when that is larger.",
10944
+ 5,
10945
+ 7,
10946
+ (args) => {
10947
+ const [cost, salvage, life, start, end] = [0, 1, 2, 3, 4].map((i) => num2(args[i]));
10948
+ const factor = args.length > 5 && args[5] !== null ? num2(args[5]) : 2;
10949
+ const noSwitch = args.length > 6 && args[6] !== null ? bool(args[6]) : false;
10950
+ 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)
10951
+ fail(ERR.NUM);
10952
+ return variableDeclining(
10953
+ cost,
10954
+ salvage,
10955
+ life,
10956
+ start,
10957
+ end,
10958
+ factor,
10959
+ noSwitch
10960
+ );
10961
+ }
10962
+ ),
10698
10963
  numeric(
10699
10964
  "DB",
10700
- C8,
10965
+ C10,
10701
10966
  "DB(cost, salvage, life, period, [month])",
10702
10967
  "Fixed-declining balance depreciation.",
10703
10968
  4,
@@ -10720,7 +10985,7 @@ var DEPRECIATION_FUNCTIONS = [
10720
10985
  ),
10721
10986
  numeric(
10722
10987
  "EFFECT",
10723
- C8,
10988
+ C10,
10724
10989
  "EFFECT(nominal_rate, npery)",
10725
10990
  "The effective annual interest rate.",
10726
10991
  2,
@@ -10733,7 +10998,7 @@ var DEPRECIATION_FUNCTIONS = [
10733
10998
  ),
10734
10999
  numeric(
10735
11000
  "NOMINAL",
10736
- C8,
11001
+ C10,
10737
11002
  "NOMINAL(effect_rate, npery)",
10738
11003
  "The nominal annual interest rate.",
10739
11004
  2,
@@ -10746,7 +11011,7 @@ var DEPRECIATION_FUNCTIONS = [
10746
11011
  ),
10747
11012
  numeric(
10748
11013
  "CUMIPMT",
10749
- C8,
11014
+ C10,
10750
11015
  "CUMIPMT(rate, nper, pv, start_period, end_period, type)",
10751
11016
  "Cumulative interest paid between periods.",
10752
11017
  6,
@@ -10755,7 +11020,7 @@ var DEPRECIATION_FUNCTIONS = [
10755
11020
  ),
10756
11021
  numeric(
10757
11022
  "CUMPRINC",
10758
- C8,
11023
+ C10,
10759
11024
  "CUMPRINC(rate, nper, pv, start_period, end_period, type)",
10760
11025
  "Cumulative principal paid between periods.",
10761
11026
  6,
@@ -10764,7 +11029,7 @@ var DEPRECIATION_FUNCTIONS = [
10764
11029
  ),
10765
11030
  numeric(
10766
11031
  "ISPMT",
10767
- C8,
11032
+ C10,
10768
11033
  "ISPMT(rate, per, nper, pv)",
10769
11034
  "Interest paid in a period of a straight-line loan.",
10770
11035
  4,
@@ -10776,7 +11041,7 @@ var DEPRECIATION_FUNCTIONS = [
10776
11041
  ),
10777
11042
  numeric(
10778
11043
  "PDURATION",
10779
- C8,
11044
+ C10,
10780
11045
  "PDURATION(rate, pv, fv)",
10781
11046
  "Periods required to reach a value.",
10782
11047
  3,
@@ -10788,7 +11053,7 @@ var DEPRECIATION_FUNCTIONS = [
10788
11053
  ),
10789
11054
  numeric(
10790
11055
  "RRI",
10791
- C8,
11056
+ C10,
10792
11057
  "RRI(nper, pv, fv)",
10793
11058
  "An equivalent interest rate for growth.",
10794
11059
  3,
@@ -10800,7 +11065,7 @@ var DEPRECIATION_FUNCTIONS = [
10800
11065
  ),
10801
11066
  spec(
10802
11067
  "FVSCHEDULE",
10803
- C8,
11068
+ C10,
10804
11069
  "FVSCHEDULE(principal, schedule)",
10805
11070
  "Future value with a schedule of rates.",
10806
11071
  2,
@@ -10810,7 +11075,7 @@ var DEPRECIATION_FUNCTIONS = [
10810
11075
  ),
10811
11076
  numeric(
10812
11077
  "DOLLARDE",
10813
- C8,
11078
+ C10,
10814
11079
  "DOLLARDE(fractional_dollar, fraction)",
10815
11080
  "Converts a fractional price to a decimal.",
10816
11081
  2,
@@ -10826,7 +11091,7 @@ var DEPRECIATION_FUNCTIONS = [
10826
11091
  ),
10827
11092
  numeric(
10828
11093
  "DOLLARFR",
10829
- C8,
11094
+ C10,
10830
11095
  "DOLLARFR(decimal_dollar, fraction)",
10831
11096
  "Converts a decimal price to a fraction.",
10832
11097
  2,
@@ -10842,8 +11107,141 @@ var DEPRECIATION_FUNCTIONS = [
10842
11107
  )
10843
11108
  ];
10844
11109
 
11110
+ // src/xlsx/formula/functions/securities.ts
11111
+ var C11 = "Financial";
11112
+ var basisOf2 = (args, index2) => {
11113
+ const basis = args.length > index2 && args[index2] !== null ? int3(args[index2]) : 0;
11114
+ if (basis < 0 || basis > 4) fail(ERR.NUM);
11115
+ return basis;
11116
+ };
11117
+ function span(args) {
11118
+ const [s, m] = [Math.floor(serialArg(args[0])), Math.floor(serialArg(args[1]))];
11119
+ if (s >= m) fail(ERR.NUM);
11120
+ return { s, m };
11121
+ }
11122
+ var positive = (...values2) => {
11123
+ for (const v of values2) if (!(v > 0)) fail(ERR.NUM);
11124
+ };
11125
+ var discount = (name, description, syntax, fn) => spec(name, C11, syntax, description, 4, 5, (args, ctx) => {
11126
+ const { s, m } = span(args);
11127
+ const [a, b] = [num2(args[2]), num2(args[3])];
11128
+ positive(a, b);
11129
+ return fn(a, b, yearFrac(s, m, basisOf2(args, 4), ctx));
11130
+ });
11131
+ var atMaturity = (name, description, syntax, fn) => spec(name, C11, syntax, description, 5, 6, (args, ctx) => {
11132
+ const { s, m } = span(args);
11133
+ const issue = Math.floor(serialArg(args[2]));
11134
+ const [rate, other] = [num2(args[3]), num2(args[4])];
11135
+ const basis = basisOf2(args, 5);
11136
+ if (issue > s || rate < 0 || other < 0) fail(ERR.NUM);
11137
+ return fn(
11138
+ rate,
11139
+ other,
11140
+ yearFrac(issue, m, basis, ctx),
11141
+ yearFrac(issue, s, basis, ctx),
11142
+ yearFrac(s, m, basis, ctx)
11143
+ );
11144
+ });
11145
+ function billDays(args) {
11146
+ const { s, m } = span(args);
11147
+ const days = m - s;
11148
+ if (days > 365) fail(ERR.NUM);
11149
+ return days;
11150
+ }
11151
+ var SECURITY_FUNCTIONS = [
11152
+ discount(
11153
+ "DISC",
11154
+ "The discount rate of a security.",
11155
+ "DISC(settlement, maturity, pr, redemption, [basis])",
11156
+ (pr, redemption, f) => (redemption - pr) / redemption / f
11157
+ ),
11158
+ discount(
11159
+ "PRICEDISC",
11160
+ "The price per 100 face value of a discounted security.",
11161
+ "PRICEDISC(settlement, maturity, discount, redemption, [basis])",
11162
+ (rate, redemption, f) => redemption - rate * redemption * f
11163
+ ),
11164
+ discount(
11165
+ "YIELDDISC",
11166
+ "The annual yield of a discounted security.",
11167
+ "YIELDDISC(settlement, maturity, pr, redemption, [basis])",
11168
+ (pr, redemption, f) => (redemption - pr) / pr / f
11169
+ ),
11170
+ discount(
11171
+ "INTRATE",
11172
+ "The interest rate of a fully invested security.",
11173
+ "INTRATE(settlement, maturity, investment, redemption, [basis])",
11174
+ (investment, redemption, f) => (redemption - investment) / investment / f
11175
+ ),
11176
+ discount(
11177
+ "RECEIVED",
11178
+ "The amount received at maturity for a fully invested security.",
11179
+ "RECEIVED(settlement, maturity, investment, discount, [basis])",
11180
+ (investment, rate, f) => investment / (1 - rate * f)
11181
+ ),
11182
+ atMaturity(
11183
+ "PRICEMAT",
11184
+ "The price per 100 face value of a security that pays interest at maturity.",
11185
+ "PRICEMAT(settlement, maturity, issue, rate, yld, [basis])",
11186
+ (rate, yld, dim, a, dsm) => (100 + dim * rate * 100) / (1 + dsm * yld) - a * rate * 100
11187
+ ),
11188
+ atMaturity(
11189
+ "YIELDMAT",
11190
+ "The annual yield of a security that pays interest at maturity.",
11191
+ "YIELDMAT(settlement, maturity, issue, rate, pr, [basis])",
11192
+ (rate, price, dim, a, dsm) => (1 + dim * rate - (price / 100 + a * rate)) / (price / 100 + a * rate) / dsm
11193
+ ),
11194
+ spec(
11195
+ "TBILLPRICE",
11196
+ C11,
11197
+ "TBILLPRICE(settlement, maturity, discount)",
11198
+ "The price per 100 face value of a Treasury bill.",
11199
+ 3,
11200
+ 3,
11201
+ (args) => {
11202
+ const days = billDays(args);
11203
+ const rate = num2(args[2]);
11204
+ positive(rate);
11205
+ const price = 100 * (1 - rate * days / 360);
11206
+ return price > 0 ? price : fail(ERR.NUM);
11207
+ }
11208
+ ),
11209
+ spec(
11210
+ "TBILLYIELD",
11211
+ C11,
11212
+ "TBILLYIELD(settlement, maturity, pr)",
11213
+ "The yield of a Treasury bill.",
11214
+ 3,
11215
+ 3,
11216
+ (args) => {
11217
+ const days = billDays(args);
11218
+ const price = num2(args[2]);
11219
+ positive(price);
11220
+ return (100 - price) / price * (360 / days);
11221
+ }
11222
+ ),
11223
+ spec(
11224
+ "TBILLEQ",
11225
+ C11,
11226
+ "TBILLEQ(settlement, maturity, discount)",
11227
+ "The bond-equivalent yield of a Treasury bill.",
11228
+ 3,
11229
+ 3,
11230
+ (args) => {
11231
+ const days = billDays(args);
11232
+ const rate = num2(args[2]);
11233
+ positive(rate);
11234
+ if (days <= 182) return 365 * rate / (360 - rate * days);
11235
+ const price = 100 - rate * 100 * (days / 360);
11236
+ const t = days / 365;
11237
+ const root = Math.sqrt(t * t - (2 * t - 1) * (1 - 100 / price));
11238
+ return (-t + root) / (t - 0.5);
11239
+ }
11240
+ )
11241
+ ];
11242
+
10845
11243
  // src/xlsx/formula/functions/financial.ts
10846
- var C9 = "Financial";
11244
+ var C12 = "Financial";
10847
11245
  var npv = (rate, values2) => values2.reduce((acc, v, i) => acc + v / Math.pow(1 + rate, i + 1), 0);
10848
11246
  function datedFlows(ctx, args) {
10849
11247
  const values2 = collectNumbers(ctx, [args[0] ?? null]);
@@ -10859,9 +11257,12 @@ var xnpv = (rate, values2, dates) => values2.reduce(
10859
11257
  );
10860
11258
  var FINANCIAL_FUNCTIONS = [
10861
11259
  ...DEPRECIATION_FUNCTIONS,
11260
+ ...COUPON_FUNCTIONS,
11261
+ ...BOND_FUNCTIONS,
11262
+ ...SECURITY_FUNCTIONS,
10862
11263
  numeric(
10863
11264
  "PMT",
10864
- C9,
11265
+ C12,
10865
11266
  "PMT(rate, nper, pv, [fv], [type])",
10866
11267
  "The payment for a loan.",
10867
11268
  3,
@@ -10870,7 +11271,7 @@ var FINANCIAL_FUNCTIONS = [
10870
11271
  ),
10871
11272
  numeric(
10872
11273
  "FV",
10873
- C9,
11274
+ C12,
10874
11275
  "FV(rate, nper, pmt, [pv], [type])",
10875
11276
  "The future value of an investment.",
10876
11277
  3,
@@ -10879,7 +11280,7 @@ var FINANCIAL_FUNCTIONS = [
10879
11280
  ),
10880
11281
  numeric(
10881
11282
  "PV",
10882
- C9,
11283
+ C12,
10883
11284
  "PV(rate, nper, pmt, [fv], [type])",
10884
11285
  "The present value of an investment.",
10885
11286
  3,
@@ -10888,7 +11289,7 @@ var FINANCIAL_FUNCTIONS = [
10888
11289
  ),
10889
11290
  numeric(
10890
11291
  "NPER",
10891
- C9,
11292
+ C12,
10892
11293
  "NPER(rate, pmt, pv, [fv], [type])",
10893
11294
  "The number of periods for an investment.",
10894
11295
  3,
@@ -10905,7 +11306,7 @@ var FINANCIAL_FUNCTIONS = [
10905
11306
  ),
10906
11307
  numeric(
10907
11308
  "IPMT",
10908
- C9,
11309
+ C12,
10909
11310
  "IPMT(rate, per, nper, pv, [fv], [type])",
10910
11311
  "The interest part of a payment.",
10911
11312
  4,
@@ -10914,7 +11315,7 @@ var FINANCIAL_FUNCTIONS = [
10914
11315
  ),
10915
11316
  numeric(
10916
11317
  "PPMT",
10917
- C9,
11318
+ C12,
10918
11319
  "PPMT(rate, per, nper, pv, [fv], [type])",
10919
11320
  "The principal part of a payment.",
10920
11321
  4,
@@ -10923,7 +11324,7 @@ var FINANCIAL_FUNCTIONS = [
10923
11324
  ),
10924
11325
  numeric(
10925
11326
  "RATE",
10926
- C9,
11327
+ C12,
10927
11328
  "RATE(nper, pmt, pv, [fv], [type], [guess])",
10928
11329
  "The interest rate per period.",
10929
11330
  3,
@@ -10936,7 +11337,7 @@ var FINANCIAL_FUNCTIONS = [
10936
11337
  ),
10937
11338
  spec(
10938
11339
  "NPV",
10939
- C9,
11340
+ C12,
10940
11341
  "NPV(rate, value1, [value2], ...)",
10941
11342
  "The net present value of cash flows.",
10942
11343
  2,
@@ -10946,7 +11347,7 @@ var FINANCIAL_FUNCTIONS = [
10946
11347
  ),
10947
11348
  spec(
10948
11349
  "IRR",
10949
- C9,
11350
+ C12,
10950
11351
  "IRR(values, [guess])",
10951
11352
  "The internal rate of return.",
10952
11353
  1,
@@ -10963,7 +11364,7 @@ var FINANCIAL_FUNCTIONS = [
10963
11364
  ),
10964
11365
  spec(
10965
11366
  "XNPV",
10966
- C9,
11367
+ C12,
10967
11368
  "XNPV(rate, values, dates)",
10968
11369
  "The net present value of dated cash flows.",
10969
11370
  3,
@@ -10976,7 +11377,7 @@ var FINANCIAL_FUNCTIONS = [
10976
11377
  ),
10977
11378
  spec(
10978
11379
  "XIRR",
10979
- C9,
11380
+ C12,
10980
11381
  "XIRR(values, dates, [guess])",
10981
11382
  "The internal rate of return of dated cash flows.",
10982
11383
  2,
@@ -10990,7 +11391,7 @@ var FINANCIAL_FUNCTIONS = [
10990
11391
  ),
10991
11392
  spec(
10992
11393
  "MIRR",
10993
- C9,
11394
+ C12,
10994
11395
  "MIRR(values, finance_rate, reinvest_rate)",
10995
11396
  "The modified internal rate of return.",
10996
11397
  3,
@@ -11000,9 +11401,9 @@ var FINANCIAL_FUNCTIONS = [
11000
11401
  const finance = num2(args[1]);
11001
11402
  const reinvest = num2(args[2]);
11002
11403
  const n = values2.length;
11003
- const positive2 = values2.map((v) => v > 0 ? v : 0);
11404
+ const positive3 = values2.map((v) => v > 0 ? v : 0);
11004
11405
  const negative = values2.map((v) => v < 0 ? v : 0);
11005
- const fvPos = positive2.reduce((acc, v, i) => acc + v * Math.pow(1 + reinvest, n - 1 - i), 0);
11406
+ const fvPos = positive3.reduce((acc, v, i) => acc + v * Math.pow(1 + reinvest, n - 1 - i), 0);
11006
11407
  const pvNeg = negative.reduce((acc, v, i) => acc + v / Math.pow(1 + finance, i), 0);
11007
11408
  if (fvPos === 0 || pvNeg === 0) fail(ERR.DIV0);
11008
11409
  return Math.pow(-fvPos / pvNeg, 1 / (n - 1)) - 1;
@@ -11018,7 +11419,7 @@ function sheetIndex(host, name) {
11018
11419
  }
11019
11420
 
11020
11421
  // src/xlsx/formula/functions/info.ts
11021
- var C10 = "Information";
11422
+ var C13 = "Information";
11022
11423
  var ERROR_NUMBERS = {
11023
11424
  "#NULL!": 1,
11024
11425
  "#DIV/0!": 2,
@@ -11031,7 +11432,7 @@ var ERROR_NUMBERS = {
11031
11432
  "#SPILL!": 9,
11032
11433
  "#CALC!": 14
11033
11434
  };
11034
- var is = (name, syntax, description, test) => spec(name, C10, syntax, description, 1, 1, (args) => test(scalar(args[0])));
11435
+ var is = (name, syntax, description, test) => spec(name, C13, syntax, description, 1, 1, (args) => test(scalar(args[0])));
11035
11436
  var parity = (v, odd) => {
11036
11437
  if (isError(v)) fail(v);
11037
11438
  if (typeof v === "boolean") fail(ERR.VALUE);
@@ -11068,7 +11469,7 @@ var INFO_FUNCTIONS = [
11068
11469
  is("ISODD", "ISODD(number)", "TRUE for odd numbers.", (v) => parity(v, true)),
11069
11470
  spec(
11070
11471
  "ISREF",
11071
- C10,
11472
+ C13,
11072
11473
  "ISREF(value)",
11073
11474
  "TRUE for references.",
11074
11475
  1,
@@ -11078,7 +11479,7 @@ var INFO_FUNCTIONS = [
11078
11479
  ),
11079
11480
  spec(
11080
11481
  "ISFORMULA",
11081
- C10,
11482
+ C13,
11082
11483
  "ISFORMULA(reference)",
11083
11484
  "TRUE when a cell holds a formula.",
11084
11485
  1,
@@ -11092,17 +11493,17 @@ var INFO_FUNCTIONS = [
11092
11493
  },
11093
11494
  ["any"]
11094
11495
  ),
11095
- spec("N", C10, "N(value)", "A value converted to a number (text is 0).", 1, 1, (args) => {
11496
+ spec("N", C13, "N(value)", "A value converted to a number (text is 0).", 1, 1, (args) => {
11096
11497
  const v = scalar(args[0]);
11097
11498
  if (isError(v)) return v;
11098
11499
  if (typeof v === "number") return v;
11099
11500
  if (typeof v === "boolean") return v ? 1 : 0;
11100
11501
  return 0;
11101
11502
  }),
11102
- spec("NA", C10, "NA()", "The #N/A error value.", 0, 0, () => ERR.NA),
11503
+ spec("NA", C13, "NA()", "The #N/A error value.", 0, 0, () => ERR.NA),
11103
11504
  spec(
11104
11505
  "TYPE",
11105
- C10,
11506
+ C13,
11106
11507
  "TYPE(value)",
11107
11508
  "The type of a value: 1 number, 2 text, 4 logical, 16 error, 64 array.",
11108
11509
  1,
@@ -11114,13 +11515,13 @@ var INFO_FUNCTIONS = [
11114
11515
  },
11115
11516
  ["any"]
11116
11517
  ),
11117
- spec("ERROR.TYPE", C10, "ERROR.TYPE(error_val)", "The number of an error value.", 1, 1, (args) => {
11518
+ spec("ERROR.TYPE", C13, "ERROR.TYPE(error_val)", "The number of an error value.", 1, 1, (args) => {
11118
11519
  const v = scalar(args[0]);
11119
11520
  return isError(v) ? ERROR_NUMBERS[v.error] ?? ERR.NA : ERR.NA;
11120
11521
  }),
11121
11522
  spec(
11122
11523
  "SHEET",
11123
- C10,
11524
+ C13,
11124
11525
  "SHEET([value])",
11125
11526
  "The sheet number of a reference or sheet name.",
11126
11527
  0,
@@ -11136,7 +11537,7 @@ var INFO_FUNCTIONS = [
11136
11537
  ),
11137
11538
  spec(
11138
11539
  "SHEETS",
11139
- C10,
11540
+ C13,
11140
11541
  "SHEETS([reference])",
11141
11542
  "The number of sheets in a reference (or the workbook).",
11142
11543
  0,
@@ -11151,7 +11552,7 @@ var INFO_FUNCTIONS = [
11151
11552
  ),
11152
11553
  spec(
11153
11554
  "CELL",
11154
- C10,
11555
+ C13,
11155
11556
  "CELL(info_type, [reference])",
11156
11557
  "Information about a cell (address, row, col, contents, type, filename, sheet).",
11157
11558
  1,
@@ -11237,7 +11638,7 @@ function broadcastShape(operands, at) {
11237
11638
  }
11238
11639
 
11239
11640
  // src/xlsx/formula/functions/lambda.ts
11240
- var C11 = "Logical";
11641
+ var C14 = "Logical";
11241
11642
  function lambdaArg(value) {
11242
11643
  if (!(value instanceof LambdaValue)) fail(ERR.VALUE);
11243
11644
  return value;
@@ -11254,7 +11655,7 @@ function element(ctx, value) {
11254
11655
  var LAMBDA_HELPERS = [
11255
11656
  spec(
11256
11657
  "MAP",
11257
- C11,
11658
+ C14,
11258
11659
  "MAP(array1, ..., lambda)",
11259
11660
  "Applies a LAMBDA to each value of arrays.",
11260
11661
  2,
@@ -11280,7 +11681,7 @@ var LAMBDA_HELPERS = [
11280
11681
  ),
11281
11682
  spec(
11282
11683
  "REDUCE",
11283
- C11,
11684
+ C14,
11284
11685
  "REDUCE([initial_value], array, lambda)",
11285
11686
  "Reduces an array to an accumulated value.",
11286
11687
  2,
@@ -11296,7 +11697,7 @@ var LAMBDA_HELPERS = [
11296
11697
  ),
11297
11698
  spec(
11298
11699
  "SCAN",
11299
- C11,
11700
+ C14,
11300
11701
  "SCAN([initial_value], array, lambda)",
11301
11702
  "The intermediate values of a reduction, as an array.",
11302
11703
  2,
@@ -11314,7 +11715,7 @@ var LAMBDA_HELPERS = [
11314
11715
  ),
11315
11716
  spec(
11316
11717
  "BYROW",
11317
- C11,
11718
+ C14,
11318
11719
  "BYROW(array, lambda)",
11319
11720
  "Applies a LAMBDA to each row, returning a column.",
11320
11721
  2,
@@ -11330,7 +11731,7 @@ var LAMBDA_HELPERS = [
11330
11731
  ),
11331
11732
  spec(
11332
11733
  "BYCOL",
11333
- C11,
11734
+ C14,
11334
11735
  "BYCOL(array, lambda)",
11335
11736
  "Applies a LAMBDA to each column, returning a row.",
11336
11737
  2,
@@ -11349,7 +11750,7 @@ var LAMBDA_HELPERS = [
11349
11750
  ),
11350
11751
  spec(
11351
11752
  "MAKEARRAY",
11352
- C11,
11753
+ C14,
11353
11754
  "MAKEARRAY(rows, columns, lambda)",
11354
11755
  "An array built by calling a LAMBDA for each position.",
11355
11756
  3,
@@ -11366,7 +11767,7 @@ var LAMBDA_HELPERS = [
11366
11767
  ];
11367
11768
 
11368
11769
  // src/xlsx/formula/functions/logical.ts
11369
- var C12 = "Logical";
11770
+ var C15 = "Logical";
11370
11771
  function deref(ctx, value) {
11371
11772
  if (value instanceof RefValue) {
11372
11773
  if (value.isCell()) {
@@ -11436,7 +11837,7 @@ function logicalValues(ctx, args) {
11436
11837
  if (out.length === 0) fail(ERR.VALUE);
11437
11838
  return out;
11438
11839
  }
11439
- var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category = C12) => ({ name, category, syntax, description, minArgs, maxArgs, lazy });
11840
+ var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category = C15) => ({ name, category, syntax, description, minArgs, maxArgs, lazy });
11440
11841
  function localName(arg) {
11441
11842
  const node = arg?.node;
11442
11843
  if (!node || node.type !== "name" || node.prefix) fail(ERR.VALUE);
@@ -11530,7 +11931,7 @@ var LOGICAL_FUNCTIONS = [
11530
11931
  ),
11531
11932
  {
11532
11933
  name: "NOT",
11533
- category: C12,
11934
+ category: C15,
11534
11935
  syntax: "NOT(logical)",
11535
11936
  description: "Reverses a logical value.",
11536
11937
  minArgs: 1,
@@ -11539,7 +11940,7 @@ var LOGICAL_FUNCTIONS = [
11539
11940
  },
11540
11941
  {
11541
11942
  name: "TRUE",
11542
- category: C12,
11943
+ category: C15,
11543
11944
  syntax: "TRUE()",
11544
11945
  description: "The logical value TRUE.",
11545
11946
  minArgs: 0,
@@ -11548,7 +11949,7 @@ var LOGICAL_FUNCTIONS = [
11548
11949
  },
11549
11950
  {
11550
11951
  name: "FALSE",
11551
- category: C12,
11952
+ category: C15,
11552
11953
  syntax: "FALSE()",
11553
11954
  description: "The logical value FALSE.",
11554
11955
  minArgs: 0,
@@ -11746,7 +12147,7 @@ function xsearch(vector, lookup2, matchMode, searchMode) {
11746
12147
  }
11747
12148
 
11748
12149
  // src/xlsx/formula/functions/reference.ts
11749
- var C13 = "Lookup & Reference";
12150
+ var C16 = "Lookup & Reference";
11750
12151
  function refArg(value) {
11751
12152
  if (value instanceof RefValue) return value;
11752
12153
  if (isError(value)) fail(value);
@@ -11835,7 +12236,7 @@ function rowsOrCols(value, ctx, axis) {
11835
12236
  var REFERENCE_FUNCTIONS = [
11836
12237
  spec(
11837
12238
  "OFFSET",
11838
- C13,
12239
+ C16,
11839
12240
  "OFFSET(reference, rows, cols, [height], [width])",
11840
12241
  "A reference offset from a starting reference.",
11841
12242
  3,
@@ -11846,7 +12247,7 @@ var REFERENCE_FUNCTIONS = [
11846
12247
  ),
11847
12248
  spec(
11848
12249
  "INDIRECT",
11849
- C13,
12250
+ C16,
11850
12251
  "INDIRECT(ref_text, [a1])",
11851
12252
  "The reference named by a text.",
11852
12253
  1,
@@ -11862,7 +12263,7 @@ var REFERENCE_FUNCTIONS = [
11862
12263
  ),
11863
12264
  spec(
11864
12265
  "ROW",
11865
- C13,
12266
+ C16,
11866
12267
  "ROW([reference])",
11867
12268
  "The row number of a reference.",
11868
12269
  0,
@@ -11872,7 +12273,7 @@ var REFERENCE_FUNCTIONS = [
11872
12273
  ),
11873
12274
  spec(
11874
12275
  "COLUMN",
11875
- C13,
12276
+ C16,
11876
12277
  "COLUMN([reference])",
11877
12278
  "The column number of a reference.",
11878
12279
  0,
@@ -11882,7 +12283,7 @@ var REFERENCE_FUNCTIONS = [
11882
12283
  ),
11883
12284
  spec(
11884
12285
  "ROWS",
11885
- C13,
12286
+ C16,
11886
12287
  "ROWS(array)",
11887
12288
  "The number of rows in a reference or array.",
11888
12289
  1,
@@ -11895,7 +12296,7 @@ var REFERENCE_FUNCTIONS = [
11895
12296
  ),
11896
12297
  spec(
11897
12298
  "COLUMNS",
11898
- C13,
12299
+ C16,
11899
12300
  "COLUMNS(array)",
11900
12301
  "The number of columns in a reference or array.",
11901
12302
  1,
@@ -11908,7 +12309,7 @@ var REFERENCE_FUNCTIONS = [
11908
12309
  ),
11909
12310
  spec(
11910
12311
  "AREAS",
11911
- C13,
12312
+ C16,
11912
12313
  "AREAS(reference)",
11913
12314
  "The number of areas in a reference.",
11914
12315
  1,
@@ -11918,7 +12319,7 @@ var REFERENCE_FUNCTIONS = [
11918
12319
  ),
11919
12320
  spec(
11920
12321
  "ADDRESS",
11921
- C13,
12322
+ C16,
11922
12323
  "ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])",
11923
12324
  "A cell address as text.",
11924
12325
  2,
@@ -11927,7 +12328,7 @@ var REFERENCE_FUNCTIONS = [
11927
12328
  ),
11928
12329
  spec(
11929
12330
  "HYPERLINK",
11930
- C13,
12331
+ C16,
11931
12332
  "HYPERLINK(link_location, [friendly_name])",
11932
12333
  "A link; the cell shows the friendly name.",
11933
12334
  1,
@@ -11936,7 +12337,7 @@ var REFERENCE_FUNCTIONS = [
11936
12337
  ),
11937
12338
  spec(
11938
12339
  "ANCHORARRAY",
11939
- C13,
12340
+ C16,
11940
12341
  "ANCHORARRAY(reference)",
11941
12342
  "The spill range of a dynamic array formula (A1#).",
11942
12343
  1,
@@ -11956,7 +12357,7 @@ var REFERENCE_FUNCTIONS = [
11956
12357
  ),
11957
12358
  spec(
11958
12359
  "SINGLE",
11959
- C13,
12360
+ C16,
11960
12361
  "SINGLE(value)",
11961
12362
  "Implicit intersection (the @ operator).",
11962
12363
  1,
@@ -11966,7 +12367,7 @@ var REFERENCE_FUNCTIONS = [
11966
12367
  ),
11967
12368
  spec(
11968
12369
  "FORMULATEXT",
11969
- C13,
12370
+ C16,
11970
12371
  "FORMULATEXT(reference)",
11971
12372
  "The formula of a cell as text.",
11972
12373
  1,
@@ -11986,7 +12387,7 @@ var REFERENCE_FUNCTIONS = [
11986
12387
  ];
11987
12388
 
11988
12389
  // src/xlsx/formula/functions/lookup.ts
11989
- var C14 = "Lookup & Reference";
12390
+ var C17 = "Lookup & Reference";
11990
12391
  function cellOf(value, row2, col) {
11991
12392
  if (value instanceof RefValue) {
11992
12393
  const area = value.areas[0];
@@ -12113,7 +12514,7 @@ var LOOKUP_FUNCTIONS = [
12113
12514
  ...REFERENCE_FUNCTIONS,
12114
12515
  spec(
12115
12516
  "VLOOKUP",
12116
- C14,
12517
+ C17,
12117
12518
  "VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])",
12118
12519
  "Looks up a value in the first column of a table.",
12119
12520
  3,
@@ -12123,7 +12524,7 @@ var LOOKUP_FUNCTIONS = [
12123
12524
  ),
12124
12525
  spec(
12125
12526
  "HLOOKUP",
12126
- C14,
12527
+ C17,
12127
12528
  "HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])",
12128
12529
  "Looks up a value in the first row of a table.",
12129
12530
  3,
@@ -12133,7 +12534,7 @@ var LOOKUP_FUNCTIONS = [
12133
12534
  ),
12134
12535
  spec(
12135
12536
  "LOOKUP",
12136
- C14,
12537
+ C17,
12137
12538
  "LOOKUP(lookup_value, lookup_vector, [result_vector])",
12138
12539
  "Looks up a value in a sorted vector or array.",
12139
12540
  2,
@@ -12143,7 +12544,7 @@ var LOOKUP_FUNCTIONS = [
12143
12544
  ),
12144
12545
  spec(
12145
12546
  "MATCH",
12146
- C14,
12547
+ C17,
12147
12548
  "MATCH(lookup_value, lookup_array, [match_type])",
12148
12549
  "The position of a value in a range.",
12149
12550
  2,
@@ -12153,7 +12554,7 @@ var LOOKUP_FUNCTIONS = [
12153
12554
  ),
12154
12555
  spec(
12155
12556
  "XMATCH",
12156
- C14,
12557
+ C17,
12157
12558
  "XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])",
12158
12559
  "The position of a value with flexible matching.",
12159
12560
  2,
@@ -12173,7 +12574,7 @@ var LOOKUP_FUNCTIONS = [
12173
12574
  ),
12174
12575
  spec(
12175
12576
  "XLOOKUP",
12176
- C14,
12577
+ C17,
12177
12578
  "XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])",
12178
12579
  "Searches a range and returns the matching item from another.",
12179
12580
  3,
@@ -12183,7 +12584,7 @@ var LOOKUP_FUNCTIONS = [
12183
12584
  ),
12184
12585
  spec(
12185
12586
  "INDEX",
12186
- C14,
12587
+ C17,
12187
12588
  "INDEX(array, row_num, [column_num], [area_num])",
12188
12589
  "The value or reference at a position.",
12189
12590
  1,
@@ -12193,7 +12594,7 @@ var LOOKUP_FUNCTIONS = [
12193
12594
  ),
12194
12595
  spec(
12195
12596
  "CHOOSE",
12196
- C14,
12597
+ C17,
12197
12598
  "CHOOSE(index_num, value1, [value2], ...)",
12198
12599
  "Chooses a value from a list by index.",
12199
12600
  2,
@@ -12397,7 +12798,7 @@ function liftCriteria(ctx, pairs, fn) {
12397
12798
  }
12398
12799
 
12399
12800
  // src/xlsx/formula/functions/math-sum.ts
12400
- var C15 = "Math & Trig";
12801
+ var C18 = "Math & Trig";
12401
12802
  var numbersOf = (values2) => values2.filter((v) => typeof v === "number");
12402
12803
  function sumProduct(ctx, args) {
12403
12804
  const matrices = args.map((a) => ctx.toMatrix(a));
@@ -12502,7 +12903,7 @@ function aggregate(code, values2, k) {
12502
12903
  var SUM_FUNCTIONS = [
12503
12904
  spec(
12504
12905
  "SUM",
12505
- C15,
12906
+ C18,
12506
12907
  "SUM(number1, [number2], ...)",
12507
12908
  "Adds its arguments.",
12508
12909
  0,
@@ -12512,7 +12913,7 @@ var SUM_FUNCTIONS = [
12512
12913
  ),
12513
12914
  spec(
12514
12915
  "PRODUCT",
12515
- C15,
12916
+ C18,
12516
12917
  "PRODUCT(number1, [number2], ...)",
12517
12918
  "Multiplies its arguments.",
12518
12919
  1,
@@ -12525,7 +12926,7 @@ var SUM_FUNCTIONS = [
12525
12926
  ),
12526
12927
  spec(
12527
12928
  "SUMSQ",
12528
- C15,
12929
+ C18,
12529
12930
  "SUMSQ(number1, [number2], ...)",
12530
12931
  "The sum of the squares of the arguments.",
12531
12932
  1,
@@ -12535,7 +12936,7 @@ var SUM_FUNCTIONS = [
12535
12936
  ),
12536
12937
  spec(
12537
12938
  "SUMPRODUCT",
12538
- C15,
12939
+ C18,
12539
12940
  "SUMPRODUCT(array1, [array2], ...)",
12540
12941
  "The sum of the products of corresponding array elements.",
12541
12942
  1,
@@ -12545,7 +12946,7 @@ var SUM_FUNCTIONS = [
12545
12946
  ),
12546
12947
  spec(
12547
12948
  "SUMX2MY2",
12548
- C15,
12949
+ C18,
12549
12950
  "SUMX2MY2(array_x, array_y)",
12550
12951
  "Sum of the differences of squares.",
12551
12952
  2,
@@ -12555,7 +12956,7 @@ var SUM_FUNCTIONS = [
12555
12956
  ),
12556
12957
  spec(
12557
12958
  "SUMX2PY2",
12558
- C15,
12959
+ C18,
12559
12960
  "SUMX2PY2(array_x, array_y)",
12560
12961
  "Sum of the sums of squares.",
12561
12962
  2,
@@ -12565,7 +12966,7 @@ var SUM_FUNCTIONS = [
12565
12966
  ),
12566
12967
  spec(
12567
12968
  "SUMXMY2",
12568
- C15,
12969
+ C18,
12569
12970
  "SUMXMY2(array_x, array_y)",
12570
12971
  "Sum of the squares of differences.",
12571
12972
  2,
@@ -12575,7 +12976,7 @@ var SUM_FUNCTIONS = [
12575
12976
  ),
12576
12977
  spec(
12577
12978
  "SUMIF",
12578
- C15,
12979
+ C18,
12579
12980
  "SUMIF(range, criteria, [sum_range])",
12580
12981
  "Adds the cells that meet a criterion.",
12581
12982
  2,
@@ -12588,7 +12989,7 @@ var SUM_FUNCTIONS = [
12588
12989
  ),
12589
12990
  spec(
12590
12991
  "SUMIFS",
12591
- C15,
12992
+ C18,
12592
12993
  "SUMIFS(sum_range, criteria_range1, criteria1, ...)",
12593
12994
  "Adds the cells that meet several criteria.",
12594
12995
  3,
@@ -12602,7 +13003,7 @@ var SUM_FUNCTIONS = [
12602
13003
  ),
12603
13004
  spec(
12604
13005
  "SUBTOTAL",
12605
- C15,
13006
+ C18,
12606
13007
  "SUBTOTAL(function_num, ref1, ...)",
12607
13008
  "A subtotal (1-11 include hidden rows, 101-111 ignore them).",
12608
13009
  2,
@@ -12617,7 +13018,7 @@ var SUM_FUNCTIONS = [
12617
13018
  ),
12618
13019
  spec(
12619
13020
  "AGGREGATE",
12620
- C15,
13021
+ C18,
12621
13022
  "AGGREGATE(function_num, options, ref1, ...)",
12622
13023
  "An aggregate that can ignore hidden rows and errors.",
12623
13024
  3,
@@ -12657,14 +13058,14 @@ var SUM_FUNCTIONS = [
12657
13058
  ];
12658
13059
 
12659
13060
  // src/xlsx/formula/functions/math-more.ts
12660
- var C16 = "Math & Trig";
13061
+ var C19 = "Math & Trig";
12661
13062
  var MATH_MORE = [
12662
- numeric("SIN", C16, "SIN(number)", "The sine of an angle in radians.", 1, 1, Math.sin),
12663
- numeric("COS", C16, "COS(number)", "The cosine of an angle in radians.", 1, 1, Math.cos),
12664
- numeric("TAN", C16, "TAN(number)", "The tangent of an angle in radians.", 1, 1, Math.tan),
13063
+ numeric("SIN", C19, "SIN(number)", "The sine of an angle in radians.", 1, 1, Math.sin),
13064
+ numeric("COS", C19, "COS(number)", "The cosine of an angle in radians.", 1, 1, Math.cos),
13065
+ numeric("TAN", C19, "TAN(number)", "The tangent of an angle in radians.", 1, 1, Math.tan),
12665
13066
  numeric(
12666
13067
  "ASIN",
12667
- C16,
13068
+ C19,
12668
13069
  "ASIN(number)",
12669
13070
  "The arcsine in radians.",
12670
13071
  1,
@@ -12673,17 +13074,17 @@ var MATH_MORE = [
12673
13074
  ),
12674
13075
  numeric(
12675
13076
  "ACOS",
12676
- C16,
13077
+ C19,
12677
13078
  "ACOS(number)",
12678
13079
  "The arccosine in radians.",
12679
13080
  1,
12680
13081
  1,
12681
13082
  (x) => domain(Math.abs(x) <= 1, Math.acos(x))
12682
13083
  ),
12683
- numeric("ATAN", C16, "ATAN(number)", "The arctangent in radians.", 1, 1, Math.atan),
13084
+ numeric("ATAN", C19, "ATAN(number)", "The arctangent in radians.", 1, 1, Math.atan),
12684
13085
  numeric(
12685
13086
  "ATAN2",
12686
- C16,
13087
+ C19,
12687
13088
  "ATAN2(x_num, y_num)",
12688
13089
  "The arctangent of x and y coordinates.",
12689
13090
  2,
@@ -12693,13 +13094,13 @@ var MATH_MORE = [
12693
13094
  return Math.atan2(y ?? 0, x);
12694
13095
  }
12695
13096
  ),
12696
- numeric("SINH", C16, "SINH(number)", "The hyperbolic sine.", 1, 1, Math.sinh),
12697
- numeric("COSH", C16, "COSH(number)", "The hyperbolic cosine.", 1, 1, Math.cosh),
12698
- numeric("TANH", C16, "TANH(number)", "The hyperbolic tangent.", 1, 1, Math.tanh),
12699
- numeric("ASINH", C16, "ASINH(number)", "The inverse hyperbolic sine.", 1, 1, Math.asinh),
13097
+ numeric("SINH", C19, "SINH(number)", "The hyperbolic sine.", 1, 1, Math.sinh),
13098
+ numeric("COSH", C19, "COSH(number)", "The hyperbolic cosine.", 1, 1, Math.cosh),
13099
+ numeric("TANH", C19, "TANH(number)", "The hyperbolic tangent.", 1, 1, Math.tanh),
13100
+ numeric("ASINH", C19, "ASINH(number)", "The inverse hyperbolic sine.", 1, 1, Math.asinh),
12700
13101
  numeric(
12701
13102
  "ACOSH",
12702
- C16,
13103
+ C19,
12703
13104
  "ACOSH(number)",
12704
13105
  "The inverse hyperbolic cosine.",
12705
13106
  1,
@@ -12708,7 +13109,7 @@ var MATH_MORE = [
12708
13109
  ),
12709
13110
  numeric(
12710
13111
  "ATANH",
12711
- C16,
13112
+ C19,
12712
13113
  "ATANH(number)",
12713
13114
  "The inverse hyperbolic tangent.",
12714
13115
  1,
@@ -12717,7 +13118,7 @@ var MATH_MORE = [
12717
13118
  ),
12718
13119
  numeric(
12719
13120
  "COT",
12720
- C16,
13121
+ C19,
12721
13122
  "COT(number)",
12722
13123
  "The cotangent of an angle.",
12723
13124
  1,
@@ -12726,7 +13127,7 @@ var MATH_MORE = [
12726
13127
  ),
12727
13128
  numeric(
12728
13129
  "COTH",
12729
- C16,
13130
+ C19,
12730
13131
  "COTH(number)",
12731
13132
  "The hyperbolic cotangent.",
12732
13133
  1,
@@ -12735,7 +13136,7 @@ var MATH_MORE = [
12735
13136
  ),
12736
13137
  numeric(
12737
13138
  "CSC",
12738
- C16,
13139
+ C19,
12739
13140
  "CSC(number)",
12740
13141
  "The cosecant of an angle.",
12741
13142
  1,
@@ -12744,19 +13145,19 @@ var MATH_MORE = [
12744
13145
  ),
12745
13146
  numeric(
12746
13147
  "CSCH",
12747
- C16,
13148
+ C19,
12748
13149
  "CSCH(number)",
12749
13150
  "The hyperbolic cosecant.",
12750
13151
  1,
12751
13152
  1,
12752
13153
  (x) => x === 0 ? fail(ERR.DIV0) : 1 / Math.sinh(x)
12753
13154
  ),
12754
- numeric("SEC", C16, "SEC(number)", "The secant of an angle.", 1, 1, (x) => 1 / Math.cos(x)),
12755
- numeric("SECH", C16, "SECH(number)", "The hyperbolic secant.", 1, 1, (x) => 1 / Math.cosh(x)),
12756
- numeric("ACOT", C16, "ACOT(number)", "The arccotangent.", 1, 1, (x) => Math.PI / 2 - Math.atan(x)),
13155
+ numeric("SEC", C19, "SEC(number)", "The secant of an angle.", 1, 1, (x) => 1 / Math.cos(x)),
13156
+ numeric("SECH", C19, "SECH(number)", "The hyperbolic secant.", 1, 1, (x) => 1 / Math.cosh(x)),
13157
+ numeric("ACOT", C19, "ACOT(number)", "The arccotangent.", 1, 1, (x) => Math.PI / 2 - Math.atan(x)),
12757
13158
  numeric(
12758
13159
  "ACOTH",
12759
- C16,
13160
+ C19,
12760
13161
  "ACOTH(number)",
12761
13162
  "The inverse hyperbolic cotangent.",
12762
13163
  1,
@@ -12765,7 +13166,7 @@ var MATH_MORE = [
12765
13166
  ),
12766
13167
  numeric(
12767
13168
  "DEGREES",
12768
- C16,
13169
+ C19,
12769
13170
  "DEGREES(angle)",
12770
13171
  "Converts radians to degrees.",
12771
13172
  1,
@@ -12774,7 +13175,7 @@ var MATH_MORE = [
12774
13175
  ),
12775
13176
  numeric(
12776
13177
  "RADIANS",
12777
- C16,
13178
+ C19,
12778
13179
  "RADIANS(angle)",
12779
13180
  "Converts degrees to radians.",
12780
13181
  1,
@@ -12783,7 +13184,7 @@ var MATH_MORE = [
12783
13184
  ),
12784
13185
  spec(
12785
13186
  "RAND",
12786
- C16,
13187
+ C19,
12787
13188
  "RAND()",
12788
13189
  "A random number between 0 and 1.",
12789
13190
  0,
@@ -12794,7 +13195,7 @@ var MATH_MORE = [
12794
13195
  ),
12795
13196
  spec(
12796
13197
  "RANDBETWEEN",
12797
- C16,
13198
+ C19,
12798
13199
  "RANDBETWEEN(bottom, top)",
12799
13200
  "A random integer between two numbers.",
12800
13201
  2,
@@ -12810,7 +13211,7 @@ var MATH_MORE = [
12810
13211
  ),
12811
13212
  spec(
12812
13213
  "SERIESSUM",
12813
- C16,
13214
+ C19,
12814
13215
  "SERIESSUM(x, n, m, coefficients)",
12815
13216
  "The sum of a power series.",
12816
13217
  4,
@@ -12829,7 +13230,7 @@ var MATH_MORE = [
12829
13230
  ];
12830
13231
 
12831
13232
  // src/xlsx/formula/functions/math-combin.ts
12832
- var C17 = "Math & Trig";
13233
+ var C20 = "Math & Trig";
12833
13234
  var fact = (n) => {
12834
13235
  if (n < 0) fail(ERR.NUM);
12835
13236
  let out = 1;
@@ -12853,8 +13254,8 @@ function integers(args, ctx) {
12853
13254
  });
12854
13255
  }
12855
13256
  var COMBINATORIC_FUNCTIONS = [
12856
- numeric("FACT", C17, "FACT(number)", "The factorial of a number.", 1, 1, fact),
12857
- numeric("FACTDOUBLE", C17, "FACTDOUBLE(number)", "The double factorial of a number.", 1, 1, (n) => {
13257
+ numeric("FACT", C20, "FACT(number)", "The factorial of a number.", 1, 1, fact),
13258
+ numeric("FACTDOUBLE", C20, "FACTDOUBLE(number)", "The double factorial of a number.", 1, 1, (n) => {
12858
13259
  if (n < -1) fail(ERR.NUM);
12859
13260
  let out = 1;
12860
13261
  for (let i = Math.trunc(n); i > 1; i -= 2) out *= i;
@@ -12862,7 +13263,7 @@ var COMBINATORIC_FUNCTIONS = [
12862
13263
  }),
12863
13264
  numeric(
12864
13265
  "COMBIN",
12865
- C17,
13266
+ C20,
12866
13267
  "COMBIN(number, number_chosen)",
12867
13268
  "The number of combinations.",
12868
13269
  2,
@@ -12871,7 +13272,7 @@ var COMBINATORIC_FUNCTIONS = [
12871
13272
  ),
12872
13273
  numeric(
12873
13274
  "COMBINA",
12874
- C17,
13275
+ C20,
12875
13276
  "COMBINA(number, number_chosen)",
12876
13277
  "Combinations with repetitions.",
12877
13278
  2,
@@ -12883,7 +13284,7 @@ var COMBINATORIC_FUNCTIONS = [
12883
13284
  ),
12884
13285
  spec(
12885
13286
  "MULTINOMIAL",
12886
- C17,
13287
+ C20,
12887
13288
  "MULTINOMIAL(number1, ...)",
12888
13289
  "The multinomial of a set of numbers.",
12889
13290
  1,
@@ -12897,7 +13298,7 @@ var COMBINATORIC_FUNCTIONS = [
12897
13298
  ),
12898
13299
  spec(
12899
13300
  "GCD",
12900
- C17,
13301
+ C20,
12901
13302
  "GCD(number1, ...)",
12902
13303
  "The greatest common divisor.",
12903
13304
  1,
@@ -12907,7 +13308,7 @@ var COMBINATORIC_FUNCTIONS = [
12907
13308
  ),
12908
13309
  spec(
12909
13310
  "LCM",
12910
- C17,
13311
+ C20,
12911
13312
  "LCM(number1, ...)",
12912
13313
  "The least common multiple.",
12913
13314
  1,
@@ -12955,7 +13356,7 @@ function mround(x, m) {
12955
13356
  }
12956
13357
 
12957
13358
  // src/xlsx/formula/functions/math.ts
12958
- var C18 = "Math & Trig";
13359
+ var C21 = "Math & Trig";
12959
13360
  function roundTo(x, digits2, mode) {
12960
13361
  if (!Number.isFinite(x)) return x;
12961
13362
  const d = Math.trunc(digits2);
@@ -12974,10 +13375,10 @@ var quotientMultiple = (x, sig, op) => {
12974
13375
  var MATH_FUNCTIONS = [
12975
13376
  ...MATH_MORE,
12976
13377
  ...SUM_FUNCTIONS,
12977
- numeric("ABS", C18, "ABS(number)", "The absolute value of a number.", 1, 1, Math.abs),
13378
+ numeric("ABS", C21, "ABS(number)", "The absolute value of a number.", 1, 1, Math.abs),
12978
13379
  numeric(
12979
13380
  "SIGN",
12980
- C18,
13381
+ C21,
12981
13382
  "SIGN(number)",
12982
13383
  "The sign of a number: 1, 0 or -1.",
12983
13384
  1,
@@ -12986,7 +13387,7 @@ var MATH_FUNCTIONS = [
12986
13387
  ),
12987
13388
  numeric(
12988
13389
  "INT",
12989
- C18,
13390
+ C21,
12990
13391
  "INT(number)",
12991
13392
  "Rounds a number down to the nearest integer.",
12992
13393
  1,
@@ -12995,7 +13396,7 @@ var MATH_FUNCTIONS = [
12995
13396
  ),
12996
13397
  numeric(
12997
13398
  "TRUNC",
12998
- C18,
13399
+ C21,
12999
13400
  "TRUNC(number, [num_digits])",
13000
13401
  "Truncates a number toward zero.",
13001
13402
  1,
@@ -13004,7 +13405,7 @@ var MATH_FUNCTIONS = [
13004
13405
  ),
13005
13406
  numeric(
13006
13407
  "ROUND",
13007
- C18,
13408
+ C21,
13008
13409
  "ROUND(number, num_digits)",
13009
13410
  "Rounds a number to a number of digits.",
13010
13411
  2,
@@ -13013,7 +13414,7 @@ var MATH_FUNCTIONS = [
13013
13414
  ),
13014
13415
  numeric(
13015
13416
  "ROUNDUP",
13016
- C18,
13417
+ C21,
13017
13418
  "ROUNDUP(number, num_digits)",
13018
13419
  "Rounds a number away from zero.",
13019
13420
  2,
@@ -13022,7 +13423,7 @@ var MATH_FUNCTIONS = [
13022
13423
  ),
13023
13424
  numeric(
13024
13425
  "ROUNDDOWN",
13025
- C18,
13426
+ C21,
13026
13427
  "ROUNDDOWN(number, num_digits)",
13027
13428
  "Rounds a number toward zero.",
13028
13429
  2,
@@ -13031,7 +13432,7 @@ var MATH_FUNCTIONS = [
13031
13432
  ),
13032
13433
  numeric(
13033
13434
  "MROUND",
13034
- C18,
13435
+ C21,
13035
13436
  "MROUND(number, multiple)",
13036
13437
  "Rounds a number to the nearest multiple.",
13037
13438
  2,
@@ -13040,7 +13441,7 @@ var MATH_FUNCTIONS = [
13040
13441
  ),
13041
13442
  numeric(
13042
13443
  "CEILING",
13043
- C18,
13444
+ C21,
13044
13445
  "CEILING(number, significance)",
13045
13446
  "Rounds a number up to a multiple of significance.",
13046
13447
  2,
@@ -13052,7 +13453,7 @@ var MATH_FUNCTIONS = [
13052
13453
  ),
13053
13454
  numeric(
13054
13455
  "FLOOR",
13055
- C18,
13456
+ C21,
13056
13457
  "FLOOR(number, significance)",
13057
13458
  "Rounds a number down to a multiple of significance.",
13058
13459
  2,
@@ -13065,7 +13466,7 @@ var MATH_FUNCTIONS = [
13065
13466
  ),
13066
13467
  numeric(
13067
13468
  "CEILING.MATH",
13068
- C18,
13469
+ C21,
13069
13470
  "CEILING.MATH(number, [significance], [mode])",
13070
13471
  "Rounds a number up to an integer or multiple.",
13071
13472
  1,
@@ -13078,7 +13479,7 @@ var MATH_FUNCTIONS = [
13078
13479
  ),
13079
13480
  numeric(
13080
13481
  "FLOOR.MATH",
13081
- C18,
13482
+ C21,
13082
13483
  "FLOOR.MATH(number, [significance], [mode])",
13083
13484
  "Rounds a number down to an integer or multiple.",
13084
13485
  1,
@@ -13091,7 +13492,7 @@ var MATH_FUNCTIONS = [
13091
13492
  ),
13092
13493
  numeric(
13093
13494
  "CEILING.PRECISE",
13094
- C18,
13495
+ C21,
13095
13496
  "CEILING.PRECISE(number, [significance])",
13096
13497
  "Rounds a number up regardless of sign.",
13097
13498
  1,
@@ -13100,7 +13501,7 @@ var MATH_FUNCTIONS = [
13100
13501
  ),
13101
13502
  numeric(
13102
13503
  "ISO.CEILING",
13103
- C18,
13504
+ C21,
13104
13505
  "ISO.CEILING(number, [significance])",
13105
13506
  "Rounds a number up regardless of sign.",
13106
13507
  1,
@@ -13109,7 +13510,7 @@ var MATH_FUNCTIONS = [
13109
13510
  ),
13110
13511
  numeric(
13111
13512
  "FLOOR.PRECISE",
13112
- C18,
13513
+ C21,
13113
13514
  "FLOOR.PRECISE(number, [significance])",
13114
13515
  "Rounds a number down regardless of sign.",
13115
13516
  1,
@@ -13118,7 +13519,7 @@ var MATH_FUNCTIONS = [
13118
13519
  ),
13119
13520
  numeric(
13120
13521
  "EVEN",
13121
- C18,
13522
+ C21,
13122
13523
  "EVEN(number)",
13123
13524
  "Rounds a number away from zero to an even integer.",
13124
13525
  1,
@@ -13127,7 +13528,7 @@ var MATH_FUNCTIONS = [
13127
13528
  ),
13128
13529
  numeric(
13129
13530
  "ODD",
13130
- C18,
13531
+ C21,
13131
13532
  "ODD(number)",
13132
13533
  "Rounds a number away from zero to an odd integer.",
13133
13534
  1,
@@ -13139,7 +13540,7 @@ var MATH_FUNCTIONS = [
13139
13540
  ),
13140
13541
  numeric(
13141
13542
  "MOD",
13142
- C18,
13543
+ C21,
13143
13544
  "MOD(number, divisor)",
13144
13545
  "The remainder after division (sign of the divisor).",
13145
13546
  2,
@@ -13148,7 +13549,7 @@ var MATH_FUNCTIONS = [
13148
13549
  ),
13149
13550
  numeric(
13150
13551
  "QUOTIENT",
13151
- C18,
13552
+ C21,
13152
13553
  "QUOTIENT(numerator, denominator)",
13153
13554
  "The integer part of a division.",
13154
13555
  2,
@@ -13160,7 +13561,7 @@ var MATH_FUNCTIONS = [
13160
13561
  ),
13161
13562
  numeric(
13162
13563
  "SQRT",
13163
- C18,
13564
+ C21,
13164
13565
  "SQRT(number)",
13165
13566
  "The positive square root.",
13166
13567
  1,
@@ -13169,7 +13570,7 @@ var MATH_FUNCTIONS = [
13169
13570
  ),
13170
13571
  numeric(
13171
13572
  "SQRTPI",
13172
- C18,
13573
+ C21,
13173
13574
  "SQRTPI(number)",
13174
13575
  "The square root of number * pi.",
13175
13576
  1,
@@ -13178,18 +13579,18 @@ var MATH_FUNCTIONS = [
13178
13579
  ),
13179
13580
  numeric(
13180
13581
  "POWER",
13181
- C18,
13582
+ C21,
13182
13583
  "POWER(number, power)",
13183
13584
  "A number raised to a power.",
13184
13585
  2,
13185
13586
  2,
13186
13587
  (b, e) => power(b, e ?? 1)
13187
13588
  ),
13188
- numeric("EXP", C18, "EXP(number)", "e raised to a power.", 1, 1, Math.exp),
13189
- numeric("LN", C18, "LN(number)", "The natural logarithm.", 1, 1, (x) => domain(x > 0, Math.log(x))),
13589
+ numeric("EXP", C21, "EXP(number)", "e raised to a power.", 1, 1, Math.exp),
13590
+ numeric("LN", C21, "LN(number)", "The natural logarithm.", 1, 1, (x) => domain(x > 0, Math.log(x))),
13190
13591
  numeric(
13191
13592
  "LOG10",
13192
- C18,
13593
+ C21,
13193
13594
  "LOG10(number)",
13194
13595
  "The base-10 logarithm.",
13195
13596
  1,
@@ -13198,7 +13599,7 @@ var MATH_FUNCTIONS = [
13198
13599
  ),
13199
13600
  numeric(
13200
13601
  "LOG",
13201
- C18,
13602
+ C21,
13202
13603
  "LOG(number, [base])",
13203
13604
  "The logarithm to a base (10 by default).",
13204
13605
  1,
@@ -13210,12 +13611,12 @@ var MATH_FUNCTIONS = [
13210
13611
  return base === 10 ? Math.log10(x) : Math.log(x) / Math.log(base);
13211
13612
  }
13212
13613
  ),
13213
- numeric("PI", C18, "PI()", "The value of pi.", 0, 0, () => Math.PI),
13614
+ numeric("PI", C21, "PI()", "The value of pi.", 0, 0, () => Math.PI),
13214
13615
  ...COMBINATORIC_FUNCTIONS
13215
13616
  ];
13216
13617
 
13217
13618
  // src/xlsx/formula/functions/matrix.ts
13218
- var C19 = "Math & Trig";
13619
+ var C22 = "Math & Trig";
13219
13620
  function numbers2(ctx, value) {
13220
13621
  return ctx.toMatrix(value ?? null).data.map(
13221
13622
  (row2) => row2.map((v) => {
@@ -13274,7 +13675,7 @@ function eliminate(input, invert2) {
13274
13675
  var MATRIX_FUNCTIONS = [
13275
13676
  spec(
13276
13677
  "MMULT",
13277
- C19,
13678
+ C22,
13278
13679
  "MMULT(array1, array2)",
13279
13680
  "The matrix product of two arrays.",
13280
13681
  2,
@@ -13295,7 +13696,7 @@ var MATRIX_FUNCTIONS = [
13295
13696
  ),
13296
13697
  spec(
13297
13698
  "MDETERM",
13298
- C19,
13699
+ C22,
13299
13700
  "MDETERM(array)",
13300
13701
  "The determinant of a square matrix.",
13301
13702
  1,
@@ -13305,7 +13706,7 @@ var MATRIX_FUNCTIONS = [
13305
13706
  ),
13306
13707
  spec(
13307
13708
  "MINVERSE",
13308
- C19,
13709
+ C22,
13309
13710
  "MINVERSE(array)",
13310
13711
  "The inverse of a square matrix.",
13311
13712
  1,
@@ -13317,7 +13718,7 @@ var MATRIX_FUNCTIONS = [
13317
13718
  },
13318
13719
  ["any"]
13319
13720
  ),
13320
- spec("MUNIT", C19, "MUNIT(dimension)", "The identity matrix.", 1, 1, (args) => {
13721
+ spec("MUNIT", C22, "MUNIT(dimension)", "The identity matrix.", 1, 1, (args) => {
13321
13722
  const n = int3(args[0]);
13322
13723
  if (n < 1) fail(ERR.VALUE);
13323
13724
  return Matrix.build(n, n, (r, c2) => r === c2 ? 1 : 0);
@@ -13384,7 +13785,7 @@ function fitStatistics(fit) {
13384
13785
  }
13385
13786
 
13386
13787
  // src/xlsx/formula/functions/regression.ts
13387
- var C20 = "Statistical";
13788
+ var C23 = "Statistical";
13388
13789
  function numbersOf2(ctx, value) {
13389
13790
  return ctx.toMatrix(value ?? null).data.map(
13390
13791
  (row2) => row2.map((v) => {
@@ -13453,7 +13854,7 @@ var ARGS = ["any"];
13453
13854
  var REGRESSION_FUNCTIONS = [
13454
13855
  spec(
13455
13856
  "LINEST",
13456
- C20,
13857
+ C23,
13457
13858
  "LINEST(known_y, [known_x], [const], [stats])",
13458
13859
  "The statistics of a straight-line (or multiple linear) least-squares fit.",
13459
13860
  1,
@@ -13467,7 +13868,7 @@ var REGRESSION_FUNCTIONS = [
13467
13868
  ),
13468
13869
  spec(
13469
13870
  "LOGEST",
13470
- C20,
13871
+ C23,
13471
13872
  "LOGEST(known_y, [known_x], [const], [stats])",
13472
13873
  "The statistics of an exponential-curve fit.",
13473
13874
  1,
@@ -13485,7 +13886,7 @@ var REGRESSION_FUNCTIONS = [
13485
13886
  ),
13486
13887
  spec(
13487
13888
  "TREND",
13488
- C20,
13889
+ C23,
13489
13890
  "TREND(known_y, [known_x], [new_x], [const])",
13490
13891
  "Values along a linear trend.",
13491
13892
  1,
@@ -13499,7 +13900,7 @@ var REGRESSION_FUNCTIONS = [
13499
13900
  ),
13500
13901
  spec(
13501
13902
  "GROWTH",
13502
- C20,
13903
+ C23,
13503
13904
  "GROWTH(known_y, [known_x], [new_x], [const])",
13504
13905
  "Values along an exponential trend.",
13505
13906
  1,
@@ -13653,7 +14054,7 @@ var tPdf = (t, df) => Math.exp(
13653
14054
  gammaLn((df + 1) / 2) - gammaLn(df / 2) - 0.5 * Math.log(df * Math.PI) - (df + 1) / 2 * Math.log(1 + t * t / df)
13654
14055
  );
13655
14056
  var chiCdf = (x, df) => gammaP(df / 2, x / 2);
13656
- var positive = (...values2) => {
14057
+ var positive2 = (...values2) => {
13657
14058
  for (const v of values2) if (v === void 0 || v <= 0) fail(ERR.NUM);
13658
14059
  };
13659
14060
  var probability = (p) => {
@@ -13678,13 +14079,13 @@ function poisson(k, mean2, cumulative2) {
13678
14079
  return Math.exp(kk * Math.log(mean2) - mean2 - gammaLn(kk + 1));
13679
14080
  }
13680
14081
  var normDist = (x, m, s, cumulative2) => {
13681
- positive(s);
14082
+ positive2(s);
13682
14083
  const z = (x - m) / s;
13683
14084
  return cumulative2 ? normCdf(z) : normPdf(z) / s;
13684
14085
  };
13685
14086
 
13686
14087
  // src/xlsx/formula/functions/distributions-f.ts
13687
- var C21 = "Statistical";
14088
+ var C24 = "Statistical";
13688
14089
  var degrees = (...values2) => {
13689
14090
  for (const v of values2) if (v === void 0 || v < 1) fail(ERR.NUM);
13690
14091
  };
@@ -13705,13 +14106,13 @@ var betaScaled = (x, a, b, lo, hi) => {
13705
14106
  return betaI((x - lo) / (hi - lo), a, b);
13706
14107
  };
13707
14108
  var betaInverse = (p, a, b, lo, hi) => {
13708
- positive(a, b);
14109
+ positive2(a, b);
13709
14110
  if (p <= 0 || p > 1 || lo >= hi) fail(ERR.NUM);
13710
14111
  return lo + (hi - lo) * invert((t) => betaI(t, a, b), p, 0, 1);
13711
14112
  };
13712
14113
  var gammaInverse = (p, a, b) => {
13713
14114
  prob(p);
13714
- positive(a, b);
14115
+ positive2(a, b);
13715
14116
  return p === 0 ? 0 : invert((x) => gammaP(a, x / b), p, 0, a * b + 1);
13716
14117
  };
13717
14118
  function binomInverse(trials, p, alpha) {
@@ -13743,7 +14144,7 @@ var negbinomPmf = (f, s, p) => {
13743
14144
  var DISTRIBUTION_F = [
13744
14145
  numeric(
13745
14146
  "F.DIST",
13746
- C21,
14147
+ C24,
13747
14148
  "F.DIST(x, deg_freedom1, deg_freedom2, cumulative)",
13748
14149
  "The left-tailed F probability distribution.",
13749
14150
  4,
@@ -13759,7 +14160,7 @@ var DISTRIBUTION_F = [
13759
14160
  ...["F.DIST.RT", "FDIST"].map(
13760
14161
  (name) => numeric(
13761
14162
  name,
13762
- C21,
14163
+ C24,
13763
14164
  `${name}(x, deg_freedom1, deg_freedom2)`,
13764
14165
  "The right-tailed F probability distribution.",
13765
14166
  3,
@@ -13773,7 +14174,7 @@ var DISTRIBUTION_F = [
13773
14174
  ),
13774
14175
  numeric(
13775
14176
  "F.INV",
13776
- C21,
14177
+ C24,
13777
14178
  "F.INV(probability, deg_freedom1, deg_freedom2)",
13778
14179
  "The inverse of the left-tailed F distribution.",
13779
14180
  3,
@@ -13787,7 +14188,7 @@ var DISTRIBUTION_F = [
13787
14188
  ...["F.INV.RT", "FINV"].map(
13788
14189
  (name) => numeric(
13789
14190
  name,
13790
- C21,
14191
+ C24,
13791
14192
  `${name}(probability, deg_freedom1, deg_freedom2)`,
13792
14193
  "The inverse of the right-tailed F distribution.",
13793
14194
  3,
@@ -13802,7 +14203,7 @@ var DISTRIBUTION_F = [
13802
14203
  ...["BETA.INV", "BETAINV"].map(
13803
14204
  (name) => numeric(
13804
14205
  name,
13805
- C21,
14206
+ C24,
13806
14207
  `${name}(probability, alpha, beta, [A], [B])`,
13807
14208
  "The inverse of the cumulative beta distribution.",
13808
14209
  3,
@@ -13813,13 +14214,13 @@ var DISTRIBUTION_F = [
13813
14214
  ),
13814
14215
  numeric(
13815
14216
  "BETADIST",
13816
- C21,
14217
+ C24,
13817
14218
  "BETADIST(x, alpha, beta, [A], [B])",
13818
14219
  "The cumulative beta distribution.",
13819
14220
  3,
13820
14221
  5,
13821
14222
  (x, a, b, lo, hi) => {
13822
- positive(a, b);
14223
+ positive2(a, b);
13823
14224
  return betaScaled(x, a ?? 1, b ?? 1, lo ?? 0, hi ?? 1);
13824
14225
  },
13825
14226
  [0, 0, 0, 0, 1]
@@ -13827,7 +14228,7 @@ var DISTRIBUTION_F = [
13827
14228
  ...["GAMMA.INV", "GAMMAINV"].map(
13828
14229
  (name) => numeric(
13829
14230
  name,
13830
- C21,
14231
+ C24,
13831
14232
  `${name}(probability, alpha, beta)`,
13832
14233
  "The inverse of the gamma cumulative distribution.",
13833
14234
  3,
@@ -13837,14 +14238,14 @@ var DISTRIBUTION_F = [
13837
14238
  ),
13838
14239
  numeric(
13839
14240
  "GAMMADIST",
13840
- C21,
14241
+ C24,
13841
14242
  "GAMMADIST(x, alpha, beta, cumulative)",
13842
14243
  "The gamma distribution.",
13843
14244
  4,
13844
14245
  4,
13845
14246
  (x, a, b, c2) => {
13846
14247
  if (x < 0) fail(ERR.NUM);
13847
- positive(a, b);
14248
+ positive2(a, b);
13848
14249
  const al = a ?? 1;
13849
14250
  const be = b ?? 1;
13850
14251
  return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
@@ -13852,33 +14253,33 @@ var DISTRIBUTION_F = [
13852
14253
  ),
13853
14254
  numeric(
13854
14255
  "LOGINV",
13855
- C21,
14256
+ C24,
13856
14257
  "LOGINV(probability, mean, standard_dev)",
13857
14258
  "The inverse of the lognormal cumulative distribution.",
13858
14259
  3,
13859
14260
  3,
13860
14261
  (p, m, s) => {
13861
- positive(s);
14262
+ positive2(s);
13862
14263
  if (p <= 0 || p >= 1) fail(ERR.NUM);
13863
14264
  return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
13864
14265
  }
13865
14266
  ),
13866
14267
  numeric(
13867
14268
  "LOGNORMDIST",
13868
- C21,
14269
+ C24,
13869
14270
  "LOGNORMDIST(x, mean, standard_dev)",
13870
14271
  "The cumulative lognormal distribution.",
13871
14272
  3,
13872
14273
  3,
13873
14274
  (x, m, s) => {
13874
- positive(x, s);
14275
+ positive2(x, s);
13875
14276
  return normCdf((Math.log(x) - (m ?? 0)) / (s ?? 1));
13876
14277
  }
13877
14278
  ),
13878
14279
  ...["BINOM.INV", "CRITBINOM"].map(
13879
14280
  (name) => numeric(
13880
14281
  name,
13881
- C21,
14282
+ C24,
13882
14283
  `${name}(trials, probability_s, alpha)`,
13883
14284
  "The smallest value whose cumulative binomial distribution reaches the criterion.",
13884
14285
  3,
@@ -13888,7 +14289,7 @@ var DISTRIBUTION_F = [
13888
14289
  ),
13889
14290
  numeric(
13890
14291
  "BINOM.DIST.RANGE",
13891
- C21,
14292
+ C24,
13892
14293
  "BINOM.DIST.RANGE(trials, probability_s, number_s, [number_s2])",
13893
14294
  "The probability of a trial result within a range, from the binomial distribution.",
13894
14295
  3,
@@ -13906,7 +14307,7 @@ var DISTRIBUTION_F = [
13906
14307
  ),
13907
14308
  numeric(
13908
14309
  "HYPGEOMDIST",
13909
- C21,
14310
+ C24,
13910
14311
  "HYPGEOMDIST(sample_s, number_sample, population_s, number_pop)",
13911
14312
  "The hypergeometric distribution.",
13912
14313
  4,
@@ -13915,7 +14316,7 @@ var DISTRIBUTION_F = [
13915
14316
  ),
13916
14317
  numeric(
13917
14318
  "NEGBINOMDIST",
13918
- C21,
14319
+ C24,
13919
14320
  "NEGBINOMDIST(number_f, number_s, probability_s)",
13920
14321
  "The negative binomial distribution.",
13921
14322
  3,
@@ -13925,7 +14326,7 @@ var DISTRIBUTION_F = [
13925
14326
  ];
13926
14327
 
13927
14328
  // src/xlsx/formula/functions/statistical-shape.ts
13928
- var C22 = "Statistical";
14329
+ var C25 = "Statistical";
13929
14330
  function moments(values2) {
13930
14331
  const n = values2.length;
13931
14332
  return { n, m: mean(values2), s: stdev(values2, true) };
@@ -13942,7 +14343,7 @@ function frequency(data, bins) {
13942
14343
  var STATISTICAL_SHAPE = [
13943
14344
  spec(
13944
14345
  "GEOMEAN",
13945
- C22,
14346
+ C25,
13946
14347
  "GEOMEAN(number1, ...)",
13947
14348
  "The geometric mean.",
13948
14349
  1,
@@ -13956,7 +14357,7 @@ var STATISTICAL_SHAPE = [
13956
14357
  ),
13957
14358
  spec(
13958
14359
  "HARMEAN",
13959
- C22,
14360
+ C25,
13960
14361
  "HARMEAN(number1, ...)",
13961
14362
  "The harmonic mean.",
13962
14363
  1,
@@ -13970,7 +14371,7 @@ var STATISTICAL_SHAPE = [
13970
14371
  ),
13971
14372
  spec(
13972
14373
  "AVEDEV",
13973
- C22,
14374
+ C25,
13974
14375
  "AVEDEV(number1, ...)",
13975
14376
  "The mean absolute deviation from the mean.",
13976
14377
  1,
@@ -13985,7 +14386,7 @@ var STATISTICAL_SHAPE = [
13985
14386
  ),
13986
14387
  spec(
13987
14388
  "DEVSQ",
13988
- C22,
14389
+ C25,
13989
14390
  "DEVSQ(number1, ...)",
13990
14391
  "The sum of squared deviations from the mean.",
13991
14392
  1,
@@ -13998,7 +14399,7 @@ var STATISTICAL_SHAPE = [
13998
14399
  ),
13999
14400
  spec(
14000
14401
  "KURT",
14001
- C22,
14402
+ C25,
14002
14403
  "KURT(number1, ...)",
14003
14404
  "The kurtosis of a data set.",
14004
14405
  1,
@@ -14014,7 +14415,7 @@ var STATISTICAL_SHAPE = [
14014
14415
  ),
14015
14416
  spec(
14016
14417
  "SKEW",
14017
- C22,
14418
+ C25,
14018
14419
  "SKEW(number1, ...)",
14019
14420
  "The skewness of a distribution.",
14020
14421
  1,
@@ -14029,7 +14430,7 @@ var STATISTICAL_SHAPE = [
14029
14430
  ),
14030
14431
  spec(
14031
14432
  "SKEW.P",
14032
- C22,
14433
+ C25,
14033
14434
  "SKEW.P(number1, ...)",
14034
14435
  "The population skewness.",
14035
14436
  1,
@@ -14045,7 +14446,7 @@ var STATISTICAL_SHAPE = [
14045
14446
  ),
14046
14447
  numeric(
14047
14448
  "STANDARDIZE",
14048
- C22,
14449
+ C25,
14049
14450
  "STANDARDIZE(x, mean, standard_dev)",
14050
14451
  "A normalized value.",
14051
14452
  3,
@@ -14057,7 +14458,7 @@ var STATISTICAL_SHAPE = [
14057
14458
  ),
14058
14459
  spec(
14059
14460
  "TRIMMEAN",
14060
- C22,
14461
+ C25,
14061
14462
  "TRIMMEAN(array, percent)",
14062
14463
  "The mean of the interior of a data set.",
14063
14464
  2,
@@ -14073,7 +14474,7 @@ var STATISTICAL_SHAPE = [
14073
14474
  ),
14074
14475
  spec(
14075
14476
  "FREQUENCY",
14076
- C22,
14477
+ C25,
14077
14478
  "FREQUENCY(data_array, bins_array)",
14078
14479
  "How often values occur within ranges, as a vertical array.",
14079
14480
  2,
@@ -14083,7 +14484,7 @@ var STATISTICAL_SHAPE = [
14083
14484
  ),
14084
14485
  numeric(
14085
14486
  "PERMUT",
14086
- C22,
14487
+ C25,
14087
14488
  "PERMUT(number, number_chosen)",
14088
14489
  "The number of permutations.",
14089
14490
  2,
@@ -14099,7 +14500,7 @@ var STATISTICAL_SHAPE = [
14099
14500
  ),
14100
14501
  numeric(
14101
14502
  "PERMUTATIONA",
14102
- C22,
14503
+ C25,
14103
14504
  "PERMUTATIONA(number, number_chosen)",
14104
14505
  "Permutations with repetitions.",
14105
14506
  2,
@@ -14109,26 +14510,26 @@ var STATISTICAL_SHAPE = [
14109
14510
  return Math.pow(Math.trunc(n), Math.trunc(k ?? 0));
14110
14511
  }
14111
14512
  ),
14112
- numeric("FISHER", C22, "FISHER(x)", "The Fisher transformation.", 1, 1, (x) => {
14513
+ numeric("FISHER", C25, "FISHER(x)", "The Fisher transformation.", 1, 1, (x) => {
14113
14514
  if (x <= -1 || x >= 1) fail(ERR.NUM);
14114
14515
  return 0.5 * Math.log((1 + x) / (1 - x));
14115
14516
  }),
14116
14517
  numeric(
14117
14518
  "FISHERINV",
14118
- C22,
14519
+ C25,
14119
14520
  "FISHERINV(y)",
14120
14521
  "The inverse of the Fisher transformation.",
14121
14522
  1,
14122
14523
  1,
14123
14524
  (y) => Math.tanh(y)
14124
14525
  ),
14125
- numeric("GAMMA", C22, "GAMMA(number)", "The gamma function value.", 1, 1, (x) => {
14526
+ numeric("GAMMA", C25, "GAMMA(number)", "The gamma function value.", 1, 1, (x) => {
14126
14527
  if (x <= 0 && Number.isInteger(x)) fail(ERR.NUM);
14127
14528
  return gamma(x);
14128
14529
  }),
14129
14530
  numeric(
14130
14531
  "GAMMALN",
14131
- C22,
14532
+ C25,
14132
14533
  "GAMMALN(x)",
14133
14534
  "The natural logarithm of the gamma function.",
14134
14535
  1,
@@ -14137,7 +14538,7 @@ var STATISTICAL_SHAPE = [
14137
14538
  ),
14138
14539
  numeric(
14139
14540
  "GAMMALN.PRECISE",
14140
- C22,
14541
+ C25,
14141
14542
  "GAMMALN.PRECISE(x)",
14142
14543
  "The natural logarithm of the gamma function.",
14143
14544
  1,
@@ -14147,7 +14548,7 @@ var STATISTICAL_SHAPE = [
14147
14548
  ];
14148
14549
 
14149
14550
  // src/xlsx/formula/functions/statistical-more.ts
14150
- var C23 = "Statistical";
14551
+ var C26 = "Statistical";
14151
14552
  function pairedNumbers(ctx, a, b) {
14152
14553
  const ma = ctx.toMatrix(a).flat();
14153
14554
  const mb = ctx.toMatrix(b).flat();
@@ -14168,7 +14569,7 @@ function pairedNumbers(ctx, a, b) {
14168
14569
  }
14169
14570
  var pairFn = (name, description, syntax, fn) => spec(
14170
14571
  name,
14171
- C23,
14572
+ C26,
14172
14573
  syntax,
14173
14574
  description,
14174
14575
  2,
@@ -14183,7 +14584,7 @@ var STATISTICAL_MORE = [
14183
14584
  ...STATISTICAL_SHAPE,
14184
14585
  spec(
14185
14586
  "MODE.MULT",
14186
- C23,
14587
+ C26,
14187
14588
  "MODE.MULT(number1, [number2], ...)",
14188
14589
  "A vertical array of the most frequent values.",
14189
14590
  1,
@@ -14265,7 +14666,7 @@ var STATISTICAL_MORE = [
14265
14666
  ...["FORECAST", "FORECAST.LINEAR"].map(
14266
14667
  (name) => spec(
14267
14668
  name,
14268
- C23,
14669
+ C26,
14269
14670
  `${name}(x, known_ys, known_xs)`,
14270
14671
  "Predicts a value along a linear trend.",
14271
14672
  3,
@@ -14282,7 +14683,7 @@ var STATISTICAL_MORE = [
14282
14683
  ];
14283
14684
 
14284
14685
  // src/xlsx/formula/functions/hypothesis-tests.ts
14285
- var C24 = "Statistical";
14686
+ var C27 = "Statistical";
14286
14687
  var ARRAYS = ["any"];
14287
14688
  var numbersOf3 = (ctx, value) => collectNumbers(ctx, [value ?? null]);
14288
14689
  function tStatistic(a, b, type) {
@@ -14367,7 +14768,7 @@ var HYPOTHESIS_TESTS = [
14367
14768
  ["Z.TEST", "ZTEST"],
14368
14769
  (name) => spec(
14369
14770
  name,
14370
- C24,
14771
+ C27,
14371
14772
  `${name}(array, x, [sigma])`,
14372
14773
  "The one-tailed P-value of a z-test.",
14373
14774
  2,
@@ -14386,7 +14787,7 @@ var HYPOTHESIS_TESTS = [
14386
14787
  ["T.TEST", "TTEST"],
14387
14788
  (name) => spec(
14388
14789
  name,
14389
- C24,
14790
+ C27,
14390
14791
  `${name}(array1, array2, tails, type)`,
14391
14792
  "The probability associated with a Student's t-test.",
14392
14793
  4,
@@ -14407,7 +14808,7 @@ var HYPOTHESIS_TESTS = [
14407
14808
  ["F.TEST", "FTEST"],
14408
14809
  (name) => spec(
14409
14810
  name,
14410
- C24,
14811
+ C27,
14411
14812
  `${name}(array1, array2)`,
14412
14813
  "The two-tailed probability that the variances of two arrays are not different.",
14413
14814
  2,
@@ -14420,7 +14821,7 @@ var HYPOTHESIS_TESTS = [
14420
14821
  ["CHISQ.TEST", "CHITEST"],
14421
14822
  (name) => spec(
14422
14823
  name,
14423
- C24,
14824
+ C27,
14424
14825
  `${name}(actual_range, expected_range)`,
14425
14826
  "The chi-squared test of independence.",
14426
14827
  2,
@@ -14431,7 +14832,7 @@ var HYPOTHESIS_TESTS = [
14431
14832
  ),
14432
14833
  spec(
14433
14834
  "PROB",
14434
- C24,
14835
+ C27,
14435
14836
  "PROB(x_range, prob_range, lower_limit, [upper_limit])",
14436
14837
  "The probability that values in a range are between two limits.",
14437
14838
  3,
@@ -14442,7 +14843,7 @@ var HYPOTHESIS_TESTS = [
14442
14843
  ];
14443
14844
 
14444
14845
  // src/xlsx/formula/functions/statistical-spread.ts
14445
- var C25 = "Statistical";
14846
+ var C28 = "Statistical";
14446
14847
  var STATISTICAL_SPREAD = [
14447
14848
  ...[
14448
14849
  ["STDEV", true, false],
@@ -14454,7 +14855,7 @@ var STATISTICAL_SPREAD = [
14454
14855
  ].map(
14455
14856
  ([name, sample, a]) => spec(
14456
14857
  name,
14457
- C25,
14858
+ C28,
14458
14859
  `${name}(number1, [number2], ...)`,
14459
14860
  `The ${sample ? "sample" : "population"} standard deviation${a ? " counting logicals and text" : ""}.`,
14460
14861
  1,
@@ -14473,7 +14874,7 @@ var STATISTICAL_SPREAD = [
14473
14874
  ].map(
14474
14875
  ([name, sample, a]) => spec(
14475
14876
  name,
14476
- C25,
14877
+ C28,
14477
14878
  `${name}(number1, [number2], ...)`,
14478
14879
  `The ${sample ? "sample" : "population"} variance${a ? " counting logicals and text" : ""}.`,
14479
14880
  1,
@@ -14485,7 +14886,7 @@ var STATISTICAL_SPREAD = [
14485
14886
  ...["PERCENTILE", "PERCENTILE.INC", "PERCENTILE.EXC"].map(
14486
14887
  (name) => spec(
14487
14888
  name,
14488
- C25,
14889
+ C28,
14489
14890
  `${name}(array, k)`,
14490
14891
  "The k-th percentile.",
14491
14892
  2,
@@ -14501,7 +14902,7 @@ var STATISTICAL_SPREAD = [
14501
14902
  ...["QUARTILE", "QUARTILE.INC", "QUARTILE.EXC"].map(
14502
14903
  (name) => spec(
14503
14904
  name,
14504
- C25,
14905
+ C28,
14505
14906
  `${name}(array, quart)`,
14506
14907
  "A quartile of a data set.",
14507
14908
  2,
@@ -14513,7 +14914,7 @@ var STATISTICAL_SPREAD = [
14513
14914
  ...["PERCENTRANK", "PERCENTRANK.INC", "PERCENTRANK.EXC"].map(
14514
14915
  (name) => spec(
14515
14916
  name,
14516
- C25,
14917
+ C28,
14517
14918
  `${name}(array, x, [significance])`,
14518
14919
  "The rank of a value as a percentage of the data set.",
14519
14920
  2,
@@ -14530,7 +14931,7 @@ var STATISTICAL_SPREAD = [
14530
14931
  ];
14531
14932
 
14532
14933
  // src/xlsx/formula/functions/statistical-count.ts
14533
- var C26 = "Statistical";
14934
+ var C29 = "Statistical";
14534
14935
  function count(ctx, args) {
14535
14936
  let n = 0;
14536
14937
  for (const arg of args) {
@@ -14596,7 +14997,7 @@ function countIf(ctx, range, criteria) {
14596
14997
  var COUNT_FUNCTIONS = [
14597
14998
  spec(
14598
14999
  "COUNT",
14599
- C26,
15000
+ C29,
14600
15001
  "COUNT(value1, [value2], ...)",
14601
15002
  "Counts the numbers in the arguments.",
14602
15003
  0,
@@ -14606,7 +15007,7 @@ var COUNT_FUNCTIONS = [
14606
15007
  ),
14607
15008
  spec(
14608
15009
  "COUNTA",
14609
- C26,
15010
+ C29,
14610
15011
  "COUNTA(value1, [value2], ...)",
14611
15012
  "Counts the non-empty values.",
14612
15013
  1,
@@ -14616,7 +15017,7 @@ var COUNT_FUNCTIONS = [
14616
15017
  ),
14617
15018
  spec(
14618
15019
  "COUNTBLANK",
14619
- C26,
15020
+ C29,
14620
15021
  "COUNTBLANK(range)",
14621
15022
  "Counts the empty cells in a range.",
14622
15023
  1,
@@ -14626,7 +15027,7 @@ var COUNT_FUNCTIONS = [
14626
15027
  ),
14627
15028
  spec(
14628
15029
  "COUNTIF",
14629
- C26,
15030
+ C29,
14630
15031
  "COUNTIF(range, criteria)",
14631
15032
  "Counts the cells that meet a criterion.",
14632
15033
  2,
@@ -14636,7 +15037,7 @@ var COUNT_FUNCTIONS = [
14636
15037
  ),
14637
15038
  spec(
14638
15039
  "COUNTIFS",
14639
- C26,
15040
+ C29,
14640
15041
  "COUNTIFS(criteria_range1, criteria1, ...)",
14641
15042
  "Counts the cells that meet several criteria.",
14642
15043
  2,
@@ -14649,7 +15050,7 @@ var COUNT_FUNCTIONS = [
14649
15050
  ),
14650
15051
  spec(
14651
15052
  "AVERAGE",
14652
- C26,
15053
+ C29,
14653
15054
  "AVERAGE(number1, [number2], ...)",
14654
15055
  "The arithmetic mean.",
14655
15056
  1,
@@ -14660,7 +15061,7 @@ var COUNT_FUNCTIONS = [
14660
15061
  ];
14661
15062
 
14662
15063
  // src/xlsx/formula/functions/statistical.ts
14663
- var C27 = "Statistical";
15064
+ var C30 = "Statistical";
14664
15065
  var numbersOf4 = (values2) => values2.filter((v) => typeof v === "number");
14665
15066
  var extreme2 = extreme;
14666
15067
  var STATISTICAL_FUNCTIONS = [
@@ -14671,7 +15072,7 @@ var STATISTICAL_FUNCTIONS = [
14671
15072
  ...COUNT_FUNCTIONS,
14672
15073
  spec(
14673
15074
  "AVERAGEA",
14674
- C27,
15075
+ C30,
14675
15076
  "AVERAGEA(value1, [value2], ...)",
14676
15077
  "The mean counting text as 0 and logicals.",
14677
15078
  1,
@@ -14681,7 +15082,7 @@ var STATISTICAL_FUNCTIONS = [
14681
15082
  ),
14682
15083
  spec(
14683
15084
  "AVERAGEIF",
14684
- C27,
15085
+ C30,
14685
15086
  "AVERAGEIF(range, criteria, [average_range])",
14686
15087
  "The mean of the cells that meet a criterion.",
14687
15088
  2,
@@ -14700,7 +15101,7 @@ var STATISTICAL_FUNCTIONS = [
14700
15101
  ),
14701
15102
  spec(
14702
15103
  "AVERAGEIFS",
14703
- C27,
15104
+ C30,
14704
15105
  "AVERAGEIFS(average_range, criteria_range1, criteria1, ...)",
14705
15106
  "The mean of the cells that meet several criteria.",
14706
15107
  3,
@@ -14714,7 +15115,7 @@ var STATISTICAL_FUNCTIONS = [
14714
15115
  ),
14715
15116
  spec(
14716
15117
  "MAX",
14717
- C27,
15118
+ C30,
14718
15119
  "MAX(number1, [number2], ...)",
14719
15120
  "The largest value.",
14720
15121
  1,
@@ -14724,7 +15125,7 @@ var STATISTICAL_FUNCTIONS = [
14724
15125
  ),
14725
15126
  spec(
14726
15127
  "MIN",
14727
- C27,
15128
+ C30,
14728
15129
  "MIN(number1, [number2], ...)",
14729
15130
  "The smallest value.",
14730
15131
  1,
@@ -14734,7 +15135,7 @@ var STATISTICAL_FUNCTIONS = [
14734
15135
  ),
14735
15136
  spec(
14736
15137
  "MAXA",
14737
- C27,
15138
+ C30,
14738
15139
  "MAXA(value1, [value2], ...)",
14739
15140
  "The largest value counting logicals and text.",
14740
15141
  1,
@@ -14744,7 +15145,7 @@ var STATISTICAL_FUNCTIONS = [
14744
15145
  ),
14745
15146
  spec(
14746
15147
  "MINA",
14747
- C27,
15148
+ C30,
14748
15149
  "MINA(value1, [value2], ...)",
14749
15150
  "The smallest value counting logicals and text.",
14750
15151
  1,
@@ -14754,7 +15155,7 @@ var STATISTICAL_FUNCTIONS = [
14754
15155
  ),
14755
15156
  spec(
14756
15157
  "MAXIFS",
14757
- C27,
15158
+ C30,
14758
15159
  "MAXIFS(max_range, criteria_range1, criteria1, ...)",
14759
15160
  "The largest value meeting criteria.",
14760
15161
  3,
@@ -14768,7 +15169,7 @@ var STATISTICAL_FUNCTIONS = [
14768
15169
  ),
14769
15170
  spec(
14770
15171
  "MINIFS",
14771
- C27,
15172
+ C30,
14772
15173
  "MINIFS(min_range, criteria_range1, criteria1, ...)",
14773
15174
  "The smallest value meeting criteria.",
14774
15175
  3,
@@ -14782,7 +15183,7 @@ var STATISTICAL_FUNCTIONS = [
14782
15183
  ),
14783
15184
  spec(
14784
15185
  "MEDIAN",
14785
- C27,
15186
+ C30,
14786
15187
  "MEDIAN(number1, [number2], ...)",
14787
15188
  "The median.",
14788
15189
  1,
@@ -14792,7 +15193,7 @@ var STATISTICAL_FUNCTIONS = [
14792
15193
  ),
14793
15194
  spec(
14794
15195
  "MODE",
14795
- C27,
15196
+ C30,
14796
15197
  "MODE(number1, [number2], ...)",
14797
15198
  "The most frequent value.",
14798
15199
  1,
@@ -14802,7 +15203,7 @@ var STATISTICAL_FUNCTIONS = [
14802
15203
  ),
14803
15204
  spec(
14804
15205
  "MODE.SNGL",
14805
- C27,
15206
+ C30,
14806
15207
  "MODE.SNGL(number1, [number2], ...)",
14807
15208
  "The most frequent value.",
14808
15209
  1,
@@ -14812,7 +15213,7 @@ var STATISTICAL_FUNCTIONS = [
14812
15213
  ),
14813
15214
  spec(
14814
15215
  "LARGE",
14815
- C27,
15216
+ C30,
14816
15217
  "LARGE(array, k)",
14817
15218
  "The k-th largest value.",
14818
15219
  2,
@@ -14822,7 +15223,7 @@ var STATISTICAL_FUNCTIONS = [
14822
15223
  ),
14823
15224
  spec(
14824
15225
  "SMALL",
14825
- C27,
15226
+ C30,
14826
15227
  "SMALL(array, k)",
14827
15228
  "The k-th smallest value.",
14828
15229
  2,
@@ -14833,7 +15234,7 @@ var STATISTICAL_FUNCTIONS = [
14833
15234
  ...["RANK", "RANK.EQ", "RANK.AVG"].map(
14834
15235
  (name) => spec(
14835
15236
  name,
14836
- C27,
15237
+ C30,
14837
15238
  `${name}(number, ref, [order])`,
14838
15239
  "The rank of a number in a list.",
14839
15240
  2,
@@ -14850,11 +15251,11 @@ var STATISTICAL_FUNCTIONS = [
14850
15251
  ];
14851
15252
 
14852
15253
  // src/xlsx/formula/functions/distributions-more.ts
14853
- var C28 = "Statistical";
15254
+ var C31 = "Statistical";
14854
15255
  var DISTRIBUTION_MORE = [
14855
15256
  numeric(
14856
15257
  "T.DIST",
14857
- C28,
15258
+ C31,
14858
15259
  "T.DIST(x, deg_freedom, cumulative)",
14859
15260
  "Student's left-tailed t-distribution.",
14860
15261
  3,
@@ -14866,7 +15267,7 @@ var DISTRIBUTION_MORE = [
14866
15267
  ),
14867
15268
  numeric(
14868
15269
  "T.DIST.RT",
14869
- C28,
15270
+ C31,
14870
15271
  "T.DIST.RT(x, deg_freedom)",
14871
15272
  "Student's right-tailed t-distribution.",
14872
15273
  2,
@@ -14878,7 +15279,7 @@ var DISTRIBUTION_MORE = [
14878
15279
  ),
14879
15280
  numeric(
14880
15281
  "T.DIST.2T",
14881
- C28,
15282
+ C31,
14882
15283
  "T.DIST.2T(x, deg_freedom)",
14883
15284
  "Student's two-tailed t-distribution.",
14884
15285
  2,
@@ -14890,7 +15291,7 @@ var DISTRIBUTION_MORE = [
14890
15291
  ),
14891
15292
  numeric(
14892
15293
  "TDIST",
14893
- C28,
15294
+ C31,
14894
15295
  "TDIST(x, deg_freedom, tails)",
14895
15296
  "Student's t-distribution.",
14896
15297
  3,
@@ -14902,7 +15303,7 @@ var DISTRIBUTION_MORE = [
14902
15303
  ),
14903
15304
  numeric(
14904
15305
  "T.INV",
14905
- C28,
15306
+ C31,
14906
15307
  "T.INV(probability, deg_freedom)",
14907
15308
  "The left-tailed inverse of Student's t-distribution.",
14908
15309
  2,
@@ -14917,7 +15318,7 @@ var DISTRIBUTION_MORE = [
14917
15318
  ...["T.INV.2T", "TINV"].map(
14918
15319
  (name) => numeric(
14919
15320
  name,
14920
- C28,
15321
+ C31,
14921
15322
  `${name}(probability, deg_freedom)`,
14922
15323
  "The two-tailed inverse of Student's t-distribution.",
14923
15324
  2,
@@ -14930,7 +15331,7 @@ var DISTRIBUTION_MORE = [
14930
15331
  ),
14931
15332
  numeric(
14932
15333
  "CHISQ.DIST",
14933
- C28,
15334
+ C31,
14934
15335
  "CHISQ.DIST(x, deg_freedom, cumulative)",
14935
15336
  "The chi-squared distribution.",
14936
15337
  3,
@@ -14944,7 +15345,7 @@ var DISTRIBUTION_MORE = [
14944
15345
  ...["CHISQ.DIST.RT", "CHIDIST"].map(
14945
15346
  (name) => numeric(
14946
15347
  name,
14947
- C28,
15348
+ C31,
14948
15349
  `${name}(x, deg_freedom)`,
14949
15350
  "The right-tailed chi-squared probability.",
14950
15351
  2,
@@ -14957,7 +15358,7 @@ var DISTRIBUTION_MORE = [
14957
15358
  ),
14958
15359
  numeric(
14959
15360
  "CHISQ.INV",
14960
- C28,
15361
+ C31,
14961
15362
  "CHISQ.INV(probability, deg_freedom)",
14962
15363
  "The inverse of the left-tailed chi-squared distribution.",
14963
15364
  2,
@@ -14970,7 +15371,7 @@ var DISTRIBUTION_MORE = [
14970
15371
  ...["CHISQ.INV.RT", "CHIINV"].map(
14971
15372
  (name) => numeric(
14972
15373
  name,
14973
- C28,
15374
+ C31,
14974
15375
  `${name}(probability, deg_freedom)`,
14975
15376
  "The inverse of the right-tailed chi-squared distribution.",
14976
15377
  2,
@@ -14983,7 +15384,7 @@ var DISTRIBUTION_MORE = [
14983
15384
  ),
14984
15385
  numeric(
14985
15386
  "BETA.DIST",
14986
- C28,
15387
+ C31,
14987
15388
  "BETA.DIST(x, alpha, beta, cumulative, [A], [B])",
14988
15389
  "The beta distribution.",
14989
15390
  4,
@@ -14991,7 +15392,7 @@ var DISTRIBUTION_MORE = [
14991
15392
  (x, a, b, c2, lo, hi) => {
14992
15393
  const A = lo ?? 0;
14993
15394
  const B = hi ?? 1;
14994
- positive(a, b);
15395
+ positive2(a, b);
14995
15396
  if (x < A || x > B || A === B) fail(ERR.NUM);
14996
15397
  const t = (x - A) / (B - A);
14997
15398
  const al = a ?? 1;
@@ -15003,7 +15404,7 @@ var DISTRIBUTION_MORE = [
15003
15404
  ),
15004
15405
  numeric(
15005
15406
  "NEGBINOM.DIST",
15006
- C28,
15407
+ C31,
15007
15408
  "NEGBINOM.DIST(number_f, number_s, probability_s, cumulative)",
15008
15409
  "The negative binomial distribution.",
15009
15410
  4,
@@ -15022,7 +15423,7 @@ var DISTRIBUTION_MORE = [
15022
15423
  ),
15023
15424
  numeric(
15024
15425
  "HYPGEOM.DIST",
15025
- C28,
15426
+ C31,
15026
15427
  "HYPGEOM.DIST(sample_s, number_sample, population_s, number_pop, cumulative)",
15027
15428
  "The hypergeometric distribution.",
15028
15429
  5,
@@ -15043,13 +15444,13 @@ var DISTRIBUTION_MORE = [
15043
15444
  ];
15044
15445
 
15045
15446
  // src/xlsx/formula/functions/distributions.ts
15046
- var C29 = "Statistical";
15447
+ var C32 = "Statistical";
15047
15448
  var DISTRIBUTION_FUNCTIONS = [
15048
15449
  ...DISTRIBUTION_MORE,
15049
15450
  ...DISTRIBUTION_F,
15050
15451
  numeric(
15051
15452
  "NORM.DIST",
15052
- C29,
15453
+ C32,
15053
15454
  "NORM.DIST(x, mean, standard_dev, cumulative)",
15054
15455
  "The normal distribution.",
15055
15456
  4,
@@ -15058,7 +15459,7 @@ var DISTRIBUTION_FUNCTIONS = [
15058
15459
  ),
15059
15460
  numeric(
15060
15461
  "NORMDIST",
15061
- C29,
15462
+ C32,
15062
15463
  "NORMDIST(x, mean, standard_dev, cumulative)",
15063
15464
  "The normal distribution.",
15064
15465
  4,
@@ -15067,7 +15468,7 @@ var DISTRIBUTION_FUNCTIONS = [
15067
15468
  ),
15068
15469
  numeric(
15069
15470
  "NORM.S.DIST",
15070
- C29,
15471
+ C32,
15071
15472
  "NORM.S.DIST(z, cumulative)",
15072
15473
  "The standard normal distribution.",
15073
15474
  2,
@@ -15076,7 +15477,7 @@ var DISTRIBUTION_FUNCTIONS = [
15076
15477
  ),
15077
15478
  numeric(
15078
15479
  "NORMSDIST",
15079
- C29,
15480
+ C32,
15080
15481
  "NORMSDIST(z)",
15081
15482
  "The standard normal cumulative distribution.",
15082
15483
  1,
@@ -15085,31 +15486,31 @@ var DISTRIBUTION_FUNCTIONS = [
15085
15486
  ),
15086
15487
  numeric(
15087
15488
  "NORM.INV",
15088
- C29,
15489
+ C32,
15089
15490
  "NORM.INV(probability, mean, standard_dev)",
15090
15491
  "The inverse of the normal cumulative distribution.",
15091
15492
  3,
15092
15493
  3,
15093
15494
  (p, m, s) => {
15094
- positive(s);
15495
+ positive2(s);
15095
15496
  return (m ?? 0) + (s ?? 1) * normInv(p);
15096
15497
  }
15097
15498
  ),
15098
15499
  numeric(
15099
15500
  "NORMINV",
15100
- C29,
15501
+ C32,
15101
15502
  "NORMINV(probability, mean, standard_dev)",
15102
15503
  "The inverse of the normal cumulative distribution.",
15103
15504
  3,
15104
15505
  3,
15105
15506
  (p, m, s) => {
15106
- positive(s);
15507
+ positive2(s);
15107
15508
  return (m ?? 0) + (s ?? 1) * normInv(p);
15108
15509
  }
15109
15510
  ),
15110
15511
  numeric(
15111
15512
  "NORM.S.INV",
15112
- C29,
15513
+ C32,
15113
15514
  "NORM.S.INV(probability)",
15114
15515
  "The inverse of the standard normal distribution.",
15115
15516
  1,
@@ -15118,17 +15519,17 @@ var DISTRIBUTION_FUNCTIONS = [
15118
15519
  ),
15119
15520
  numeric(
15120
15521
  "NORMSINV",
15121
- C29,
15522
+ C32,
15122
15523
  "NORMSINV(probability)",
15123
15524
  "The inverse of the standard normal distribution.",
15124
15525
  1,
15125
15526
  1,
15126
15527
  normInv
15127
15528
  ),
15128
- numeric("PHI", C29, "PHI(x)", "The standard normal density.", 1, 1, normPdf),
15529
+ numeric("PHI", C32, "PHI(x)", "The standard normal density.", 1, 1, normPdf),
15129
15530
  numeric(
15130
15531
  "GAUSS",
15131
- C29,
15532
+ C32,
15132
15533
  "GAUSS(z)",
15133
15534
  "The probability between the mean and z standard deviations.",
15134
15535
  1,
@@ -15166,14 +15567,14 @@ var DISTRIBUTION_FUNCTIONS = [
15166
15567
  ...["CONFIDENCE", "CONFIDENCE.NORM"].map(
15167
15568
  (name) => numeric(
15168
15569
  name,
15169
- C29,
15570
+ C32,
15170
15571
  `${name}(alpha, standard_dev, size)`,
15171
15572
  "The confidence interval for a population mean (normal).",
15172
15573
  3,
15173
15574
  3,
15174
15575
  (a, s, n) => {
15175
15576
  probability(a);
15176
- positive(s);
15577
+ positive2(s);
15177
15578
  if ((n ?? 0) < 1) fail(ERR.NUM);
15178
15579
  return normInv(1 - a / 2) * (s ?? 1) / Math.sqrt(Math.trunc(n ?? 1));
15179
15580
  }
@@ -15181,14 +15582,14 @@ var DISTRIBUTION_FUNCTIONS = [
15181
15582
  ),
15182
15583
  numeric(
15183
15584
  "CONFIDENCE.T",
15184
- C29,
15585
+ C32,
15185
15586
  "CONFIDENCE.T(alpha, standard_dev, size)",
15186
15587
  "The confidence interval for a population mean (Student's t).",
15187
15588
  3,
15188
15589
  3,
15189
15590
  (a, s, n) => {
15190
15591
  probability(a);
15191
- positive(s);
15592
+ positive2(s);
15192
15593
  const size = Math.trunc(n ?? 1);
15193
15594
  if (size < 2) fail(ERR.DIV0);
15194
15595
  return invert((t) => tCdf(t, size - 1), 1 - a / 2, 0, 10) * (s ?? 1) / Math.sqrt(size);
@@ -15197,7 +15598,7 @@ var DISTRIBUTION_FUNCTIONS = [
15197
15598
  ...["BINOM.DIST", "BINOMDIST"].map(
15198
15599
  (name) => numeric(
15199
15600
  name,
15200
- C29,
15601
+ C32,
15201
15602
  `${name}(number_s, trials, probability_s, cumulative)`,
15202
15603
  "The binomial distribution probability.",
15203
15604
  4,
@@ -15208,7 +15609,7 @@ var DISTRIBUTION_FUNCTIONS = [
15208
15609
  ...["POISSON.DIST", "POISSON"].map(
15209
15610
  (name) => numeric(
15210
15611
  name,
15211
- C29,
15612
+ C32,
15212
15613
  `${name}(x, mean, cumulative)`,
15213
15614
  "The Poisson distribution.",
15214
15615
  3,
@@ -15219,54 +15620,54 @@ var DISTRIBUTION_FUNCTIONS = [
15219
15620
  ...["EXPON.DIST", "EXPONDIST"].map(
15220
15621
  (name) => numeric(
15221
15622
  name,
15222
- C29,
15623
+ C32,
15223
15624
  `${name}(x, lambda, cumulative)`,
15224
15625
  "The exponential distribution.",
15225
15626
  3,
15226
15627
  3,
15227
15628
  (x, l, c2) => {
15228
15629
  if (x < 0) fail(ERR.NUM);
15229
- positive(l);
15630
+ positive2(l);
15230
15631
  return c2 ? 1 - Math.exp(-(l ?? 1) * x) : (l ?? 1) * Math.exp(-(l ?? 1) * x);
15231
15632
  }
15232
15633
  )
15233
15634
  ),
15234
15635
  numeric(
15235
15636
  "LOGNORM.DIST",
15236
- C29,
15637
+ C32,
15237
15638
  "LOGNORM.DIST(x, mean, standard_dev, cumulative)",
15238
15639
  "The lognormal distribution.",
15239
15640
  4,
15240
15641
  4,
15241
15642
  (x, m, s, c2) => {
15242
- positive(x, s);
15643
+ positive2(x, s);
15243
15644
  const z = (Math.log(x) - (m ?? 0)) / (s ?? 1);
15244
15645
  return c2 ? normCdf(z) : normPdf(z) / (x * (s ?? 1));
15245
15646
  }
15246
15647
  ),
15247
15648
  numeric(
15248
15649
  "LOGNORM.INV",
15249
- C29,
15650
+ C32,
15250
15651
  "LOGNORM.INV(probability, mean, standard_dev)",
15251
15652
  "The inverse of the lognormal distribution.",
15252
15653
  3,
15253
15654
  3,
15254
15655
  (p, m, s) => {
15255
- positive(s);
15656
+ positive2(s);
15256
15657
  return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
15257
15658
  }
15258
15659
  ),
15259
15660
  ...["WEIBULL.DIST", "WEIBULL"].map(
15260
15661
  (name) => numeric(
15261
15662
  name,
15262
- C29,
15663
+ C32,
15263
15664
  `${name}(x, alpha, beta, cumulative)`,
15264
15665
  "The Weibull distribution.",
15265
15666
  4,
15266
15667
  4,
15267
15668
  (x, a, b, c2) => {
15268
15669
  if (x < 0) fail(ERR.NUM);
15269
- positive(a, b);
15670
+ positive2(a, b);
15270
15671
  const al = a ?? 1;
15271
15672
  const be = b ?? 1;
15272
15673
  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));
@@ -15275,14 +15676,14 @@ var DISTRIBUTION_FUNCTIONS = [
15275
15676
  ),
15276
15677
  numeric(
15277
15678
  "GAMMA.DIST",
15278
- C29,
15679
+ C32,
15279
15680
  "GAMMA.DIST(x, alpha, beta, cumulative)",
15280
15681
  "The gamma distribution.",
15281
15682
  4,
15282
15683
  4,
15283
15684
  (x, a, b, c2) => {
15284
15685
  if (x < 0) fail(ERR.NUM);
15285
- positive(a, b);
15686
+ positive2(a, b);
15286
15687
  const al = a ?? 1;
15287
15688
  const be = b ?? 1;
15288
15689
  return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
@@ -15291,7 +15692,7 @@ var DISTRIBUTION_FUNCTIONS = [
15291
15692
  ];
15292
15693
 
15293
15694
  // src/xlsx/formula/functions/text-convert.ts
15294
- var C30 = "Text";
15695
+ var C33 = "Text";
15295
15696
  var CP1252 = {
15296
15697
  128: 8364,
15297
15698
  130: 8218,
@@ -15336,7 +15737,7 @@ function fixed(value, decimals, commas) {
15336
15737
  var TEXT_CONVERT = [
15337
15738
  spec(
15338
15739
  "TEXT",
15339
- C30,
15740
+ C33,
15340
15741
  "TEXT(value, format_text)",
15341
15742
  "Formats a value with a number format.",
15342
15743
  2,
@@ -15349,7 +15750,7 @@ var TEXT_CONVERT = [
15349
15750
  return formatValue(value, str(args[1]), { date1904: ctx.date1904 }).text;
15350
15751
  }
15351
15752
  ),
15352
- spec("VALUE", C30, "VALUE(text)", "Converts text to a number.", 1, 1, (args) => {
15753
+ spec("VALUE", C33, "VALUE(text)", "Converts text to a number.", 1, 1, (args) => {
15353
15754
  const v = scalar(args[0]);
15354
15755
  if (typeof v === "number") return v;
15355
15756
  if (v === null) return 0;
@@ -15359,7 +15760,7 @@ var TEXT_CONVERT = [
15359
15760
  }),
15360
15761
  spec(
15361
15762
  "NUMBERVALUE",
15362
- C30,
15763
+ C33,
15363
15764
  "NUMBERVALUE(text, [decimal_separator], [group_separator])",
15364
15765
  "Converts text to a number with given separators.",
15365
15766
  1,
@@ -15386,7 +15787,7 @@ var TEXT_CONVERT = [
15386
15787
  ),
15387
15788
  spec(
15388
15789
  "FIXED",
15389
- C30,
15790
+ C33,
15390
15791
  "FIXED(number, [decimals], [no_commas])",
15391
15792
  "Formats a number as text with fixed decimals.",
15392
15793
  1,
@@ -15395,7 +15796,7 @@ var TEXT_CONVERT = [
15395
15796
  ),
15396
15797
  spec(
15397
15798
  "DOLLAR",
15398
- C30,
15799
+ C33,
15399
15800
  "DOLLAR(number, [decimals])",
15400
15801
  "Formats a number as currency text.",
15401
15802
  1,
@@ -15406,28 +15807,28 @@ var TEXT_CONVERT = [
15406
15807
  return value < 0 && text.replace(/[0.,]/g, "") !== "" ? `($${text})` : `$${text}`;
15407
15808
  }
15408
15809
  ),
15409
- spec("CHAR", C30, "CHAR(number)", "The character for a code (Windows-1252).", 1, 1, (args) => {
15810
+ spec("CHAR", C33, "CHAR(number)", "The character for a code (Windows-1252).", 1, 1, (args) => {
15410
15811
  const n = int3(args[0]);
15411
15812
  if (n < 1 || n > 255) fail(ERR.VALUE);
15412
15813
  return String.fromCharCode(CP1252[n] ?? n);
15413
15814
  }),
15414
- spec("CODE", C30, "CODE(text)", "The code of the first character (Windows-1252).", 1, 1, (args) => {
15815
+ spec("CODE", C33, "CODE(text)", "The code of the first character (Windows-1252).", 1, 1, (args) => {
15415
15816
  const text = str(args[0]);
15416
15817
  if (text === "") fail(ERR.VALUE);
15417
15818
  const code = text.charCodeAt(0);
15418
15819
  return CP1252_REVERSE.get(code) ?? (code <= 255 ? code : 63);
15419
15820
  }),
15420
- spec("UNICHAR", C30, "UNICHAR(number)", "The Unicode character for a code point.", 1, 1, (args) => {
15821
+ spec("UNICHAR", C33, "UNICHAR(number)", "The Unicode character for a code point.", 1, 1, (args) => {
15421
15822
  const n = int3(args[0]);
15422
15823
  if (n < 1 || n > 1114111) fail(ERR.VALUE);
15423
15824
  return String.fromCodePoint(n);
15424
15825
  }),
15425
- spec("UNICODE", C30, "UNICODE(text)", "The code point of the first character.", 1, 1, (args) => {
15826
+ spec("UNICODE", C33, "UNICODE(text)", "The code point of the first character.", 1, 1, (args) => {
15426
15827
  const text = str(args[0]);
15427
15828
  if (text === "") fail(ERR.VALUE);
15428
15829
  return text.codePointAt(0) ?? fail(ERR.VALUE);
15429
15830
  }),
15430
- spec("T", C30, "T(value)", "The text of a value, or empty text.", 1, 1, (args) => {
15831
+ spec("T", C33, "T(value)", "The text of a value, or empty text.", 1, 1, (args) => {
15431
15832
  const v = scalar(args[0]);
15432
15833
  if (isError(v)) return v;
15433
15834
  return typeof v === "string" ? v : "";
@@ -15477,7 +15878,7 @@ function right(text, n) {
15477
15878
  }
15478
15879
 
15479
15880
  // src/xlsx/formula/functions/text.ts
15480
- var C31 = "Text";
15881
+ var C34 = "Text";
15481
15882
  var MAX_TEXT = 32767;
15482
15883
  var limit = (text) => text.length > MAX_TEXT ? fail(ERR.VALUE) : text;
15483
15884
  function find(args, insensitive) {
@@ -15510,7 +15911,7 @@ var TEXT_FUNCTIONS = [
15510
15911
  ...TEXT_CONVERT,
15511
15912
  spec(
15512
15913
  "CONCATENATE",
15513
- C31,
15914
+ C34,
15514
15915
  "CONCATENATE(text1, [text2], ...)",
15515
15916
  "Joins text items.",
15516
15917
  1,
@@ -15519,7 +15920,7 @@ var TEXT_FUNCTIONS = [
15519
15920
  ),
15520
15921
  spec(
15521
15922
  "CONCAT",
15522
- C31,
15923
+ C34,
15523
15924
  "CONCAT(text1, [text2], ...)",
15524
15925
  "Joins text from items and ranges.",
15525
15926
  1,
@@ -15529,7 +15930,7 @@ var TEXT_FUNCTIONS = [
15529
15930
  ),
15530
15931
  spec(
15531
15932
  "TEXTJOIN",
15532
- C31,
15933
+ C34,
15533
15934
  "TEXTJOIN(delimiter, ignore_empty, text1, ...)",
15534
15935
  "Joins text with a delimiter.",
15535
15936
  3,
@@ -15548,14 +15949,14 @@ var TEXT_FUNCTIONS = [
15548
15949
  ["any"]
15549
15950
  ),
15550
15951
  ...["LEFT", "LEFTB"].map(
15551
- (name) => spec(name, C31, `${name}(text, [num_chars])`, "The first characters of a text.", 1, 2, (args) => {
15952
+ (name) => spec(name, C34, `${name}(text, [num_chars])`, "The first characters of a text.", 1, 2, (args) => {
15552
15953
  const n = optNum(args, 1, 1);
15553
15954
  if (n < 0) fail(ERR.VALUE);
15554
15955
  return left(str(args[0]), Math.trunc(n));
15555
15956
  })
15556
15957
  ),
15557
15958
  ...["RIGHT", "RIGHTB"].map(
15558
- (name) => spec(name, C31, `${name}(text, [num_chars])`, "The last characters of a text.", 1, 2, (args) => {
15959
+ (name) => spec(name, C34, `${name}(text, [num_chars])`, "The last characters of a text.", 1, 2, (args) => {
15559
15960
  const n = Math.trunc(optNum(args, 1, 1));
15560
15961
  if (n < 0) fail(ERR.VALUE);
15561
15962
  return right(str(args[0]), n);
@@ -15564,7 +15965,7 @@ var TEXT_FUNCTIONS = [
15564
15965
  ...["MID", "MIDB"].map(
15565
15966
  (name) => spec(
15566
15967
  name,
15567
- C31,
15968
+ C34,
15568
15969
  `${name}(text, start_num, num_chars)`,
15569
15970
  "Characters from the middle of a text.",
15570
15971
  3,
@@ -15580,7 +15981,7 @@ var TEXT_FUNCTIONS = [
15580
15981
  ...["LEN", "LENB"].map(
15581
15982
  (name) => spec(
15582
15983
  name,
15583
- C31,
15984
+ C34,
15584
15985
  `${name}(text)`,
15585
15986
  "The number of characters in a text.",
15586
15987
  1,
@@ -15590,7 +15991,7 @@ var TEXT_FUNCTIONS = [
15590
15991
  ),
15591
15992
  spec(
15592
15993
  "LOWER",
15593
- C31,
15994
+ C34,
15594
15995
  "LOWER(text)",
15595
15996
  "Converts text to lower case.",
15596
15997
  1,
@@ -15599,7 +16000,7 @@ var TEXT_FUNCTIONS = [
15599
16000
  ),
15600
16001
  spec(
15601
16002
  "UPPER",
15602
- C31,
16003
+ C34,
15603
16004
  "UPPER(text)",
15604
16005
  "Converts text to upper case.",
15605
16006
  1,
@@ -15608,7 +16009,7 @@ var TEXT_FUNCTIONS = [
15608
16009
  ),
15609
16010
  spec(
15610
16011
  "PROPER",
15611
- C31,
16012
+ C34,
15612
16013
  "PROPER(text)",
15613
16014
  "Capitalizes the first letter of each word.",
15614
16015
  1,
@@ -15617,7 +16018,7 @@ var TEXT_FUNCTIONS = [
15617
16018
  ),
15618
16019
  spec(
15619
16020
  "TRIM",
15620
- C31,
16021
+ C34,
15621
16022
  "TRIM(text)",
15622
16023
  "Removes extra spaces.",
15623
16024
  1,
@@ -15626,7 +16027,7 @@ var TEXT_FUNCTIONS = [
15626
16027
  ),
15627
16028
  spec(
15628
16029
  "CLEAN",
15629
- C31,
16030
+ C34,
15630
16031
  "CLEAN(text)",
15631
16032
  "Removes non-printable characters.",
15632
16033
  1,
@@ -15638,7 +16039,7 @@ var TEXT_FUNCTIONS = [
15638
16039
  ),
15639
16040
  spec(
15640
16041
  "SUBSTITUTE",
15641
- C31,
16042
+ C34,
15642
16043
  "SUBSTITUTE(text, old_text, new_text, [instance_num])",
15643
16044
  "Replaces occurrences of a text.",
15644
16045
  3,
@@ -15662,7 +16063,7 @@ var TEXT_FUNCTIONS = [
15662
16063
  ...["REPLACE", "REPLACEB"].map(
15663
16064
  (name) => spec(
15664
16065
  name,
15665
- C31,
16066
+ C34,
15666
16067
  `${name}(old_text, start_num, num_chars, new_text)`,
15667
16068
  "Replaces part of a text.",
15668
16069
  4,
@@ -15679,7 +16080,7 @@ var TEXT_FUNCTIONS = [
15679
16080
  ...["FIND", "FINDB"].map(
15680
16081
  (name) => spec(
15681
16082
  name,
15682
- C31,
16083
+ C34,
15683
16084
  `${name}(find_text, within_text, [start_num])`,
15684
16085
  "The position of a text (case-sensitive).",
15685
16086
  2,
@@ -15690,7 +16091,7 @@ var TEXT_FUNCTIONS = [
15690
16091
  ...["SEARCH", "SEARCHB"].map(
15691
16092
  (name) => spec(
15692
16093
  name,
15693
- C31,
16094
+ C34,
15694
16095
  `${name}(find_text, within_text, [start_num])`,
15695
16096
  "The position of a text (wildcards, any case).",
15696
16097
  2,
@@ -15698,7 +16099,7 @@ var TEXT_FUNCTIONS = [
15698
16099
  (args) => find(args, true)
15699
16100
  )
15700
16101
  ),
15701
- spec("REPT", C31, "REPT(text, number_times)", "Repeats a text.", 2, 2, (args) => {
16102
+ spec("REPT", C34, "REPT(text, number_times)", "Repeats a text.", 2, 2, (args) => {
15702
16103
  const n = Math.trunc(num2(args[1]));
15703
16104
  const text = str(args[0]);
15704
16105
  if (n < 0 || text.length * n > MAX_TEXT) fail(ERR.VALUE);
@@ -15706,7 +16107,7 @@ var TEXT_FUNCTIONS = [
15706
16107
  }),
15707
16108
  spec(
15708
16109
  "EXACT",
15709
- C31,
16110
+ C34,
15710
16111
  "EXACT(text1, text2)",
15711
16112
  "Whether two texts are identical (case-sensitive).",
15712
16113
  2,
@@ -15715,8 +16116,78 @@ var TEXT_FUNCTIONS = [
15715
16116
  )
15716
16117
  ];
15717
16118
 
16119
+ // src/xlsx/formula/functions/text-regex.ts
16120
+ var C35 = "Text";
16121
+ function compile(pattern, caseMode2, global) {
16122
+ if (caseMode2 !== 0 && caseMode2 !== 1) fail(ERR.VALUE);
16123
+ try {
16124
+ return new RegExp(pattern, `${global ? "g" : ""}${caseMode2 === 1 ? "i" : ""}u`);
16125
+ } catch {
16126
+ return fail(ERR.VALUE);
16127
+ }
16128
+ }
16129
+ var caseMode = (args, index2) => optNum(args, index2, 0);
16130
+ function encodeUrl(text) {
16131
+ return encodeURIComponent(text).replace(
16132
+ /[!'()*]/g,
16133
+ (c2) => `%${c2.charCodeAt(0).toString(16).toUpperCase()}`
16134
+ );
16135
+ }
16136
+ var TEXT_REGEX_FUNCTIONS = [
16137
+ spec(
16138
+ "ENCODEURL",
16139
+ C35,
16140
+ "ENCODEURL(text)",
16141
+ "Percent-encodes text for use in a URL.",
16142
+ 1,
16143
+ 1,
16144
+ (args) => encodeUrl(str(args[0]))
16145
+ ),
16146
+ spec(
16147
+ "REGEXTEST",
16148
+ C35,
16149
+ "REGEXTEST(text, pattern, [case_sensitivity])",
16150
+ "Whether any part of the text matches the pattern.",
16151
+ 2,
16152
+ 3,
16153
+ (args) => compile(str(args[1]), caseMode(args, 2), false).test(str(args[0]))
16154
+ ),
16155
+ spec(
16156
+ "REGEXEXTRACT",
16157
+ C35,
16158
+ "REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])",
16159
+ "The first part of the text that matches the pattern.",
16160
+ 2,
16161
+ 4,
16162
+ (args) => {
16163
+ if (optNum(args, 2, 0) !== 0) fail(ERR.VALUE);
16164
+ const match2 = compile(str(args[1]), caseMode(args, 3), false).exec(str(args[0]));
16165
+ return match2 ? match2[0] : fail(ERR.NA);
16166
+ }
16167
+ ),
16168
+ spec(
16169
+ "REGEXREPLACE",
16170
+ C35,
16171
+ "REGEXREPLACE(text, pattern, replacement, [occurrence], [case_sensitivity])",
16172
+ "Replaces the parts of the text that match the pattern.",
16173
+ 3,
16174
+ 5,
16175
+ (args) => {
16176
+ const text = str(args[0]);
16177
+ const regex = compile(str(args[1]), caseMode(args, 4), true);
16178
+ const replacement = str(args[2]);
16179
+ const occurrence = args.length > 3 && args[3] !== null ? int3(args[3]) : 0;
16180
+ if (occurrence === 0) return text.replace(regex, replacement);
16181
+ const matches2 = [...text.matchAll(regex)];
16182
+ const picked = occurrence > 0 ? matches2[occurrence - 1] : matches2.at(occurrence);
16183
+ if (!picked || picked.index === void 0) return text;
16184
+ 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);
16185
+ }
16186
+ )
16187
+ ];
16188
+
15718
16189
  // src/xlsx/formula/functions/text-extra.ts
15719
- var C32 = "Text";
16190
+ var C36 = "Text";
15720
16191
  function delimitersOf(ctx, value) {
15721
16192
  if (value === void 0 || value === null) return [];
15722
16193
  return ctx.toMatrix(value).flat().map((v) => {
@@ -15782,9 +16253,10 @@ function valueToText(value, strict) {
15782
16253
  return toText(value);
15783
16254
  }
15784
16255
  var TEXT_EXTRA_FUNCTIONS = [
16256
+ ...TEXT_REGEX_FUNCTIONS,
15785
16257
  spec(
15786
16258
  "TEXTBEFORE",
15787
- C32,
16259
+ C36,
15788
16260
  "TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
15789
16261
  "The text before a delimiter.",
15790
16262
  2,
@@ -15794,7 +16266,7 @@ var TEXT_EXTRA_FUNCTIONS = [
15794
16266
  ),
15795
16267
  spec(
15796
16268
  "TEXTAFTER",
15797
- C32,
16269
+ C36,
15798
16270
  "TEXTAFTER(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
15799
16271
  "The text after a delimiter.",
15800
16272
  2,
@@ -15804,7 +16276,7 @@ var TEXT_EXTRA_FUNCTIONS = [
15804
16276
  ),
15805
16277
  spec(
15806
16278
  "TEXTSPLIT",
15807
- C32,
16279
+ C36,
15808
16280
  "TEXTSPLIT(text, col_delimiter, [row_delimiter], [ignore_empty], [match_mode], [pad_with])",
15809
16281
  "Splits text into an array.",
15810
16282
  2,
@@ -15827,7 +16299,7 @@ var TEXT_EXTRA_FUNCTIONS = [
15827
16299
  ),
15828
16300
  spec(
15829
16301
  "VALUETOTEXT",
15830
- C32,
16302
+ C36,
15831
16303
  "VALUETOTEXT(value, [format])",
15832
16304
  "Text for any value.",
15833
16305
  1,
@@ -15836,7 +16308,7 @@ var TEXT_EXTRA_FUNCTIONS = [
15836
16308
  ),
15837
16309
  spec(
15838
16310
  "ARRAYTOTEXT",
15839
- C32,
16311
+ C36,
15840
16312
  "ARRAYTOTEXT(array, [format])",
15841
16313
  "Text for an array.",
15842
16314
  1,
@@ -15995,16 +16467,16 @@ function shiftSpan(start, end, shift2) {
15995
16467
  }
15996
16468
  function shiftRange(range, shift2) {
15997
16469
  if (shift2.axis === "row") {
15998
- const span2 = shiftSpan(range.start.row, range.end.row, shift2);
15999
- return span2 && {
16000
- start: { row: span2.start, col: range.start.col },
16001
- end: { row: span2.end, col: range.end.col }
16470
+ const span3 = shiftSpan(range.start.row, range.end.row, shift2);
16471
+ return span3 && {
16472
+ start: { row: span3.start, col: range.start.col },
16473
+ end: { row: span3.end, col: range.end.col }
16002
16474
  };
16003
16475
  }
16004
- const span = shiftSpan(range.start.col, range.end.col, shift2);
16005
- return span && {
16006
- start: { row: range.start.row, col: span.start },
16007
- end: { row: range.end.row, col: span.end }
16476
+ const span2 = shiftSpan(range.start.col, range.end.col, shift2);
16477
+ return span2 && {
16478
+ start: { row: range.start.row, col: span2.start },
16479
+ end: { row: range.end.row, col: span2.end }
16008
16480
  };
16009
16481
  }
16010
16482
  function shiftRangeInBand(range, shift2, lo, hi) {
@@ -16796,7 +17268,9 @@ function workbookXml(workbook, sheets, activeTab, sourceXml) {
16796
17268
  ).join("")}</definedNames>`;
16797
17269
  const calc = kept.get("calcPr");
16798
17270
  const mode = workbook.calcMode === "manual" ? ' calcMode="manual"' : "";
16799
- out += `<calcPr${copyAttrs(calc, ["fullCalcOnLoad", "calcId", "calcMode"])} calcId="191029"${mode} fullCalcOnLoad="1"/>`;
17271
+ const iterate = workbook.iterate ? ` iterate="1" iterateCount="${workbook.iterate.count}" iterateDelta="${workbook.iterate.delta}"` : "";
17272
+ const owned = ["fullCalcOnLoad", "calcId", "calcMode", "iterate", "iterateCount", "iterateDelta"];
17273
+ out += `<calcPr${copyAttrs(calc, owned)} calcId="191029"${mode}${iterate} fullCalcOnLoad="1"/>`;
16800
17274
  out += raw(KEPT_TAIL);
16801
17275
  return `${out}</workbook>`;
16802
17276
  }