@sheetxl/formulas-extended 0.8.0-beta.1 → 0.8.0-beta.10

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.
Files changed (136) hide show
  1. package/browser/esm/{BuGemmv84T8m0wqw.mjs → B8U2Eza2ZD4YA-kx.mjs} +1 -1
  2. package/browser/esm/{DpoZ7h1ScIJvbOY9.mjs → BFtgupqxZCxn0dyD.mjs} +5 -5
  3. package/{node/esm/vu0NRDeeTbEHPMYS.mjs → browser/esm/Bg1eKDrYnq3wm8Vk.mjs} +2 -2
  4. package/browser/esm/Bg54DWqi-iRcswhc.mjs +119 -0
  5. package/browser/esm/BiXqZc5QZjxe9VkT.mjs +32 -0
  6. package/browser/esm/BskZz_6FiOeOABjK.mjs +20 -0
  7. package/browser/esm/C2QrdSuGHG9jhlMh.mjs +23 -0
  8. package/{node/esm/BRwwvGaJ6HvkxjFC.mjs → browser/esm/C9G09aQXW2LLuPt3.mjs} +1 -1
  9. package/browser/esm/CFee1d5IBiv4fv1i.mjs +37 -0
  10. package/browser/esm/{BFnDPCjxJcoIItFa.mjs → CHIJMJGn8-ecsv3s.mjs} +3 -3
  11. package/browser/esm/CJjzoao3hDloxUGc.mjs +19 -0
  12. package/browser/esm/CcDbY4A8EXqKtmVV.mjs +47 -0
  13. package/{node/esm/DodhOXkSzelSxHmB.mjs → browser/esm/Cl3Yo2J4W4DMr8oz.mjs} +27 -29
  14. package/browser/esm/D02eJGMi5PwKHsoL.mjs +58 -0
  15. package/{node/esm/Bma3CN4_Nec6_4n7.mjs → browser/esm/DEQlCPiGb8bsBizr.mjs} +6 -6
  16. package/browser/esm/{B1VmvhXuEn7zaTB9.mjs → DSBsgMaUW3RQ6ceC.mjs} +1 -1
  17. package/{node/esm/COqdI1LYTHd9oLA6.mjs → browser/esm/Db0ejvxhdCFJuDKI.mjs} +1 -1
  18. package/{node/esm/srpVt74r2zbvm1N0.mjs → browser/esm/Dcl4zSjM1tlh53wy.mjs} +5 -5
  19. package/browser/esm/Djzfm7ZsIsQvtPGt.mjs +32 -0
  20. package/{node/esm/CnVJ8GAsshRjRGA-.mjs → browser/esm/WS_eaJSI0r2L5MVv.mjs} +2 -2
  21. package/browser/esm/g9IHvvfn4bYTwHgl.mjs +33 -0
  22. package/browser/esm/index.mjs +3818 -1682
  23. package/browser/esm/{DY3kG36QGyDbrANO.mjs → yS93vAhNdRw2bt-z.mjs} +1 -1
  24. package/node/esm/{BuGemmv84T8m0wqw.mjs → B8U2Eza2ZD4YA-kx.mjs} +1 -1
  25. package/node/esm/{DpoZ7h1ScIJvbOY9.mjs → BFtgupqxZCxn0dyD.mjs} +5 -5
  26. package/node/esm/BHHFJIl22DBeM9aP.mjs +19 -0
  27. package/{browser/esm/vu0NRDeeTbEHPMYS.mjs → node/esm/Bg1eKDrYnq3wm8Vk.mjs} +2 -2
  28. package/node/esm/Bg54DWqi-iRcswhc.mjs +119 -0
  29. package/node/esm/BiXqZc5QZjxe9VkT.mjs +32 -0
  30. package/node/esm/BskZz_6FiOeOABjK.mjs +20 -0
  31. package/node/esm/C2QrdSuGHG9jhlMh.mjs +23 -0
  32. package/{browser/esm/BRwwvGaJ6HvkxjFC.mjs → node/esm/C9G09aQXW2LLuPt3.mjs} +1 -1
  33. package/node/esm/CFee1d5IBiv4fv1i.mjs +37 -0
  34. package/node/esm/{BQyZVLTMNFLbjVap.mjs → C_IrfNxfWXKc8kjo.mjs} +3 -3
  35. package/node/esm/{LAkTk93odAfpvx50.mjs → Cc4Bkwtihl8DmEub.mjs} +1 -1
  36. package/node/esm/CcDbY4A8EXqKtmVV.mjs +47 -0
  37. package/{browser/esm/DodhOXkSzelSxHmB.mjs → node/esm/Cl3Yo2J4W4DMr8oz.mjs} +27 -29
  38. package/node/esm/D02eJGMi5PwKHsoL.mjs +58 -0
  39. package/{browser/esm/Bma3CN4_Nec6_4n7.mjs → node/esm/DEQlCPiGb8bsBizr.mjs} +6 -6
  40. package/node/esm/{B1VmvhXuEn7zaTB9.mjs → DSBsgMaUW3RQ6ceC.mjs} +1 -1
  41. package/{browser/esm/COqdI1LYTHd9oLA6.mjs → node/esm/Db0ejvxhdCFJuDKI.mjs} +1 -1
  42. package/{browser/esm/srpVt74r2zbvm1N0.mjs → node/esm/Dcl4zSjM1tlh53wy.mjs} +5 -5
  43. package/node/esm/Djzfm7ZsIsQvtPGt.mjs +32 -0
  44. package/{browser/esm/CnVJ8GAsshRjRGA-.mjs → node/esm/WS_eaJSI0r2L5MVv.mjs} +2 -2
  45. package/node/esm/g9IHvvfn4bYTwHgl.mjs +33 -0
  46. package/node/esm/index.mjs +4147 -1993
  47. package/package.json +5 -6
  48. package/types/src/.generated/decl/financial/Annuity.decl.d.ts +5 -0
  49. package/types/src/.generated/decl/financial/{Financial.decl.d.ts → Cashflow.decl.d.ts} +1 -1
  50. package/types/src/.generated/decl/financial/Convert.decl.d.ts +4 -0
  51. package/types/src/.generated/decl/financial/Coupon.decl.d.ts +4 -0
  52. package/types/src/.generated/decl/financial/{Financial2.decl.d.ts → Depreciation.decl.d.ts} +1 -1
  53. package/types/src/.generated/decl/financial/Growth.decl.d.ts +4 -0
  54. package/types/src/.generated/decl/financial/{ODD.decl.d.ts → Odd.decl.d.ts} +1 -1
  55. package/types/src/.generated/decl/financial/{Financial3.decl.d.ts → STOCKHISTORY.decl.d.ts} +1 -1
  56. package/types/src/.generated/decl/financial/Security.decl.d.ts +4 -0
  57. package/types/src/.generated/decl/financial/{Financial4.decl.d.ts → SecurityMaturity.decl.d.ts} +1 -1
  58. package/types/src/.generated/decl/{statistical/TTEST.decl.d.ts → financial/TBill.decl.d.ts} +1 -1
  59. package/types/src/.generated/decl/lookupReference/GroupBy.decl.d.ts +4 -0
  60. package/types/src/.generated/decl/lookupReference/PivotBy.decl.d.ts +4 -0
  61. package/types/src/.generated/decl/statistical/{ETS.decl.d.ts → Ets.decl.d.ts} +1 -1
  62. package/types/src/.generated/decl/statistical/TTest.decl.d.ts +4 -0
  63. package/types/src/.generated/desc/financial/Annuity.desc.d.ts +5 -0
  64. package/types/src/.generated/desc/financial/{Financial.desc.d.ts → Cashflow.desc.d.ts} +1 -1
  65. package/types/src/.generated/desc/financial/Convert.desc.d.ts +4 -0
  66. package/types/src/.generated/desc/financial/Coupon.desc.d.ts +4 -0
  67. package/types/src/.generated/desc/financial/{Financial2.desc.d.ts → Depreciation.desc.d.ts} +1 -1
  68. package/types/src/.generated/desc/financial/Growth.desc.d.ts +4 -0
  69. package/types/src/.generated/desc/financial/{ODD.desc.d.ts → Odd.desc.d.ts} +1 -1
  70. package/types/src/.generated/desc/financial/{Financial3.desc.d.ts → STOCKHISTORY.desc.d.ts} +1 -1
  71. package/types/src/.generated/desc/financial/Security.desc.d.ts +4 -0
  72. package/types/src/.generated/desc/financial/{Financial4.desc.d.ts → SecurityMaturity.desc.d.ts} +1 -1
  73. package/types/src/.generated/desc/{statistical/TTEST.desc.d.ts → financial/TBill.desc.d.ts} +1 -1
  74. package/types/src/.generated/desc/lookupReference/GroupBy.desc.d.ts +4 -0
  75. package/types/src/.generated/desc/lookupReference/PivotBy.desc.d.ts +4 -0
  76. package/types/src/.generated/desc/statistical/{ETS.desc.d.ts → Ets.desc.d.ts} +1 -1
  77. package/types/src/.generated/desc/statistical/TTest.desc.d.ts +4 -0
  78. package/types/src/_utils/AnyArgs.d.ts +17 -3
  79. package/types/src/_utils/FinanaceSolver.d.ts +39 -2
  80. package/types/src/_utils/FinanceAmor.d.ts +23 -0
  81. package/types/src/_utils/FinanceCashflow.d.ts +42 -0
  82. package/types/src/_utils/FinanceCoupon.d.ts +92 -82
  83. package/types/src/_utils/FinanceDate.d.ts +24 -0
  84. package/types/src/_utils/FinanceDayCount.d.ts +46 -0
  85. package/types/src/_utils/FinanceOdd.d.ts +93 -0
  86. package/types/src/_utils/FinanceSecurity.d.ts +84 -0
  87. package/types/src/_utils/FinanceUtils.d.ts +37 -1
  88. package/types/src/_utils/LeastSquares.d.ts +20 -22
  89. package/types/src/_utils/Pivot.d.ts +205 -0
  90. package/types/src/_utils/RegexCompile.d.ts +33 -0
  91. package/types/src/cube/Cube.d.ts +7 -7
  92. package/types/src/financial/ACCRINT.d.ts +33 -6
  93. package/types/src/financial/AMORDEGRC.d.ts +22 -40
  94. package/types/src/financial/Annuity.d.ts +118 -0
  95. package/types/src/financial/Cashflow.d.ts +84 -0
  96. package/types/src/financial/Convert.d.ts +26 -0
  97. package/types/src/financial/Coupon.d.ts +72 -0
  98. package/types/src/financial/Date.d.ts +34 -5
  99. package/types/src/financial/Depreciation.d.ts +58 -0
  100. package/types/src/financial/Growth.d.ts +22 -0
  101. package/types/src/financial/Odd.d.ts +82 -0
  102. package/types/src/financial/STOCKHISTORY.d.ts +17 -0
  103. package/types/src/financial/Security.d.ts +68 -0
  104. package/types/src/financial/SecurityMaturity.d.ts +107 -0
  105. package/types/src/financial/TBill.d.ts +40 -0
  106. package/types/src/financial/VDB.d.ts +15 -13
  107. package/types/src/lookupReference/GroupBy.d.ts +14 -0
  108. package/types/src/lookupReference/PivotBy.d.ts +17 -0
  109. package/types/src/statistical/{ETS.d.ts → Ets.d.ts} +14 -14
  110. package/types/src/statistical/Regression.d.ts +13 -18
  111. package/types/src/statistical/{TTEST.d.ts → TTest.d.ts} +5 -5
  112. package/types/src/text/RegEx.d.ts +34 -11
  113. package/browser/cjs/B4JJfKSI4ppwU855.cjs +0 -1
  114. package/browser/cjs/BWDfauDHqB6U_2ka.cjs +0 -1
  115. package/browser/cjs/BwLx9ix5Sq7suAYP.cjs +0 -1
  116. package/browser/cjs/C2uDl8VIJqh58YF_.cjs +0 -1
  117. package/browser/cjs/CW-b31_-r-_raT8Y.cjs +0 -1
  118. package/browser/cjs/Clu7XiAsCB48GDXN.cjs +0 -1
  119. package/browser/cjs/CnZfa45XxA-9Jhmp.cjs +0 -1
  120. package/browser/cjs/DsFZgtSQpC75d1M0.cjs +0 -1
  121. package/browser/cjs/JfM6P_qoQQTWakZf.cjs +0 -1
  122. package/browser/cjs/bM25C5avKgBAJVfk.cjs +0 -1
  123. package/browser/cjs/fqTQ_p3ehzUvc1tF.cjs +0 -1
  124. package/browser/cjs/h3dw1jAp2J5Pu4p3.cjs +0 -1
  125. package/browser/cjs/index.cjs +0 -1
  126. package/browser/cjs/jev6VGWTdgEgm4Yk.cjs +0 -1
  127. package/browser/cjs/lEQC21-Sk4lwHy2r.cjs +0 -1
  128. package/browser/esm/CwoMEzOtRihuYUTr.mjs +0 -20
  129. package/browser/esm/Dy6UD7hQRBsT0WNp.mjs +0 -304
  130. package/node/esm/CwoMEzOtRihuYUTr.mjs +0 -20
  131. package/node/esm/Dy6UD7hQRBsT0WNp.mjs +0 -304
  132. package/types/src/financial/Financial.d.ts +0 -288
  133. package/types/src/financial/Financial2.d.ts +0 -99
  134. package/types/src/financial/Financial3.d.ts +0 -95
  135. package/types/src/financial/Financial4.d.ts +0 -82
  136. package/types/src/financial/ODD.d.ts +0 -106
@@ -23,4 +23,28 @@ export declare function isMoreThanOneYearAfter(startSerial: number, endSerial: n
23
23
  * `setMonth` which truncates automatically.
24
24
  */
25
25
  export declare function dateAddMonths(date: Date, months: number): Date;
26
+ /**
27
+ * Calendar fields of a serial date. `m` is 1-based.
28
+ */
29
+ export interface DateFields {
30
+ y: number;
31
+ m: number;
32
+ d: number;
33
+ }
34
+ /** Days in month `m` (1-based), on the real Gregorian calendar. */
35
+ export declare const daysInMonth: (y: number, m: number) => number;
36
+ /** True when `x` is the last day of its month. */
37
+ export declare const isMonthEnd: (x: DateFields) => boolean;
38
+ /** The workbook calendar's fields for a serial. */
39
+ export declare function getDateFields(serial: number): DateFields;
40
+ /**
41
+ * The serial of calendar fields, extended linearly BELOW the calendar (1899-12-31 is 0, and on
42
+ * down) and with a day past the month's end OVERFLOWING into the next month — a "Feb 30" is
43
+ * Mar 1. The coupon chains that walk off either end of the calendar are measured against Excel
44
+ * on those extended values, so they need an arithmetic that keeps producing them
45
+ * (fn-battery financial/ACCRINT and /ODDLPRICE).
46
+ */
47
+ export declare function getSerialOfFields(y: number, m: number, d: number): number;
48
+ /** The fields `months` months on from `x`, the day clamped to the destination month. */
49
+ export declare function addMonthsClamped(x: DateFields, months: number): DateFields;
26
50
  //# sourceMappingURL=FinanceDate.d.ts.map
@@ -77,4 +77,50 @@ export declare function getDayCount(startSerial: number, endSerial: number, basi
77
77
  *
78
78
  */
79
79
  export declare function getDays360US(startSerial: number, endSerial: number): number;
80
+ /** The last serial of the 1900 calendar (9999-12-31). */
81
+ export declare const MAX_SERIAL_DATE = 2958465;
82
+ /**
83
+ * Excel's date-slot domain for the day-count family, measured on DAYS360, YEARFRAC, DATEDIF
84
+ * and the six coupon functions (fn-battery financial/*, 2026-08-28): the RAW value must not be
85
+ * negative (`-1E-9` is #NUM!) and the truncated serial must not pass 9999-12-31 (`2958465.9` is
86
+ * a legal 9999-12-31). The fraction is otherwise discarded by every function in the family.
87
+ */
88
+ export declare function isSerialDateInRange(serial: number): boolean;
89
+ /**
90
+ * `YEARFRAC` — measured against Excel 16.0 (fn-battery financial/YEARFRAC, 2026-08-28). Both
91
+ * serials are truncated first, the earlier date becomes the start, and basis 0 is then the
92
+ * SIGNED NASD count: Excel orders the dates but never takes a magnitude, so
93
+ * `YEARFRAC(59,60,0)` — 1900-02-28, a real month end, against the phantom 1900-02-29 that is
94
+ * not — is `-1/360`. The other bases cannot go negative once ordered. The caller has validated
95
+ * the serials and the basis.
96
+ */
97
+ export declare function getYearFrac(startSerial: number, endSerial: number, basis: number): number;
98
+ /**
99
+ * The years to maturity a bond-yield ITERATION starts from — not `YEARFRAC`, and not the coupon
100
+ * count over the frequency. Whole years are stepped off the settlement (the day clamped to each
101
+ * destination month) and the remainder is the basis's own day count over the basis's year: the
102
+ * 30/360 counts over 360 at bases 0 and 4, real days over 360 at basis 2 and over 365 at basis 3,
103
+ * and real days over the MATURITY'S OWN year at basis 1 — 366 out of a leap year, whatever the
104
+ * remainder itself covers. Basis 0's February here is the LEGACY calendar's: a Feb 29 start is a
105
+ * month end and a Feb 28 is not, which is neither `getDayCount`'s rule (the real calendar's month
106
+ * end, so Feb 28 counts too) nor `getDays360US`'s (which also lets the conversion steer the end).
107
+ *
108
+ * Measured on 1,154 rows where the answer depends on nothing else (fn-battery
109
+ * financial/adhoc-yield-n, -n2, -n3), 2026-09-09.
110
+ *
111
+ * Used by: YIELD, ODDFYIELD.
112
+ */
113
+ export declare function getYearsToMaturity(settlement: number, maturity: number, basis: number): number;
114
+ /**
115
+ * The stub-period day count of AMORLINC/AMORDEGRC (the year fraction is `days / yearDays`, and
116
+ * the caller groups that as Excel does) — measured against Excel 16.0 (fn-battery
117
+ * financial/AMORLINC, /AMORDEGRC, 2026-08-28), and NOT YEARFRAC's: serials are truncated, the
118
+ * 30/360 bases count days as `getDayCount` does over 360, basis 3 is actual days over 365, and
119
+ * basis 1 is actual days over the length of the PURCHASE year (366 only when that year is a
120
+ * Gregorian leap year — 1900 is not — whatever the span crosses; 2007-12-31 → 2008-12-31 is
121
+ * 366/365), and in both actual bases a real Feb 29 counts as the 28th (`_feb29AsFeb28`). A zero-day stub is a whole period (`purchase = first period`, or Dec 30 → Dec 31
122
+ * at basis 0), and a stub longer than a year is not capped. Basis 2 is not accepted by either
123
+ * function; the caller has refused it before this is called.
124
+ */
125
+ export declare function getAmorDayCount(purchased: number, firstPeriod: number, basis: number): DayCount;
80
126
  //# sourceMappingURL=FinanceDayCount.d.ts.map
@@ -0,0 +1,93 @@
1
+ import { Omittable, Scalar } from '@sheetxl/primitives';
2
+ /**
3
+ * The odd-coupon securities' shared machinery — the quasi-coupon chain of an irregular period
4
+ * and the day-count sums the price and yield forms are built from, measured against Excel 16.0
5
+ * (fn-battery financial/ODDLPRICE + /ODDLYIELD + /ODDFPRICE and the `adhoc-oddl-*` /
6
+ * `adhoc-oddf-*` probes, 2026-08-28/29).
7
+ */
8
+ /**
9
+ * `(settlement, maturity, …dates, …numbers, frequency, [basis])` as the four ODD functions read
10
+ * it: every slot is Excel-declared `any` (a boolean is #VALUE!, an empty argument #N/A, a blank
11
+ * cell 0, a multi-cell reference does not broadcast — `NoLift<>` on every slot), and the order is
12
+ * coupon six's, not PRICE's. Each DATE is coerced and range-checked as it is read, so a negative
13
+ * `last_interest` is #NUM! over a text frequency; then the numbers are coerced; then the
14
+ * frequency is validated (1, 2 or 4 after truncation); then the BASIS, last. Only after all of
15
+ * that do the date ORDER and the signs decide — a text frequency beats a settlement that is
16
+ * after its maturity. Serials come back truncated.
17
+ */
18
+ export declare function readOddArgs(dates: Omittable<Scalar>[], numbers: Omittable<Scalar>[], frequency: Omittable<Scalar>, basis: Omittable<Scalar>): {
19
+ dates: number[];
20
+ numbers: number[];
21
+ frequency: number;
22
+ basis: number;
23
+ };
24
+ /**
25
+ * The three day-count sums of the odd LAST period `[lastInterest, maturity]`, in coupon-period
26
+ * units — the numbers ODDLPRICE and ODDLYIELD are built from. Measured on 1,780
27
+ * (shape, frequency, basis) triples, each sum exact (`fn-battery/financial/fit-oddl.mjs`).
28
+ *
29
+ * It takes TWO chains, as COUPDAYS' basis 1 did (batch 3): the DECAYING chain anchored at
30
+ * `lastInterest` gives the period ends and their lengths, while the STICKY chain decides only
31
+ * which period the maturity lands in — so an Aug 31 maturity against a decayed Aug 28 boundary
32
+ * is still inside the period that ENDS there and overhangs it by three days.
33
+ *
34
+ * Over the periods `[B₀ = lastInterest, B₁] … [B_{J−1}, B_J]`:
35
+ *
36
+ * - `A` and `DSC` walk their span (`lastInterest → settlement`, `settlement → maturity`) period
37
+ * by period, no period contributing more than itself — a 31st period end counted raw runs one
38
+ * day past its own length.
39
+ * - `DC` counts every period 1 except the last, which is measured BACKWARD from its end,
40
+ * `(NL − count(maturity, B_J)) / NL`. That is what makes `DC ≠ A + DSC` at basis 0.
41
+ *
42
+ * A chain that leaves the calendar is #NUM!: past its end going forward, and — stepping BACK
43
+ * from the MATURITY to the first date at or below `lastInterest` — below serial 1 going back
44
+ * (measured: a ladder landing on serial 1 computes, one landing on serial 0 is #NUM!).
45
+ */
46
+ export declare function oddLastSums(settlement: number, maturity: number, lastInterest: number, frequency: number, basis: number): {
47
+ A: number;
48
+ DC: number;
49
+ DSC: number;
50
+ };
51
+ /**
52
+ * The numbers ODDFPRICE's form is built from — `N` regular coupons after `firstCoupon`, the
53
+ * accrued sum `A` and the first coupon's sum `DC` (both in coupon-period units), and `u`, the
54
+ * fractional exponent every cash flow after the settlement is discounted by. Measured on 1,125
55
+ * (shape, frequency, basis) triples, the four sums solved out of Excel by linearity
56
+ * (`fn-battery/financial/oddf-model.mjs`, `verify-oddf.mjs`, `adhoc-oddf-*`, 2026-08-29).
57
+ *
58
+ * The maturity must sit on `firstCoupon`'s grid — `COUPPCD(firstCoupon, maturity) = firstCoupon`
59
+ * — and the doc's two branches are real, on DIFFERENT date machinery. `E` is the regular period
60
+ * around the settlement on that grid, PRICE's {@link couponPeriod} (`COUPDAYBS + COUPDAYSNC` at
61
+ * basis 1); `DFC` the basis's count issue → firstCoupon:
62
+ *
63
+ * - `DFC = E` is #NUM! — an odd period that is exactly a regular one.
64
+ * - SHORT (`DFC < E`): one period, every count over `E` — `A = issue→settlement`, `DC = DFC`,
65
+ * `u = settlement→firstCoupon`, the last straight from the settlement (the NASD advance
66
+ * included). `N` is `COUPNUM(settlement, maturity) − 1`, which counts a grid date between the
67
+ * settlement and the first coupon when there is one (a settlement in the gap between a
68
+ * decayed boundary and its sticky twin).
69
+ * - LONG (`DFC > E`): `COUPNUM(issue, firstCoupon)` quasi periods on the STICKY grid, their
70
+ * boundaries walked DECAYED back from `firstCoupon` (each step subtracts `12/f` months from
71
+ * the previous date and clamps: an Aug 31 anchor semiannual is Feb 28, then Aug 28) — so the
72
+ * earliest period can end at or before the issue and count nothing. `NL` is each period's
73
+ * own actual span at basis 1, `360/f` or `365/f` elsewhere; `A` walks issue → settlement as
74
+ * days over `NL`; `DC` is the issue's period as days over `NL` and every later period exactly
75
+ * 1 (the doc's DCᵢ — visible at bases 2 and 3). The exponent `u = Nq + DSC/E` is on the
76
+ * sticky grid instead: `DSC = E − COUPDAYBS` at bases 0/1/4 and the actual days to the next
77
+ * grid date at 2/3, and `Nq` is `COUPNUM(settlement, firstCoupon) − 1` PLUS ONE on a
78
+ * month-end first coupon — Excel discounts every cash flow one period too far — unless the
79
+ * settlement is itself a month end or its month holds an earlier quasi-coupon date
80
+ * (`adhoc-oddf-nq`, 957 settlements swept day by day).
81
+ *
82
+ * A chain that walks below the calendar is #NUM! in either branch (a settlement in the first
83
+ * days of 1900 has quasi dates in 1899).
84
+ */
85
+ export declare function oddFirstSums(settlement: number, maturity: number, issue: number, firstCoupon: number, frequency: number, basis: number): {
86
+ N: number;
87
+ A: number;
88
+ DC: number;
89
+ u: number;
90
+ };
91
+ /** The ATP arithmetic of the family: a product that overflowed is 0 (batch 4's `overflowIsZero`). */
92
+ export declare const zeroIfOverflow: (value: number) => number;
93
+ //# sourceMappingURL=FinanceOdd.d.ts.map
@@ -0,0 +1,84 @@
1
+ import { Omittable, Scalar } from '@sheetxl/primitives';
2
+ /**
3
+ * Argument readers for the securities functions — every slot Excel-declared `any`, read in the
4
+ * order Excel reads them (measured against Excel 16.0, fn-battery financial/*, 2026-08-28).
5
+ *
6
+ * Two orders exist in the family. The discount securities (DISC PRICEDISC YIELDDISC INTRATE
7
+ * RECEIVED) CONVERT from the last slot to the first and only then look for errors in slot
8
+ * order; ACCRINTM, ACCRINT and the coupon functions convert and validate each slot from the
9
+ * first. Each function names its own.
10
+ */
11
+ /** The basis slot: omitted or blank is 0, text parses, a boolean is #VALUE!, out of 0–4 after truncation is #NUM!. */
12
+ export declare function readBasis(basis: Omittable<Scalar>): number;
13
+ /** The two dates of a security, truncated, both in the calendar and the settlement strictly first — else #NUM!. */
14
+ export declare function checkDateOrder(settlement: number, maturity: number): {
15
+ settlement: number;
16
+ maturity: number;
17
+ };
18
+ /**
19
+ * `(settlement, maturity, x, y, [basis])` as DISC, PRICEDISC, YIELDDISC, INTRATE and RECEIVED
20
+ * read it: the basis FIRST — coerced and range-checked, so a text basis is #VALUE!, a basis of 5
21
+ * is #NUM! and an error there is the answer whatever an earlier slot holds — then the four
22
+ * slots from the first, each coerced (its error or a text answered) before the next is read;
23
+ * then the domain: serials in the calendar, `settlement < maturity` once truncated, `x > 0`,
24
+ * `y > 0`. An omitted required slot is #N/A, a blank cell 0.
25
+ */
26
+ export declare function readDiscountArgs(settlement: Omittable<Scalar>, maturity: Omittable<Scalar>, x: Omittable<Scalar>, y: Omittable<Scalar>, basis: Omittable<Scalar>): {
27
+ settlement: number;
28
+ maturity: number;
29
+ x: number;
30
+ y: number;
31
+ basis: number;
32
+ };
33
+ /**
34
+ * `(settlement, maturity, x)` as TBILLEQ, TBILLPRICE and TBILLYIELD read it: each slot coerced
35
+ * from the first (an error or a text is answered before the next slot is read, so a text `x`
36
+ * beats swapped dates), then the domain: both serials in the calendar, `settlement < maturity`
37
+ * once truncated, the maturity at most one calendar year out ({@link _anniversary}), `x > 0`.
38
+ * `days` is the actual span of the truncated serials.
39
+ */
40
+ export declare function readTbillArgs(settlement: Omittable<Scalar>, maturity: Omittable<Scalar>, x: Omittable<Scalar>): {
41
+ settlement: number;
42
+ maturity: number;
43
+ x: number;
44
+ days: number;
45
+ };
46
+ /**
47
+ * `(settlement, maturity, issue, rate, x, [basis])` as PRICEMAT and YIELDMAT read it: the basis
48
+ * first (coerced and range-checked, so a text basis is #VALUE! and a basis of 5 #NUM! whatever
49
+ * the other slots hold, and an error there wins), then the five slots from the first, each
50
+ * coerced before the next is read; then the domain — every serial in the calendar,
51
+ * `issue < settlement < maturity` once truncated, and the signs the caller checks. The three
52
+ * day counts come back with `DSM` as `DIM − A`, which is how Excel has it: at basis 0 a Feb 28
53
+ * settlement against a Mar 31 maturity counts 32 days inside a Jan 31 issue (60 − 28), where
54
+ * the NASD count of the pair alone is 31. `B` is the year length of the issue→settlement pair.
55
+ */
56
+ export declare function readMatArgs(settlement: Omittable<Scalar>, maturity: Omittable<Scalar>, issue: Omittable<Scalar>, rate: Omittable<Scalar>, x: Omittable<Scalar>, basis: Omittable<Scalar>): {
57
+ rate: number;
58
+ x: number;
59
+ DIM: number;
60
+ DSM: number;
61
+ A: number;
62
+ B: number;
63
+ };
64
+ /**
65
+ * `(settlement, maturity, …numbers, frequency, [basis])` as PRICE, YIELD, DURATION and
66
+ * MDURATION read it (measured on all four, fn-battery 2026-08-28). PRICE and YIELD read the
67
+ * basis FIRST — coerced and range-checked, so a text basis is #VALUE! and a 5 is #NUM! whatever
68
+ * else is wrong, and an error there wins over an error in the settlement; DURATION and
69
+ * MDURATION read it LAST (`basisLast`), the coupon functions' way. In between, the settlement
70
+ * and the maturity are each coerced and checked against the calendar before the next slot is
71
+ * read (a negative settlement is #NUM! over a text frequency), then the numeric slots are
72
+ * coerced, then the frequency is coerced and validated (1, 2 or 4 after truncation); the date
73
+ * order (`settlement < maturity` once truncated) and the signs of the numbers come last.
74
+ */
75
+ export declare function readBondArgs(settlement: Omittable<Scalar>, maturity: Omittable<Scalar>, numbers: Omittable<Scalar>[], frequency: Omittable<Scalar>, basis: Omittable<Scalar>, basisLast?: boolean): {
76
+ settlement: number;
77
+ maturity: number;
78
+ numbers: number[];
79
+ frequency: number;
80
+ basis: number;
81
+ };
82
+ /** Excel's Analysis-ToolPak arithmetic answers 0 for a product that overflowed (measured on ACCRINTM, TBILLEQ, TBILLPRICE, PRICEMAT). */
83
+ export declare const overflowIsZero: (value: number) => number;
84
+ //# sourceMappingURL=FinanceSecurity.d.ts.map
@@ -1,4 +1,25 @@
1
1
  import { IRuntime } from '@sheetxl/primitives';
2
+ /**
3
+ * The secant step cap shared by RATE and IRR — Excel gives up after 200, not the documented 20
4
+ * (measured on one 24-period loan: a path of 200 steps converges, one of 203 is #NUM!). IRR runs
5
+ * the same iteration on the discount factor rather than the rate, so the cap is one fact.
6
+ */
7
+ export declare const RATE_MAX_ITERATIONS = 200;
8
+ /**
9
+ * The currency format Excel gives a financial result cell, in the runtime's locale.
10
+ *
11
+ * @remarks
12
+ * Which functions auto-format is a per-function fact and was MEASURED across the category
13
+ * (2026-08-29, `Range.NumberFormat` read after a `Formula2` entry into a General cell): the
14
+ * legacy core formats by result kind — money through this helper (NPV PMT IPMT PPMT FV PV SLN
15
+ * SYD DB DDB VDB) and a rate as `0%` (IRR MIRR RATE) — while everything ATP-era or added later
16
+ * sets nothing at all (XIRR XNPV NPER ISPMT RRI PDURATION EFFECT NOMINAL FVSCHEDULE CUMIPMT
17
+ * CUMPRINC and every security, COUPNCD and COUPPCD included).
18
+ *
19
+ * Excel applies it at ENTRY, before it knows the answer, so a `#NUM!`, `#VALUE!` or `#DIV/0!`
20
+ * cell carries the format too. That is why every `formatResults` call in this category LEADS its
21
+ * body instead of following the domain guards.
22
+ */
2
23
  export declare const defaultCurrencyFormat: (runtime: IRuntime) => string;
3
24
  /**
4
25
  * `base ^ exponent` as Excel evaluates it (the `^` operator, POWER, and the powers inside the
@@ -14,7 +35,22 @@ export declare const defaultCurrencyFormat: (runtime: IRuntime) => string;
14
35
  * on the sensitive rows (`FV(1E-15,12.5,…)` is 2 digits on `Math.pow`, exact here), and equal to
15
36
  * it everywhere else measured.
16
37
  *
17
- * A zero base follows the `^` operator: `0^0` is #NUM! and `0^negative` is #DIV/0!.
38
+ * A zero base follows the `^` operator: `0^0` is #NUM! and `0^negative` is #DIV/0!. So does a
39
+ * negative base under a fractional exponent: real only when the exponent's reciprocal, read at 15
40
+ * significant digits, is an odd integer — `FV(-3,1/3,1)` is -0.7533 — and #NUM! otherwise.
18
41
  */
19
42
  export declare const excelPow: (base: number, exponent: number) => number;
43
+ /**
44
+ * Excel's C `(int)` cast of an argument: truncation toward zero, and INT_MIN for anything out of
45
+ * the 32-bit range (the x64 `cvttsd2si` convention), NaN included. Measured on DB (fn-battery,
46
+ * 2026-08-28): `DB(…,3E9,2E9)` is #NUM! because only `life` overflows to INT_MIN while
47
+ * `DB(…,1E10,5E9)` is 0 because both do.
48
+ */
49
+ export declare const excelInt32: (value: number) => number;
50
+ /**
51
+ * Round to `digits` decimals as Excel's ROUND does: ties away from zero, decided on the value's
52
+ * 15-significant-digit decimal form rather than its binary one — `550 · 0.45` is
53
+ * 247.49999999999997 in double and Excel rounds it to 248 (AMORDEGRC, measured 2026-08-28).
54
+ */
55
+ export declare const excelRound: (value: number, digits?: number) => number;
20
56
  //# sourceMappingURL=FinanceUtils.d.ts.map
@@ -1,4 +1,4 @@
1
- import { FormulaError, IRange } from '@sheetxl/primitives';
1
+ import { FormulaError, IRange, IReferenceRange, Scalar } from '@sheetxl/primitives';
2
2
  /**
3
3
  * How Excel reads `known_y` / `known_x` into (observations x predictors).
4
4
  *
@@ -33,15 +33,22 @@ export interface RegressionData {
33
33
  /**
34
34
  * Reads `known_y` / `known_x` the way the whole LINEST family does.
35
35
  *
36
- * STRICT membership: any non-numeric member of either range — text, boolean, or BLANK — is
37
- * `#VALUE!`. There is no skipping and no coercion here (`LINEST({2;TRUE;5;4}, …)` and
38
- * `LINEST({2;"3";5;4}, …)` are both `#VALUE!`), which is the opposite of the paired statistics
39
- * (CORREL/SLOPE/…) where a non-numeric member drops its pair. Dropping a member here would shift
40
- * every later observation against its x and silently return a different fit.
36
+ * The SHAPES are judged first — a mismatch is #REF! whatever the members hold — and then the
37
+ * members, in order. Membership is STRICT: any non-numeric member of either range — text,
38
+ * boolean, or BLANK — is `#VALUE!`. There is no skipping and no coercion here
39
+ * (`LINEST({2;TRUE;5;4}, …)` and `LINEST({2;"3";5;4}, …)` are both `#VALUE!`), which is the
40
+ * opposite of the paired statistics (CORREL/SLOPE/…) where a non-numeric member drops its pair.
41
+ * Dropping a member here would shift every later observation against its x and silently return a
42
+ * different fit.
41
43
  *
42
- * @throws #VALUE! on a non-numeric member, #REF! on a dimension mismatch.
44
+ * `log` is the LOGEST/GROWTH read: each y is checked as it is met, so a y at or below zero is
45
+ * #NUM! even when a text member sits later in the range, and the ys come back as their logarithms.
46
+ *
47
+ * @throws #VALUE! on a non-numeric member, #REF! on a dimension mismatch, #NUM! on a y without a
48
+ * logarithm.
43
49
  */
44
- export declare const readRegressionData: (knownYs: IRange, knownXs: IRange | undefined) => RegressionData;
50
+ export declare const readRegressionData: (knownYs: IRange, knownXs: IRange | undefined, log?: boolean) => RegressionData;
51
+ export declare const overLogical: (value: boolean | IReferenceRange | IReferenceRange[] | null | undefined, absent: boolean, compute: (value: boolean) => Scalar[][]) => Scalar[][];
45
52
  /**
46
53
  * Reads a `new_x` range into (observations x k), and reports the shape its predictions spill into.
47
54
  *
@@ -57,15 +64,6 @@ export declare const readNewX: (newXs: IRange, data: RegressionData) => {
57
64
  rows: number;
58
65
  cols: number;
59
66
  };
60
- /**
61
- * `ln(y)` for the log-space members of the family (LOGEST / GROWTH).
62
- *
63
- * A y at or below zero has no logarithm, and Excel reports that as #NUM! — a distinct outcome from
64
- * the #VALUE! a non-numeric member gets, so the two checks stay separate.
65
- *
66
- * @throws #NUM! when any y is <= 0.
67
- */
68
- export declare const toLogYs: (ys: number[]) => number[];
69
67
  /**
70
68
  * Evaluates a fit over `new_x`, in the shape Excel spills.
71
69
  *
@@ -73,7 +71,7 @@ export declare const toLogYs: (ys: number[]) => number[];
73
71
  * the fitted values, so a 6x2 `known_y` spills 6x2. Otherwise the shape comes from `new_x`
74
72
  * ({@link readNewX} decides whether that is element-wise or one row/column per observation).
75
73
  */
76
- export declare const predictInShape: (data: RegressionData, newXs: IRange | undefined, predict: (x: number[]) => number) => number[][];
74
+ export declare const predictInShape: (data: RegressionData, newXs: IRange | undefined, predict: (x: number[]) => Scalar) => Scalar[][];
77
75
  /** A fitted model — coefficients in Excel's slot order plus everything the stats grid needs. */
78
76
  export interface RegressionFit {
79
77
  /**
@@ -81,11 +79,11 @@ export interface RegressionFit {
81
79
  * belongs to the LAST column of `known_x`.
82
80
  */
83
81
  coefficients: number[];
84
- /** Standard errors in the same slot order. `se[k]` is meaningless when `!useConst` (Excel: #N/A). */
82
+ /** Standard errors in the same slot order. `se[k]` is meaningless when `!constant` (Excel: #N/A). */
85
83
  standardErrors: number[];
86
84
  /** Number of predictors actually used — a column dropped for rank deficiency does not count. */
87
85
  kEffective: number;
88
- /** `n - kEffective - (useConst ? 1 : 0)`. */
86
+ /** `n - kEffective - (constant ? 1 : 0)`. */
89
87
  df: number;
90
88
  /** Standard error of the y estimate. 0 when `df <= 0`, which is what Excel returns. */
91
89
  sey: number;
@@ -111,7 +109,7 @@ export interface RegressionFit {
111
109
  * The same path covers "not enough observations": with n = 2 and 2 predictors the second column
112
110
  * has no residual left and is dropped, which is exactly what Excel returns.
113
111
  */
114
- export declare const fitLeastSquares: (ys: number[], xs: number[][], useConst: boolean) => RegressionFit;
112
+ export declare const fitLeastSquares: (ys: number[], xs: number[][], constant: boolean) => RegressionFit;
115
113
  /**
116
114
  * The `stats = TRUE` grid: 5 rows x (k + 1) columns.
117
115
  *
@@ -127,5 +125,5 @@ export declare const fitLeastSquares: (ys: number[], xs: number[][], useConst: b
127
125
  * `se(b)` when the intercept was not fitted — the b slot itself still carries a value (0 for
128
126
  * LINEST, 1 for LOGEST), it is only its error that is #N/A.
129
127
  */
130
- export declare const buildStatsGrid: (fit: RegressionFit, coefficients: number[], useConst: boolean) => (number | FormulaError.Known)[][];
128
+ export declare const buildStatsGrid: (fit: RegressionFit, coefficients: (number | FormulaError.Known)[], constant: boolean) => (number | FormulaError.Known)[][];
131
129
  //# sourceMappingURL=LeastSquares.d.ts.map
@@ -0,0 +1,205 @@
1
+ import { FormulaError, IFormulaContext, IFunction, IRange, Scalar } from '@sheetxl/primitives';
2
+ /**
3
+ * One aggregate column: a function applied to one value column.
4
+ */
5
+ export interface Measure {
6
+ readonly fn: IFunction;
7
+ /** The value column it reads. */
8
+ readonly column: number;
9
+ /** Called with `(x, y)` rather than `(x)` — see {@link aggregate}. */
10
+ readonly twoArgs: boolean;
11
+ /** What the function-name row shows. */
12
+ readonly label: string;
13
+ }
14
+ /**
15
+ * The function argument, resolved.
16
+ */
17
+ export interface Functions {
18
+ /** One per output column (or, when `vertical`, one per output row of each group). */
19
+ readonly measures: Measure[];
20
+ /** The functions were a column (`VSTACK(SUM,COUNT)`): each group gets one row per function. */
21
+ readonly vertical: boolean;
22
+ /** More than one function — a row or column names them. */
23
+ readonly named: boolean;
24
+ }
25
+ /**
26
+ * Resolves the function argument against the value columns, or answers the whole call's error.
27
+ *
28
+ * @remarks
29
+ * A row of functions is one column per function, a column of them one row per function (a13, a14),
30
+ * and a 2-D block is refused (a15). Functions pair with value columns one to many, many to one, or
31
+ * one to one (a37, a38, a42). A function that cannot take one argument, or needs more than two, is
32
+ * refused up front (a23, a24, a43) — the call shape is decided before any group runs.
33
+ */
34
+ export declare const resolveFunctions: (fn: any, valueColumns: number) => Functions | FormulaError.Known;
35
+ /**
36
+ * Applies a measure to a group's members.
37
+ *
38
+ * @remarks
39
+ * `y` is every kept value of the column, and only a function that REQUIRES two arguments gets it
40
+ * (`PERCENTOF`, `LAMBDA(x,y,…)`; a20–a22). An array result, a 1×1 included, is `#VALUE!` for that
41
+ * cell (a25, r05, r06); a single-cell reference reads as its value, and an error — returned or
42
+ * thrown — is just the cell's value.
43
+ */
44
+ export declare const aggregate: (measure: Measure, x: IRange, y: () => IRange) => Scalar;
45
+ /**
46
+ * How the first row is read — see {@link resolveHeaders}.
47
+ */
48
+ export interface Headers {
49
+ /** The first row is a header, not data. */
50
+ readonly hasHeader: boolean;
51
+ /** A header row is output (the data's own, or generated). */
52
+ readonly show: boolean;
53
+ }
54
+ /**
55
+ * The `field_headers` argument, resolved; omitted, it is guessed from the values.
56
+ *
57
+ * @remarks
58
+ * 0: data; 1: header, hidden; 2: no header, generate one; 3: header, shown. Anything else is
59
+ * `#VALUE!` (b10, b11, b16).
60
+ *
61
+ * The guess is the one sort uses: a header when the first two rows hold values of different types
62
+ * in some value column (b01 has `"Sales"` over `10`, b08 has `"Product"` over `"Apple"`). Excel's
63
+ * own rule is not fully measured yet.
64
+ */
65
+ export declare const resolveHeaders: (fieldHeaders: number | undefined, values: IRange) => Headers | FormulaError.Known;
66
+ /**
67
+ * Validates a `total_depth` against the number of key fields.
68
+ *
69
+ * @remarks
70
+ * An integer no deeper than the fields (c04, c16, c20, c21); the sign puts totals first.
71
+ */
72
+ export declare const isValidDepth: (depth: number, fieldCount: number) => boolean;
73
+ /**
74
+ * One axis's sort: a direction per key level, or a sort by an aggregate.
75
+ */
76
+ export interface SortSpec {
77
+ /** Per key level, 1 ascending or -1 descending. */
78
+ readonly keyDirections: number[];
79
+ /** Sort by an aggregate column: the measure's index and its direction. */
80
+ readonly byValue: {
81
+ readonly measure: number;
82
+ readonly direction: number;
83
+ } | null;
84
+ }
85
+ /**
86
+ * Parses a `sort_order` argument.
87
+ *
88
+ * @param valueColumns How many aggregate columns follow the keys; an index past the keys picks one.
89
+ *
90
+ * @remarks
91
+ * `±k` sorts key level `k`, or, past the keys, an aggregate column (d02, d05). Several indices must
92
+ * be distinct key levels, no more than there are (d09, d11, r12–r15). Zero, out of range, text, a
93
+ * fraction and a logical are `#VALUE!` (d07, d08, d16, d17, r24).
94
+ */
95
+ export declare const resolveSort: (sortOrder: IRange | undefined, fieldCount: number, valueColumns: number) => SortSpec | FormulaError.Known;
96
+ /**
97
+ * Whether `values` is one blank CELL — refused for the whole call (g16, g19).
98
+ *
99
+ * @remarks
100
+ * The rule `ARRAYTOTEXT` has for a lone blank: a reference to one empty cell is `#VALUE!`, while a
101
+ * blank KEY (g21), two blank cells (g18) or a blank array member are ordinary values.
102
+ */
103
+ export declare const isLoneBlankCell: (values: IRange) => boolean;
104
+ /**
105
+ * Validates a `filter_array` against the record count.
106
+ *
107
+ * @remarks
108
+ * One column as tall as the data, holding logicals and numbers only: an error or text anywhere is
109
+ * `#VALUE!` for the whole call (f06, f08), as is a shape mismatch (f03, f09, f11).
110
+ */
111
+ export declare const isValidFilter: (filter: IRange, recordCount: number) => boolean;
112
+ /**
113
+ * A group at one key level of an axis.
114
+ */
115
+ export interface AxisNode {
116
+ /** The key level, 0 for the outermost field. */
117
+ readonly level: number;
118
+ /** The group within that level's grouping. */
119
+ readonly group: number;
120
+ /** The keys down to this level, as spelled by the group's first record. */
121
+ readonly keys: readonly Scalar[];
122
+ /** The group one level up, `null` at the outermost level. */
123
+ readonly parent: AxisNode | null;
124
+ readonly children: AxisNode[];
125
+ }
126
+ /**
127
+ * One output line of an axis: a group at the innermost level, a subtotal, or the grand total.
128
+ */
129
+ export interface AxisLine {
130
+ readonly kind: 'group' | 'subtotal' | 'total';
131
+ /** `null` for the grand total. */
132
+ readonly node: AxisNode | null;
133
+ }
134
+ /**
135
+ * One axis of groups — `GROUPBY`'s rows, or either side of `PIVOTBY`.
136
+ *
137
+ * @remarks
138
+ * Each key level has its own grouping, over the key columns down to it, so a subtotal's members are
139
+ * one group of that grouping rather than a union of its children's. A level's parent is read
140
+ * through its first record (`getFirstRecord`/`getGroup`).
141
+ */
142
+ export declare class PivotAxis {
143
+ readonly fieldCount: number;
144
+ /** Per key level, the grouping over the key columns down to it. */
145
+ readonly groupings: IFormulaContext.Grouping[];
146
+ /** Per key level, the key columns down to it. */
147
+ readonly prefixes: IRange[];
148
+ readonly roots: AxisNode[];
149
+ constructor(keys: IRange, filter: IRange | undefined);
150
+ /** The number of records kept. */
151
+ getRecordCount(): number;
152
+ /** A node's members of one value column. */
153
+ getMembers(values: IRange, node: AxisNode | null): IRange;
154
+ /**
155
+ * Orders the groups at every level.
156
+ *
157
+ * @param valueOf A node's aggregate, for a sort by value.
158
+ * @param table Field relationship 1: one flat order over the innermost groups (d18).
159
+ *
160
+ * @remarks
161
+ * Keys sort by the comparison operators' order — numbers, text, `FALSE`, `TRUE`, errors — with
162
+ * a blank key last in either direction (e01, e02). A sort by value orders each level by its own
163
+ * aggregate, parents by their subtotal (d05); ties keep key order (e06), and an error aggregate
164
+ * sorts last.
165
+ */
166
+ sort(spec: SortSpec, valueOf: (node: AxisNode) => Scalar, table: boolean): AxisNode[];
167
+ /**
168
+ * The output lines in order, with subtotals and the grand total placed per `depth`.
169
+ *
170
+ * @remarks
171
+ * `|depth|` 1 is the grand total alone; each step deeper adds subtotals for one more level from
172
+ * the top (c03, c13, c14). A negative depth puts every total before what it totals (c06, c15).
173
+ */
174
+ lines(roots: AxisNode[], depth: number): AxisLine[];
175
+ /**
176
+ * The key cells of a line: its keys, `""` past its level, and the total's label.
177
+ *
178
+ * @remarks
179
+ * A blank key shows as `0`, as Excel spills it (a01); padding is `""` (b09, c03). The grand total
180
+ * is `Grand Total` once subtotals show, `Total` otherwise (c02, c03).
181
+ */
182
+ keyCells(line: AxisLine, depth: number): Scalar[];
183
+ }
184
+ /**
185
+ * The generated header of key field `index` (0-based), for `field_headers` 2 (b04).
186
+ */
187
+ export declare const generatedFieldLabel: (index: number) => string;
188
+ /**
189
+ * The generated header of `PIVOTBY` column field `index` (0-based), for `field_headers` 2 (p43).
190
+ */
191
+ export declare const generatedColumnFieldLabel: (index: number) => string;
192
+ /**
193
+ * The generated header of value column `index` (0-based), for `field_headers` 2 (b04).
194
+ */
195
+ export declare const generatedValueLabel: (index: number) => string;
196
+ /**
197
+ * The columns of a range, one slice each — the same object every time it is asked for, which is
198
+ * what lets a grouping reuse its work on a value column.
199
+ */
200
+ export declare const columnsOf: (range: IRange) => IRange[];
201
+ /**
202
+ * A range without its first row — the data under a header.
203
+ */
204
+ export declare const withoutFirstRow: (range: IRange) => IRange;
205
+ //# sourceMappingURL=Pivot.d.ts.map
@@ -0,0 +1,33 @@
1
+ import { FormulaError } from '@sheetxl/primitives';
2
+ /** A compiled Excel pattern: the regex, and how many capture groups it has. */
3
+ export interface CompiledPattern {
4
+ regex: RegExp;
5
+ groups: number;
6
+ }
7
+ /**
8
+ * Compiles one of Excel's patterns, or `#VALUE!` when neither reading of it will compile.
9
+ *
10
+ * The translated form is tried first, under `u`. A pattern that will not compile that way is
11
+ * retried EXACTLY AS WRITTEN and without `u` — that is the pre-translation reading, and it keeps
12
+ * the patterns that only `u`'s stricter escaping would have broken (`\-` outside a class) working.
13
+ */
14
+ export declare const compilePattern: (pattern: string, caseInsensitive: boolean, extraFlags?: string) => CompiledPattern | FormulaError.Known;
15
+ /**
16
+ * Excel's replacement text, as JavaScript's.
17
+ *
18
+ * The two languages nearly agree — `$1`, `$&`, `` $` `` and `$'` mean the same in both — and
19
+ * differ in three places: Excel's `$0` is the whole match (JavaScript spells that `$&`), its
20
+ * `${1}` and `${name}` are references where JavaScript reads them literally, and a reference to a
21
+ * group that does not exist is `#VALUE!` rather than literal text. That last one is why this
22
+ * returns an error instead of a string: `REGEXREPLACE("ab","(a)(b)","$3")` is refused by Excel,
23
+ * and so is a lone `$`.
24
+ */
25
+ export declare const translateReplacement: (replacement: string, groups: number) => string | FormulaError.Known;
26
+ /**
27
+ * Excel's 0-or-1 enum slots (`caseSensitivity`, and `returnMode`'s three values).
28
+ *
29
+ * Truncated first — 1.5 is 1 — and anything outside the list is `#VALUE!`, including a huge value
30
+ * and non-numeric text.
31
+ */
32
+ export declare const readMode: (value: number, max: number) => number | FormulaError.Known;
33
+ //# sourceMappingURL=RegexCompile.d.ts.map