@sheetxl/sdk 0.8.0-beta.14 → 0.8.0-beta.16

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 (195) hide show
  1. package/LICENSE.md +8 -7
  2. package/browser/esm/4MbBwfmW2hDXk9_w.mjs +165 -0
  3. package/browser/esm/{ChYgQL-8qIDFmX31.mjs → 9YWdxmSjzLN4j_ts.mjs} +22 -22
  4. package/browser/esm/B6BdiHigbUdbZp3J.mjs +686 -0
  5. package/browser/esm/{CImFKFaYToUH-bSE.mjs → BF_QwkZ_hs2rFoTT.mjs} +3 -3
  6. package/browser/esm/{DBvu0tdSf-5vol4e.mjs → BMo2_9Ul36IwRm3S.mjs} +3 -3
  7. package/browser/esm/{B1aH_qa-czVyEVHd.mjs → BWY1qiidTUBVPJoD.mjs} +506 -502
  8. package/browser/esm/{BSXQAXwZdJKYTO4P.mjs → Bf80epSsm_RyAOb9.mjs} +29 -29
  9. package/browser/esm/{D_XMi4_5iO2rkET5.mjs → BfoE6Dn_GQCIkQD3.mjs} +2 -2
  10. package/browser/esm/{Dhw5XEJYFrkYjdU2.mjs → BlMYYQZP-QM-iBHz.mjs} +23 -22
  11. package/browser/esm/{MuNBN02MyZ558c_K.mjs → BqT-ASHP0NVSUUnY.mjs} +1528 -1433
  12. package/browser/esm/{DnR0xY7_iE3TmMcg.mjs → BtNuoQIrrHw_jnbJ.mjs} +4 -4
  13. package/browser/esm/BxFzcCYhvo9NXFjC.mjs +527 -0
  14. package/browser/esm/{DonQz2Tc3k9lNT8E.mjs → BxYuRTSF9ykc-Tpz.mjs} +3 -3
  15. package/browser/esm/{aRXqxIzjuSLwawMh.mjs → C2PvZwqK-uvsugVS.mjs} +2 -2
  16. package/browser/esm/C3JOjQwdG9kAig7i.mjs +2017 -0
  17. package/browser/esm/{SwLp-iElwDjfcJtv.mjs → C5x0EzqElYGTiTQc.mjs} +2 -2
  18. package/browser/esm/{AXlD9K1gCwPU4gCO.mjs → CMChv-fCFh68VQQt.mjs} +588 -587
  19. package/browser/esm/{BpwULQPKbb4R9Jew.mjs → CRbQATfI0yZxe1kX.mjs} +3 -3
  20. package/browser/esm/{CM_X1zZYzEUPaNJL.mjs → CUu3zeHqcwMRYiov.mjs} +2 -2
  21. package/{node/esm/b3XnssSr9lmvAC2N.mjs → browser/esm/C_jLGkFemj55_BP3.mjs} +3 -3
  22. package/browser/esm/{CtC__ALh4I8PKIln.mjs → CkZoDPUCK5jMUaeJ.mjs} +26955 -22064
  23. package/browser/esm/{DvvqmUQ9Z0NFm1-4.mjs → D-iHJ3q4nwOLcn1D.mjs} +2 -2
  24. package/browser/esm/{qCqzZW74-fhaIG2V.mjs → D807piM0VSokWz-L.mjs} +2 -2
  25. package/browser/esm/{BLYl-afJe_3std8i.mjs → DW3oQ39IF0bsc_lm.mjs} +2 -2
  26. package/browser/esm/{Ln4gsmhqH1LyoANj.mjs → DcB52JPBPmkc3l1m.mjs} +4 -4
  27. package/browser/esm/{DIfAk63CvaOZ3QKi.mjs → DlVnybrgwZWxWN3_.mjs} +10 -10
  28. package/browser/esm/{Dh84MDs-OhdCPCIg.mjs → DvVhatd0J1ch3OCO.mjs} +22 -22
  29. package/browser/esm/{BWoz4kQdA5KKJfl6.mjs → Dx9Fya60meMpuHqm.mjs} +2 -2
  30. package/browser/esm/{r_EZapMBdyS4gUd-.mjs → HV0FkJ6k3Ils318J.mjs} +78 -78
  31. package/browser/esm/{C7hpfT-sX2lyLS-D.mjs → JV9Szh5qTssjxJoE.mjs} +2 -2
  32. package/browser/esm/{CPIWV3Enlh_BF2TY.mjs → KpuD1kEcWB7cT0VM.mjs} +3 -3
  33. package/browser/esm/{3t4S9eda2I6jFad0.mjs → U4FL-QeC0bRUhTEo.mjs} +2 -2
  34. package/browser/esm/{D39XcmtPXVtMN4yF.mjs → WLlpmgLN5OVLoLrC.mjs} +3 -3
  35. package/browser/esm/{Cy8uYCggktF83278.mjs → WR146UAqrsUsL39e.mjs} +2 -2
  36. package/browser/esm/{BPPMKyMn65i1a1mE.mjs → WcHfawW2lkTHtWUd.mjs} +51 -49
  37. package/browser/esm/{Bdcd3QOzsc0aVMjN.mjs → Zp5-cTJ0Llb6EfGi.mjs} +4 -4
  38. package/browser/esm/{oSCy1X5CJ1iYtGDp.mjs → ad9PX897hYE4Srkc.mjs} +3 -3
  39. package/browser/esm/{UMQTbO0zNmBpzW1V.mjs → d_t-7d5BD1AdHg3u.mjs} +404 -404
  40. package/browser/esm/{BVqIknGhQCLUB_7Q.mjs → dwGdnbV-CykjNrlm.mjs} +2 -2
  41. package/browser/esm/{DiXeQjc0WJGLSVEo.mjs → e69NcYnKMLnAmqyA.mjs} +2 -2
  42. package/browser/esm/index.mjs +886 -578
  43. package/browser/esm/{yuF8SbWfjBfrxcq5.mjs → r-o0UCm7KtluNmyK.mjs} +3 -3
  44. package/licenses/dependencies.txt +69 -69
  45. package/node/esm/{BEBt5fo__rvT2q_u.mjs → 446KYBjJQa8g-8Gg.mjs} +52 -50
  46. package/node/esm/{BELc5aQ_pFPgbiso.mjs → 5OfKfTRX2_y2NwpU.mjs} +2 -2
  47. package/node/esm/{C-5JLSNof0FhkuFd.mjs → A3PEHO1HJvkHfb5n.mjs} +2 -2
  48. package/node/esm/{YpOpRyciqQLIY1-G.mjs → B4WUGzJBkQu7BXRm.mjs} +2 -2
  49. package/node/esm/{I-FZojIFWluC6X-j.mjs → BH8J6vKSO5zI_TWo.mjs} +2 -2
  50. package/node/esm/BLmdKnkLwkb3wWe6.mjs +2040 -0
  51. package/node/esm/{BuyAYLI4s33-vmgG.mjs → BZSxu_ZqX8-Uczzn.mjs} +2 -2
  52. package/node/esm/{DiCMnYA2bttmrX3q.mjs → BfPBiAgVmWhuFgFP.mjs} +3 -3
  53. package/node/esm/{BSVttk12GXNfKZ9k.mjs → Bknw7zWZhl2-w1pi.mjs} +3 -3
  54. package/node/esm/{uLrulyR7IXq0SF4j.mjs → BvIPsPiHhMclZ1kH.mjs} +22 -22
  55. package/node/esm/{clgEkmEwfB28nkz2.mjs → By2TFKOjA1HekZap.mjs} +4 -4
  56. package/node/esm/{BXg-D8Rc_iyB8p7X.mjs → BywIhvYkWk2o7MSW.mjs} +2 -2
  57. package/node/esm/{pF2vCOTmrxPAB41Q.mjs → C3zyhnMwQ2hRQBz7.mjs} +31 -30
  58. package/node/esm/{BCjHRVU8tC5lYypg.mjs → C884edhUf9yMqpPp.mjs} +2 -2
  59. package/node/esm/{B6jhx5pHPs2W5GE7.mjs → CDHY-0OyQ9348Brb.mjs} +189 -189
  60. package/node/esm/{xRGObcoaGDnAZFnj.mjs → CERNLhFrAwtu_p-q.mjs} +2 -2
  61. package/node/esm/{DbPUG2DcQ3T_QhcJ.mjs → CFkX_Cn6avQqQiVC.mjs} +78 -78
  62. package/node/esm/CJDV8P3hI8lu--3Z.mjs +530 -0
  63. package/node/esm/{Cyeq1rDslIqF1LKz.mjs → CKwiipdPJGzAiPjg.mjs} +2 -2
  64. package/node/esm/{BLPrFp_jKGYgWPX1.mjs → CLtUMJfKsy4SevWE.mjs} +3 -3
  65. package/node/esm/{DLdXl0O0TXuyqLU4.mjs → CVPieTgKCwkL21nD.mjs} +28573 -23108
  66. package/node/esm/{Dlk2ZYExFgQ0xE2H.mjs → C_fYuynP2a_70WdL.mjs} +2 -2
  67. package/{browser/esm/BEDfJP2tcuRy2Y2E.mjs → node/esm/CgdNA3B_GFG_yJiN.mjs} +3 -3
  68. package/node/esm/Cs3ibv6YHCDwLRlk.mjs +115 -0
  69. package/node/esm/{DeFE8QfuCeGw-mvd.mjs → Cxak8i2NidZ4Uv6v.mjs} +487 -483
  70. package/node/esm/{NA-8urR7T1NCwrgD.mjs → D88A3UpCyGRjcX3U.mjs} +3 -3
  71. package/node/esm/{99miMotf3dOuG5Jk.mjs → DBIUe2BC9xU7qMHR.mjs} +3 -3
  72. package/node/esm/{BEdxa3I4VOiCsvy7.mjs → DELfV5HQZo1mInBd.mjs} +4 -4
  73. package/node/esm/{BfEdeOg4iYXaYTlh.mjs → DOt3t-13tsnM7Fj6.mjs} +2 -2
  74. package/node/esm/{B3hBxzqJ2_hUylNr.mjs → DfWc3nW_Z_qqc_Wf.mjs} +1762 -1674
  75. package/node/esm/DgnwKbUEyQN5_gWT.mjs +169 -0
  76. package/node/esm/{Ccocd9DTvOnlOE9D.mjs → Dhv9JymnXqcF54oo.mjs} +2 -2
  77. package/node/esm/{Lj98EH6coGdKUzuS.mjs → DvtyKKzOnoOM80NB.mjs} +22 -22
  78. package/node/esm/{Crn6dnSQQRCQAnQ-.mjs → KDGrIa9R5XzWfjM2.mjs} +2 -2
  79. package/node/esm/{D30rC6AWaGGf3CaC.mjs → RTwm9ge1KoPdlBNt.mjs} +2 -2
  80. package/node/esm/{CdSTmD2ZvG9NesNR.mjs → _RIAmJI98l6bIFfZ.mjs} +2 -2
  81. package/node/esm/{CI8UIWR01z9QDlzH.mjs → bIGdvfpnijWeCac6.mjs} +1005 -1004
  82. package/node/esm/index.mjs +913 -598
  83. package/node/esm/kaiXmn0AA5WDsLPo.mjs +199 -0
  84. package/node/esm/{B5VmOC0jO9Zbh9Mq.mjs → mTIhoz1gEcaEm7s1.mjs} +3 -3
  85. package/package.json +7 -7
  86. package/resources/locales/de/model.msg.json +82 -1
  87. package/resources/locales/en/model.msg.json +80 -1
  88. package/types/scripting-api.json +9967 -9497
  89. package/types/scripting-enums.json +27 -0
  90. package/types/scripting.d.ts +2282 -166
  91. package/types/src/.generated/wasm/sdk.d.ts +332 -0
  92. package/types/src/calculation/Calculation.d.ts +8 -0
  93. package/types/src/calculation/ICalculation.d.ts +51 -0
  94. package/types/src/calculation/compiler/Types.d.ts +5 -0
  95. package/types/src/calculation/executor/CalcExecutorUtils.d.ts +1 -1
  96. package/types/src/calculation/formula/FormulaBlock.d.ts +2 -0
  97. package/types/src/calculation/formula/IFormulaBlock.d.ts +18 -0
  98. package/types/src/calculation/grid/CalcGrid.d.ts +5 -1
  99. package/types/src/calculation/grid/CalcGridBackend.d.ts +36 -1
  100. package/types/src/calculation/grid/CalcGridProxy.d.ts +2 -0
  101. package/types/src/calculation/grid/CalcGridUtils.d.ts +4 -2
  102. package/types/src/calculation/grid/FormulaHost.d.ts +3 -1
  103. package/types/src/calculation/grid/ICalcGrid.d.ts +88 -0
  104. package/types/src/calculation/grid/_CalcRequest.d.ts +9 -0
  105. package/types/src/calculation/spatial/FormulaSpatialValue.d.ts +2 -0
  106. package/types/src/calculation/spatial/SpillEntry.d.ts +55 -4
  107. package/types/src/calculation/state/CalcNode.d.ts +6 -3
  108. package/types/src/calculation/state/CalculationContext.d.ts +4 -2
  109. package/types/src/calculation/state/_PivotView.d.ts +22 -0
  110. package/types/src/cell/ICell.d.ts +1 -21
  111. package/types/src/cellRange/ICellRange.d.ts +18 -2
  112. package/types/src/collections/MixedTypedArrayList.d.ts +16 -2
  113. package/types/src/condition/BuiltInOperators/AbstractOperator.d.ts +10 -0
  114. package/types/src/condition/BuiltInOperators/GreaterThanEqualToOperator.d.ts +3 -0
  115. package/types/src/condition/BuiltInOperators/GreaterThanOperator.d.ts +3 -0
  116. package/types/src/condition/BuiltInOperators/LessThanEqualToOperator.d.ts +3 -0
  117. package/types/src/condition/BuiltInOperators/LessThanOperator.d.ts +3 -0
  118. package/types/src/condition/BuiltInOperators/MatchesOperator.d.ts +10 -0
  119. package/types/src/condition/BuiltInOperators/TimePeriodOperator.d.ts +2 -0
  120. package/types/src/condition/BuiltInOperators/index.d.ts +2 -0
  121. package/types/src/condition/Condition.d.ts +1 -0
  122. package/types/src/condition/ICondition.d.ts +15 -0
  123. package/types/src/condition/_ConditionUtils.d.ts +14 -0
  124. package/types/src/conditionalFormat/ConditionalFormat.d.ts +2 -1
  125. package/types/src/conditionalFormat/IConditionalFormat.d.ts +4 -3
  126. package/types/src/license/LicenseDetails.d.ts +27 -0
  127. package/types/src/license/LicenseManager.d.ts +24 -7
  128. package/types/src/license/_Utils.d.ts +34 -3
  129. package/types/src/license/index.d.ts +1 -0
  130. package/types/src/license/runtime.browser.d.ts +32 -4
  131. package/types/src/license/runtime.node.d.ts +8 -5
  132. package/types/src/license/summary.d.ts +18 -0
  133. package/types/src/pivot/IPivotTable.d.ts +1549 -13
  134. package/types/src/pivot/IPivotTableCollection.d.ts +70 -4
  135. package/types/src/pivot/PivotCache.d.ts +95 -11
  136. package/types/src/pivot/PivotDataField.d.ts +73 -0
  137. package/types/src/pivot/PivotField.d.ts +142 -0
  138. package/types/src/pivot/PivotTable.d.ts +548 -14
  139. package/types/src/pivot/PivotTableCollection.d.ts +18 -3
  140. package/types/src/pivot/_PivotAreas.d.ts +48 -0
  141. package/types/src/pivot/_PivotControls.d.ts +140 -0
  142. package/types/src/pivot/_PivotEngine.d.ts +9 -0
  143. package/types/src/pivot/_PivotGroups.d.ts +25 -0
  144. package/types/src/pivot/_PivotItems.d.ts +167 -0
  145. package/types/src/pivot/_PivotStructure.d.ts +237 -0
  146. package/types/src/pivot/_PivotStylePreview.d.ts +21 -0
  147. package/types/src/pivot/_PivotUtils.d.ts +37 -0
  148. package/types/src/pivot/engine/PivotAdd.d.ts +37 -0
  149. package/types/src/pivot/engine/PivotData.d.ts +65 -0
  150. package/types/src/pivot/engine/PivotEdit.d.ts +45 -0
  151. package/types/src/pivot/engine/PivotFilters.d.ts +50 -0
  152. package/types/src/pivot/engine/PivotFormulas.d.ts +72 -0
  153. package/types/src/pivot/engine/PivotLayout.d.ts +133 -0
  154. package/types/src/pivot/engine/PivotMove.d.ts +24 -0
  155. package/types/src/pivot/engine/PivotRefresh.d.ts +87 -0
  156. package/types/src/pivot/engine/PivotSort.d.ts +26 -0
  157. package/types/src/pivot/engine/PivotViewBuilder.d.ts +22 -0
  158. package/types/src/pivot/engine/index.d.ts +15 -0
  159. package/types/src/pivot/index.d.ts +4 -0
  160. package/types/src/pivot/kernel/KernelPivot.d.ts +63 -0
  161. package/types/src/pivot/kernel/_KernelLeaves.d.ts +100 -0
  162. package/types/src/pivot/kernel/_PivotAxisTree.d.ts +71 -0
  163. package/types/src/primitives/Range.d.ts +12 -1
  164. package/types/src/sheet/IWorksheet.d.ts +35 -0
  165. package/types/src/sheet/SheetCell.d.ts +21 -14
  166. package/types/src/sheet/SheetRange.d.ts +3 -0
  167. package/types/src/sheet/Worksheet.d.ts +175 -7
  168. package/types/src/sheet/_PivotFootprint.d.ts +42 -0
  169. package/types/src/sheet/_SheetAutoFitUtils.d.ts +12 -1
  170. package/types/src/sheet/_SheetMutations.d.ts +47 -0
  171. package/types/src/sheet/_SheetStateTypes.d.ts +11 -0
  172. package/types/src/sheet/style/SheetCellStyle.d.ts +6 -0
  173. package/types/src/sheet/style/SheetPivotStyle.d.ts +83 -0
  174. package/types/src/sheet/style/_IndentUnit.d.ts +14 -0
  175. package/types/src/sheetHeader/SheetCellHeader.d.ts +1 -1
  176. package/types/src/slicer/ISlicer.d.ts +114 -34
  177. package/types/src/slicer/ITimeline.d.ts +61 -0
  178. package/types/src/slicer/Slicer.d.ts +76 -3
  179. package/types/src/slicer/_PivotSlicer.d.ts +51 -0
  180. package/types/src/slicer/index.d.ts +1 -0
  181. package/types/src/table/AnchoredTable.d.ts +11 -1
  182. package/types/src/table/ITable.d.ts +5 -6
  183. package/types/src/table/ITableStyle.d.ts +50 -34
  184. package/types/src/table/_BuiltInPivotStyles.d.ts +8 -0
  185. package/types/src/table/_BuiltInTableStyles.d.ts +0 -1
  186. package/types/src/type/ITypes.d.ts +5 -1
  187. package/types/src/workbook/IWorkbook.d.ts +8 -2
  188. package/types/src/workbook/Workbook.d.ts +72 -6
  189. package/browser/esm/D2NFcBM4xsv0JJ1q.mjs +0 -184
  190. package/browser/esm/DnqwX3-2NfGBaXXl.mjs +0 -357
  191. package/node/esm/C3S4hF1vn0NyJPPd.mjs +0 -199
  192. package/node/esm/CPsGyt3vnOdLTShj.mjs +0 -360
  193. package/node/esm/D4Y1WJgjiFEgbWrW.mjs +0 -115
  194. package/types/src/pivot/_PivotXml.d.ts +0 -24
  195. package/types/src/primitives/Grouping.d.ts +0 -65
@@ -3301,6 +3301,18 @@ declare global {
3301
3301
  */
3302
3302
  export type ESIterator<T, TReturn = any, TNext = undefined> = Iterator<T, TReturn, TNext>;
3303
3303
 
3304
+ /**
3305
+ * Where a process stands under its license, as enforcement sees it.
3306
+ *
3307
+ * - `licensed` — a key covers it; nothing below applies.
3308
+ * - `evaluation` — unlicensed, inside the evaluation period: runs in full. A page served over
3309
+ * http(s) stays here for good — the watermark is its enforcement.
3310
+ * - `grace` — past the period: exports (every format but `.sxl`) are refused.
3311
+ * - `stopped` — past the grace too: calculation and scripts stop as well. A workbook still opens
3312
+ * and still saves as `.sxl`, so no one is locked out of their own work.
3313
+ */
3314
+ export type EvalState = 'licensed' | 'evaluation' | 'grace' | 'stopped';
3315
+
3304
3316
  /**
3305
3317
  * Special classification that that indicated the error is caused by user input.
3306
3318
  */
@@ -5146,6 +5158,35 @@ declare global {
5146
5158
  * The expression is read as storage text unless `options.target` is `'display'`.
5147
5159
  */
5148
5160
  evaluate(expression: string, options?: number | ICalculation.EvaluateOptions & Partial<IRange.CellCoords> & ICalculation.CreateFormulaOptions): Promise<Scalar | IRange>;
5161
+ /**
5162
+ * Evaluates several formulas over values of the caller's, in one request.
5163
+ *
5164
+ * @param request The values and the formulas.
5165
+ * @returns One range per {@link ICalculation.BatchRequest.formulas | formula}, in the order given,
5166
+ * the shape of its `coords` (a single cell included), read with local coordinates:
5167
+ * `getValueAt(0, 0)` is the top-left of `coords`.
5168
+ *
5169
+ * @remarks
5170
+ * - The values and formulas sit on a grid of their own, on no sheet, kept for this request only.
5171
+ * Nothing in the workbook changes, and it is never an undo step.
5172
+ * - A formula reads the values by address and may read another formula's cells; the engine
5173
+ * orders them. Each is filled across its `coords`, relative references moving with it.
5174
+ * - A cell that errors carries its error; the others are unaffected.
5175
+ *
5176
+ * @example
5177
+ * ```typescript
5178
+ * const [margin, doubled] = await calculation.evaluateBatch({
5179
+ * values: [[0, [[0, [100, 60]]]], [1, [[0, [50, 40]]]]],
5180
+ * formulas: [
5181
+ * { expression: 'A1-B1', coords: { rowStart: 0, colStart: 2, rowEnd: 1, colEnd: 2 } },
5182
+ * { expression: 'C1*2', coords: { rowStart: 0, colStart: 3, rowEnd: 1, colEnd: 3 } }
5183
+ * ]
5184
+ * });
5185
+ * margin.getValueAt(1, 0); // 10
5186
+ * doubled.getValueAt(1, 0); // 20
5187
+ * ```
5188
+ */
5189
+ evaluateBatch(request: ICalculation.BatchRequest): Promise<IRange[]>;
5149
5190
  /**
5150
5191
  * When the engine recalculates on its own — Excel's Calculation Options.
5151
5192
  *
@@ -6045,6 +6086,27 @@ declare global {
6045
6086
  /**
6046
6087
  * Options for evaluating a formula.
6047
6088
  */
6089
+ /** What {@link ICalculation.evaluateBatch} evaluates. */
6090
+ interface BatchRequest {
6091
+ /** The values the formulas read, by row: `[row, [[column, values]]]`, A1 at row 0, column 0. */
6092
+ values: Tuple.GridTuple<Scalar>;
6093
+ /** The formulas. One over cells that hold a value replaces it. */
6094
+ formulas: readonly BatchFormula[];
6095
+ /**
6096
+ * How long to wait, in milliseconds, for the answers of async functions; a cell still waiting
6097
+ * then answers a `#TIMEOUT!` error.
6098
+ *
6099
+ * @defaultValue `30000`
6100
+ */
6101
+ timeout?: number;
6102
+ }
6103
+ /** One formula of a {@link BatchRequest}. */
6104
+ interface BatchFormula {
6105
+ /** The expression, with or without a leading `=`, written for the top-left of {@link coords}. */
6106
+ expression: string;
6107
+ /** The cells it is filled across. */
6108
+ coords: IRange.Coords;
6109
+ }
6048
6110
  interface EvaluateOptions {
6049
6111
  /**
6050
6112
  * If specified, evaluates only the token span associated with this index.
@@ -6901,20 +6963,6 @@ declare global {
6901
6963
  * values, as 'general' is resolved to left or right based on the cell's content type.
6902
6964
  */
6903
6965
  getRenderHorizontalAlignment(): ITextFrame.HorizontalAlignment;
6904
- /**
6905
- * Return an {@link ITable.IColumn} if the cell is the the first row of an ITable range.
6906
- */
6907
- getColumn(): ITable.IColumn | null;
6908
- /**
6909
- * Returns the cell's primary data validation: the highest-priority one that covers it, or `null`
6910
- * when none does.
6911
- *
6912
- * @remarks
6913
- * Validations may overlap, and every one that covers the cell applies; see
6914
- * {@link ICellRange.getDataValidations} for all of them. The primary one is also the one Excel
6915
- * honors when it opens a file whose validations overlap.
6916
- */
6917
- getDataValidation(): IDataValidation | null;
6918
6966
  /**
6919
6967
  * Returns what the cell's conditional formatting DRAWS in it — an in-cell bar, an icon, or
6920
6968
  * neither.
@@ -6942,10 +6990,6 @@ declare global {
6942
6990
  * checkbox cell holding `2` has a control and draws `2`.
6943
6991
  */
6944
6992
  getControl(): ICellControl | null;
6945
- /**
6946
- * If the cell is in a table this will return it.
6947
- */
6948
- getTable(): ITable | null;
6949
6993
  /**
6950
6994
  * Returns `true` if the cell contains a value.
6951
6995
  *
@@ -8659,14 +8703,16 @@ declare global {
8659
8703
  */
8660
8704
  setControl(control: ICellControl.JSON | null, options?: ITransaction.OperationOptions): this;
8661
8705
  /**
8662
- * Returns the {@link IDataValidation}s that overlap the range.
8706
+ * Returns the {@link IDataValidation}s that overlap the range, in priority order.
8663
8707
  *
8664
8708
  * @param options The filters of {@link IDataValidationCollection.getItems} without `address` —
8665
8709
  * this range is the address.
8666
8710
  *
8667
8711
  * @remarks
8668
8712
  * **Plural, unlike Excel.** A cell carries at most one validation there, so Excel's range accessor
8669
- * is singular; here a range may overlap any number of independently anchored validations.
8713
+ * is singular; here a range may overlap any number of independently anchored validations. Every
8714
+ * one that covers a cell applies to it. For a single cell the first is its primary validation,
8715
+ * the one Excel honors when it opens a file whose validations overlap.
8670
8716
  *
8671
8717
  * See {@link getConditionalFormats} for the overlap and one-entry-per-item rules, which are the
8672
8718
  * same for every ranged item lookup.
@@ -8694,6 +8740,14 @@ declare global {
8694
8740
  * `fullyContained` to ask only for tables the range wholly encloses.
8695
8741
  */
8696
8742
  getTables(options?: ICellRange.GetItemsOptions<ITableCollection.GetItemsOptions>): ITable[];
8743
+ /**
8744
+ * Returns the {@link IPivotTable}s with a cell in the range, in the order the sheet lists them.
8745
+ *
8746
+ * @remarks
8747
+ * A table's cells are its location and its page fields, not the blank row between them, as
8748
+ * Excel's `Range.PivotTable` answers. A table showing `#SPILL!` holds its anchor alone.
8749
+ */
8750
+ getPivotTables(): IPivotTable[];
8697
8751
  /**
8698
8752
  * Returns the {@link IMovable}s anchored over the range.
8699
8753
  *
@@ -11322,6 +11376,11 @@ declare global {
11322
11376
  readonly Table: "table";
11323
11377
  /** Auto-table membership. */
11324
11378
  readonly AutoTable: "autoTable";
11379
+ /**
11380
+ * Cells a pivot table is laid out over, the page fields above it included. A blocked table
11381
+ * covers none; {@link ICellRange.getPivotTables} names the tables over a range.
11382
+ */
11383
+ readonly Pivot: "pivot";
11325
11384
  /** Has a hyperlink. Regions group by what the link says, so the same link set twice is one region. */
11326
11385
  readonly Hyperlink: "hyperlink";
11327
11386
  /**
@@ -17326,6 +17385,12 @@ declare global {
17326
17385
  * Checks any text value is greater than or equal to.
17327
17386
  */
17328
17387
  readonly TextContains: "textContains";
17388
+ /**
17389
+ * Checks any text value matches a pattern, the whole text and ignoring case: `*` is any run of
17390
+ * characters, `?` any one, and `~` makes the next `*`, `?` or `~` itself. Excel's filter
17391
+ * `equal` with a wildcard (`a?ple`, `N*th`).
17392
+ */
17393
+ readonly TextMatches: "textMatches";
17329
17394
  /**
17330
17395
  * Evaluates a formula expression.
17331
17396
  *
@@ -17636,8 +17701,17 @@ declare global {
17636
17701
  limit?: number;
17637
17702
  /**
17638
17703
  * Flag indicating whether or not to filter by percent value. A `false` value filters by number of items.
17704
+ *
17705
+ * @remarks
17706
+ * With {@link sum}, the percent of the values' total rather than of their count.
17639
17707
  */
17640
17708
  percent?: boolean;
17709
+ /**
17710
+ * Whether {@link limit} bounds the values' sum rather than their count: values are taken from
17711
+ * the top (or the bottom) until their running sum reaches the limit, the one that reaches it
17712
+ * included. A pivot table's Top 10 by Sum, and by Percent with {@link percent}.
17713
+ */
17714
+ sum?: boolean;
17641
17715
  /**
17642
17716
  * Flag indicating whether or not to filter by top order. A `false` value filters by bottom order.
17643
17717
  */
@@ -18651,11 +18725,12 @@ declare global {
18651
18725
  */
18652
18726
  interface JSON extends Properties {
18653
18727
  /**
18654
- * If associated with a pivot.
18728
+ * Present when the rule belongs to a pivot table: the number the table names it by, which is
18729
+ * the priority the rule had in the file it was read from.
18655
18730
  *
18656
- * @defaultValue false
18731
+ * @internal
18657
18732
  */
18658
- pivot?: boolean;
18733
+ pivotKey?: number;
18659
18734
  /**
18660
18735
  * Payload from a rule this build does not understand.
18661
18736
  *
@@ -22288,7 +22363,7 @@ declare global {
22288
22363
  * | Dates | `getNow`, `toSerialDate`, `fromSerialDate`, `getDateParts`, `getSerialDate`, `parseAsDate`, `parseAsSerialDate`, `isValidDate` |
22289
22364
  * | Coercion | `parseAsNumber`, `parseAsLiteral`, `toText`, `compare` |
22290
22365
  * | Criteria | `createCriteria` |
22291
- * | Grouping | `createGrouping` |
22366
+ * | Grouping | `createPivot`, `getPivotAt` |
22292
22367
  * | Sheet introspection | `getSheetCount`, `getSheetIndex`, `getAddress`, `getNumberFormat` |
22293
22368
  *
22294
22369
  * ### Implementors
@@ -22600,32 +22675,50 @@ declare global {
22600
22675
  */
22601
22676
  createCriteria(criteria: Scalar, options?: IFormulaContext.CriteriaOptions): IFormulaContext.CriteriaEvaluator;
22602
22677
  /**
22603
- * Groups the records of a range — its rows — by their values.
22678
+ * Groups the records of a range two ways at once — by row keys and by column keys — at every
22679
+ * key level of each, and crosses every row group with every column group.
22604
22680
  *
22605
- * @param keys The key columns. Each row is one record, and records with equal values in every
22606
- * column form one group.
22607
- * @param options Which records take part. See {@link IFormulaContext.GroupingOptions}.
22608
- * @returns The groups, numbered in the order they first appear.
22681
+ * @param rows The row key columns, or `null` for none: every record is then in the one row group.
22682
+ * @param columns The column key columns, or `null` for none.
22683
+ * @param options Which records take part. See {@link IFormulaContext.PivotOptions}.
22684
+ * @returns The two axes of groups and what their crossings hold.
22685
+ * @throws `#VALUE!` for more than 32 key columns on one axis, or more groups and crossings than
22686
+ * the pivot can number.
22609
22687
  *
22610
22688
  * @remarks
22611
- * Two keys are equal by the rule `UNIQUE` uses: text ignores case, and types never mix, so `1`,
22612
- * `"1"` and `TRUE` are three groups. A blank key is a key of its own, distinct from `""`, and an
22613
- * error is a key like any other value. Every row is a record, blank rows included.
22689
+ * Every row is a record, blank rows included. Two keys are equal by the rule `UNIQUE` uses: text
22690
+ * ignores case, and types never mix, so `1`, `"1"` and `TRUE` are three groups. A blank key is a
22691
+ * key of its own, distinct from `""`, and an error is a key like any other value.
22614
22692
  *
22615
- * Group ONCE and ask the grouping for each group's members. The grouping does the work a
22616
- * per-group scan would repeat, so it stays proportional to the data rather than to the data
22617
- * times the number of groups.
22693
+ * Each axis is a tree: its root is every kept record, the root's children are the groups of the
22694
+ * first key column, theirs add the second, and so on, each in the order its first record appears.
22695
+ * A subtotal is then one group, never a union of its children.
22696
+ *
22697
+ * One pivot answers what a grouping per key level, and another per pair of levels, would — in
22698
+ * one pass, which is what `PIVOTBY` and a pivot table need.
22618
22699
  *
22619
22700
  * @example
22620
22701
  * ```typescript
22621
- * const grouping = FormulaContext.createGrouping(regions);
22622
- * for (let g = 0; g < grouping.getGroupCount(); g++) {
22623
- * const [region] = grouping.getKeys(g);
22624
- * const sales = grouping.getMembers(amounts, [g]);
22702
+ * const pivot = FormulaContext.createPivot(regions, years);
22703
+ * for (const region of pivot.getRows().getRoot().getChildren()) {
22704
+ * const total = pivot.getMembers(sales, region); // every year
22705
+ * const [name] = region.getKeys();
22625
22706
  * }
22626
22707
  * ```
22627
22708
  */
22628
- createGrouping(keys: IRange, options?: IFormulaContext.GroupingOptions): IFormulaContext.Grouping;
22709
+ createPivot(rows: IRange | null, columns: IRange | null, options?: IFormulaContext.PivotOptions): IFormulaContext.Pivot;
22710
+ /**
22711
+ * The pivot table a reference touches, as the values it shows.
22712
+ *
22713
+ * @param reference Any cell or range of the table, its page fields included.
22714
+ * @returns The view, or `null` when the reference touches no pivot table, or the table's values
22715
+ * are not computed (it is not modeled, or its view has not loaded yet).
22716
+ *
22717
+ * @remarks
22718
+ * What `GETPIVOTDATA` reads. The view answers for the values the table shows; matching a request
22719
+ * to its fields and items by name is the caller's.
22720
+ */
22721
+ getPivotAt(reference: IReferenceRange): IFormulaContext.PivotView | null;
22629
22722
  /**
22630
22723
  * Reads a typed literal in the workbook's language — the parse side of {@link toText}.
22631
22724
  *
@@ -22974,9 +23067,9 @@ declare global {
22974
23067
  anchor?: 'whole' | 'start';
22975
23068
  }
22976
23069
  /**
22977
- * Options for {@link IFormulaContext.createGrouping}.
23070
+ * Options for {@link IFormulaContext.createPivot}.
22978
23071
  */
22979
- interface GroupingOptions {
23072
+ interface PivotOptions {
22980
23073
  /**
22981
23074
  * One column, as tall as the keys, selecting the records that take part. A record is kept
22982
23075
  * when its member is `TRUE` or a nonzero number, and left out otherwise.
@@ -22984,48 +23077,148 @@ declare global {
22984
23077
  filter?: IRange;
22985
23078
  }
22986
23079
  /**
22987
- * The records of a range divided into groups — see {@link IFormulaContext.createGrouping}.
23080
+ * The records of a range grouped by rows and by columns — see {@link IFormulaContext.createPivot}.
22988
23081
  */
22989
- interface Grouping {
23082
+ interface Pivot {
22990
23083
  /**
22991
23084
  * The number of records kept by the filter.
22992
23085
  */
22993
23086
  getRecordCount(): number;
22994
23087
  /**
22995
- * The number of groups.
23088
+ * The row groups.
22996
23089
  */
22997
- getGroupCount(): number;
23090
+ getRows(): PivotAxis;
22998
23091
  /**
22999
- * The number of records in a group.
23092
+ * The column groups.
23000
23093
  */
23001
- getSize(group: number): number;
23094
+ getColumns(): PivotAxis;
23002
23095
  /**
23003
- * A group's key, one value per key column, as spelled by the group's first record. A blank
23004
- * key is `null`.
23096
+ * The members of `values` in both a row group and a column group, as one column in record order.
23097
+ *
23098
+ * @param values One column, as tall as the keys.
23099
+ * @param row A group of this pivot's rows; omit it, or pass the root, for every row.
23100
+ * @param column A group of this pivot's columns; omit it, or pass the root, for every column.
23101
+ * @returns An array, never a reference, or `null` when no kept record is in both groups.
23005
23102
  */
23006
- getKeys(group: number): readonly Scalar[];
23103
+ getMembers(values: IRange, row?: PivotGroup, column?: PivotGroup): IRange | null;
23007
23104
  /**
23008
- * The group a record belongs to, or `-1` when the filter left it out.
23105
+ * What `fn` returns over the members {@link getMembers} would give, computed without them.
23106
+ *
23107
+ * @returns `null` when no kept record is in both groups, `undefined` when the pivot does not
23108
+ * compute `fn` this way: call `fn` over {@link getMembers} instead.
23009
23109
  *
23010
- * @param record The record's row within the keys.
23110
+ * @remarks
23111
+ * Optional. Where it is present it answers for the built-in aggregates it knows (`SUM`,
23112
+ * `COUNT`, `AVERAGE`, ...) with exactly the value the call would return, the first error
23113
+ * member included.
23011
23114
  */
23012
- getGroup(record: number): number;
23115
+ getAggregate?(values: IRange, fn: IFunction, row?: PivotGroup, column?: PivotGroup): Scalar | null | undefined;
23116
+ }
23117
+ /**
23118
+ * A pivot table as the values it shows — see {@link IFormulaContext.getPivotAt}.
23119
+ */
23120
+ interface PivotView {
23121
+ /**
23122
+ * The table's values, in its order.
23123
+ */
23124
+ getDataFields(): readonly PivotViewDataField[];
23013
23125
  /**
23014
- * The row of a group's first record within the keys.
23126
+ * The fields on the table's rows, columns and pages, in that order.
23127
+ */
23128
+ getFields(): readonly PivotViewField[];
23129
+ /**
23130
+ * A value the table shows.
23015
23131
  *
23016
- * @remarks
23017
- * With {@link getGroup} on another grouping of the same records, this maps a group of one
23018
- * grouping onto the group of another — a finer grouping's group onto its parent's.
23132
+ * @param dataField The value, by index into {@link getDataFields}.
23133
+ * @param items Per field, by index into {@link getFields}, the item by index into its
23134
+ * {@link PivotViewField.items}. A field left out is totaled over.
23135
+ * @returns The value, or `undefined` when the table does not show it: a line it does not show
23136
+ * (a hidden or collapsed item, a subtotal or grand total turned off), an item not on its page,
23137
+ * or a crossing with no records.
23019
23138
  */
23020
- getFirstRecord(group: number): number;
23139
+ getValue(dataField: number, items: ReadonlyMap<number, number>): Scalar | undefined;
23021
23140
  /**
23022
- * The members of `values` that belong to some groups, as one column in record order.
23141
+ * Whether the table's values are known here.
23023
23142
  *
23024
- * @param values One column, as tall as the keys.
23025
- * @param groups The groups to take members from. Omit it for every kept record.
23026
- * @returns An array, never a reference. A blank member stays blank.
23143
+ * @returns `false` for a table that is there but whose values the host does not compute: its
23144
+ * fields and values are empty, and a caller that answered from it before keeps that answer, as
23145
+ * the table only changes on a refresh. Absent means `true`.
23146
+ */
23147
+ isComputed?(): boolean;
23148
+ }
23149
+ /**
23150
+ * A value of a {@link PivotView}.
23151
+ */
23152
+ interface PivotViewDataField {
23153
+ /** As the table shows it (`Sum of Sales`). */
23154
+ readonly name: string;
23155
+ /** The name of the source field it summarizes (`Sales`). */
23156
+ readonly sourceName: string;
23157
+ }
23158
+ /**
23159
+ * A field of a {@link PivotView}.
23160
+ */
23161
+ interface PivotViewField {
23162
+ /** As the table shows it: its caption, or the source field's name. */
23163
+ readonly name: string;
23164
+ readonly items: readonly PivotViewItem[];
23165
+ }
23166
+ /**
23167
+ * An item of a {@link PivotViewField}.
23168
+ */
23169
+ interface PivotViewItem {
23170
+ /** The item's value; `null` for the blank item. */
23171
+ readonly value: Scalar;
23172
+ /** The value as the table shows it, in the field's number format; `(blank)` for the blank item. */
23173
+ readonly text: string;
23174
+ /** The caption the item was renamed to, if it was. */
23175
+ readonly name?: string;
23176
+ }
23177
+ /**
23178
+ * One axis of a {@link Pivot}: its groups at every key level, as a tree under one root.
23179
+ */
23180
+ interface PivotAxis {
23181
+ /**
23182
+ * The group of every kept record, at level `0`.
23183
+ */
23184
+ getRoot(): PivotGroup;
23185
+ /**
23186
+ * The number of groups, the root included.
23187
+ */
23188
+ getGroupCount(): number;
23189
+ }
23190
+ /**
23191
+ * One group of a {@link PivotAxis}. The axis answers the same object for a group every time, so a
23192
+ * group can key a map.
23193
+ */
23194
+ interface PivotGroup {
23195
+ /**
23196
+ * The number of key columns the group is keyed by: `0` for the root, `1` for the groups of the
23197
+ * first key column, and so on.
23198
+ */
23199
+ getLevel(): number;
23200
+ /**
23201
+ * The group one level up, or `null` for the root.
23202
+ */
23203
+ getParent(): PivotGroup | null;
23204
+ /**
23205
+ * The groups one level down, in the order their first records appear.
23206
+ */
23207
+ getChildren(): readonly PivotGroup[];
23208
+ /**
23209
+ * The keys, one per level down to this group's own. Each level's key is spelled by the first
23210
+ * record of the group at that level, so a group's keys begin with its parent's. A blank key is
23211
+ * `null`.
23212
+ */
23213
+ getKeys(): readonly Scalar[];
23214
+ /**
23215
+ * The number of kept records in the group.
23027
23216
  */
23028
- getMembers(values: IRange, groups?: readonly number[]): IRange;
23217
+ getSize(): number;
23218
+ /**
23219
+ * The row of the group's first record within the keys.
23220
+ */
23221
+ getFirstRecord(): number;
23029
23222
  }
23030
23223
  /**
23031
23224
  * A serial date split into fields — see {@link IFormulaContext.getDateParts}.
@@ -29468,37 +29661,150 @@ declare global {
29468
29661
  }
29469
29662
 
29470
29663
  /**
29471
- * A pivot table laid out on a sheet: the part it was read from, anchored at its location.
29664
+ * A pivot table laid out on a sheet, anchored at the top-left cell of its location.
29472
29665
  *
29473
29666
  * @remarks
29474
- * The table is not modeled yet beyond where it sits and what it summarizes: its markup is kept
29475
- * as read and written back as read, with the location restated. Where it sits follows
29476
- * structural edits as a table's range does; an edit that would move only part of it is refused,
29477
- * as Excel refuses it, and one that takes every cell of it deletes it.
29667
+ * Until it is refreshed, a table is written back as it was read, with the location restated.
29668
+ * Where it sits follows structural edits; an edit that would move only part of it, its page
29669
+ * fields included, is refused, as Excel refuses it, and one that takes every cell of it deletes it.
29670
+ * While something is in the way of its cells, the table shows `#SPILL!` at its anchor and covers
29671
+ * that cell alone, as in Excel.
29478
29672
  */
29479
29673
  export interface IPivotTable extends IAnchored {
29480
29674
  toJSON(toResourceId?: (resource: IResource) => number | null): IPivotTable.JSON | null;
29481
29675
  /**
29482
- * Returns the name, unique across the workbook as Excel keeps it.
29676
+ * Returns the name.
29677
+ *
29678
+ * @remarks
29679
+ * Unique on the table's sheet, as Excel keeps it. Tables on different sheets may share a name:
29680
+ * a duplicated sheet's tables keep theirs, as they do in Excel.
29483
29681
  */
29484
29682
  getName(): string;
29683
+ /**
29684
+ * Renames the table, as one step that can be undone.
29685
+ *
29686
+ * @remarks
29687
+ * Any text of 1 to 255 characters, spaces and punctuation included, unless another table on this
29688
+ * sheet has it, without regard to case. A table on another sheet may have it. Slicers on the table
29689
+ * follow it; `GETPIVOTDATA` names a cell, not the table, so it is unaffected.
29690
+ *
29691
+ * @throws ExpectedError For an empty name, one longer than 255 characters, or one another table on
29692
+ * this sheet has.
29693
+ */
29694
+ setName(name: string, options?: ITransaction.OperationOptions): Promise<void>;
29485
29695
  /**
29486
29696
  * Returns the sheet the table is laid out on.
29487
29697
  */
29488
29698
  getWorksheet(): IWorksheet;
29489
29699
  /**
29490
- * Returns the cells the table is laid out on.
29700
+ * Returns the cells the table is laid out on: its location, without the page fields above it.
29491
29701
  *
29492
29702
  * @remarks
29493
- * The anchor: an insert or delete before the table moves it, one taking every cell of it
29494
- * deletes it ({@link IAnchored.isDeleted}), and one that would move part of it - a row deleted
29495
- * or inserted inside it, a column cut through it - is refused.
29703
+ * The anchor cell alone while the table shows `#SPILL!`. An insert or delete before the table
29704
+ * moves it, one taking every cell of it deletes it ({@link IAnchored.isDeleted}), and one that
29705
+ * would move part of it - a row deleted or inserted inside it or its page fields, a column cut
29706
+ * through it - is refused.
29496
29707
  */
29497
29708
  getRange(options?: ICellRange.GetRangeOptions): ICellRange;
29498
29709
  /**
29499
- * Returns the markup of the table's part, with the location as it is now.
29710
+ * Returns the cells of the page fields above the table, each a caption and its pick; `null` when
29711
+ * the table has no page field, or shows `#SPILL!`.
29712
+ */
29713
+ getPageRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
29714
+ /**
29715
+ * Returns the cells that hold the table's values, its subtotals and grand totals included; `null`
29716
+ * while the table shows `#SPILL!`.
29717
+ *
29718
+ * @remarks
29719
+ * Every line below the header rows, right of the label columns. A table with no values still has
29720
+ * its lines: then the last column, which holds the labels (as Excel's `DataBodyRange`).
29721
+ */
29722
+ getBodyAndTotalRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
29723
+ /**
29724
+ * Returns the label columns down the side, from the row of their captions to the last line; `null`
29725
+ * when nothing is on the rows, or the table shows `#SPILL!`.
29726
+ */
29727
+ getRowLabelRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
29728
+ /**
29729
+ * Returns the header rows across the top, right of the label columns, from the row of their
29730
+ * caption; `null` when nothing is on the columns, or the table shows `#SPILL!`.
29731
+ */
29732
+ getColumnLabelRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
29733
+ /**
29734
+ * Moves the table on its sheet, as one step that can be undone.
29735
+ *
29736
+ * @remarks
29737
+ * `cell` takes the table's top-left cell, as {@link IPivotTableCollection.add}'s location does:
29738
+ * page fields sit above it, a blank row between, and at the top of a sheet the table moves down
29739
+ * to make room for them. The cells it leaves are cleared. The cells it needs must hold no value,
29740
+ * unless {@link IPivotTable.MoveOptions.discardValues} clears them; another pivot table or an
29741
+ * array's cells there always refuse it. The new place may overlap the old.
29742
+ *
29743
+ * @throws ExpectedError When `cell` is on another sheet, the cells it needs hold a value, an array
29744
+ * or another pivot table, or the table is not modeled; ProtectedError on a locked sheet.
29745
+ */
29746
+ moveTo(cell: ICellRange.Address, options?: IPivotTable.MoveOptions): Promise<void>;
29747
+ /**
29748
+ * Returns the cells the table summarizes, as {@link IPivotTableCollection.add} takes them: a table's
29749
+ * or defined name's name, or a sheet-qualified range; `null` when its cache names none, as one
29750
+ * from another workbook or a database may not.
29751
+ */
29752
+ getSource(): string | null;
29753
+ /**
29754
+ * Summarizes other cells, as one step that can be undone: the table reads `source` as a refresh
29755
+ * does and is laid out again.
29756
+ *
29757
+ * @param source The cells to summarize, as {@link IPivotTableCollection.add} takes them.
29758
+ *
29759
+ * @remarks
29760
+ * Fields are matched to the new columns by their header, without regard to case. A field whose
29761
+ * column is gone, or whose header changed, leaves the table; the rest keep their place, hidden
29762
+ * items, filters, captions and formats. Other tables that shared the cache keep the cells they
29763
+ * summarized. When the table grows over a value it shows `#SPILL!`, as after a refresh. A slicer
29764
+ * on a field the new source does not have is deleted with it.
29765
+ *
29766
+ * @throws ExpectedError When `source` names nothing, has no row of data, overlaps the table, the
29767
+ * table is not modeled, or a slicer on the table also filters another; ProtectedError on a locked
29768
+ * sheet.
29769
+ */
29770
+ setSource(source: IPivotTableCollection.Source, options?: ITransaction.OperationOptions): Promise<void>;
29771
+ /**
29772
+ * Adds a slicer that filters one of the table's fields, as one step that can be undone.
29773
+ *
29774
+ * @param field The field, or its name.
29775
+ * @param options Where it goes and how it looks. Sized 192 × 280 pixels and centered in the
29776
+ * view unless `bounds` says otherwise; placed on the table's sheet unless `sheet` says otherwise.
29777
+ *
29778
+ * @returns The slicer, named for the field's name in the source (`Region`, then `Region 1`), unique
29779
+ * in the workbook, and captioned with the field's caption.
29780
+ *
29781
+ * @remarks
29782
+ * The field need not be on the table. The slicer's selection is the items the field hides.
29783
+ *
29784
+ * @throws ExpectedError When the table has no such field, the name is taken, or the table is not
29785
+ * modeled.
29786
+ *
29787
+ * @example
29788
+ * ```ts
29789
+ * const slicer = await pivot.addSlicer('Region');
29790
+ * await slicer.selectItems(['East']);
29791
+ * ```
29792
+ */
29793
+ addSlicer(field: IPivotTable.IField | string, options?: ISlicer.AddOptions): Promise<ISlicer>;
29794
+ /**
29795
+ * Returns whether the cells the table summarizes have been edited since its cache last read them.
29796
+ *
29797
+ * @remarks
29798
+ * As in Excel, an edit to the source does not change the table; it shows what the cache held
29799
+ * until it is refreshed from the source. Every table on the same cache is stale together.
29800
+ *
29801
+ * An edit is a value or formula written or cleared in the source (an undo of one too), a row
29802
+ * or column inserted or deleted inside it, or a resize of the table it names. Moving the source
29803
+ * whole is not. Neither is a recalculation: a formula in the source that reads cells outside it
29804
+ * can change value without the table reading as stale. A source this workbook does not hold,
29805
+ * such as another workbook's, never reads as stale.
29500
29806
  */
29501
- getXML(): string | null;
29807
+ isStale(): boolean;
29502
29808
  /**
29503
29809
  * Returns the id of the cache this table summarizes.
29504
29810
  *
@@ -29508,17 +29814,911 @@ declare global {
29508
29814
  * @internal
29509
29815
  */
29510
29816
  getCacheId(): number;
29817
+ /**
29818
+ * Reads the table's source again and lays the table out from it, as one step that can be undone.
29819
+ *
29820
+ * @remarks
29821
+ * The cache is read again from the cells its source names now, and every table on that cache is
29822
+ * laid out again with this one, as in Excel. A field follows its column by the header's text
29823
+ * (without regard to case): a column whose header changed, or that is gone, takes its field out
29824
+ * of every table. Each field keeps its items in their place, with what was hidden, collapsed or
29825
+ * renamed; an item no longer in the source is kept, missing, until it comes back, and a new one
29826
+ * is added after the others (in its place under a sort), hidden when the field hides items.
29827
+ * With `source: false` the table alone is laid out again from its cache as it is.
29828
+ *
29829
+ * The table takes the cells its layout needs: its range grows or shrinks from its top-left
29830
+ * cell, and the cells it gives up are cleared. When a cell it needs holds anything, the table
29831
+ * shows `#SPILL!` in its top-left cell, as a dynamic array does, and is laid out again as soon
29832
+ * as the cells are clear.
29833
+ *
29834
+ * @throws When the table is not modeled, on a locked sheet, or its source is not in this
29835
+ * workbook or its cache has calculated fields.
29836
+ */
29837
+ refresh(options?: IPivotTable.RefreshOptions): Promise<void>;
29838
+ /**
29839
+ * Returns the name of the table's style and which of its parts show.
29840
+ *
29841
+ * @remarks
29842
+ * Absent flags are off; a table with no style has no `name`.
29843
+ */
29844
+ getStyleOptions(): IPivotTable.StyleOptions;
29845
+ /**
29846
+ * Changes the table's style or which of its parts show, as one step that can be undone.
29847
+ *
29848
+ * @param options Merged with the current options; `name: null` removes the style and keeps the flags.
29849
+ *
29850
+ * @throws When the table is not modeled.
29851
+ */
29852
+ updateStyleOptions(options: IPivotTable.StyleOptions, operation?: ITransaction.OperationOptions): IPivotTable;
29853
+ /**
29854
+ * Returns the table's pivot table style, or `null` when it names none or one the workbook does not have.
29855
+ */
29856
+ getStyle(): ITableStyle | null;
29857
+ /**
29858
+ * Returns the style the table gives the cell at a sheet position: its pivot table style, and
29859
+ * the formats its layout sets, such as a row label set left and indented by its level.
29860
+ * @param row The row on the sheet.
29861
+ * @param column The column on the sheet.
29862
+ *
29863
+ * @remarks
29864
+ * Not the cell's own formats or any other layer. A cell the table does not cover, or a table
29865
+ * that is not laid out, has none of the table's styling.
29866
+ */
29867
+ getStyleAt(row: number, column: number): ICellStyle;
29868
+ /**
29869
+ * Sets whether the expand/collapse buttons beside the items are hidden, as one step that can be
29870
+ * undone.
29871
+ *
29872
+ * @remarks
29873
+ * The items still expand and collapse through {@link IPivotTable.IItem.setExpanded}.
29874
+ *
29875
+ * @throws When the table is not modeled.
29876
+ */
29877
+ setHiddenDrillIndicators(hidden: boolean, options?: ITransaction.OperationOptions): this;
29878
+ /**
29879
+ * Returns whether the expand/collapse buttons beside the items are hidden.
29880
+ */
29881
+ isHiddenDrillIndicators(): boolean;
29882
+ /**
29883
+ * Sets whether the captions over the row and column fields, and their buttons, are hidden, as
29884
+ * one step that can be undone.
29885
+ *
29886
+ * @remarks
29887
+ * The table is laid out again from its cache: the caption cells are left blank, and the row of
29888
+ * column captions is dropped when nothing else is in it, so the table can shrink by a row, as in
29889
+ * Excel. A page field keeps its caption and button.
29890
+ *
29891
+ * @throws When the table is not modeled.
29892
+ */
29893
+ setHiddenFieldHeaders(hidden: boolean, options?: ITransaction.OperationOptions): Promise<this>;
29894
+ /**
29895
+ * Returns whether the captions over the row and column fields, and their buttons, are hidden.
29896
+ */
29897
+ isHiddenFieldHeaders(): boolean;
29898
+ /**
29899
+ * Returns how the table lays out its fields, or `null` when the row and column fields differ.
29900
+ */
29901
+ getForm(): 'compact' | IPivotTable.PivotForm | null;
29902
+ /**
29903
+ * Lays out every field of the table in a form, those off the table too, as one step that can be
29904
+ * undone.
29905
+ *
29906
+ * @remarks
29907
+ * The table is laid out again from its cache. As with every setting that changes its cells, when
29908
+ * a cell it needs holds anything the setting stands and the table shows `#SPILL!` until the cells
29909
+ * are clear.
29910
+ *
29911
+ * @throws ExpectedError For a form that is none, or when the table is not modeled.
29912
+ */
29913
+ setForm(form: 'compact' | IPivotTable.PivotForm, options?: ITransaction.OperationOptions): Promise<this>;
29914
+ /**
29915
+ * Returns whether the row and column fields repeat their labels, or `null` when they differ.
29916
+ */
29917
+ getRepeatLabels(): boolean | null;
29918
+ /**
29919
+ * Sets whether every field repeats its item's label on each line the item spans, those off the
29920
+ * table too, as one step that can be undone.
29921
+ *
29922
+ * @remarks
29923
+ * Nothing shows in compact form, whose labels share a column; the setting stands for a later form.
29924
+ *
29925
+ * @throws When the table is not modeled.
29926
+ */
29927
+ setRepeatLabels(repeat: boolean, options?: ITransaction.OperationOptions): Promise<this>;
29928
+ /**
29929
+ * Returns whether the row and column fields leave a blank line after each item, or `null` when
29930
+ * they differ.
29931
+ */
29932
+ getBlankRowAfterItems(): boolean | null;
29933
+ /**
29934
+ * Sets whether every field leaves a blank line after each of its items, those off the table too,
29935
+ * as one step that can be undone.
29936
+ *
29937
+ * @remarks
29938
+ * A blank line shows only after the items of a row field with another row field inside it.
29939
+ *
29940
+ * @throws When the table is not modeled.
29941
+ */
29942
+ setBlankRowAfterItems(blank: boolean, options?: ITransaction.OperationOptions): Promise<this>;
29943
+ /**
29944
+ * Returns whether the row and column fields show their subtotals on their items' first line, or
29945
+ * `null` when they differ.
29946
+ */
29947
+ getSubtotalsOnTop(): boolean | null;
29948
+ /**
29949
+ * Sets whether every field shows its subtotals on its items' first line rather than on a line
29950
+ * after them, those off the table too, as one step that can be undone.
29951
+ *
29952
+ * @remarks
29953
+ * Tabular form always shows them after; the setting stands for a later form.
29954
+ *
29955
+ * @throws When the table is not modeled.
29956
+ */
29957
+ setSubtotalsOnTop(top: boolean, options?: ITransaction.OperationOptions): Promise<this>;
29958
+ /**
29959
+ * Returns whether each row shows a grand total: the column of totals at the table's right.
29960
+ */
29961
+ isShowRowGrandTotals(): boolean;
29962
+ /**
29963
+ * Sets whether each row shows a grand total, as one step that can be undone.
29964
+ *
29965
+ * @remarks
29966
+ * That is the column of totals at the table's right, so a table with no column fields has none to
29967
+ * show. With the grand total of the whole table gone from the cells, `GETPIVOTDATA` for it is `#REF!`.
29968
+ *
29969
+ * @throws When the table is not modeled.
29970
+ */
29971
+ setShowRowGrandTotals(show: boolean, options?: ITransaction.OperationOptions): Promise<this>;
29972
+ /**
29973
+ * Returns whether each column shows a grand total: the row of totals at the table's bottom.
29974
+ */
29975
+ isShowColumnGrandTotals(): boolean;
29976
+ /**
29977
+ * Sets whether each column shows a grand total, as one step that can be undone.
29978
+ *
29979
+ * @remarks
29980
+ * That is the row of totals at the table's bottom.
29981
+ *
29982
+ * @throws When the table is not modeled.
29983
+ */
29984
+ setShowColumnGrandTotals(show: boolean, options?: ITransaction.OperationOptions): Promise<this>;
29985
+ /**
29986
+ * Returns what a crossing no record falls in shows: this text, empty by default for a blank cell,
29987
+ * or `null` when it shows 0.
29988
+ */
29989
+ getEmptyCaption(): string | null;
29990
+ /**
29991
+ * Sets what a crossing no record falls in shows, as one step that can be undone.
29992
+ *
29993
+ * @param text The text; empty for a blank cell; `null` for 0. Text that reads as a number shows as
29994
+ * that number.
29995
+ *
29996
+ * @throws When the table is not modeled.
29997
+ */
29998
+ setEmptyCaption(text: string | null, options?: ITransaction.OperationOptions): Promise<this>;
29999
+ /**
30000
+ * Returns what an error value shows as: this text, or `null`, the default, when it shows the error.
30001
+ */
30002
+ getErrorCaption(): string | null;
30003
+ /**
30004
+ * Sets what an error value shows as, as one step that can be undone.
30005
+ *
30006
+ * @param text The text; empty for a blank cell; `null` for the error itself.
30007
+ *
30008
+ * @throws When the table is not modeled.
30009
+ */
30010
+ setErrorCaption(text: string | null, options?: ITransaction.OperationOptions): Promise<this>;
30011
+ /**
30012
+ * Returns whether the formats set on the table's cells follow their items through a relayout.
30013
+ */
30014
+ isPreserveFormatting(): boolean;
30015
+ /**
30016
+ * Sets whether the formats set on the table's cells follow their items through a relayout, as one
30017
+ * step that can be undone.
30018
+ *
30019
+ * @remarks
30020
+ * Turned off, the table lets go of the formats it holds, for good: turning it on again does not bring
30021
+ * them back. While off, a format set on the cells lasts until the next time the table is laid out,
30022
+ * whatever causes that.
30023
+ *
30024
+ * @throws When the table is not modeled.
30025
+ */
30026
+ setPreserveFormatting(preserve: boolean, options?: ITransaction.OperationOptions): this;
30027
+ /**
30028
+ * Returns whether the table fits its columns to its cells each time it is laid out.
30029
+ */
30030
+ isAutoFitColumns(): boolean;
30031
+ /**
30032
+ * Sets whether the table fits its columns to its cells each time it is laid out, as one step that
30033
+ * can be undone.
30034
+ *
30035
+ * @remarks
30036
+ * A fit measures only the table's cells, and sets the width of every column the table covers, a
30037
+ * width set by hand included. Setting this does not fit the columns; the next layout does.
30038
+ *
30039
+ * @throws When the table is not modeled.
30040
+ */
30041
+ setAutoFitColumns(autoFit: boolean, options?: ITransaction.OperationOptions): this;
30042
+ /**
30043
+ * Returns whether a field's filters are allowed to combine.
30044
+ */
30045
+ isMultipleFiltersPerField(): boolean;
30046
+ /**
30047
+ * Sets whether a field's filters are allowed to combine, as one step that can be undone.
30048
+ *
30049
+ * @remarks
30050
+ * Turned off, a field holding more than one filter loses all of them, and the table is laid out
30051
+ * again if any went; a field with one keeps it. The flag does not limit
30052
+ * {@link IPivotTable.IField.applyFilter}.
30053
+ *
30054
+ * @throws When the table is not modeled.
30055
+ */
30056
+ setMultipleFiltersPerField(multiple: boolean, options?: ITransaction.OperationOptions): Promise<this>;
30057
+ /**
30058
+ * Returns the table's fields, one per field of its cache, in the cache's order; empty for a table
30059
+ * that is not modeled.
30060
+ *
30061
+ * @example
30062
+ * ```ts
30063
+ * await pivot.getField('Region').getItem('East').setExpanded(false);
30064
+ * await pivot.getField('Channel').setCurrentPage('Web');
30065
+ * ```
30066
+ */
30067
+ getFields(): readonly IPivotTable.IField[];
30068
+ /**
30069
+ * Returns the field with a caption, matched without regard to case, or `null` when there is none.
30070
+ */
30071
+ getField(name: string): IPivotTable.IField | null;
30072
+ /**
30073
+ * Returns the fields down the rows, outermost first; the values, where they sit among them, are
30074
+ * {@link getValuesField}.
30075
+ */
30076
+ getRowFields(): readonly IPivotTable.IField[];
30077
+ /**
30078
+ * Returns the fields across the columns, outermost first; the values, where they sit among them,
30079
+ * are {@link getValuesField}.
30080
+ */
30081
+ getColumnFields(): readonly IPivotTable.IField[];
30082
+ /**
30083
+ * Returns the page fields above the table, in the order they are listed.
30084
+ */
30085
+ getPageFields(): readonly IPivotTable.IField[];
30086
+ /**
30087
+ * Returns the table's values, in the order they show; empty for a table that is not modeled.
30088
+ */
30089
+ getDataFields(): readonly IPivotTable.IDataField[];
30090
+ /**
30091
+ * Returns the value with a caption, matched without regard to case, or `null` when there is none.
30092
+ */
30093
+ getDataField(name: string): IPivotTable.IDataField | null;
30094
+ /**
30095
+ * Summarizes a field in the table's values, after the last, as one step that can be undone.
30096
+ *
30097
+ * @remarks
30098
+ * The field comes off any row, column or page axis it is on, as in Excel, keeping what
30099
+ * {@link IPivotTable.IField.setAxis} keeps. {@link IPivotTable.IField.setAxis} can then put it back,
30100
+ * holding both. One source can be summarized any number of times.
30101
+ *
30102
+ * With a second value the table gains its {@link getValuesField | values field}.
30103
+ *
30104
+ * @param field The field, or its caption.
30105
+ * @param input Its caption, function and number format; absent, as {@link IPivotTable.IDataField.Input} says.
30106
+ *
30107
+ * @example
30108
+ * ```ts
30109
+ * await pivot.addDataField('Sales');
30110
+ * const average = await pivot.addDataField('Sales', { function: 'average', numberFormat: '0.00' });
30111
+ * ```
30112
+ *
30113
+ * @throws ExpectedError For a field the table does not have, a caption another field or value has, a
30114
+ * function that is none or a number format that does not parse.
30115
+ */
30116
+ addDataField(field: string | IPivotTable.IField, input?: Omit<IPivotTable.IDataField.Input, 'field'>, options?: ITransaction.OperationOptions): Promise<IPivotTable.IDataField>;
30117
+ /**
30118
+ * Returns where the table's values sit among the fields of an axis; `null` below two values, when
30119
+ * there is nothing for them to be placed among.
30120
+ */
30121
+ getValuesField(): IPivotTable.IValuesField | null;
29511
30122
  /** For runtime type checking. */
29512
30123
  readonly isIPivotTable: true;
29513
30124
  }
29514
30125
 
29515
30126
  export namespace IPivotTable {
29516
30127
  /**
29517
- * A pivot cache as the workbook carries it: the part, by the id the tables name.
30128
+ * The axis a {@link IField | field} is on: down the rows, across the columns, as a page field
30129
+ * above the table, or where the values sit.
30130
+ */
30131
+ const Axis: {
30132
+ readonly Row: "row";
30133
+ readonly Column: "column";
30134
+ readonly Page: "page";
30135
+ readonly Values: "values";
30136
+ };
30137
+ type Axis = typeof Axis[keyof typeof Axis];
30138
+ /**
30139
+ * A field of a pivot table: a field of its cache, as the table uses it.
30140
+ *
30141
+ * @remarks
30142
+ * Changing what a field shows - collapsing items, hiding them, choosing a page item - changes the
30143
+ * table's definition and lays the table out again from its cache, as one step that can be undone.
30144
+ * The source is not read again. A table that grows over cells that hold anything shows `#SPILL!`,
30145
+ * as a {@link IPivotTable.refresh | refresh} does.
30146
+ *
30147
+ * A field is a view of the table: it reads the table as it is now.
30148
+ */
30149
+ interface IField {
30150
+ /**
30151
+ * Returns the field's caption: its own name in the table, else its cache field's.
30152
+ */
30153
+ getName(): string;
30154
+ /**
30155
+ * Returns what the field's items are: numbers, dates, text (logicals and errors among it), a
30156
+ * mix of those, or `blank` when it holds nothing. A calculated field is numbers.
30157
+ *
30158
+ * @remarks
30159
+ * The rule {@link IPivotTable.addDataField} follows for a value's function: `number` sums, any
30160
+ * other counts. A field list places a field by it, numbers in the values and the rest on the rows.
30161
+ */
30162
+ getDataType(): IField.DataType;
30163
+ /**
30164
+ * Returns the axis the field is on, or `null` when it is on none.
30165
+ */
30166
+ getAxis(): Axis | null;
30167
+ /**
30168
+ * Puts the field on an axis, or takes it off the table for `null`, as one step that can be undone.
30169
+ *
30170
+ * @remarks
30171
+ * The table is laid out again from its cache. Where a value is in the way it shows `#SPILL!`, and
30172
+ * a page field with no room above moves the table down, where it stays once the field has gone.
30173
+ *
30174
+ * What the field holds goes with it, off the table and back too: hidden items, filters, sort and
30175
+ * names. On the page axis it loses its filters, and items hidden there are a multiple selection;
30176
+ * off the page it loses its pick. A field off the table filters nothing. Taking it off also drops
30177
+ * the formats on its labels and on the values under them, for good; a move between axes keeps them.
30178
+ * A sort by one line of the other axis ends when that line's fields are no longer that axis's
30179
+ * outermost.
30180
+ *
30181
+ * A field stays with its data fields either way: one source can be on an axis and summarized at
30182
+ * once. To remove a value, delete its {@link IDataField}.
30183
+ *
30184
+ * @param axis Where it goes; `null` is nothing for a field already off the table.
30185
+ * @param position Its place on the axis, counted from 1, the values counting where they sit among
30186
+ * the fields; absent, after the last. Absent is nothing for a field already on `axis`.
30187
+ *
30188
+ * @example
30189
+ * ```ts
30190
+ * await pivot.getField('Year').setAxis('column');
30191
+ * await pivot.getField('Product').setAxis('row', 1);
30192
+ * await pivot.getField('Region').setAxis(null);
30193
+ * ```
30194
+ *
30195
+ * @throws ExpectedError For `values`, for a position not on the axis, and for a calculated field
30196
+ * on any axis or a field with calculated items on the page axis.
30197
+ */
30198
+ setAxis(axis: Axis | null, position?: number, options?: ITransaction.OperationOptions): Promise<void>;
30199
+ /**
30200
+ * Returns the field's place on its axis, counted from 1, the values counting where they sit among
30201
+ * the fields; `null` off the table.
30202
+ */
30203
+ getPosition(): number | null;
30204
+ /**
30205
+ * Moves the field along its axis, as one step that can be undone.
30206
+ *
30207
+ * @param position Its place, counted from 1 as {@link getPosition} counts.
30208
+ * @throws ExpectedError When the field is off the table or the position is not on its axis.
30209
+ */
30210
+ setPosition(position: number, options?: ITransaction.OperationOptions): Promise<void>;
30211
+ /**
30212
+ * Returns the subtotals the field shows, in the order they show: `automatic`, or its functions;
30213
+ * empty for none.
30214
+ */
30215
+ getSubtotals(): readonly IField.Subtotal[];
30216
+ /**
30217
+ * Sets the subtotals the field shows, as one step that can be undone.
30218
+ *
30219
+ * @remarks
30220
+ * The automatic subtotal takes the place of any function asked for with it, and functions show in
30221
+ * one order whatever the order asked. One function alone sits where the automatic subtotal does; two
30222
+ * or more always show on lines after the items. With none, an item's own line holds no value in
30223
+ * compact and outline forms. The setting holds for a field off the table, and shows when it is an
30224
+ * outer field of its axis.
30225
+ *
30226
+ * @param subtotals Empty for none.
30227
+ *
30228
+ * @example
30229
+ * ```ts
30230
+ * await pivot.getField('Region').setSubtotals([]);
30231
+ * await pivot.getField('Region').setSubtotals(['average', 'max']);
30232
+ * ```
30233
+ *
30234
+ * @throws ExpectedError For a subtotal that is none, on a calculated field, and for functions on a
30235
+ * field with calculated items.
30236
+ */
30237
+ setSubtotals(subtotals: readonly IField.Subtotal[], options?: ITransaction.OperationOptions): Promise<void>;
30238
+ /**
30239
+ * Returns how the field's items are laid out.
30240
+ */
30241
+ getForm(): 'compact' | PivotForm;
30242
+ /**
30243
+ * Lays out the field's items in a form, as one step that can be undone.
30244
+ *
30245
+ * @remarks
30246
+ * Fields of different forms share an axis: a compact field shares its label column with the field
30247
+ * inside it. {@link IPivotTable.setForm} sets every field at once.
30248
+ *
30249
+ * @throws ExpectedError For a form that is none.
30250
+ */
30251
+ setForm(form: 'compact' | PivotForm, options?: ITransaction.OperationOptions): Promise<void>;
30252
+ /**
30253
+ * Returns whether the field repeats its item's label on each line the item spans.
30254
+ */
30255
+ getRepeatLabels(): boolean;
30256
+ /**
30257
+ * Sets whether the field repeats its item's label on each line the item spans, as one step that
30258
+ * can be undone.
30259
+ *
30260
+ * @remarks
30261
+ * It shows only where the field has a label column or row of its own, and has a field inside it.
30262
+ */
30263
+ setRepeatLabels(repeat: boolean, options?: ITransaction.OperationOptions): Promise<void>;
30264
+ /**
30265
+ * Returns whether the field leaves a blank line after each of its items.
30266
+ */
30267
+ getBlankRowAfter(): boolean;
30268
+ /**
30269
+ * Sets whether the field leaves a blank line after each of its items, as one step that can be undone.
30270
+ *
30271
+ * @remarks
30272
+ * It shows only on a row field with another row field inside it; a field inside it that also leaves
30273
+ * one shares that line.
30274
+ */
30275
+ setBlankRowAfter(blank: boolean, options?: ITransaction.OperationOptions): Promise<void>;
30276
+ /**
30277
+ * Returns whether the field's subtotals show on its items' first line rather than after them.
30278
+ */
30279
+ getSubtotalsOnTop(): boolean;
30280
+ /**
30281
+ * Sets whether the field's subtotals show on its items' first line rather than after them, as one
30282
+ * step that can be undone.
30283
+ *
30284
+ * @remarks
30285
+ * Tabular form always shows them after, as do two or more functions.
30286
+ */
30287
+ setSubtotalsOnTop(top: boolean, options?: ITransaction.OperationOptions): Promise<void>;
30288
+ /**
30289
+ * Returns the format code of the field's item labels: its own, else its source column's, else
30290
+ * `General`; empty for a field holding anything but numbers and dates, which takes none.
30291
+ */
30292
+ getNumberFormat(): string;
30293
+ /**
30294
+ * Sets the number format of the field's item labels, as one step that can be undone.
30295
+ *
30296
+ * @remarks
30297
+ * `GETPIVOTDATA` still finds items by their values, and by the text they show. It does not reach a value that
30298
+ * summarizes the field: see {@link IDataField.setNumberFormat}.
30299
+ *
30300
+ * @param format A format code, or a built-in format's id.
30301
+ * @throws ExpectedError For a format that does not parse, and on a field holding anything but
30302
+ * numbers and dates.
30303
+ */
30304
+ setNumberFormat(format: string | number, options?: ITransaction.OperationOptions): Promise<void>;
30305
+ /**
30306
+ * Returns the table the field belongs to.
30307
+ */
30308
+ getPivotTable(): IPivotTable;
30309
+ /**
30310
+ * Returns the field's items in the table's order; empty for a field the table lists none for.
30311
+ */
30312
+ getItems(): readonly IItem[];
30313
+ /**
30314
+ * Returns the item with a caption, matched without regard to case, or `null` when there is none.
30315
+ *
30316
+ * @remarks
30317
+ * A renamed item is found by its new caption only, as in Excel.
30318
+ */
30319
+ getItem(name: string): IItem | null;
30320
+ /**
30321
+ * Shows or hides the details of every item of the field, as one step that can be undone.
30322
+ *
30323
+ * @throws When the field is not a row or column field with another field inside it.
30324
+ */
30325
+ setExpanded(expanded: boolean, options?: ITransaction.OperationOptions): Promise<void>;
30326
+ /**
30327
+ * Shows only the named items, or every item for `null`, as one step that can be undone.
30328
+ *
30329
+ * @remarks
30330
+ * On a page field the items shown are its selection: the field selects more than one item, and
30331
+ * its page cell shows the item when one is left, else `(Multiple Items)`.
30332
+ *
30333
+ * @throws When a name is not an item of the field, or no item would show.
30334
+ */
30335
+ setVisibleItems(names: readonly string[] | null, options?: ITransaction.OperationOptions): Promise<void>;
30336
+ /**
30337
+ * Returns the item a page field shows, or `null` when it shows every item or more than one.
30338
+ */
30339
+ getCurrentPage(): IItem | null;
30340
+ /**
30341
+ * Shows one item of a page field, or every item for `null`, as one step that can be undone.
30342
+ *
30343
+ * @remarks
30344
+ * The field selects a single item: any items hidden by {@link setVisibleItems} are shown again.
30345
+ *
30346
+ * @throws When the field is not a page field or the name is not one of its items.
30347
+ */
30348
+ setCurrentPage(name: string | null, options?: ITransaction.OperationOptions): Promise<void>;
30349
+ /**
30350
+ * Returns the field's filters: its label or date filter, its value or top filter, and the items
30351
+ * it shows when some are hidden by hand. Empty when the field is not filtered.
30352
+ */
30353
+ getFilters(): IField.Filters;
30354
+ /**
30355
+ * Returns whether the field is filtered: by a filter of `type`, or by any when omitted.
30356
+ */
30357
+ isFiltered(type?: IField.FilterType): boolean;
30358
+ /**
30359
+ * Sets the field's filters of the kinds given and leaves its others, as one step that can be
30360
+ * undone.
30361
+ *
30362
+ * @remarks
30363
+ * A field takes one label-or-date filter and one value-or-top filter, as Excel's does; one given
30364
+ * replaces the field's filter of its kind. Items hidden by hand stand beside them.
30365
+ *
30366
+ * - `label` tests each item's caption as its cell shows it; given no selector, it takes the
30367
+ * Display selector.
30368
+ * - `date` tests each item's date.
30369
+ * - `value` tests each item's total of a data field within each item of the fields outside it;
30370
+ * a top N ranks the items under one outer item together.
30371
+ * - `manual` names the items shown, every item for `null`; on a page field, its selection.
30372
+ *
30373
+ * A condition no Excel pivot filter type spells is kept and laid out, and is left out of an
30374
+ * xlsx file with a warning.
30375
+ *
30376
+ * @example
30377
+ * ```ts
30378
+ * const region = table.getField('Region')!;
30379
+ * await region.applyFilter({ label: { selector: 'display', operator: 'textStartsWith', param: 'N' } });
30380
+ * await region.applyFilter({ value: { condition: { operator: 'greaterThan', param: 100 }, dataField: 'Sum of Sales' } });
30381
+ * ```
30382
+ *
30383
+ * @throws ExpectedError When a label, date or value filter is given for a field that is not a
30384
+ * row or column field, both a label and a date filter are given, a top N names no data field,
30385
+ * a data field or item is not the table's, or no item would show.
30386
+ */
30387
+ applyFilter(filters: IField.FilterInput, options?: ITransaction.OperationOptions): Promise<void>;
30388
+ /**
30389
+ * Clears the field's filter of `type`, as one step that can be undone; `manual` shows every
30390
+ * item.
30391
+ */
30392
+ clearFilter(type: IField.FilterType, options?: ITransaction.OperationOptions): Promise<void>;
30393
+ /**
30394
+ * Clears every filter of the field and shows every item, as one step that can be undone; a page
30395
+ * field shows all its items again.
30396
+ */
30397
+ clearAllFilters(options?: ITransaction.OperationOptions): Promise<void>;
30398
+ /**
30399
+ * Returns how the field's items are sorted, or `null` when they are in the order listed.
30400
+ */
30401
+ getSort(): IField.Sort | null;
30402
+ /**
30403
+ * Sorts the field's items by their labels, as one step that can be undone: numbers, then text
30404
+ * without regard to case, logicals, errors, and blanks last; descending is the exact reverse.
30405
+ * A sort by value is replaced.
30406
+ *
30407
+ * @throws ExpectedError When the field is not a row or column field.
30408
+ */
30409
+ sortByLabels(order: 'ascending' | 'descending', options?: ITransaction.OperationOptions): Promise<void>;
30410
+ /**
30411
+ * Sorts the field's items under each outer item by a data field's value, as one step that can
30412
+ * be undone: their totals, or their values in one line of the other axis.
30413
+ *
30414
+ * @remarks
30415
+ * An empty value sorts as 0. Hiding an item of the scope ends the sort, as in Excel.
30416
+ *
30417
+ * @param dataField The data field, by name.
30418
+ * @param scope The line of the other axis to read: its items' names, outermost field first.
30419
+ * Fewer names than the axis has fields name a subtotal line (`['2023']` over Year and Quarter
30420
+ * is the 2023 total). Absent or empty, the grand total.
30421
+ * @throws ExpectedError When the field is not a row or column field, the data field is not the
30422
+ * table's, or the scope names no line of the other axis.
30423
+ */
30424
+ sortByValues(order: 'ascending' | 'descending', dataField: string, scope?: readonly string[] | null, options?: ITransaction.OperationOptions): Promise<void>;
30425
+ /**
30426
+ * Returns whether the field shows every item, those with no data included.
30427
+ */
30428
+ getShowAllItems(): boolean;
30429
+ /**
30430
+ * Shows every item of the field, those with no data included, or only those with data, as one
30431
+ * step that can be undone.
30432
+ */
30433
+ setShowAllItems(showAllItems: boolean, options?: ITransaction.OperationOptions): Promise<void>;
30434
+ /**
30435
+ * Renames the field in the table, as one step that can be undone; its source field's name
30436
+ * restores the original.
30437
+ *
30438
+ * @throws ExpectedError When another field or data field of the table has the name.
30439
+ */
30440
+ setName(name: string, options?: ITransaction.OperationOptions): Promise<void>;
30441
+ /** For runtime type checking. */
30442
+ readonly isIPivotField: true;
30443
+ }
30444
+ namespace IField {
30445
+ /** What a field's items are ({@link IField.getDataType}). */
30446
+ type DataType = 'number' | 'date' | 'text' | 'mixed' | 'blank';
30447
+ /** A subtotal a field can show: the automatic one, or a function. */
30448
+ type Subtotal = 'automatic' | IDataField.Function;
30449
+ /** A kind of filter a field takes. `manual` is the items hidden by hand. */
30450
+ type FilterType = 'label' | 'date' | 'value' | 'manual';
30451
+ /** A field's filters, by kind; a kind the field does not have is absent. */
30452
+ interface Filters {
30453
+ label?: ICondition.JSON;
30454
+ date?: ICondition.JSON;
30455
+ value?: {
30456
+ condition: ICondition.JSON;
30457
+ dataField: string;
30458
+ };
30459
+ /** The items shown, when some are hidden by hand. */
30460
+ manual?: readonly string[];
30461
+ }
30462
+ /** Filters to set on a field ({@link IField.applyFilter}); a kind absent is left as it is. */
30463
+ interface FilterInput {
30464
+ label?: ICondition.Input;
30465
+ date?: ICondition.Input;
30466
+ /** The data field by name. */
30467
+ value?: {
30468
+ condition: ICondition.Input;
30469
+ dataField: string;
30470
+ };
30471
+ /** The items shown, by name; `null` every item. */
30472
+ manual?: readonly string[] | null;
30473
+ }
30474
+ /** How a field's items are sorted ({@link IField.getSort}). */
30475
+ interface Sort {
30476
+ order: 'ascending' | 'descending';
30477
+ /** Sorted by this data field's values; absent, by label. */
30478
+ dataField?: string;
30479
+ /** The line of the other axis the values are read in, outermost item first; absent, the grand total. */
30480
+ scope?: readonly string[];
30481
+ }
30482
+ }
30483
+ /**
30484
+ * An item of a {@link IField | pivot field}: a value of its cache field, as the table lists it.
30485
+ */
30486
+ interface IItem {
30487
+ /**
30488
+ * Returns the item's caption: its own name in the table, else its value as text; `(blank)` for
30489
+ * the blank item.
30490
+ */
30491
+ getName(): string;
30492
+ /**
30493
+ * Returns the field the item belongs to.
30494
+ */
30495
+ getField(): IField;
30496
+ /**
30497
+ * Returns whether the item shows: `false` when it is hidden from the field.
30498
+ */
30499
+ isVisible(): boolean;
30500
+ /**
30501
+ * Shows or hides the item, as one step that can be undone.
30502
+ *
30503
+ * @throws When it is the last item showing.
30504
+ */
30505
+ setVisible(visible: boolean, options?: ITransaction.OperationOptions): Promise<void>;
30506
+ /**
30507
+ * Returns whether the item's details show: `false` when it is collapsed.
30508
+ */
30509
+ isExpanded(): boolean;
30510
+ /**
30511
+ * Shows or hides the item's details, as one step that can be undone.
30512
+ *
30513
+ * @remarks
30514
+ * An item of the innermost field takes the setting, which shows nothing different, as in Excel.
30515
+ *
30516
+ * @throws When the field is not a row or column field.
30517
+ */
30518
+ setExpanded(expanded: boolean, options?: ITransaction.OperationOptions): Promise<void>;
30519
+ /**
30520
+ * Returns the item's place among the items of its field that show, counted from 1; `null` for
30521
+ * a hidden item, or when the field is off the table.
30522
+ */
30523
+ getPosition(): number | null;
30524
+ /**
30525
+ * Moves the item among the items of its field that show, as one step that can be undone.
30526
+ *
30527
+ * @remarks
30528
+ * The field's order is then by hand: a sort it had, by label or by value, ends, as in Excel, and
30529
+ * the order holds through a refresh. The page pick, a sort by the item's line, a base item and
30530
+ * the formats on the item follow it.
30531
+ *
30532
+ * @param position Its place, counted from 1 as {@link getPosition} counts.
30533
+ * @throws ExpectedError For a hidden item or a field off the table, and for a position not
30534
+ * among the items that show.
30535
+ */
30536
+ setPosition(position: number, options?: ITransaction.OperationOptions): Promise<void>;
30537
+ /**
30538
+ * Renames the item in the table, as one step that can be undone; its value's own text restores
30539
+ * the original.
30540
+ *
30541
+ * @remarks
30542
+ * The name is kept as given, spaces and all, and may be empty. Under a sort by label the field
30543
+ * is sorted again, by the captions, as in Excel. `GETPIVOTDATA` finds the item by the caption or
30544
+ * by its value, and {@link IField.getItem} by the caption alone.
30545
+ *
30546
+ * @throws ExpectedError When another item of the field has the name, without regard to case.
30547
+ */
30548
+ setName(name: string, options?: ITransaction.OperationOptions): Promise<void>;
30549
+ /** For runtime type checking. */
30550
+ readonly isIPivotItem: true;
30551
+ }
30552
+ /**
30553
+ * Options for {@link IPivotTable.refresh}.
30554
+ */
30555
+ interface RefreshOptions extends ITransaction.OperationOptions {
30556
+ /**
30557
+ * Whether the cache is read again from the source first; `false` lays the table out from the
30558
+ * cache as it is.
30559
+ *
30560
+ * @defaultValue `true`
30561
+ */
30562
+ source?: boolean;
30563
+ }
30564
+ /** Options for {@link IPivotTable.moveTo}. */
30565
+ interface MoveOptions extends ITransaction.OperationOptions {
30566
+ /**
30567
+ * Whether values in the cells the table moves to are cleared; `false` refuses the move instead.
30568
+ *
30569
+ * @defaultValue `false`
30570
+ */
30571
+ discardValues?: boolean;
30572
+ }
30573
+ /**
30574
+ * Options for {@link IPivotTable.updateStyleOptions}: the style's name, and which parts of it show.
30575
+ */
30576
+ interface StyleOptions extends Omit<PivotStyleJSON, 'name'> {
30577
+ /** A pivot table style's name; `null` removes the style. */
30578
+ name?: string | null;
30579
+ }
30580
+ /**
30581
+ * A pivot cache as the workbook carries it, by the id the tables name.
30582
+ *
30583
+ * @remarks
30584
+ * A cache over a worksheet source is modeled: its fields, their items and the records, which
30585
+ * are what a refresh rebuilds and what a pivot is computed from. `part`, the definition and
30586
+ * records as they were read, is present only while the cache is unchanged, and is then what is
30587
+ * written. A cache with no `fields` is carried as its `part` alone.
29518
30588
  */
29519
30589
  interface CacheJSON {
29520
30590
  cacheId: number;
30591
+ /** The parts as read, written as they are while the cache is unchanged. */
29521
30592
  part?: IEmbeddedPart.JSON;
30593
+ /**
30594
+ * The cells the records were read from: a sheet and a range, or a table's name. Present for a
30595
+ * cache carried as its part too, when it names cells in this workbook.
30596
+ */
30597
+ source?: CacheSourceJSON;
30598
+ fields?: CacheFieldJSON[];
30599
+ /**
30600
+ * Each field's items: the field's index, then its items in order. A string is literal; a
30601
+ * missing item is `{ t: 'z', v: 0 }`; a date is its serial number (see
30602
+ * {@link CacheFieldJSON.dates} and {@link CacheFieldJSON.dateItems}).
30603
+ */
30604
+ items?: Tuple.GridTuple<Scalar.JSON>;
30605
+ /**
30606
+ * Each field's records: the field's index, then, per record in order, the index of its item
30607
+ * in {@link items}. A field with {@link CacheFieldJSON.noRecords} has none. Absent when the file
30608
+ * saved no records: its tables are not laid out until a refresh from the source.
30609
+ */
30610
+ records?: Tuple.GridTuple<number>;
30611
+ recordCount?: number;
30612
+ refreshOnLoad?: boolean;
30613
+ /**
30614
+ * For a cache with no `fields`: what the format ids its `part` cites named in the file it was
30615
+ * read from.
30616
+ * @internal
30617
+ */
30618
+ partFormats?: PartFormatsJSON;
30619
+ /**
30620
+ * The definition's markup with what is modeled taken out (the fields, the source's cells, the
30621
+ * record count and refresh flag): what the cache holds that is not typed yet.
30622
+ */
30623
+ rest?: string;
30624
+ }
30625
+ /**
30626
+ * What the format ids in a part carried without a model name, by id, in the file it was read
30627
+ * from. A save numbers its formats afresh and restates each id the part cites from these.
30628
+ * @internal
30629
+ */
30630
+ interface PartFormatsJSON {
30631
+ /** By `numFmtId`: a custom number format's code. Built-in ids are kept as they are. */
30632
+ numberFormats?: Record<number, string>;
30633
+ /** By `dxfId`: the differential format. */
30634
+ dxfs?: Record<number, ICellStyle.Properties>;
30635
+ }
30636
+ /**
30637
+ * The cells a {@link CacheJSON | cache} was read from.
30638
+ */
30639
+ interface CacheSourceJSON {
30640
+ /** The range, A1 without `$`. With `sheet`. */
30641
+ ref?: string;
30642
+ sheet?: string;
30643
+ /** A table's or a defined name's name, in place of `ref` and `sheet`. */
30644
+ name?: string;
30645
+ }
30646
+ /**
30647
+ * One field of a {@link CacheJSON | cache}: a column of its source, or a grouping of one.
30648
+ */
30649
+ interface CacheFieldJSON {
30650
+ name: string;
30651
+ /** The number format of its values: a format code, or a built-in format's id; absent, General. */
30652
+ numberFormat?: string | number;
30653
+ /** The records hold the values themselves, not the index of a shared item. */
30654
+ inline?: true;
30655
+ /** The items that are numbers are dates. */
30656
+ dates?: true;
30657
+ /**
30658
+ * The items that are dates, by index, when others are plain numbers. A date and a number of the
30659
+ * same value are two items.
30660
+ */
30661
+ dateItems?: number[];
30662
+ /** The items the source no longer holds, kept from an earlier refresh. */
30663
+ unused?: number[];
30664
+ /** Not a column of the source (a grouping or calculated field): the records hold nothing for it. */
30665
+ noRecords?: true;
30666
+ /** How the field groups values, or the field its values are grouped by. */
30667
+ group?: CacheFieldGroupJSON;
30668
+ /** A calculated field's formula, as a file spells it (`Sales-Cost`), with {@link noRecords}. */
30669
+ formula?: string;
30670
+ /**
30671
+ * The field's calculated items: each one's index in its items, and its formula, as a file spells
30672
+ * it (`Region[North]+Region[South]`).
30673
+ */
30674
+ calculatedItems?: {
30675
+ item: number;
30676
+ formula: string;
30677
+ }[];
30678
+ /**
30679
+ * The field's markup with what is modeled taken out (name, number format, items): its
30680
+ * grouping, formula and anything else not typed yet.
30681
+ */
30682
+ rest?: string;
30683
+ }
30684
+ /**
30685
+ * How a {@link CacheFieldJSON | cache field} groups the values of another, or its own.
30686
+ *
30687
+ * @remarks
30688
+ * A table lists a grouping field's {@link items}, not its cache items. With neither
30689
+ * {@link range} nor {@link discrete} the field groups nothing itself and only names its
30690
+ * {@link parent}: a date field grouped by months.
30691
+ */
30692
+ interface CacheFieldGroupJSON {
30693
+ /** The cache field whose values are grouped: this field, for a number range in place. */
30694
+ base: number;
30695
+ /** The next coarser field grouping the same values (Date to Months to Years). */
30696
+ parent?: number;
30697
+ /**
30698
+ * Each group's caption. A range's first and last hold what falls before and after it. An item of
30699
+ * the base that no group holds is its own group here, as itself: a number, a date's serial
30700
+ * number ({@link dateItems}), a boolean, or the items' spelling of a blank or an error
30701
+ * ({@link CacheJSON.items}).
30702
+ */
30703
+ items: Scalar.JSON[];
30704
+ /** The {@link items} that are dates, by index. */
30705
+ dateItems?: number[];
30706
+ /** Groups by range of the base's values. */
30707
+ range?: {
30708
+ by: 'numbers' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'quarters' | 'years';
30709
+ /** The first value; a date is its serial number. */
30710
+ start: number;
30711
+ /** The last value; a date range's whole-day end is the day after the last. */
30712
+ end: number;
30713
+ /** The width of each step, in values or days; absent, 1. */
30714
+ interval?: number;
30715
+ /** The start stays when the source changes, rather than following its least value. */
30716
+ fixedStart?: true;
30717
+ /** The end stays when the source changes, rather than following its greatest value. */
30718
+ fixedEnd?: true;
30719
+ };
30720
+ /** Groups by hand: for each cache item of the base, its index in {@link items}. */
30721
+ discrete?: number[];
29522
30722
  }
29523
30723
  /**
29524
30724
  * JSON representation of a pivot table.
@@ -29526,7 +30726,528 @@ declare global {
29526
30726
  interface JSON {
29527
30727
  name?: string;
29528
30728
  cacheId: number;
30729
+ /**
30730
+ * The cells the table's body is laid out on, as an A1 range (`A3:C20`): where it is anchored.
30731
+ * Its page fields sit above it.
30732
+ */
30733
+ location: string;
29529
30734
  part?: IEmbeddedPart.JSON;
30735
+ /**
30736
+ * For a table with no `fields`: what the format ids its `part` cites named in the file it was
30737
+ * read from.
30738
+ * @internal
30739
+ */
30740
+ partFormats?: PartFormatsJSON;
30741
+ /**
30742
+ * The cells that show a field button, as addresses relative to the table's top-left cell
30743
+ * (`A1` is that cell).
30744
+ *
30745
+ * @remarks
30746
+ * A button belongs to the table, not to the cell's format: Excel drops it from a copied cell.
30747
+ *
30748
+ * @internal
30749
+ */
30750
+ buttons?: string[];
30751
+ /**
30752
+ * One per field of the cache, in the cache's order.
30753
+ *
30754
+ * @remarks
30755
+ * A table is modeled when its markup holds nothing the model does not type yet on the
30756
+ * elements it reads (OLAP hierarchies, item properties, extensions on a field or data field
30757
+ * other than Excel's own repeat labels and show-values-as); it is then written from the model
30758
+ * once it has no `part`.
30759
+ */
30760
+ fields?: PivotFieldJSON[];
30761
+ /** The fields on the row axis, outermost first, by index; `-2` is where the values sit. */
30762
+ rowFields?: number[];
30763
+ /** The fields on the column axis, outermost first, by index; `-2` is where the values sit. */
30764
+ columnFields?: number[];
30765
+ pageFields?: PageFieldJSON[];
30766
+ dataFields?: DataFieldJSON[];
30767
+ /** Shown unless `false`. */
30768
+ rowGrandTotals?: false;
30769
+ /** Shown unless `false`. */
30770
+ columnGrandTotals?: false;
30771
+ /**
30772
+ * The layout of fields added to the table and of the values; absent, compact. Each field
30773
+ * keeps its own ({@link PivotFieldJSON.form}).
30774
+ */
30775
+ form?: PivotForm;
30776
+ /** How far each level of a compact row field is indented, in characters past the first; absent, 0. */
30777
+ indent?: number;
30778
+ /** The caption of the values field; absent, `Values`. */
30779
+ valuesCaption?: string;
30780
+ /** The caption of the grand totals; absent, `Grand Total`. */
30781
+ grandTotalCaption?: string;
30782
+ /** The caption over the row labels in compact form; absent, `Row Labels`. */
30783
+ rowHeaderCaption?: string;
30784
+ /** The caption over the column labels in compact form; absent, `Column Labels`. */
30785
+ columnHeaderCaption?: string;
30786
+ /** Shown in place of an error value when {@link showError} is `true`. */
30787
+ errorCaption?: string;
30788
+ /** An error value shows as {@link errorCaption}. */
30789
+ showError?: true;
30790
+ /** Shown in a crossing no record falls in, unless {@link showEmpty} is `false`. */
30791
+ emptyCaption?: string;
30792
+ /** `false`: a crossing no record falls in shows 0 rather than {@link emptyCaption}. */
30793
+ showEmpty?: false;
30794
+ /** The values are laid out down the rows, or are to be with a second; their position is `-2` in {@link rowFields}. */
30795
+ valuesOnRows?: true;
30796
+ /**
30797
+ * Below two values, where a second puts them among the fields of their axis, counted from 0; absent,
30798
+ * after the last.
30799
+ */
30800
+ valuesPosition?: number;
30801
+ /** A field takes more than one filter; absent, a new filter on a field replaces its last. */
30802
+ multipleFiltersPerField?: true;
30803
+ /** How many page fields sit in a row (or a column) before the next; absent, 0, no wrap. */
30804
+ pageWrap?: number;
30805
+ /** The page fields run across, then down; absent, down, then across. */
30806
+ pageOverThenDown?: true;
30807
+ /** The items' expand/collapse buttons are hidden; absent, shown. */
30808
+ hiddenDrillIndicators?: true;
30809
+ /** The field captions and their buttons are hidden; absent, shown. */
30810
+ hiddenFieldHeaders?: true;
30811
+ /** The table style and which of its parts show; absent, no style. */
30812
+ style?: PivotStyleJSON;
30813
+ /** The label, value and date filters, in the order they apply. */
30814
+ filters?: PivotFilterJSON[];
30815
+ /** `false`: a refresh drops the formats a user put on the table's cells; absent, they follow their areas. */
30816
+ preserveFormatting?: false;
30817
+ /** `false`: a layout leaves the columns' widths alone; absent, it fits the columns the table covers. */
30818
+ autoFitColumns?: false;
30819
+ /** The formats a user put on parts of the table, in the order they apply. */
30820
+ formats?: PivotFormatJSON[];
30821
+ /** The table's conditional formats: which sheet rule applies where in the table. */
30822
+ conditionalFormats?: PivotConditionalFormatJSON[];
30823
+ /** Where the laid-out parts start; absent, not laid out. */
30824
+ header?: PivotHeaderJSON;
30825
+ /** The lines of the rows as last laid out, top to bottom; absent, not laid out. */
30826
+ rowLines?: PivotLineJSON[];
30827
+ /** The lines of the columns as last laid out, left to right; absent, not laid out. */
30828
+ columnLines?: PivotLineJSON[];
30829
+ /** The definition's markup with what is modeled taken out: anything not typed yet. */
30830
+ rest?: string;
30831
+ }
30832
+ /** How a field's items are laid out: compact (absent), outline, or tabular. */
30833
+ type PivotForm = 'outline' | 'tabular';
30834
+ /** The style of a {@link JSON | pivot table}: a pivot table style by name, and which parts of it show. */
30835
+ interface PivotStyleJSON {
30836
+ name?: string;
30837
+ showRowHeaders?: boolean;
30838
+ showColumnHeaders?: boolean;
30839
+ showRowStripes?: boolean;
30840
+ showColumnStripes?: boolean;
30841
+ showLastColumn?: boolean;
30842
+ }
30843
+ /**
30844
+ * A filter of a {@link JSON | pivot table}: which items of a field show.
30845
+ *
30846
+ * @remarks
30847
+ * A label filter tests each item's caption (the Display selector), a date filter its date (the
30848
+ * Date selector, or a time period), and a value or top filter the item's total of a data field,
30849
+ * within each item of the fields outside it.
30850
+ */
30851
+ interface PivotFilterJSON {
30852
+ /** The field filtered, by index. */
30853
+ field: number;
30854
+ /** A value or top filter: the data field whose total is tested, by index into {@link JSON.dataFields}. */
30855
+ dataField?: number;
30856
+ condition: ICondition.JSON;
30857
+ id?: number;
30858
+ /** The order the filter applies in; absent, -1, the order listed. */
30859
+ evalOrder?: number;
30860
+ name?: string;
30861
+ description?: string;
30862
+ /** A date filter that takes whole days, as a timeline sets it. */
30863
+ useWholeDay?: true;
30864
+ }
30865
+ /** A conditional format of a {@link JSON | pivot table}: a sheet rule, by priority, and the areas it applies to. */
30866
+ interface PivotConditionalFormatJSON {
30867
+ /** The sheet rule's priority, as read. */
30868
+ priority: number;
30869
+ /** What the areas select, as OOXML spells it (`selection`, `data`, `field`). */
30870
+ scope?: string;
30871
+ /** Which way the rule runs over the areas, as OOXML spells it (`none`, `all`, `row`, `column`). */
30872
+ type?: string;
30873
+ areas: PivotAreaJSON[];
30874
+ }
30875
+ /** A format on part of a {@link JSON | pivot table}: what it sets, and where. */
30876
+ interface PivotFormatJSON {
30877
+ /** What it sets, as a conditional format's style holds it. */
30878
+ style: ICellStyle.Properties;
30879
+ area: PivotAreaJSON;
30880
+ /** `blank`: the area shows nothing; absent, the style is applied. */
30881
+ action?: 'blank';
30882
+ }
30883
+ /** A part of a {@link JSON | pivot table}, as a format or a conditional format names it. */
30884
+ interface PivotAreaJSON {
30885
+ /** What kind of part, as OOXML spells it; absent, `normal`: the cells the references pick. */
30886
+ type?: 'data' | 'all' | 'origin' | 'button' | 'topEnd' | 'topRight' | 'none';
30887
+ /** The field, by index; `-2` the values. A button's field, or the field whose labels. */
30888
+ field?: number;
30889
+ /** `false`: labels as well as values; absent, values only. */
30890
+ dataOnly?: false;
30891
+ /** Labels only. */
30892
+ labelOnly?: true;
30893
+ /** The grand total row. */
30894
+ grandRow?: true;
30895
+ /** The grand total column. */
30896
+ grandCol?: true;
30897
+ /** `false`: tabular rather than outline positions; absent, outline. */
30898
+ outline?: false;
30899
+ /** A collapsed item's line counts as its subtotal. */
30900
+ collapsedLevelsAreSubtotals?: true;
30901
+ axis?: Axis;
30902
+ /** The field's position on its axis; absent, 0. */
30903
+ fieldPosition?: number;
30904
+ /** The cells picked, one reference per field. */
30905
+ references?: PivotAreaReferenceJSON[];
30906
+ /** The area's attributes not typed yet (`offset`, `cacheIndex`), as markup; absent, none. */
30907
+ rest?: string;
30908
+ }
30909
+ /** The items of one field a {@link PivotAreaJSON} picks. */
30910
+ interface PivotAreaReferenceJSON {
30911
+ /** The field, by index; `-2` the values. */
30912
+ field: number;
30913
+ /** By index into the field's items, or into the data fields for `-2`; absent, all of them. */
30914
+ items?: number[];
30915
+ /** `false`: the items are not selected; absent, they are. */
30916
+ selected?: false;
30917
+ /** The items count by position, not by index. */
30918
+ byPosition?: true;
30919
+ /** The items are relative to the cell. */
30920
+ relative?: true;
30921
+ /** Which of the field's subtotals, as OOXML spells them (`defaultSubtotal`, `sumSubtotal`, ...). */
30922
+ subtotals?: string[];
30923
+ }
30924
+ /**
30925
+ * One field of a {@link JSON | pivot table}: how the table uses a field of its cache.
30926
+ */
30927
+ interface PivotFieldJSON {
30928
+ axis?: Axis;
30929
+ /** The field is summarized by a data field. */
30930
+ dataField?: true;
30931
+ /** The caption shown for the field. */
30932
+ name?: string;
30933
+ /**
30934
+ * The subtotals shown for the field: `default` is the automatic one. Absent, the automatic
30935
+ * subtotal alone; empty, none.
30936
+ */
30937
+ subtotals?: PivotSubtotal[];
30938
+ /** The whole caption of the field's automatic subtotal lines, in place of `<item> Total`. */
30939
+ subtotalCaption?: string;
30940
+ /** The field's items in the table's order, which is state: a refresh keeps it. */
30941
+ items?: PivotItemJSON[];
30942
+ /** How the field's items are laid out; absent, compact. */
30943
+ form?: PivotForm;
30944
+ /** `false`: the field's subtotals sit under its items rather than on their row. */
30945
+ subtotalsOnTop?: false;
30946
+ /** A blank line follows each item. */
30947
+ blankRowAfter?: true;
30948
+ /** Items no record falls in show as well. */
30949
+ showItemsWithNoData?: true;
30950
+ /** Each item's label repeats on every line it spans. */
30951
+ repeatLabels?: true;
30952
+ /** The number format of the items' labels: a format code, or a built-in format's id; absent, General. */
30953
+ numberFormat?: string | number;
30954
+ /**
30955
+ * The items are sorted by label, or by the total of a data field (by index into
30956
+ * {@link JSON.dataFields}); absent, they stay in {@link items}' order.
30957
+ */
30958
+ sort?: {
30959
+ order: 'ascending' | 'descending';
30960
+ dataField?: number;
30961
+ /** Sorted by one line of the other axis rather than by its grand total; absent, the total. */
30962
+ scope?: PivotSortScopeJSON;
30963
+ };
30964
+ /** Items new to the cache show after a refresh while the field is filtered. */
30965
+ includeNewItemsInFilter?: true;
30966
+ /** A page field shows more than one item. */
30967
+ multipleItemSelection?: true;
30968
+ /** The field's markup with what is modeled taken out. */
30969
+ rest?: string;
30970
+ }
30971
+ /**
30972
+ * The line of the other axis a {@link PivotFieldJSON.sort | sort by value} reads: its items, as a
30973
+ * line's path names them.
30974
+ */
30975
+ interface PivotSortScopeJSON {
30976
+ /** The line's items, outermost field of the other axis first; each by index into its field's items. */
30977
+ items: {
30978
+ field: number;
30979
+ item: number;
30980
+ }[];
30981
+ /** The line is its innermost item's subtotal (a `2023 Total` column) rather than the item's own line. */
30982
+ subtotal?: true;
30983
+ }
30984
+ /**
30985
+ * One line of a laid-out {@link JSON | pivot table}'s rows or columns: an item, a subtotal, the
30986
+ * grand total, or a blank row, as Excel stores it in `rowItems` and `colItems`.
30987
+ *
30988
+ * @remarks
30989
+ * A line names its items by index into each axis field's {@link PivotFieldJSON.items}, from the
30990
+ * outermost field in; where the values sit, the index is a data field's. The first
30991
+ * {@link repeat} of them are the line above's and are left out.
30992
+ */
30993
+ interface PivotLineJSON {
30994
+ /** Absent: an item. `default` (or a subtotal function) for a subtotal, `grand`, `blank`. */
30995
+ type?: string;
30996
+ /** How many leading items are the same as the line above's, and so not in {@link items}. */
30997
+ repeat?: number;
30998
+ /** The item indexes after the repeated ones. */
30999
+ items: number[];
31000
+ /** The data field the line shows, by index into {@link JSON.dataFields}; absent, the first. */
31001
+ dataField?: number;
31002
+ }
31003
+ /**
31004
+ * Where a laid-out {@link JSON | pivot table}'s parts start, relative to its location's
31005
+ * top-left cell, as Excel stores them on `location`.
31006
+ */
31007
+ interface PivotHeaderJSON {
31008
+ /** The row of the column items' labels. */
31009
+ firstHeaderRow: number;
31010
+ /** The first row of values. */
31011
+ firstDataRow: number;
31012
+ /** The first column of values. */
31013
+ firstDataCol: number;
31014
+ }
31015
+ /** A subtotal function of a {@link PivotFieldJSON | field}, as OOXML spells it. */
31016
+ type PivotSubtotal = 'default' | 'sum' | 'countA' | 'avg' | 'max' | 'min' | 'product' | 'count' | 'stdDev' | 'stdDevP' | 'var' | 'varP';
31017
+ /**
31018
+ * One item of a {@link PivotFieldJSON | field}: an item of the cache field, or a subtotal or
31019
+ * grand-total line.
31020
+ */
31021
+ interface PivotItemJSON {
31022
+ /** The index of the item in the cache field's items. */
31023
+ item?: number;
31024
+ /** The line it is, when not an item of the cache, as OOXML spells it (`default`, `sum`, `grand`…). */
31025
+ type?: string;
31026
+ hidden?: true;
31027
+ /** Its details are not shown. */
31028
+ collapsed?: true;
31029
+ /** The caption shown in place of the item's value. */
31030
+ name?: string;
31031
+ /** A calculated item: its value is a formula over the field's other items, the cache's. */
31032
+ calculated?: true;
31033
+ /** The item is no longer in the source; kept until a refresh drops it. */
31034
+ missing?: true;
31035
+ }
31036
+ /**
31037
+ * A field on the page axis and the item it shows.
31038
+ */
31039
+ interface PageFieldJSON {
31040
+ /** The field, by index. */
31041
+ field: number;
31042
+ /** The item shown, by index into the field's {@link PivotFieldJSON.items}; absent, all. */
31043
+ item?: number;
31044
+ }
31045
+ /**
31046
+ * A value of a {@link JSON | pivot table}: a field of the cache summarized by a function.
31047
+ */
31048
+ interface DataFieldJSON {
31049
+ name: string;
31050
+ /** The field summarized, by index. */
31051
+ field: number;
31052
+ /** The function, as OOXML spells it; absent, `sum`. */
31053
+ subtotal?: string;
31054
+ /**
31055
+ * How the value is shown, as OOXML spells it (`percentOfTotal`, `difference`,
31056
+ * `percentOfParentRow`, `rankAscending`…); absent, as is.
31057
+ */
31058
+ showDataAs?: string;
31059
+ /** The field `showDataAs` compares against, by index. */
31060
+ baseField?: number;
31061
+ /**
31062
+ * The item of {@link baseField} `showDataAs` compares against: by index, or the one before or
31063
+ * after each item.
31064
+ */
31065
+ baseItem?: number | 'previous' | 'next';
31066
+ /** The number format of its values: a format code, or a built-in format's id; absent, General. */
31067
+ numberFormat?: string | number;
31068
+ }
31069
+ /**
31070
+ * A value of a pivot table: a field summarized by a function.
31071
+ *
31072
+ * @remarks
31073
+ * A view of the table, found by its caption: what is asked of it after the value is deleted, or after
31074
+ * another view has renamed it, throws. Each change lays the table out again from its cache, as one
31075
+ * step that can be undone, and a table that grows over cells that hold anything shows `#SPILL!`.
31076
+ */
31077
+ interface IDataField {
31078
+ /** Returns its caption. */
31079
+ getName(): string;
31080
+ /**
31081
+ * Changes its caption.
31082
+ *
31083
+ * @remarks
31084
+ * Its source's caption is taken, unless that field has been renamed; so is any other field's, any
31085
+ * other value's and the {@link IValuesField | values'}, without regard to case.
31086
+ *
31087
+ * @throws ExpectedError For a caption taken.
31088
+ */
31089
+ setName(name: string, options?: ITransaction.OperationOptions): Promise<void>;
31090
+ /** Returns the field it summarizes. */
31091
+ getField(): IField;
31092
+ /** Returns the function it summarizes by. */
31093
+ getFunction(): IDataField.Function;
31094
+ /**
31095
+ * Changes the function it summarizes by.
31096
+ *
31097
+ * @remarks
31098
+ * Its caption changes too, a caption typed by hand included, as in Excel: what comes before its
31099
+ * first ` of ` takes the function's name, a caption with none becomes the function's name and the
31100
+ * field's (`Average of Sales`), and one that is taken is numbered. Its number format stays. Nothing
31101
+ * changes when the function is the one it has.
31102
+ *
31103
+ * A value over a calculated field takes the function in name alone, as in Excel: its formula
31104
+ * decides what it shows.
31105
+ *
31106
+ * @throws ExpectedError For a function that is none.
31107
+ */
31108
+ setFunction(fn: IDataField.Function, options?: ITransaction.OperationOptions): Promise<void>;
31109
+ /**
31110
+ * Returns the caption it would take with `fn`, as {@link setFunction} gives it; its own when `fn`
31111
+ * is its function already.
31112
+ *
31113
+ * @example
31114
+ * ```ts
31115
+ * value.getName(); // 'Sum of Sales'
31116
+ * value.getCaptionFor('average'); // 'Average of Sales'
31117
+ * ```
31118
+ *
31119
+ * @throws ExpectedError For a function that is none.
31120
+ */
31121
+ getCaptionFor(fn: IDataField.Function): string;
31122
+ /** Returns how it is shown; `null` as it is. */
31123
+ getShowAs(): IDataField.ShowAs | null;
31124
+ /**
31125
+ * Changes how it is shown; `null` shows it as it is.
31126
+ *
31127
+ * @remarks
31128
+ * A kind that reads a base field and is given none reads the one it has, at first the cache's
31129
+ * first; every line shows `#N/A` when that is not on the rows or columns. A new base field starts
31130
+ * at its first item. The base stays when the kind changes, and through `null`.
31131
+ *
31132
+ * The number format changes with the kind, as in Excel. A kind that shows a share takes `0.00%`
31133
+ * unless it reads as a percent already; a rank or an index drops what it has; going from a share to
31134
+ * any other drops a percent format. A format on single cells stays over any of it.
31135
+ *
31136
+ * @example
31137
+ * ```ts
31138
+ * await value.setShowAs({ kind: 'percentOfTotal' });
31139
+ * await value.setShowAs({ kind: 'difference', baseField: 'Year', baseItem: '(previous)' });
31140
+ * await value.setShowAs(null);
31141
+ * ```
31142
+ *
31143
+ * @throws ExpectedError For a kind that is none, or a base field or item that is not the table's.
31144
+ */
31145
+ setShowAs(rule: IDataField.ShowAs | null, options?: ITransaction.OperationOptions): Promise<void>;
31146
+ /** Returns the format code its values show in. */
31147
+ getNumberFormat(): string;
31148
+ /**
31149
+ * Changes the format of its values, over any number format on single cells of them, whose other
31150
+ * formats (a fill) stay.
31151
+ *
31152
+ * @param format A format code, or a built-in format's id.
31153
+ * @throws ExpectedError For a format that does not parse.
31154
+ */
31155
+ setNumberFormat(format: string | number, options?: ITransaction.OperationOptions): Promise<void>;
31156
+ /** Returns its place among the values, counted from 1. */
31157
+ getPosition(): number;
31158
+ /**
31159
+ * Moves it among the values. A sort, a value filter and the formats on it follow it.
31160
+ *
31161
+ * @param position Its place, counted from 1.
31162
+ * @throws ExpectedError For a position that is not among the values.
31163
+ */
31164
+ setPosition(position: number, options?: ITransaction.OperationOptions): Promise<void>;
31165
+ /**
31166
+ * Takes it off the table.
31167
+ *
31168
+ * @remarks
31169
+ * What names it goes too: a sort by it leaves its items in their listed order, and a value filter
31170
+ * and the formats on it are gone for good. Its source stays on any axis it is on. The
31171
+ * {@link IValuesField | values field} goes below two values, and comes back where it was. A table
31172
+ * with nothing left on it is empty again.
31173
+ */
31174
+ delete(options?: ITransaction.OperationOptions): Promise<void>;
31175
+ /** Returns the table it belongs to. */
31176
+ getPivotTable(): IPivotTable;
31177
+ /** For runtime type checking. */
31178
+ readonly isIPivotDataField: true;
31179
+ }
31180
+ /**
31181
+ * Where a table's values sit among the fields of an axis, with two or more of them.
31182
+ *
31183
+ * @remarks
31184
+ * A view of the table. While a table has fewer than two values they sit nowhere, and the table keeps
31185
+ * the axis and the place for the next.
31186
+ */
31187
+ interface IValuesField {
31188
+ /** Returns its caption. */
31189
+ getName(): string;
31190
+ /**
31191
+ * Changes its caption, which no field or value of the table can have, without regard to case.
31192
+ *
31193
+ * @throws ExpectedError For a caption taken.
31194
+ */
31195
+ setName(name: string, options?: ITransaction.OperationOptions): Promise<void>;
31196
+ /** Returns the axis the values are on; `null` once they have gone. */
31197
+ getAxis(): Axis | null;
31198
+ /**
31199
+ * Moves the values to the rows or the columns, as one step that can be undone; `null` deletes every
31200
+ * value.
31201
+ *
31202
+ * @param position Its place, counted from 1, among the axis's fields; absent, after the last, and
31203
+ * nothing when it is on `axis`.
31204
+ * @throws ExpectedError For the page axis, the values, or a position not on the axis.
31205
+ */
31206
+ setAxis(axis: Axis | null, position?: number, options?: ITransaction.OperationOptions): Promise<void>;
31207
+ /** Returns its place among the fields of its axis, counted from 1; `null` once the values have gone. */
31208
+ getPosition(): number | null;
31209
+ /**
31210
+ * Moves it along its axis, as one step that can be undone.
31211
+ *
31212
+ * @param position Its place, counted from 1.
31213
+ * @throws ExpectedError For a position not on the axis, or once the values have gone.
31214
+ */
31215
+ setPosition(position: number, options?: ITransaction.OperationOptions): Promise<void>;
31216
+ /** Returns the table it belongs to. */
31217
+ getPivotTable(): IPivotTable;
31218
+ /** For runtime type checking. */
31219
+ readonly isIPivotValuesField: true;
31220
+ }
31221
+ /** What belongs to {@link IDataField}. */
31222
+ namespace IDataField {
31223
+ /** A function that summarizes a value, as OOXML spells it. */
31224
+ type Function = 'sum' | 'count' | 'average' | 'max' | 'min' | 'product' | 'countNums' | 'stdDev' | 'stdDevp' | 'var' | 'varp';
31225
+ /** How a value can be shown, as OOXML spells it. */
31226
+ type ShowAsKind = 'percentOfTotal' | 'percentOfRow' | 'percentOfCol' | 'index' | 'percentOfParentRow' | 'percentOfParentCol' | 'percentOfParent' | 'runTotal' | 'percentOfRunningTotal' | 'rankAscending' | 'rankDescending' | 'difference' | 'percent' | 'percentDiff';
31227
+ /** How a value is shown. */
31228
+ interface ShowAs {
31229
+ kind: ShowAsKind;
31230
+ /** The field a kind reads across, by caption; absent, the one it has. */
31231
+ baseField?: string;
31232
+ /**
31233
+ * The item of {@link baseField} a kind compares with, by caption, or `(previous)` or `(next)` for
31234
+ * the neighbor of each item; absent, the one it has.
31235
+ */
31236
+ baseItem?: string;
31237
+ }
31238
+ /** A value to add. */
31239
+ interface Input {
31240
+ /** The field to summarize. */
31241
+ field: string;
31242
+ /** Absent, the function's name and the field's (`Sum of Sales`), numbered when taken. */
31243
+ name?: string;
31244
+ /**
31245
+ * Absent, sum for a column of numbers and count for any other.
31246
+ */
31247
+ function?: Function;
31248
+ /** A format code, or a built-in format's id; absent, General. */
31249
+ numberFormat?: string | number;
31250
+ }
29530
31251
  }
29531
31252
  /**
29532
31253
  * `Events` for {@link IPivotTable}.
@@ -29537,12 +31258,37 @@ declare global {
29537
31258
 
29538
31259
  /**
29539
31260
  * Holds {@link IPivotTable | pivot tables} — a sheet's, or every sheet's in the workbook.
29540
- *
29541
- * @remarks
29542
- * Read-only for now: a table is carried as it was read and written back unchanged. Adding,
29543
- * deleting and refreshing wait on the table having a model of its own.
29544
31261
  */
29545
31262
  export interface IPivotTableCollection extends ICollection<IPivotTable> {
31263
+ /**
31264
+ * Adds a pivot table on this sheet, as one step that can be undone.
31265
+ *
31266
+ * @param source The cells to summarize, their first row the field names: a range, a table, or a
31267
+ * table's or defined name's name. A table already summarizing the same source shares its cache
31268
+ * unless the source was edited since, so they refresh together.
31269
+ * @param location Where the table's top-left cell goes. Filters sit above it, a blank row between;
31270
+ * at the top of a sheet the table moves down to make room for them.
31271
+ * @param options The fields to place. With none, the table is empty and holds 18 rows by 3 columns.
31272
+ *
31273
+ * @remarks
31274
+ * The cells the table needs, its filters' included, must hold no value, unless
31275
+ * {@link IPivotTableCollection.AddOptions.discardValues} clears them. Another pivot table or an
31276
+ * array's cells there always refuse it.
31277
+ *
31278
+ * @example
31279
+ * ```ts
31280
+ * const pivot = await sheet.getPivotTables().add('Data!A1:H500', 'A3', {
31281
+ * rows: ['Region'],
31282
+ * columns: ['Year'],
31283
+ * values: ['Sales', { field: 'Sales', function: 'average' }]
31284
+ * });
31285
+ * ```
31286
+ *
31287
+ * @throws When the cells it needs hold a value, an array or another pivot table, a field or the source does not
31288
+ * exist, the source has no row of data, the name is taken on this sheet or the sheet is locked; and
31289
+ * on the workbook's collection, which holds no sheet to add to.
31290
+ */
31291
+ add(source: IPivotTableCollection.Source, location: ICellRange.Address, options?: IPivotTableCollection.AddOptions): Promise<IPivotTable>;
29546
31292
  /**
29547
31293
  * Returns the pivot tables, in the order they were read; the workbook's walks its sheets in
29548
31294
  * sheet order.
@@ -29552,12 +31298,51 @@ declare global {
29552
31298
  * Returns the pivot table with the given name, or `null` if there is none.
29553
31299
  *
29554
31300
  * @param name The name of the pivot table. This is case insensitive.
31301
+ *
31302
+ * @remarks
31303
+ * A name is unique only on its sheet, so the workbook's collection returns the first table with
31304
+ * that name in sheet order. Ask the sheet's collection to find one table for certain.
29555
31305
  */
29556
31306
  getByName(name: string): IPivotTable | null;
31307
+ /**
31308
+ * Refreshes every table ({@link IPivotTable.refresh}) as one step that can be undone.
31309
+ *
31310
+ * @remarks
31311
+ * A table that cannot be refreshed refuses the whole step, and nothing changes.
31312
+ */
31313
+ refreshAll(options?: IPivotTable.RefreshOptions): Promise<void>;
29557
31314
  /** For runtime type checking. */
29558
31315
  readonly isIPivotTableCollection: true;
29559
31316
  }
29560
31317
 
31318
+ export namespace IPivotTableCollection {
31319
+ /** What a pivot table summarizes. A string is a table's name, a defined name, or an address. */
31320
+ type Source = ICellRange.Address | ITable;
31321
+ /** Options for {@link IPivotTableCollection.add}. */
31322
+ interface AddOptions extends ITransaction.OperationOptions {
31323
+ /** Absent, `PivotTable` and one past the highest number the workbook's tables have. */
31324
+ name?: string;
31325
+ /** The fields down the rows, outermost first. */
31326
+ rows?: readonly string[];
31327
+ /** The fields across the columns, outermost first. */
31328
+ columns?: readonly string[];
31329
+ /** The fields above the table, each filtering it by an item. */
31330
+ pages?: readonly string[];
31331
+ /** The values. A field's name alone sums a column of numbers, blanks among them, and counts any other. */
31332
+ values?: readonly (string | IPivotTable.IDataField.Input)[];
31333
+ /** Absent, compact. */
31334
+ form?: 'compact' | IPivotTable.PivotForm;
31335
+ /** A pivot table style by name; absent, `PivotStyleLight16`. */
31336
+ style?: string;
31337
+ /**
31338
+ * Whether values in the cells the table needs are cleared; `false` refuses the table instead.
31339
+ *
31340
+ * @defaultValue `false`
31341
+ */
31342
+ discardValues?: boolean;
31343
+ }
31344
+ }
31345
+
29561
31346
  /**
29562
31347
  * Contains interfaces for working with properties.
29563
31348
  */
@@ -34305,17 +36090,20 @@ declare global {
34305
36090
  export const isLazyValue: (value: unknown) => value is ILazy;
34306
36091
 
34307
36092
  /**
34308
- * A slicer: buttons that filter one column of a table.
36093
+ * A slicer: buttons that filter one column of a table, or one field of pivot tables.
34309
36094
  *
34310
36095
  * @remarks
34311
- * A slicer holds no selection of its own. What it shows as selected is the column's filter
34312
- * ({@link ITable.IColumn.getFilter}), so a filter set from the column's menu shows on the slicer,
34313
- * and a selection made on the slicer is the column's filter, saved with the table. Two slicers on
34314
- * one column always agree.
34315
- *
34316
- * The column is named by a structured reference ({@link getSource}), which follows the table and
34317
- * the column through a rename. When the column or its table is deleted, the slicer is deleted with
34318
- * it, in the same step; an undo brings both back.
36096
+ * A slicer holds no selection of its own. On a table, what it shows as selected is the column's
36097
+ * filter ({@link ITable.IColumn.getFilter}), so a filter set from the column's menu shows on the
36098
+ * slicer, and a selection made on the slicer is the column's filter, saved with the table. On pivot
36099
+ * tables it is the field's items hidden by hand ({@link IPivotTable.IField.setVisibleItems}), the
36100
+ * same on every pivot table it filters; a label or value filter on the field does not show on it.
36101
+ * Two slicers on one column or field always agree.
36102
+ *
36103
+ * A table slicer follows its table and column through a rename. When the column or its table is
36104
+ * deleted, the slicer is deleted with it, in the same step; an undo brings both back. A pivot slicer
36105
+ * stays when its pivot tables are deleted, filtering nothing, and is deleted with its field when a
36106
+ * pivot table's source no longer has it.
34319
36107
  *
34320
36108
  * Where a slicer sits is its movable's ({@link IMovable.getBounds}); it moves freely of the cells
34321
36109
  * under it by default.
@@ -34329,31 +36117,46 @@ declare global {
34329
36117
  */
34330
36118
  export interface ISlicer extends IModel, IMovable.IContent {
34331
36119
  /**
34332
- * Returns the column the slicer filters, as a structured reference: `Sales[Region]`.
36120
+ * Returns the name of what the slicer filters: the column's, or the pivot field's in its source.
34333
36121
  *
34334
36122
  * @remarks
34335
- * Follows a rename of the table or the column.
36123
+ * A table slicer's follows a rename of the column.
34336
36124
  */
34337
- getSource(): string;
36125
+ getSourceName(): string;
34338
36126
  /**
34339
- * Returns the table the slicer filters, or `null` if it names none.
36127
+ * Returns what the slicer filters: the table, or the first pivot table; `null` if there is none.
36128
+ *
36129
+ * @see {@link getPivotTables} for every pivot table a pivot slicer filters.
34340
36130
  */
34341
- getTable(): ITable | null;
36131
+ getTable(): ITable | IPivotTable | null;
34342
36132
  /**
34343
- * Returns the column the slicer filters, or `null` if it names none.
36133
+ * Returns the column the slicer filters, or `null` for a pivot slicer or one naming no column.
34344
36134
  */
34345
36135
  getColumn(): ITable.IColumn | null;
36136
+ /**
36137
+ * Returns the pivot tables the slicer filters; empty for a table slicer, or once they are deleted.
36138
+ */
36139
+ getPivotTables(): readonly IPivotTable[];
36140
+ /**
36141
+ * Returns the field a pivot slicer filters, as its first pivot table has it; `null` for a table
36142
+ * slicer, or when there is no pivot table.
36143
+ *
36144
+ * @remarks
36145
+ * Each pivot table has its own field. Select through the slicer, which changes every one of them.
36146
+ */
36147
+ getPivotField(): IPivotTable.IField | null;
34346
36148
  /**
34347
36149
  * Returns the text shown in the slicer's header.
34348
36150
  *
34349
36151
  * @remarks
34350
- * The column's name unless a caption has been set, and then it follows a rename of the column.
36152
+ * {@link getSourceName} unless a caption has been set. A slicer added on a pivot field with a
36153
+ * caption of its own starts with that caption, and keeps it when the field's changes.
34351
36154
  */
34352
36155
  getCaption(): string;
34353
36156
  /**
34354
36157
  * Sets the text shown in the slicer's header.
34355
36158
  *
34356
- * @param caption The caption, or `null` to show the column's name.
36159
+ * @param caption The caption, or `null` to show {@link getSourceName}.
34357
36160
  */
34358
36161
  setCaption(caption: string | null, options?: ITransaction.OperationOptions): this;
34359
36162
  /**
@@ -34388,6 +36191,8 @@ declare global {
34388
36191
  getSortOrder(): ISlicer.SortOrder;
34389
36192
  /**
34390
36193
  * Sets the order the items are listed in.
36194
+ *
36195
+ * @throws ExpectedError For `'dataSource'` on a pivot slicer, which Excel does not offer.
34391
36196
  */
34392
36197
  setSortOrder(sortOrder: ISlicer.SortOrder, options?: ITransaction.OperationOptions): this;
34393
36198
  /**
@@ -34423,15 +36228,18 @@ declare global {
34423
36228
  */
34424
36229
  setLockedPosition(locked: boolean, options?: ITransaction.OperationOptions): this;
34425
36230
  /**
34426
- * Returns `true` when the column has no filter: every item is selected.
36231
+ * Returns `true` when every item is selected: the column has no filter, or the field hides no item.
34427
36232
  */
34428
36233
  isFilterCleared(): boolean;
34429
36234
  /**
34430
- * Returns the items: the column's distinct values as it shows them, in the slicer's order.
36235
+ * Returns the items: the column's distinct values as it shows them, or the field's items, in the
36236
+ * slicer's order.
34431
36237
  *
34432
36238
  * @remarks
34433
36239
  * Every row of the column is read, hidden or not. An item has data when at least one row
34434
- * holding it passes the other columns' filters. Blanks are one item, keyed `''`, listed last.
36240
+ * holding it passes the other columns' filters; on pivot tables, when a source row holding it
36241
+ * passes the items the first pivot table's other fields hide, and an item the source no longer
36242
+ * holds has none. Blanks are one item, keyed `''`, listed last in ascending order.
34435
36243
  */
34436
36244
  getItems(): Promise<readonly ISlicer.Item[]>;
34437
36245
  /**
@@ -34439,17 +36247,18 @@ declare global {
34439
36247
  */
34440
36248
  getItem(key: string): Promise<ISlicer.Item | null>;
34441
36249
  /**
34442
- * Selects the items with `keys` and no others, by filtering the column.
36250
+ * Selects the items with `keys` and no others, by filtering the column or by hiding the field's
36251
+ * other items on every pivot table, as one step that can be undone.
34443
36252
  *
34444
36253
  * @param keys The items' keys. `null`, an empty list or every item clears the filter.
34445
36254
  *
34446
36255
  * @remarks
34447
36256
  * The other columns' filters stay. On a date column the selection is saved as the dates
34448
- * themselves, not their text.
36257
+ * themselves, not their text. A pivot field's label, date and value filters stay.
34449
36258
  */
34450
36259
  selectItems(keys: readonly string[] | null, options?: ITransaction.OperationOptions): Promise<this>;
34451
36260
  /**
34452
- * Clears the column's filter, selecting every item.
36261
+ * Clears the column's filter, or shows every item of the field, selecting every item.
34453
36262
  */
34454
36263
  clearFilters(options?: ITransaction.OperationOptions): Promise<this>;
34455
36264
  /**
@@ -34500,21 +36309,21 @@ declare global {
34500
36309
  */
34501
36310
  interface Item {
34502
36311
  /**
34503
- * The item's identity: the text the column shows for it, `''` for the blank item. What
34504
- * {@link ISlicer.selectItems} takes.
36312
+ * The item's identity: the text the column shows for it, or the pivot item's caption; `''` for
36313
+ * the blank item. What {@link ISlicer.selectItems} takes.
34505
36314
  */
34506
36315
  key: string;
34507
36316
  /** The text shown on the button. */
34508
36317
  name: string;
34509
- /** The value of the first cell showing the item; `null` for the blank item. */
36318
+ /** The value of the first cell showing the item, or the pivot item's; `null` for the blank item. */
34510
36319
  value: Scalar;
34511
- /** Whether at least one row holding the item passes the other columns' filters. */
36320
+ /** Whether at least one row holding the item passes the other columns' or fields' filters. */
34512
36321
  hasData: boolean;
34513
- /** Whether the column's filter selects the item. */
36322
+ /** Whether the column's filter selects the item, or the field shows it. */
34514
36323
  isSelected: boolean;
34515
36324
  }
34516
36325
  /**
34517
- * Options for {@link ITable.addSlicer}.
36326
+ * Options for {@link ITable.addSlicer} and {@link IPivotTable.addSlicer}.
34518
36327
  */
34519
36328
  interface AddOptions extends IMovableCollection.AddOptions<ISlicer.JSON> {
34520
36329
  /**
@@ -34523,7 +36332,11 @@ declare global {
34523
36332
  * @defaultValue The table's sheet.
34524
36333
  */
34525
36334
  sheet?: IWorksheet;
34526
- /** {@inheritDoc ISlicer.JSON.caption} */
36335
+ /**
36336
+ * The header text.
36337
+ *
36338
+ * @defaultValue The column's name, or the pivot field's caption.
36339
+ */
34527
36340
  caption?: string;
34528
36341
  /**
34529
36342
  * The slicer style's name.
@@ -34539,11 +36352,12 @@ declare global {
34539
36352
  */
34540
36353
  interface Events extends IMovable.ContentEvents {
34541
36354
  /**
34542
- * Called when the column's filter changes, by this slicer or anything else.
36355
+ * Called when the column's filter or the field's hidden items change, by this slicer or anything
36356
+ * else.
34543
36357
  */
34544
36358
  onSelectionChange?(source: ISlicer): void;
34545
36359
  /**
34546
- * Called when the column's values change, so the items may have.
36360
+ * Called when the column's values or the pivot tables change, so the items may have.
34547
36361
  */
34548
36362
  onItemsChange?(source: ISlicer): void;
34549
36363
  }
@@ -34554,11 +36368,11 @@ declare global {
34554
36368
  */
34555
36369
  interface JSON {
34556
36370
  /**
34557
- * The column, as a structured reference: `Sales[Region]`.
36371
+ * The column, as a structured reference: `Sales[Region]`. Absent for a slicer on a pivot table.
34558
36372
  */
34559
- source: string;
36373
+ source?: string;
34560
36374
  /**
34561
- * The header text. Absent, the column's name.
36375
+ * The header text. Absent, the column's or the pivot field's name.
34562
36376
  */
34563
36377
  caption?: string;
34564
36378
  /**
@@ -34619,6 +36433,56 @@ declare global {
34619
36433
  * The id the file gave the slicer.
34620
36434
  */
34621
36435
  uid?: string;
36436
+ /**
36437
+ * What a slicer on pivot tables filters.
36438
+ *
36439
+ * @internal
36440
+ */
36441
+ pivot?: ISlicer.PivotJSON;
36442
+ }
36443
+ /**
36444
+ * A slicer on pivot tables: the field and the pivot tables it filters. A slicer on worksheet pivot
36445
+ * tables takes its items and their states from the field; a data-model slicer's and a timeline's
36446
+ * are carried as read.
36447
+ *
36448
+ * @internal
36449
+ */
36450
+ interface PivotJSON {
36451
+ /** The field the slicer filters, by its name in the cache: `Region`, or `[Table1].[Region]` for a data model. */
36452
+ sourceName: string;
36453
+ /** The pivot tables the slicer filters, by sheet and name. Empty once they are deleted. */
36454
+ tables: {
36455
+ sheet: string;
36456
+ name: string;
36457
+ }[];
36458
+ /**
36459
+ * The workbook pivot cache the slicer's items index: its first pivot table's, kept once they are
36460
+ * deleted. Absent for a data-model slicer.
36461
+ */
36462
+ cacheId?: number;
36463
+ /**
36464
+ * Present for a slicer or timeline on worksheet pivot tables the model holds, whose items and
36465
+ * selection, or state, are the field's: what a slicer cache's `tabular` says beyond the slicer's
36466
+ * sort order and cross filter.
36467
+ */
36468
+ tabular?: {
36469
+ /** Whether items the source no longer holds are left out. */
36470
+ hideMissing?: true;
36471
+ };
36472
+ /**
36473
+ * The cache's children after its pivot tables, verbatim: for a {@link tabular} slicer what
36474
+ * follows `<data>`, for a {@link tabular} timeline what follows `<state>`, else all of them.
36475
+ */
36476
+ body: string;
36477
+ /**
36478
+ * Present for a timeline, which Excel keeps as a slicer whose items are dates: the timeline's
36479
+ * attributes beyond its name, cache and caption (level, scroll position, style, ...) and its
36480
+ * children, as read. Its cache's `body` is then the `<state>` and what follows.
36481
+ */
36482
+ timeline?: {
36483
+ attributes: Record<string, string>;
36484
+ body: string;
36485
+ };
34622
36486
  }
34623
36487
  }
34624
36488
 
@@ -36581,15 +38445,14 @@ declare global {
36581
38445
  */
36582
38446
  getRangedStyle(): IProperties.ICellRanged<ICellStyle.Properties>;
36583
38447
  /**
36584
- * Returns a cell style for the given coords.
36585
- * @param coords The absolute coords.
38448
+ * Returns the style the table gives the cell at a sheet position.
38449
+ * @param row The row on the sheet.
38450
+ * @param column The column on the sheet.
36586
38451
  *
36587
38452
  * @remarks
36588
- * This will return a CellStyle rendered with the table styling but not any other styling.
36589
- *
36590
- * * This is used by the preview.
38453
+ * The table's styling only, not the cell's own formats or any other layer.
36591
38454
  */
36592
- getStyleAt(coords: IRange.CellCoords): ICellStyle;
38455
+ getStyleAt(row: number, column: number): ICellStyle;
36593
38456
  /**
36594
38457
  * Specifies if totals are being shown for the table.
36595
38458
  */
@@ -37023,6 +38886,29 @@ declare global {
37023
38886
  readonly LastTotalCell: "lastTotalCell";
37024
38887
  };
37025
38888
  type ElementType = typeof ElementType[keyof typeof ElementType];
38889
+ /**
38890
+ * The elements only a pivot table style has, beside the {@link ElementType}s a pivot table also
38891
+ * uses (all but `lastHeaderCell`, `firstTotalCell` and `lastTotalCell`). On a pivot table,
38892
+ * `totalRow` is the grand total row and `lastColumn` the grand total column.
38893
+ */
38894
+ const PivotElementType: {
38895
+ readonly FirstSubtotalColumn: "firstSubtotalColumn";
38896
+ readonly SecondSubtotalColumn: "secondSubtotalColumn";
38897
+ readonly ThirdSubtotalColumn: "thirdSubtotalColumn";
38898
+ readonly FirstSubtotalRow: "firstSubtotalRow";
38899
+ readonly SecondSubtotalRow: "secondSubtotalRow";
38900
+ readonly ThirdSubtotalRow: "thirdSubtotalRow";
38901
+ readonly BlankRow: "blankRow";
38902
+ readonly FirstColumnSubheading: "firstColumnSubheading";
38903
+ readonly SecondColumnSubheading: "secondColumnSubheading";
38904
+ readonly ThirdColumnSubheading: "thirdColumnSubheading";
38905
+ readonly FirstRowSubheading: "firstRowSubheading";
38906
+ readonly SecondRowSubheading: "secondRowSubheading";
38907
+ readonly ThirdRowSubheading: "thirdRowSubheading";
38908
+ readonly PageFieldLabels: "pageFieldLabels";
38909
+ readonly PageFieldValues: "pageFieldValues";
38910
+ };
38911
+ type PivotElementType = typeof PivotElementType[keyof typeof PivotElementType];
37026
38912
  /**
37027
38913
  * Extends {@link ICellStyle.Properties} to include a size.
37028
38914
  *
@@ -37060,6 +38946,11 @@ declare global {
37060
38946
  * * Last Header Cell
37061
38947
  * * First Total Cell
37062
38948
  * * Last Total Cell
38949
+ *
38950
+ * A pivot table style also has the {@link PivotElementType} elements, and is applied in its own
38951
+ * order: whole table, page field labels and values, column then row stripes, first column,
38952
+ * header row, first header cell, subtotal columns, blank row, subtotal rows, column
38953
+ * subheadings, row subheadings, grand total column (`lastColumn`), grand total row (`totalRow`).
37063
38954
  */
37064
38955
  interface Properties {
37065
38956
  /**
@@ -37136,6 +39027,28 @@ declare global {
37136
39027
  * both the total and last column must be selected.
37137
39028
  */
37138
39029
  lastTotalCell?: ICellStyle.Properties;
39030
+ /** A pivot table's first, second and third level of subtotal columns. */
39031
+ firstSubtotalColumn?: ICellStyle.Properties;
39032
+ secondSubtotalColumn?: ICellStyle.Properties;
39033
+ thirdSubtotalColumn?: ICellStyle.Properties;
39034
+ /** A pivot table's first, second and third level of subtotal rows. */
39035
+ firstSubtotalRow?: ICellStyle.Properties;
39036
+ secondSubtotalRow?: ICellStyle.Properties;
39037
+ thirdSubtotalRow?: ICellStyle.Properties;
39038
+ /** A pivot table's blank row after an item. */
39039
+ blankRow?: ICellStyle.Properties;
39040
+ /** A pivot table's column labels at the first, second and third level. */
39041
+ firstColumnSubheading?: ICellStyle.Properties;
39042
+ secondColumnSubheading?: ICellStyle.Properties;
39043
+ thirdColumnSubheading?: ICellStyle.Properties;
39044
+ /** A pivot table's items with items under them, at the first, second and third level. */
39045
+ firstRowSubheading?: ICellStyle.Properties;
39046
+ secondRowSubheading?: ICellStyle.Properties;
39047
+ thirdRowSubheading?: ICellStyle.Properties;
39048
+ /** A pivot table's page field captions. */
39049
+ pageFieldLabels?: ICellStyle.Properties;
39050
+ /** A pivot table's page field items. */
39051
+ pageFieldValues?: ICellStyle.Properties;
37139
39052
  }
37140
39053
  type ResolvableProperties = IProperties.ResolvableProperties<ITableStyle.Properties>;
37141
39054
  interface JSON extends ITableStyle.Properties {
@@ -37148,40 +39061,6 @@ declare global {
37148
39061
  defaultPivotStyle?: string;
37149
39062
  styles?: Record<string, ITableStyle.JSON>;
37150
39063
  }
37151
- /**
37152
- * Properties for a pivot table style.
37153
- *
37154
- * @remarks
37155
- * **NOT IMPLEMENTED**
37156
- */
37157
- interface PivotProperties {
37158
- name?: string;
37159
- wholeTable?: ICellStyle.Properties;
37160
- firstColumnStripe?: ITableStyle.SizeBasedProperties;
37161
- secondColumnStripe?: ITableStyle.SizeBasedProperties;
37162
- firstRowStripe?: ITableStyle.SizeBasedProperties;
37163
- secondRowStripe?: ITableStyle.SizeBasedProperties;
37164
- firstColumn?: ICellStyle.Properties;
37165
- headerRow?: ICellStyle.Properties;
37166
- firstHeaderCell?: ICellStyle.Properties;
37167
- pageFieldLabels?: ICellStyle.Properties;
37168
- pageFieldValues?: ICellStyle.Properties;
37169
- subtotalColumn1?: ICellStyle.Properties;
37170
- subtotalColumn2?: ICellStyle.Properties;
37171
- subtotalColumn3?: ICellStyle.Properties;
37172
- blankRow?: ICellStyle.Properties;
37173
- subtotalRow1?: ICellStyle.Properties;
37174
- subtotalRow2?: ICellStyle.Properties;
37175
- subtotalRow3?: ICellStyle.Properties;
37176
- columnSubheading1?: ICellStyle.Properties;
37177
- columnSubheading2?: ICellStyle.Properties;
37178
- columnSubheading3?: ICellStyle.Properties;
37179
- rowSubheading1?: ICellStyle.Properties;
37180
- rowSubheading2?: ICellStyle.Properties;
37181
- rowSubheading3?: ICellStyle.Properties;
37182
- grandTotalColumn?: ICellStyle.Properties;
37183
- grandTotalRow?: ICellStyle.Properties;
37184
- }
37185
39064
  }
37186
39065
 
37187
39066
  /**
@@ -38825,6 +40704,66 @@ declare global {
38825
40704
  type BuiltInFilterType = typeof BuiltInFilterType[keyof typeof BuiltInFilterType];
38826
40705
  }
38827
40706
 
40707
+ /**
40708
+ * A timeline: a slicer on a date field of pivot tables, whose selection is a range of dates.
40709
+ *
40710
+ * @remarks
40711
+ * A timeline holds no selection of its own. What it selects is the field's date filter, the same on
40712
+ * every pivot table it filters, so a date filter set on the field shows on the timeline, and a range
40713
+ * set on the timeline is the field's date filter. While a timeline is on the field, that filter
40714
+ * filters the tables whether or not the field is on an axis.
40715
+ *
40716
+ * It has no items: {@link ISlicer.getItems} answers none, and {@link ISlicer.clearFilters} clears the
40717
+ * range.
40718
+ *
40719
+ * @example
40720
+ * ```ts
40721
+ * const content = movable.getContent<ISlicer>();
40722
+ * if ((content as ITimeline).isITimeline) {
40723
+ * await (content as ITimeline).setDateRange({ start: 45689, end: 45747 });
40724
+ * }
40725
+ * ```
40726
+ */
40727
+ export interface ITimeline extends ISlicer {
40728
+ /**
40729
+ * Returns the dates selected, or `null` when every date is, or the field's date filter is not a
40730
+ * range of dates.
40731
+ */
40732
+ getDateRange(): ITimeline.DateRange | null;
40733
+ /**
40734
+ * Selects a range of dates on every pivot table, as one step that can be undone.
40735
+ *
40736
+ * @param range The dates, or `null` to select every date.
40737
+ *
40738
+ * @remarks
40739
+ * The range replaces the field's label or date filter; its value filter and the items it hides
40740
+ * stay.
40741
+ */
40742
+ setDateRange(range: ITimeline.DateRange | null, options?: ITransaction.OperationOptions): Promise<this>;
40743
+ /** For runtime type checking. */
40744
+ readonly isITimeline: true;
40745
+ }
40746
+
40747
+ /**
40748
+ * {@inheritDoc ITimeline}
40749
+ *
40750
+ * @see
40751
+ * ### **Interface**
40752
+ *
40753
+ * {@link ITimeline}
40754
+ */
40755
+ export namespace ITimeline {
40756
+ /**
40757
+ * A range of whole days, as date serial numbers.
40758
+ */
40759
+ interface DateRange {
40760
+ /** The first day selected. */
40761
+ start: number;
40762
+ /** The last day selected. */
40763
+ end: number;
40764
+ }
40765
+ }
40766
+
38828
40767
  /**
38829
40768
  * Objects that implement this interface have ACID properties.
38830
40769
  */
@@ -39717,8 +41656,12 @@ declare global {
39717
41656
  * `fixed + error` is not a state: a fixed block owns its cells, so a write into part of it is
39718
41657
  * refused at the write site rather than detected at calc. That is what lets these three be one
39719
41658
  * enum rather than two booleans.
41659
+ *
41660
+ * A fourth kind is the calculation engine's alone: `pivot`, the cells a pivot table lays out. It
41661
+ * is never saved, and a cell never reports it ({@link ICell.getSpillKind}): a pivot table's
41662
+ * cells are the table's, not an array's. A blocked pivot table is `error`.
39720
41663
  */
39721
- type FormulaArrayKind = 'dynamic' | 'fixed' | 'error';
41664
+ type FormulaArrayKind = 'dynamic' | 'fixed' | 'error' | 'pivot';
39722
41665
  /**
39723
41666
  * Options for controlling selection behavior, including scrolling and focus.
39724
41667
  */
@@ -40720,13 +42663,19 @@ declare global {
40720
42663
  * Absent when the source said nothing, which Excel reads as `userSet`.
40721
42664
  */
40722
42665
  updateLinks?: IExternalBookCollection.UpdateLinks;
42666
+ /**
42667
+ * The PivotTable Fields pane does not open when a pivot table is selected; absent, it does.
42668
+ *
42669
+ * @remarks
42670
+ * Carried, not obeyed: SheetXL has no fields pane yet. Round-trips as `workbookPr@hidePivotFieldList`.
42671
+ */
42672
+ hiddenPivotFieldList?: true;
40723
42673
  /**
40724
42674
  * The workbook's pivot caches — the source snapshots its pivot tables summarize, each shared
40725
42675
  * by every table that references its id.
40726
42676
  *
40727
42677
  * @remarks
40728
- * Carried, not modeled — see {@link IPivotTable.CacheJSON}. The tables that summarize a cache
40729
- * are the modeled side; a table names its cache by {@link IPivotTable.getCacheId}.
42678
+ * See {@link IPivotTable.CacheJSON}. A table names its cache by {@link IPivotTable.getCacheId}.
40730
42679
  */
40731
42680
  pivotCaches?: IPivotTable.CacheJSON[];
40732
42681
  /**
@@ -43150,6 +45099,14 @@ declare global {
43150
45099
  * own sheet).
43151
45100
  */
43152
45101
  getCalculation(): ICalculation;
45102
+ /**
45103
+ * Returns the {@link IFontCollection} the sheet measures text with.
45104
+ *
45105
+ * @remarks
45106
+ * Fonts are shared: every sheet, with or without a workbook, returns the same collection, so a
45107
+ * face loaded for one is loaded for all.
45108
+ */
45109
+ getFonts(): IFontCollection;
43153
45110
  /**
43154
45111
  * Recalculates THIS sheet — Excel's "Calculate Sheet" (Shift+F9) / `Worksheet.Calculate`.
43155
45112
  *
@@ -43186,6 +45143,25 @@ declare global {
43186
45143
  * it has not been started.
43187
45144
  */
43188
45145
  whenCalculationReady(): Promise<ICalculation.Status>;
45146
+ /**
45147
+ * Returns when every font the sheet measures with has loaded and every autofit that was taken
45148
+ * with a stand-in meanwhile has been taken again.
45149
+ *
45150
+ * @remarks
45151
+ * Measuring never waits: a style naming a face not yet loaded measures with a related or
45152
+ * built-in one and the lookup starts the load, the way a browser paints with a fallback until
45153
+ * a web font arrives. This is the point after which sizes are final. Fonts are shared, so this
45154
+ * also waits for faces other sheets and workbooks started loading; a load that fails leaves its
45155
+ * stand-in and still settles.
45156
+ *
45157
+ * The same point as {@link IWorkbook.whenFontsReady}; a sheet without a workbook has it here.
45158
+ */
45159
+ whenFontsReady(): Promise<void>;
45160
+ /**
45161
+ * Returns when the sheet is settled: {@link whenCalculationReady} and {@link whenFontsReady}
45162
+ * both hold.
45163
+ */
45164
+ whenReady(): Promise<void>;
43189
45165
  /**
43190
45166
  * Returns the {@link IWorkbook} for the sheet.
43191
45167
  *
@@ -43525,6 +45501,13 @@ declare global {
43525
45501
  * Called when any table are added or removed.
43526
45502
  */
43527
45503
  onTablesChange?(source: IWorksheet): void;
45504
+ /**
45505
+ * Called when a pivot table changes: its style, its layout, or where it sits.
45506
+ *
45507
+ * @remarks
45508
+ * Always accompanied by the coarse {@link onStyleChange}.
45509
+ */
45510
+ onPivotTablesChange?(source: IWorksheet): void;
43528
45511
  /**
43529
45512
  * Called when any data validation is added, removed, re-anchored, or re-evaluates its results.
43530
45513
  *
@@ -45354,6 +47337,21 @@ declare global {
45354
47337
  getKeyFrom(): string;
45355
47338
  getBuildVersion(): string;
45356
47339
  getBuildDate(): string;
47340
+ /**
47341
+ * When this build's evaluation period ends — from then on, unlicensed, it refuses exports — or
47342
+ * `null` for an unstamped build.
47343
+ */
47344
+ getEvalPeriodEnd(): Date | null;
47345
+ /**
47346
+ * When this build's grace ends — from then on, unlicensed, it stops calculating and running
47347
+ * scripts — or `null` for an unstamped build.
47348
+ */
47349
+ getEvalStopDate(): Date | null;
47350
+ /**
47351
+ * The license as one report row — what `info` and `sheetxl info` print. `includeHost` adds where
47352
+ * the key came from and its capacity, for a human diagnosing a machine.
47353
+ */
47354
+ getSummary(includeHost?: boolean): LicenseSummary;
45357
47355
  }
45358
47356
 
45359
47357
  /**
@@ -45363,6 +47361,19 @@ declare global {
45363
47361
  */
45364
47362
  export const LicenseManager: LM;
45365
47363
 
47364
+ /**
47365
+ * @hidden
47366
+ *
47367
+ * A license as one report row: how it stands, the edition, what qualifies it, and the exact command
47368
+ * that resolves a `warn`.
47369
+ */
47370
+ export interface LicenseSummary {
47371
+ level: 'ok' | 'warn';
47372
+ value: string;
47373
+ detail?: string;
47374
+ fix?: string;
47375
+ }
47376
+
45366
47377
  /**
45367
47378
  * Rotated cell-text layout (the Excel model).
45368
47379
  *
@@ -45439,16 +47450,31 @@ declare global {
45439
47450
  */
45440
47451
  getDetails(): Promise<LicenseDetails>;
45441
47452
  /**
45442
- * Return the current license details, after confirming this runtime may run under them.
47453
+ * Return the current license details, after confirming this runtime may use `meter` under them.
47454
+ *
47455
+ * @param meter What is about to be used: `'calcs'`, `'exports'` (a write in any format but
47456
+ * `.sxl`) or `'scripts'`. Omitted, it asks whether this runtime may run at all.
47457
+ * @param count How much of it — what a metered license will count against its limit.
45443
47458
  *
45444
47459
  * @remarks
45445
- * {@link getDetails} only reports. This also enforces: in a browser it always resolves, because
45446
- * an unlicensed page runs with the evaluation watermark. Outside a browser an evaluation runs
45447
- * for a limited period from the build's date; past it a valid license key is required, and this
45448
- * rejects with the reason and what to do. The engine calls it when it starts, so a host that
45449
- * wants to fail at startup instead of at the first workbook calls it itself.
47460
+ * {@link getDetails} only reports. This also enforces: on a web page it always resolves, because
47461
+ * an unlicensed page runs with the evaluation watermark. Anywhere else an unlicensed build runs
47462
+ * for an evaluation period from its build date; after it `'exports'` are refused, and after its
47463
+ * grace everything metered is. The rejection carries the reason and what to do. Opening a
47464
+ * workbook and saving it as `.sxl` are never refused. The engine calls this when it starts, so a
47465
+ * host that wants to fail at startup instead of at the first workbook calls it itself.
47466
+ */
47467
+ assertUsable(meter?: string, count?: number): Promise<LicenseDetails>;
47468
+ /**
47469
+ * Where this runtime stands under its license: `licensed`, in its `evaluation`, in the `grace`
47470
+ * that refuses exports, or `stopped` (no calculation, scripts or exports).
47471
+ */
47472
+ getEvalState(): Promise<EvalState>;
47473
+ /**
47474
+ * Whether this runtime runs under the evaluation watermark: an unlicensed web page off localhost.
47475
+ * An xlsx exported from it carries the watermark as a sheet added before the workbook's own.
45450
47476
  */
45451
- assertUsable(): Promise<LicenseDetails>;
47477
+ isWatermarked(): Promise<boolean>;
45452
47478
  /**
45453
47479
  * Return the license key in use, or `null` for an evaluation.
45454
47480
  *
@@ -46666,6 +48692,96 @@ declare global {
46666
48692
  outerRadius: number;
46667
48693
  }
46668
48694
 
48695
+ /**
48696
+ * The expand/collapse box of a pivot label `cell`, in px at 100% from its left edge; `null` for a
48697
+ * cell that keeps no box gutter.
48698
+ * @internal
48699
+ */
48700
+ export const pivotBoxOf: (cell: ICell) => {
48701
+ left: number;
48702
+ size: number;
48703
+ } | null;
48704
+
48705
+ /** What a laid-out table's definition writes into its cells' formats ({@link pivotCellFormatsOf}). */
48706
+ export interface PivotCellFormats {
48707
+ /** How many rows and columns it lays out, from the top-left cell of its page fields and location. */
48708
+ readonly rows: number;
48709
+ readonly columns: number;
48710
+ /** How many rows sit above its location: the page rows and the gap. */
48711
+ readonly top: number;
48712
+ /** It has no fields: its cells hold nothing, and every one has a format, its box's. */
48713
+ readonly empty: boolean;
48714
+ /**
48715
+ * The number format of the cell (`undefined` for General), the indent it is set left by (`null`
48716
+ * when it is not), and the style the table's own formats give it (`null` for none), which wins
48717
+ * over the other two: those a user put on the table, or an empty table's box.
48718
+ */
48719
+ formatAt(row: number, column: number): {
48720
+ numberFormat: string | number | undefined;
48721
+ labelIndent: number | null;
48722
+ user: ICellStyle.Properties | null;
48723
+ };
48724
+ }
48725
+
48726
+ /**
48727
+ * The formats a table's definition explains in its cells, as Excel writes them into each cell's
48728
+ * xf: its number formats ({@link pivotNumberFormatAt}), its row labels' alignment
48729
+ * ({@link pivotRowLabelIndentAt}), its user formats ({@link pivotUserFormatAt}) and, while it is
48730
+ * empty, its box ({@link pivotEmptyBoxAt}). `null` for a table that is not laid out.
48731
+ * @internal
48732
+ */
48733
+ export const pivotCellFormatsOf: (table: IPivotTable.JSON, cacheFields?: readonly {
48734
+ numberFormat?: string | number;
48735
+ }[]) => PivotCellFormats | null;
48736
+
48737
+ /**
48738
+ * A control on a cell of a laid-out table, by row and column from the top-left cell of its page
48739
+ * fields and location:
48740
+ * - `dropdown`: a field button, for the fields it lists (more than one on a compact header);
48741
+ * - `toggle`: an item's expand/collapse box; `item` by index into the field's items, `name` its
48742
+ * caption where the table has said it.
48743
+ */
48744
+ export type PivotControl = {
48745
+ readonly kind: 'dropdown';
48746
+ readonly row: number;
48747
+ readonly column: number;
48748
+ readonly fields: readonly number[];
48749
+ } | {
48750
+ readonly kind: 'toggle';
48751
+ readonly row: number;
48752
+ readonly column: number;
48753
+ readonly field: number;
48754
+ readonly item: number;
48755
+ readonly expanded: boolean;
48756
+ readonly name?: string;
48757
+ };
48758
+
48759
+ /**
48760
+ * The field dropdowns and expand/collapse boxes of `table` within `coords`, at sheet cells; empty
48761
+ * for a table that is not placed.
48762
+ * @internal
48763
+ */
48764
+ export const pivotControlsIn: (table: IPivotTable, coords: IRange.Coords) => PivotControl[];
48765
+
48766
+ /** A pivot table style over a small schematic table, cell by cell, for a gallery swatch. */
48767
+ export interface PivotStylePreview {
48768
+ readonly rows: number;
48769
+ readonly columns: number;
48770
+ /** The style a cell shows, from the preview's top-left. */
48771
+ getStyleAt(row: number, column: number): ICellStyle;
48772
+ }
48773
+
48774
+ /**
48775
+ * `style` over Excel's gallery swatch, with no sheet and no WebAssembly; `null` is the gallery's
48776
+ * None, a table with no style.
48777
+ *
48778
+ * @param options Which parts of the style show; absent, those Excel gives a new table.
48779
+ * @param rows How many rows the swatch has, at least 3; 5 by default, as Excel online's. Excel
48780
+ * desktop's has 8.
48781
+ * @internal
48782
+ */
48783
+ export const pivotStylePreviewOf: (styles: IStyleCollection, style: ITableStyle | null, options?: IPivotTable.PivotStyleJSON, rows?: number) => PivotStylePreview;
48784
+
46669
48785
  /**
46670
48786
  * Represents a point in 2D space.
46671
48787
  */