@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
@@ -3,38 +3,159 @@ import { IWorksheet } from '../sheet';
3
3
  import { ICellRange } from '../cellRange';
4
4
  import { IAnchored } from '../anchored';
5
5
  import { IEmbeddedPart } from '../io';
6
+ import { Tuple } from '../collections';
7
+ import { Scalar } from '@sheetxl/primitives';
8
+ import { ICondition } from '../condition';
9
+ import { ITransaction } from '../transaction';
10
+ import { ICellStyle } from '../style';
11
+ import { ITableStyle } from '../table';
12
+ import { ISlicer } from '../slicer';
13
+ import { IPivotTableCollection } from './IPivotTableCollection';
6
14
  /**
7
- * A pivot table laid out on a sheet: the part it was read from, anchored at its location.
15
+ * A pivot table laid out on a sheet, anchored at the top-left cell of its location.
8
16
  *
9
17
  * @remarks
10
- * The table is not modeled yet beyond where it sits and what it summarizes: its markup is kept
11
- * as read and written back as read, with the location restated. Where it sits follows
12
- * structural edits as a table's range does; an edit that would move only part of it is refused,
13
- * as Excel refuses it, and one that takes every cell of it deletes it.
18
+ * Until it is refreshed, a table is written back as it was read, with the location restated.
19
+ * Where it sits follows structural edits; an edit that would move only part of it, its page
20
+ * fields included, is refused, as Excel refuses it, and one that takes every cell of it deletes it.
21
+ * While something is in the way of its cells, the table shows `#SPILL!` at its anchor and covers
22
+ * that cell alone, as in Excel.
14
23
  */
15
24
  export interface IPivotTable extends IAnchored {
16
25
  toJSON(toResourceId?: (resource: IResource) => number | null): IPivotTable.JSON | null;
17
26
  /**
18
- * Returns the name, unique across the workbook as Excel keeps it.
27
+ * Returns the name.
28
+ *
29
+ * @remarks
30
+ * Unique on the table's sheet, as Excel keeps it. Tables on different sheets may share a name:
31
+ * a duplicated sheet's tables keep theirs, as they do in Excel.
19
32
  */
20
33
  getName(): string;
34
+ /**
35
+ * Renames the table, as one step that can be undone.
36
+ *
37
+ * @remarks
38
+ * Any text of 1 to 255 characters, spaces and punctuation included, unless another table on this
39
+ * sheet has it, without regard to case. A table on another sheet may have it. Slicers on the table
40
+ * follow it; `GETPIVOTDATA` names a cell, not the table, so it is unaffected.
41
+ *
42
+ * @throws ExpectedError For an empty name, one longer than 255 characters, or one another table on
43
+ * this sheet has.
44
+ */
45
+ setName(name: string, options?: ITransaction.OperationOptions): Promise<void>;
21
46
  /**
22
47
  * Returns the sheet the table is laid out on.
23
48
  */
24
49
  getWorksheet(): IWorksheet;
25
50
  /**
26
- * Returns the cells the table is laid out on.
51
+ * Returns the cells the table is laid out on: its location, without the page fields above it.
27
52
  *
28
53
  * @remarks
29
- * The anchor: an insert or delete before the table moves it, one taking every cell of it
30
- * deletes it ({@link IAnchored.isDeleted}), and one that would move part of it - a row deleted
31
- * or inserted inside it, a column cut through it - is refused.
54
+ * The anchor cell alone while the table shows `#SPILL!`. An insert or delete before the table
55
+ * moves it, one taking every cell of it deletes it ({@link IAnchored.isDeleted}), and one that
56
+ * would move part of it - a row deleted or inserted inside it or its page fields, a column cut
57
+ * through it - is refused.
32
58
  */
33
59
  getRange(options?: ICellRange.GetRangeOptions): ICellRange;
34
60
  /**
35
- * Returns the markup of the table's part, with the location as it is now.
61
+ * Returns the cells of the page fields above the table, each a caption and its pick; `null` when
62
+ * the table has no page field, or shows `#SPILL!`.
36
63
  */
37
- getXML(): string | null;
64
+ getPageRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
65
+ /**
66
+ * Returns the cells that hold the table's values, its subtotals and grand totals included; `null`
67
+ * while the table shows `#SPILL!`.
68
+ *
69
+ * @remarks
70
+ * Every line below the header rows, right of the label columns. A table with no values still has
71
+ * its lines: then the last column, which holds the labels (as Excel's `DataBodyRange`).
72
+ */
73
+ getBodyAndTotalRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
74
+ /**
75
+ * Returns the label columns down the side, from the row of their captions to the last line; `null`
76
+ * when nothing is on the rows, or the table shows `#SPILL!`.
77
+ */
78
+ getRowLabelRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
79
+ /**
80
+ * Returns the header rows across the top, right of the label columns, from the row of their
81
+ * caption; `null` when nothing is on the columns, or the table shows `#SPILL!`.
82
+ */
83
+ getColumnLabelRange(options?: ICellRange.GetRangeOptions): ICellRange | null;
84
+ /**
85
+ * Moves the table on its sheet, as one step that can be undone.
86
+ *
87
+ * @remarks
88
+ * `cell` takes the table's top-left cell, as {@link IPivotTableCollection.add}'s location does:
89
+ * page fields sit above it, a blank row between, and at the top of a sheet the table moves down
90
+ * to make room for them. The cells it leaves are cleared. The cells it needs must hold no value,
91
+ * unless {@link IPivotTable.MoveOptions.discardValues} clears them; another pivot table or an
92
+ * array's cells there always refuse it. The new place may overlap the old.
93
+ *
94
+ * @throws ExpectedError When `cell` is on another sheet, the cells it needs hold a value, an array
95
+ * or another pivot table, or the table is not modeled; ProtectedError on a locked sheet.
96
+ */
97
+ moveTo(cell: ICellRange.Address, options?: IPivotTable.MoveOptions): Promise<void>;
98
+ /**
99
+ * Returns the cells the table summarizes, as {@link IPivotTableCollection.add} takes them: a table's
100
+ * or defined name's name, or a sheet-qualified range; `null` when its cache names none, as one
101
+ * from another workbook or a database may not.
102
+ */
103
+ getSource(): string | null;
104
+ /**
105
+ * Summarizes other cells, as one step that can be undone: the table reads `source` as a refresh
106
+ * does and is laid out again.
107
+ *
108
+ * @param source The cells to summarize, as {@link IPivotTableCollection.add} takes them.
109
+ *
110
+ * @remarks
111
+ * Fields are matched to the new columns by their header, without regard to case. A field whose
112
+ * column is gone, or whose header changed, leaves the table; the rest keep their place, hidden
113
+ * items, filters, captions and formats. Other tables that shared the cache keep the cells they
114
+ * summarized. When the table grows over a value it shows `#SPILL!`, as after a refresh. A slicer
115
+ * on a field the new source does not have is deleted with it.
116
+ *
117
+ * @throws ExpectedError When `source` names nothing, has no row of data, overlaps the table, the
118
+ * table is not modeled, or a slicer on the table also filters another; ProtectedError on a locked
119
+ * sheet.
120
+ */
121
+ setSource(source: IPivotTableCollection.Source, options?: ITransaction.OperationOptions): Promise<void>;
122
+ /**
123
+ * Adds a slicer that filters one of the table's fields, as one step that can be undone.
124
+ *
125
+ * @param field The field, or its name.
126
+ * @param options Where it goes and how it looks. Sized 192 × 280 pixels and centered in the
127
+ * view unless `bounds` says otherwise; placed on the table's sheet unless `sheet` says otherwise.
128
+ *
129
+ * @returns The slicer, named for the field's name in the source (`Region`, then `Region 1`), unique
130
+ * in the workbook, and captioned with the field's caption.
131
+ *
132
+ * @remarks
133
+ * The field need not be on the table. The slicer's selection is the items the field hides.
134
+ *
135
+ * @throws ExpectedError When the table has no such field, the name is taken, or the table is not
136
+ * modeled.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * const slicer = await pivot.addSlicer('Region');
141
+ * await slicer.selectItems(['East']);
142
+ * ```
143
+ */
144
+ addSlicer(field: IPivotTable.IField | string, options?: ISlicer.AddOptions): Promise<ISlicer>;
145
+ /**
146
+ * Returns whether the cells the table summarizes have been edited since its cache last read them.
147
+ *
148
+ * @remarks
149
+ * As in Excel, an edit to the source does not change the table; it shows what the cache held
150
+ * until it is refreshed from the source. Every table on the same cache is stale together.
151
+ *
152
+ * An edit is a value or formula written or cleared in the source (an undo of one too), a row
153
+ * or column inserted or deleted inside it, or a resize of the table it names. Moving the source
154
+ * whole is not. Neither is a recalculation: a formula in the source that reads cells outside it
155
+ * can change value without the table reading as stale. A source this workbook does not hold,
156
+ * such as another workbook's, never reads as stale.
157
+ */
158
+ isStale(): boolean;
38
159
  /**
39
160
  * Returns the id of the cache this table summarizes.
40
161
  *
@@ -44,16 +165,910 @@ export interface IPivotTable extends IAnchored {
44
165
  * @internal
45
166
  */
46
167
  getCacheId(): number;
168
+ /**
169
+ * Reads the table's source again and lays the table out from it, as one step that can be undone.
170
+ *
171
+ * @remarks
172
+ * The cache is read again from the cells its source names now, and every table on that cache is
173
+ * laid out again with this one, as in Excel. A field follows its column by the header's text
174
+ * (without regard to case): a column whose header changed, or that is gone, takes its field out
175
+ * of every table. Each field keeps its items in their place, with what was hidden, collapsed or
176
+ * renamed; an item no longer in the source is kept, missing, until it comes back, and a new one
177
+ * is added after the others (in its place under a sort), hidden when the field hides items.
178
+ * With `source: false` the table alone is laid out again from its cache as it is.
179
+ *
180
+ * The table takes the cells its layout needs: its range grows or shrinks from its top-left
181
+ * cell, and the cells it gives up are cleared. When a cell it needs holds anything, the table
182
+ * shows `#SPILL!` in its top-left cell, as a dynamic array does, and is laid out again as soon
183
+ * as the cells are clear.
184
+ *
185
+ * @throws When the table is not modeled, on a locked sheet, or its source is not in this
186
+ * workbook or its cache has calculated fields.
187
+ */
188
+ refresh(options?: IPivotTable.RefreshOptions): Promise<void>;
189
+ /**
190
+ * Returns the name of the table's style and which of its parts show.
191
+ *
192
+ * @remarks
193
+ * Absent flags are off; a table with no style has no `name`.
194
+ */
195
+ getStyleOptions(): IPivotTable.StyleOptions;
196
+ /**
197
+ * Changes the table's style or which of its parts show, as one step that can be undone.
198
+ *
199
+ * @param options Merged with the current options; `name: null` removes the style and keeps the flags.
200
+ *
201
+ * @throws When the table is not modeled.
202
+ */
203
+ updateStyleOptions(options: IPivotTable.StyleOptions, operation?: ITransaction.OperationOptions): IPivotTable;
204
+ /**
205
+ * Returns the table's pivot table style, or `null` when it names none or one the workbook does not have.
206
+ */
207
+ getStyle(): ITableStyle | null;
208
+ /**
209
+ * Returns the style the table gives the cell at a sheet position: its pivot table style, and
210
+ * the formats its layout sets, such as a row label set left and indented by its level.
211
+ * @param row The row on the sheet.
212
+ * @param column The column on the sheet.
213
+ *
214
+ * @remarks
215
+ * Not the cell's own formats or any other layer. A cell the table does not cover, or a table
216
+ * that is not laid out, has none of the table's styling.
217
+ */
218
+ getStyleAt(row: number, column: number): ICellStyle;
219
+ /**
220
+ * Sets whether the expand/collapse buttons beside the items are hidden, as one step that can be
221
+ * undone.
222
+ *
223
+ * @remarks
224
+ * The items still expand and collapse through {@link IPivotTable.IItem.setExpanded}.
225
+ *
226
+ * @throws When the table is not modeled.
227
+ */
228
+ setHiddenDrillIndicators(hidden: boolean, options?: ITransaction.OperationOptions): this;
229
+ /**
230
+ * Returns whether the expand/collapse buttons beside the items are hidden.
231
+ */
232
+ isHiddenDrillIndicators(): boolean;
233
+ /**
234
+ * Sets whether the captions over the row and column fields, and their buttons, are hidden, as
235
+ * one step that can be undone.
236
+ *
237
+ * @remarks
238
+ * The table is laid out again from its cache: the caption cells are left blank, and the row of
239
+ * column captions is dropped when nothing else is in it, so the table can shrink by a row, as in
240
+ * Excel. A page field keeps its caption and button.
241
+ *
242
+ * @throws When the table is not modeled.
243
+ */
244
+ setHiddenFieldHeaders(hidden: boolean, options?: ITransaction.OperationOptions): Promise<this>;
245
+ /**
246
+ * Returns whether the captions over the row and column fields, and their buttons, are hidden.
247
+ */
248
+ isHiddenFieldHeaders(): boolean;
249
+ /**
250
+ * Returns how the table lays out its fields, or `null` when the row and column fields differ.
251
+ */
252
+ getForm(): 'compact' | IPivotTable.PivotForm | null;
253
+ /**
254
+ * Lays out every field of the table in a form, those off the table too, as one step that can be
255
+ * undone.
256
+ *
257
+ * @remarks
258
+ * The table is laid out again from its cache. As with every setting that changes its cells, when
259
+ * a cell it needs holds anything the setting stands and the table shows `#SPILL!` until the cells
260
+ * are clear.
261
+ *
262
+ * @throws ExpectedError For a form that is none, or when the table is not modeled.
263
+ */
264
+ setForm(form: 'compact' | IPivotTable.PivotForm, options?: ITransaction.OperationOptions): Promise<this>;
265
+ /**
266
+ * Returns whether the row and column fields repeat their labels, or `null` when they differ.
267
+ */
268
+ getRepeatLabels(): boolean | null;
269
+ /**
270
+ * Sets whether every field repeats its item's label on each line the item spans, those off the
271
+ * table too, as one step that can be undone.
272
+ *
273
+ * @remarks
274
+ * Nothing shows in compact form, whose labels share a column; the setting stands for a later form.
275
+ *
276
+ * @throws When the table is not modeled.
277
+ */
278
+ setRepeatLabels(repeat: boolean, options?: ITransaction.OperationOptions): Promise<this>;
279
+ /**
280
+ * Returns whether the row and column fields leave a blank line after each item, or `null` when
281
+ * they differ.
282
+ */
283
+ getBlankRowAfterItems(): boolean | null;
284
+ /**
285
+ * Sets whether every field leaves a blank line after each of its items, those off the table too,
286
+ * as one step that can be undone.
287
+ *
288
+ * @remarks
289
+ * A blank line shows only after the items of a row field with another row field inside it.
290
+ *
291
+ * @throws When the table is not modeled.
292
+ */
293
+ setBlankRowAfterItems(blank: boolean, options?: ITransaction.OperationOptions): Promise<this>;
294
+ /**
295
+ * Returns whether the row and column fields show their subtotals on their items' first line, or
296
+ * `null` when they differ.
297
+ */
298
+ getSubtotalsOnTop(): boolean | null;
299
+ /**
300
+ * Sets whether every field shows its subtotals on its items' first line rather than on a line
301
+ * after them, those off the table too, as one step that can be undone.
302
+ *
303
+ * @remarks
304
+ * Tabular form always shows them after; the setting stands for a later form.
305
+ *
306
+ * @throws When the table is not modeled.
307
+ */
308
+ setSubtotalsOnTop(top: boolean, options?: ITransaction.OperationOptions): Promise<this>;
309
+ /**
310
+ * Returns whether each row shows a grand total: the column of totals at the table's right.
311
+ */
312
+ isShowRowGrandTotals(): boolean;
313
+ /**
314
+ * Sets whether each row shows a grand total, as one step that can be undone.
315
+ *
316
+ * @remarks
317
+ * That is the column of totals at the table's right, so a table with no column fields has none to
318
+ * show. With the grand total of the whole table gone from the cells, `GETPIVOTDATA` for it is `#REF!`.
319
+ *
320
+ * @throws When the table is not modeled.
321
+ */
322
+ setShowRowGrandTotals(show: boolean, options?: ITransaction.OperationOptions): Promise<this>;
323
+ /**
324
+ * Returns whether each column shows a grand total: the row of totals at the table's bottom.
325
+ */
326
+ isShowColumnGrandTotals(): boolean;
327
+ /**
328
+ * Sets whether each column shows a grand total, as one step that can be undone.
329
+ *
330
+ * @remarks
331
+ * That is the row of totals at the table's bottom.
332
+ *
333
+ * @throws When the table is not modeled.
334
+ */
335
+ setShowColumnGrandTotals(show: boolean, options?: ITransaction.OperationOptions): Promise<this>;
336
+ /**
337
+ * Returns what a crossing no record falls in shows: this text, empty by default for a blank cell,
338
+ * or `null` when it shows 0.
339
+ */
340
+ getEmptyCaption(): string | null;
341
+ /**
342
+ * Sets what a crossing no record falls in shows, as one step that can be undone.
343
+ *
344
+ * @param text The text; empty for a blank cell; `null` for 0. Text that reads as a number shows as
345
+ * that number.
346
+ *
347
+ * @throws When the table is not modeled.
348
+ */
349
+ setEmptyCaption(text: string | null, options?: ITransaction.OperationOptions): Promise<this>;
350
+ /**
351
+ * Returns what an error value shows as: this text, or `null`, the default, when it shows the error.
352
+ */
353
+ getErrorCaption(): string | null;
354
+ /**
355
+ * Sets what an error value shows as, as one step that can be undone.
356
+ *
357
+ * @param text The text; empty for a blank cell; `null` for the error itself.
358
+ *
359
+ * @throws When the table is not modeled.
360
+ */
361
+ setErrorCaption(text: string | null, options?: ITransaction.OperationOptions): Promise<this>;
362
+ /**
363
+ * Returns whether the formats set on the table's cells follow their items through a relayout.
364
+ */
365
+ isPreserveFormatting(): boolean;
366
+ /**
367
+ * Sets whether the formats set on the table's cells follow their items through a relayout, as one
368
+ * step that can be undone.
369
+ *
370
+ * @remarks
371
+ * Turned off, the table lets go of the formats it holds, for good: turning it on again does not bring
372
+ * them back. While off, a format set on the cells lasts until the next time the table is laid out,
373
+ * whatever causes that.
374
+ *
375
+ * @throws When the table is not modeled.
376
+ */
377
+ setPreserveFormatting(preserve: boolean, options?: ITransaction.OperationOptions): this;
378
+ /**
379
+ * Returns whether the table fits its columns to its cells each time it is laid out.
380
+ */
381
+ isAutoFitColumns(): boolean;
382
+ /**
383
+ * Sets whether the table fits its columns to its cells each time it is laid out, as one step that
384
+ * can be undone.
385
+ *
386
+ * @remarks
387
+ * A fit measures only the table's cells, and sets the width of every column the table covers, a
388
+ * width set by hand included. Setting this does not fit the columns; the next layout does.
389
+ *
390
+ * @throws When the table is not modeled.
391
+ */
392
+ setAutoFitColumns(autoFit: boolean, options?: ITransaction.OperationOptions): this;
393
+ /**
394
+ * Returns whether a field's filters are allowed to combine.
395
+ */
396
+ isMultipleFiltersPerField(): boolean;
397
+ /**
398
+ * Sets whether a field's filters are allowed to combine, as one step that can be undone.
399
+ *
400
+ * @remarks
401
+ * Turned off, a field holding more than one filter loses all of them, and the table is laid out
402
+ * again if any went; a field with one keeps it. The flag does not limit
403
+ * {@link IPivotTable.IField.applyFilter}.
404
+ *
405
+ * @throws When the table is not modeled.
406
+ */
407
+ setMultipleFiltersPerField(multiple: boolean, options?: ITransaction.OperationOptions): Promise<this>;
408
+ /**
409
+ * Returns the table's fields, one per field of its cache, in the cache's order; empty for a table
410
+ * that is not modeled.
411
+ *
412
+ * @example
413
+ * ```ts
414
+ * await pivot.getField('Region').getItem('East').setExpanded(false);
415
+ * await pivot.getField('Channel').setCurrentPage('Web');
416
+ * ```
417
+ */
418
+ getFields(): readonly IPivotTable.IField[];
419
+ /**
420
+ * Returns the field with a caption, matched without regard to case, or `null` when there is none.
421
+ */
422
+ getField(name: string): IPivotTable.IField | null;
423
+ /**
424
+ * Returns the fields down the rows, outermost first; the values, where they sit among them, are
425
+ * {@link getValuesField}.
426
+ */
427
+ getRowFields(): readonly IPivotTable.IField[];
428
+ /**
429
+ * Returns the fields across the columns, outermost first; the values, where they sit among them,
430
+ * are {@link getValuesField}.
431
+ */
432
+ getColumnFields(): readonly IPivotTable.IField[];
433
+ /**
434
+ * Returns the page fields above the table, in the order they are listed.
435
+ */
436
+ getPageFields(): readonly IPivotTable.IField[];
437
+ /**
438
+ * Returns the table's values, in the order they show; empty for a table that is not modeled.
439
+ */
440
+ getDataFields(): readonly IPivotTable.IDataField[];
441
+ /**
442
+ * Returns the value with a caption, matched without regard to case, or `null` when there is none.
443
+ */
444
+ getDataField(name: string): IPivotTable.IDataField | null;
445
+ /**
446
+ * Summarizes a field in the table's values, after the last, as one step that can be undone.
447
+ *
448
+ * @remarks
449
+ * The field comes off any row, column or page axis it is on, as in Excel, keeping what
450
+ * {@link IPivotTable.IField.setAxis} keeps. {@link IPivotTable.IField.setAxis} can then put it back,
451
+ * holding both. One source can be summarized any number of times.
452
+ *
453
+ * With a second value the table gains its {@link getValuesField | values field}.
454
+ *
455
+ * @param field The field, or its caption.
456
+ * @param input Its caption, function and number format; absent, as {@link IPivotTable.IDataField.Input} says.
457
+ *
458
+ * @example
459
+ * ```ts
460
+ * await pivot.addDataField('Sales');
461
+ * const average = await pivot.addDataField('Sales', { function: 'average', numberFormat: '0.00' });
462
+ * ```
463
+ *
464
+ * @throws ExpectedError For a field the table does not have, a caption another field or value has, a
465
+ * function that is none or a number format that does not parse.
466
+ */
467
+ addDataField(field: string | IPivotTable.IField, input?: Omit<IPivotTable.IDataField.Input, 'field'>, options?: ITransaction.OperationOptions): Promise<IPivotTable.IDataField>;
468
+ /**
469
+ * Returns where the table's values sit among the fields of an axis; `null` below two values, when
470
+ * there is nothing for them to be placed among.
471
+ */
472
+ getValuesField(): IPivotTable.IValuesField | null;
47
473
  /** For runtime type checking. */
48
474
  readonly isIPivotTable: true;
49
475
  }
50
476
  export declare namespace IPivotTable {
51
477
  /**
52
- * A pivot cache as the workbook carries it: the part, by the id the tables name.
478
+ * The axis a {@link IField | field} is on: down the rows, across the columns, as a page field
479
+ * above the table, or where the values sit.
480
+ */
481
+ const Axis: {
482
+ readonly Row: "row";
483
+ readonly Column: "column";
484
+ readonly Page: "page";
485
+ readonly Values: "values";
486
+ };
487
+ type Axis = typeof Axis[keyof typeof Axis];
488
+ /**
489
+ * A field of a pivot table: a field of its cache, as the table uses it.
490
+ *
491
+ * @remarks
492
+ * Changing what a field shows - collapsing items, hiding them, choosing a page item - changes the
493
+ * table's definition and lays the table out again from its cache, as one step that can be undone.
494
+ * The source is not read again. A table that grows over cells that hold anything shows `#SPILL!`,
495
+ * as a {@link IPivotTable.refresh | refresh} does.
496
+ *
497
+ * A field is a view of the table: it reads the table as it is now.
498
+ */
499
+ interface IField {
500
+ /**
501
+ * Returns the field's caption: its own name in the table, else its cache field's.
502
+ */
503
+ getName(): string;
504
+ /**
505
+ * Returns what the field's items are: numbers, dates, text (logicals and errors among it), a
506
+ * mix of those, or `blank` when it holds nothing. A calculated field is numbers.
507
+ *
508
+ * @remarks
509
+ * The rule {@link IPivotTable.addDataField} follows for a value's function: `number` sums, any
510
+ * other counts. A field list places a field by it, numbers in the values and the rest on the rows.
511
+ */
512
+ getDataType(): IField.DataType;
513
+ /**
514
+ * Returns the axis the field is on, or `null` when it is on none.
515
+ */
516
+ getAxis(): Axis | null;
517
+ /**
518
+ * Puts the field on an axis, or takes it off the table for `null`, as one step that can be undone.
519
+ *
520
+ * @remarks
521
+ * The table is laid out again from its cache. Where a value is in the way it shows `#SPILL!`, and
522
+ * a page field with no room above moves the table down, where it stays once the field has gone.
523
+ *
524
+ * What the field holds goes with it, off the table and back too: hidden items, filters, sort and
525
+ * names. On the page axis it loses its filters, and items hidden there are a multiple selection;
526
+ * off the page it loses its pick. A field off the table filters nothing. Taking it off also drops
527
+ * the formats on its labels and on the values under them, for good; a move between axes keeps them.
528
+ * A sort by one line of the other axis ends when that line's fields are no longer that axis's
529
+ * outermost.
530
+ *
531
+ * A field stays with its data fields either way: one source can be on an axis and summarized at
532
+ * once. To remove a value, delete its {@link IDataField}.
533
+ *
534
+ * @param axis Where it goes; `null` is nothing for a field already off the table.
535
+ * @param position Its place on the axis, counted from 1, the values counting where they sit among
536
+ * the fields; absent, after the last. Absent is nothing for a field already on `axis`.
537
+ *
538
+ * @example
539
+ * ```ts
540
+ * await pivot.getField('Year').setAxis('column');
541
+ * await pivot.getField('Product').setAxis('row', 1);
542
+ * await pivot.getField('Region').setAxis(null);
543
+ * ```
544
+ *
545
+ * @throws ExpectedError For `values`, for a position not on the axis, and for a calculated field
546
+ * on any axis or a field with calculated items on the page axis.
547
+ */
548
+ setAxis(axis: Axis | null, position?: number, options?: ITransaction.OperationOptions): Promise<void>;
549
+ /**
550
+ * Returns the field's place on its axis, counted from 1, the values counting where they sit among
551
+ * the fields; `null` off the table.
552
+ */
553
+ getPosition(): number | null;
554
+ /**
555
+ * Moves the field along its axis, as one step that can be undone.
556
+ *
557
+ * @param position Its place, counted from 1 as {@link getPosition} counts.
558
+ * @throws ExpectedError When the field is off the table or the position is not on its axis.
559
+ */
560
+ setPosition(position: number, options?: ITransaction.OperationOptions): Promise<void>;
561
+ /**
562
+ * Returns the subtotals the field shows, in the order they show: `automatic`, or its functions;
563
+ * empty for none.
564
+ */
565
+ getSubtotals(): readonly IField.Subtotal[];
566
+ /**
567
+ * Sets the subtotals the field shows, as one step that can be undone.
568
+ *
569
+ * @remarks
570
+ * The automatic subtotal takes the place of any function asked for with it, and functions show in
571
+ * one order whatever the order asked. One function alone sits where the automatic subtotal does; two
572
+ * or more always show on lines after the items. With none, an item's own line holds no value in
573
+ * compact and outline forms. The setting holds for a field off the table, and shows when it is an
574
+ * outer field of its axis.
575
+ *
576
+ * @param subtotals Empty for none.
577
+ *
578
+ * @example
579
+ * ```ts
580
+ * await pivot.getField('Region').setSubtotals([]);
581
+ * await pivot.getField('Region').setSubtotals(['average', 'max']);
582
+ * ```
583
+ *
584
+ * @throws ExpectedError For a subtotal that is none, on a calculated field, and for functions on a
585
+ * field with calculated items.
586
+ */
587
+ setSubtotals(subtotals: readonly IField.Subtotal[], options?: ITransaction.OperationOptions): Promise<void>;
588
+ /**
589
+ * Returns how the field's items are laid out.
590
+ */
591
+ getForm(): 'compact' | PivotForm;
592
+ /**
593
+ * Lays out the field's items in a form, as one step that can be undone.
594
+ *
595
+ * @remarks
596
+ * Fields of different forms share an axis: a compact field shares its label column with the field
597
+ * inside it. {@link IPivotTable.setForm} sets every field at once.
598
+ *
599
+ * @throws ExpectedError For a form that is none.
600
+ */
601
+ setForm(form: 'compact' | PivotForm, options?: ITransaction.OperationOptions): Promise<void>;
602
+ /**
603
+ * Returns whether the field repeats its item's label on each line the item spans.
604
+ */
605
+ getRepeatLabels(): boolean;
606
+ /**
607
+ * Sets whether the field repeats its item's label on each line the item spans, as one step that
608
+ * can be undone.
609
+ *
610
+ * @remarks
611
+ * It shows only where the field has a label column or row of its own, and has a field inside it.
612
+ */
613
+ setRepeatLabels(repeat: boolean, options?: ITransaction.OperationOptions): Promise<void>;
614
+ /**
615
+ * Returns whether the field leaves a blank line after each of its items.
616
+ */
617
+ getBlankRowAfter(): boolean;
618
+ /**
619
+ * Sets whether the field leaves a blank line after each of its items, as one step that can be undone.
620
+ *
621
+ * @remarks
622
+ * It shows only on a row field with another row field inside it; a field inside it that also leaves
623
+ * one shares that line.
624
+ */
625
+ setBlankRowAfter(blank: boolean, options?: ITransaction.OperationOptions): Promise<void>;
626
+ /**
627
+ * Returns whether the field's subtotals show on its items' first line rather than after them.
628
+ */
629
+ getSubtotalsOnTop(): boolean;
630
+ /**
631
+ * Sets whether the field's subtotals show on its items' first line rather than after them, as one
632
+ * step that can be undone.
633
+ *
634
+ * @remarks
635
+ * Tabular form always shows them after, as do two or more functions.
636
+ */
637
+ setSubtotalsOnTop(top: boolean, options?: ITransaction.OperationOptions): Promise<void>;
638
+ /**
639
+ * Returns the format code of the field's item labels: its own, else its source column's, else
640
+ * `General`; empty for a field holding anything but numbers and dates, which takes none.
641
+ */
642
+ getNumberFormat(): string;
643
+ /**
644
+ * Sets the number format of the field's item labels, as one step that can be undone.
645
+ *
646
+ * @remarks
647
+ * `GETPIVOTDATA` still finds items by their values, and by the text they show. It does not reach a value that
648
+ * summarizes the field: see {@link IDataField.setNumberFormat}.
649
+ *
650
+ * @param format A format code, or a built-in format's id.
651
+ * @throws ExpectedError For a format that does not parse, and on a field holding anything but
652
+ * numbers and dates.
653
+ */
654
+ setNumberFormat(format: string | number, options?: ITransaction.OperationOptions): Promise<void>;
655
+ /**
656
+ * Returns the table the field belongs to.
657
+ */
658
+ getPivotTable(): IPivotTable;
659
+ /**
660
+ * Returns the field's items in the table's order; empty for a field the table lists none for.
661
+ */
662
+ getItems(): readonly IItem[];
663
+ /**
664
+ * Returns the item with a caption, matched without regard to case, or `null` when there is none.
665
+ *
666
+ * @remarks
667
+ * A renamed item is found by its new caption only, as in Excel.
668
+ */
669
+ getItem(name: string): IItem | null;
670
+ /**
671
+ * Shows or hides the details of every item of the field, as one step that can be undone.
672
+ *
673
+ * @throws When the field is not a row or column field with another field inside it.
674
+ */
675
+ setExpanded(expanded: boolean, options?: ITransaction.OperationOptions): Promise<void>;
676
+ /**
677
+ * Shows only the named items, or every item for `null`, as one step that can be undone.
678
+ *
679
+ * @remarks
680
+ * On a page field the items shown are its selection: the field selects more than one item, and
681
+ * its page cell shows the item when one is left, else `(Multiple Items)`.
682
+ *
683
+ * @throws When a name is not an item of the field, or no item would show.
684
+ */
685
+ setVisibleItems(names: readonly string[] | null, options?: ITransaction.OperationOptions): Promise<void>;
686
+ /**
687
+ * Returns the item a page field shows, or `null` when it shows every item or more than one.
688
+ */
689
+ getCurrentPage(): IItem | null;
690
+ /**
691
+ * Shows one item of a page field, or every item for `null`, as one step that can be undone.
692
+ *
693
+ * @remarks
694
+ * The field selects a single item: any items hidden by {@link setVisibleItems} are shown again.
695
+ *
696
+ * @throws When the field is not a page field or the name is not one of its items.
697
+ */
698
+ setCurrentPage(name: string | null, options?: ITransaction.OperationOptions): Promise<void>;
699
+ /**
700
+ * Returns the field's filters: its label or date filter, its value or top filter, and the items
701
+ * it shows when some are hidden by hand. Empty when the field is not filtered.
702
+ */
703
+ getFilters(): IField.Filters;
704
+ /**
705
+ * Returns whether the field is filtered: by a filter of `type`, or by any when omitted.
706
+ */
707
+ isFiltered(type?: IField.FilterType): boolean;
708
+ /**
709
+ * Sets the field's filters of the kinds given and leaves its others, as one step that can be
710
+ * undone.
711
+ *
712
+ * @remarks
713
+ * A field takes one label-or-date filter and one value-or-top filter, as Excel's does; one given
714
+ * replaces the field's filter of its kind. Items hidden by hand stand beside them.
715
+ *
716
+ * - `label` tests each item's caption as its cell shows it; given no selector, it takes the
717
+ * Display selector.
718
+ * - `date` tests each item's date.
719
+ * - `value` tests each item's total of a data field within each item of the fields outside it;
720
+ * a top N ranks the items under one outer item together.
721
+ * - `manual` names the items shown, every item for `null`; on a page field, its selection.
722
+ *
723
+ * A condition no Excel pivot filter type spells is kept and laid out, and is left out of an
724
+ * xlsx file with a warning.
725
+ *
726
+ * @example
727
+ * ```ts
728
+ * const region = table.getField('Region')!;
729
+ * await region.applyFilter({ label: { selector: 'display', operator: 'textStartsWith', param: 'N' } });
730
+ * await region.applyFilter({ value: { condition: { operator: 'greaterThan', param: 100 }, dataField: 'Sum of Sales' } });
731
+ * ```
732
+ *
733
+ * @throws ExpectedError When a label, date or value filter is given for a field that is not a
734
+ * row or column field, both a label and a date filter are given, a top N names no data field,
735
+ * a data field or item is not the table's, or no item would show.
736
+ */
737
+ applyFilter(filters: IField.FilterInput, options?: ITransaction.OperationOptions): Promise<void>;
738
+ /**
739
+ * Clears the field's filter of `type`, as one step that can be undone; `manual` shows every
740
+ * item.
741
+ */
742
+ clearFilter(type: IField.FilterType, options?: ITransaction.OperationOptions): Promise<void>;
743
+ /**
744
+ * Clears every filter of the field and shows every item, as one step that can be undone; a page
745
+ * field shows all its items again.
746
+ */
747
+ clearAllFilters(options?: ITransaction.OperationOptions): Promise<void>;
748
+ /**
749
+ * Returns how the field's items are sorted, or `null` when they are in the order listed.
750
+ */
751
+ getSort(): IField.Sort | null;
752
+ /**
753
+ * Sorts the field's items by their labels, as one step that can be undone: numbers, then text
754
+ * without regard to case, logicals, errors, and blanks last; descending is the exact reverse.
755
+ * A sort by value is replaced.
756
+ *
757
+ * @throws ExpectedError When the field is not a row or column field.
758
+ */
759
+ sortByLabels(order: 'ascending' | 'descending', options?: ITransaction.OperationOptions): Promise<void>;
760
+ /**
761
+ * Sorts the field's items under each outer item by a data field's value, as one step that can
762
+ * be undone: their totals, or their values in one line of the other axis.
763
+ *
764
+ * @remarks
765
+ * An empty value sorts as 0. Hiding an item of the scope ends the sort, as in Excel.
766
+ *
767
+ * @param dataField The data field, by name.
768
+ * @param scope The line of the other axis to read: its items' names, outermost field first.
769
+ * Fewer names than the axis has fields name a subtotal line (`['2023']` over Year and Quarter
770
+ * is the 2023 total). Absent or empty, the grand total.
771
+ * @throws ExpectedError When the field is not a row or column field, the data field is not the
772
+ * table's, or the scope names no line of the other axis.
773
+ */
774
+ sortByValues(order: 'ascending' | 'descending', dataField: string, scope?: readonly string[] | null, options?: ITransaction.OperationOptions): Promise<void>;
775
+ /**
776
+ * Returns whether the field shows every item, those with no data included.
777
+ */
778
+ getShowAllItems(): boolean;
779
+ /**
780
+ * Shows every item of the field, those with no data included, or only those with data, as one
781
+ * step that can be undone.
782
+ */
783
+ setShowAllItems(showAllItems: boolean, options?: ITransaction.OperationOptions): Promise<void>;
784
+ /**
785
+ * Renames the field in the table, as one step that can be undone; its source field's name
786
+ * restores the original.
787
+ *
788
+ * @throws ExpectedError When another field or data field of the table has the name.
789
+ */
790
+ setName(name: string, options?: ITransaction.OperationOptions): Promise<void>;
791
+ /** For runtime type checking. */
792
+ readonly isIPivotField: true;
793
+ }
794
+ namespace IField {
795
+ /** What a field's items are ({@link IField.getDataType}). */
796
+ type DataType = 'number' | 'date' | 'text' | 'mixed' | 'blank';
797
+ /** A subtotal a field can show: the automatic one, or a function. */
798
+ type Subtotal = 'automatic' | IDataField.Function;
799
+ /** A kind of filter a field takes. `manual` is the items hidden by hand. */
800
+ type FilterType = 'label' | 'date' | 'value' | 'manual';
801
+ /** A field's filters, by kind; a kind the field does not have is absent. */
802
+ interface Filters {
803
+ label?: ICondition.JSON;
804
+ date?: ICondition.JSON;
805
+ value?: {
806
+ condition: ICondition.JSON;
807
+ dataField: string;
808
+ };
809
+ /** The items shown, when some are hidden by hand. */
810
+ manual?: readonly string[];
811
+ }
812
+ /** Filters to set on a field ({@link IField.applyFilter}); a kind absent is left as it is. */
813
+ interface FilterInput {
814
+ label?: ICondition.Input;
815
+ date?: ICondition.Input;
816
+ /** The data field by name. */
817
+ value?: {
818
+ condition: ICondition.Input;
819
+ dataField: string;
820
+ };
821
+ /** The items shown, by name; `null` every item. */
822
+ manual?: readonly string[] | null;
823
+ }
824
+ /** How a field's items are sorted ({@link IField.getSort}). */
825
+ interface Sort {
826
+ order: 'ascending' | 'descending';
827
+ /** Sorted by this data field's values; absent, by label. */
828
+ dataField?: string;
829
+ /** The line of the other axis the values are read in, outermost item first; absent, the grand total. */
830
+ scope?: readonly string[];
831
+ }
832
+ }
833
+ /**
834
+ * An item of a {@link IField | pivot field}: a value of its cache field, as the table lists it.
835
+ */
836
+ interface IItem {
837
+ /**
838
+ * Returns the item's caption: its own name in the table, else its value as text; `(blank)` for
839
+ * the blank item.
840
+ */
841
+ getName(): string;
842
+ /**
843
+ * Returns the field the item belongs to.
844
+ */
845
+ getField(): IField;
846
+ /**
847
+ * Returns whether the item shows: `false` when it is hidden from the field.
848
+ */
849
+ isVisible(): boolean;
850
+ /**
851
+ * Shows or hides the item, as one step that can be undone.
852
+ *
853
+ * @throws When it is the last item showing.
854
+ */
855
+ setVisible(visible: boolean, options?: ITransaction.OperationOptions): Promise<void>;
856
+ /**
857
+ * Returns whether the item's details show: `false` when it is collapsed.
858
+ */
859
+ isExpanded(): boolean;
860
+ /**
861
+ * Shows or hides the item's details, as one step that can be undone.
862
+ *
863
+ * @remarks
864
+ * An item of the innermost field takes the setting, which shows nothing different, as in Excel.
865
+ *
866
+ * @throws When the field is not a row or column field.
867
+ */
868
+ setExpanded(expanded: boolean, options?: ITransaction.OperationOptions): Promise<void>;
869
+ /**
870
+ * Returns the item's place among the items of its field that show, counted from 1; `null` for
871
+ * a hidden item, or when the field is off the table.
872
+ */
873
+ getPosition(): number | null;
874
+ /**
875
+ * Moves the item among the items of its field that show, as one step that can be undone.
876
+ *
877
+ * @remarks
878
+ * The field's order is then by hand: a sort it had, by label or by value, ends, as in Excel, and
879
+ * the order holds through a refresh. The page pick, a sort by the item's line, a base item and
880
+ * the formats on the item follow it.
881
+ *
882
+ * @param position Its place, counted from 1 as {@link getPosition} counts.
883
+ * @throws ExpectedError For a hidden item or a field off the table, and for a position not
884
+ * among the items that show.
885
+ */
886
+ setPosition(position: number, options?: ITransaction.OperationOptions): Promise<void>;
887
+ /**
888
+ * Renames the item in the table, as one step that can be undone; its value's own text restores
889
+ * the original.
890
+ *
891
+ * @remarks
892
+ * The name is kept as given, spaces and all, and may be empty. Under a sort by label the field
893
+ * is sorted again, by the captions, as in Excel. `GETPIVOTDATA` finds the item by the caption or
894
+ * by its value, and {@link IField.getItem} by the caption alone.
895
+ *
896
+ * @throws ExpectedError When another item of the field has the name, without regard to case.
897
+ */
898
+ setName(name: string, options?: ITransaction.OperationOptions): Promise<void>;
899
+ /** For runtime type checking. */
900
+ readonly isIPivotItem: true;
901
+ }
902
+ /**
903
+ * Options for {@link IPivotTable.refresh}.
904
+ */
905
+ interface RefreshOptions extends ITransaction.OperationOptions {
906
+ /**
907
+ * Whether the cache is read again from the source first; `false` lays the table out from the
908
+ * cache as it is.
909
+ *
910
+ * @defaultValue `true`
911
+ */
912
+ source?: boolean;
913
+ }
914
+ /** Options for {@link IPivotTable.moveTo}. */
915
+ interface MoveOptions extends ITransaction.OperationOptions {
916
+ /**
917
+ * Whether values in the cells the table moves to are cleared; `false` refuses the move instead.
918
+ *
919
+ * @defaultValue `false`
920
+ */
921
+ discardValues?: boolean;
922
+ }
923
+ /**
924
+ * Options for {@link IPivotTable.updateStyleOptions}: the style's name, and which parts of it show.
925
+ */
926
+ interface StyleOptions extends Omit<PivotStyleJSON, 'name'> {
927
+ /** A pivot table style's name; `null` removes the style. */
928
+ name?: string | null;
929
+ }
930
+ /**
931
+ * A pivot cache as the workbook carries it, by the id the tables name.
932
+ *
933
+ * @remarks
934
+ * A cache over a worksheet source is modeled: its fields, their items and the records, which
935
+ * are what a refresh rebuilds and what a pivot is computed from. `part`, the definition and
936
+ * records as they were read, is present only while the cache is unchanged, and is then what is
937
+ * written. A cache with no `fields` is carried as its `part` alone.
53
938
  */
54
939
  interface CacheJSON {
55
940
  cacheId: number;
941
+ /** The parts as read, written as they are while the cache is unchanged. */
56
942
  part?: IEmbeddedPart.JSON;
943
+ /**
944
+ * The cells the records were read from: a sheet and a range, or a table's name. Present for a
945
+ * cache carried as its part too, when it names cells in this workbook.
946
+ */
947
+ source?: CacheSourceJSON;
948
+ fields?: CacheFieldJSON[];
949
+ /**
950
+ * Each field's items: the field's index, then its items in order. A string is literal; a
951
+ * missing item is `{ t: 'z', v: 0 }`; a date is its serial number (see
952
+ * {@link CacheFieldJSON.dates} and {@link CacheFieldJSON.dateItems}).
953
+ */
954
+ items?: Tuple.GridTuple<Scalar.JSON>;
955
+ /**
956
+ * Each field's records: the field's index, then, per record in order, the index of its item
957
+ * in {@link items}. A field with {@link CacheFieldJSON.noRecords} has none. Absent when the file
958
+ * saved no records: its tables are not laid out until a refresh from the source.
959
+ */
960
+ records?: Tuple.GridTuple<number>;
961
+ recordCount?: number;
962
+ refreshOnLoad?: boolean;
963
+ /**
964
+ * For a cache with no `fields`: what the format ids its `part` cites named in the file it was
965
+ * read from.
966
+ * @internal
967
+ */
968
+ partFormats?: PartFormatsJSON;
969
+ /**
970
+ * The definition's markup with what is modeled taken out (the fields, the source's cells, the
971
+ * record count and refresh flag): what the cache holds that is not typed yet.
972
+ */
973
+ rest?: string;
974
+ }
975
+ /**
976
+ * What the format ids in a part carried without a model name, by id, in the file it was read
977
+ * from. A save numbers its formats afresh and restates each id the part cites from these.
978
+ * @internal
979
+ */
980
+ interface PartFormatsJSON {
981
+ /** By `numFmtId`: a custom number format's code. Built-in ids are kept as they are. */
982
+ numberFormats?: Record<number, string>;
983
+ /** By `dxfId`: the differential format. */
984
+ dxfs?: Record<number, ICellStyle.Properties>;
985
+ }
986
+ /**
987
+ * The cells a {@link CacheJSON | cache} was read from.
988
+ */
989
+ interface CacheSourceJSON {
990
+ /** The range, A1 without `$`. With `sheet`. */
991
+ ref?: string;
992
+ sheet?: string;
993
+ /** A table's or a defined name's name, in place of `ref` and `sheet`. */
994
+ name?: string;
995
+ }
996
+ /**
997
+ * One field of a {@link CacheJSON | cache}: a column of its source, or a grouping of one.
998
+ */
999
+ interface CacheFieldJSON {
1000
+ name: string;
1001
+ /** The number format of its values: a format code, or a built-in format's id; absent, General. */
1002
+ numberFormat?: string | number;
1003
+ /** The records hold the values themselves, not the index of a shared item. */
1004
+ inline?: true;
1005
+ /** The items that are numbers are dates. */
1006
+ dates?: true;
1007
+ /**
1008
+ * The items that are dates, by index, when others are plain numbers. A date and a number of the
1009
+ * same value are two items.
1010
+ */
1011
+ dateItems?: number[];
1012
+ /** The items the source no longer holds, kept from an earlier refresh. */
1013
+ unused?: number[];
1014
+ /** Not a column of the source (a grouping or calculated field): the records hold nothing for it. */
1015
+ noRecords?: true;
1016
+ /** How the field groups values, or the field its values are grouped by. */
1017
+ group?: CacheFieldGroupJSON;
1018
+ /** A calculated field's formula, as a file spells it (`Sales-Cost`), with {@link noRecords}. */
1019
+ formula?: string;
1020
+ /**
1021
+ * The field's calculated items: each one's index in its items, and its formula, as a file spells
1022
+ * it (`Region[North]+Region[South]`).
1023
+ */
1024
+ calculatedItems?: {
1025
+ item: number;
1026
+ formula: string;
1027
+ }[];
1028
+ /**
1029
+ * The field's markup with what is modeled taken out (name, number format, items): its
1030
+ * grouping, formula and anything else not typed yet.
1031
+ */
1032
+ rest?: string;
1033
+ }
1034
+ /**
1035
+ * How a {@link CacheFieldJSON | cache field} groups the values of another, or its own.
1036
+ *
1037
+ * @remarks
1038
+ * A table lists a grouping field's {@link items}, not its cache items. With neither
1039
+ * {@link range} nor {@link discrete} the field groups nothing itself and only names its
1040
+ * {@link parent}: a date field grouped by months.
1041
+ */
1042
+ interface CacheFieldGroupJSON {
1043
+ /** The cache field whose values are grouped: this field, for a number range in place. */
1044
+ base: number;
1045
+ /** The next coarser field grouping the same values (Date to Months to Years). */
1046
+ parent?: number;
1047
+ /**
1048
+ * Each group's caption. A range's first and last hold what falls before and after it. An item of
1049
+ * the base that no group holds is its own group here, as itself: a number, a date's serial
1050
+ * number ({@link dateItems}), a boolean, or the items' spelling of a blank or an error
1051
+ * ({@link CacheJSON.items}).
1052
+ */
1053
+ items: Scalar.JSON[];
1054
+ /** The {@link items} that are dates, by index. */
1055
+ dateItems?: number[];
1056
+ /** Groups by range of the base's values. */
1057
+ range?: {
1058
+ by: 'numbers' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'quarters' | 'years';
1059
+ /** The first value; a date is its serial number. */
1060
+ start: number;
1061
+ /** The last value; a date range's whole-day end is the day after the last. */
1062
+ end: number;
1063
+ /** The width of each step, in values or days; absent, 1. */
1064
+ interval?: number;
1065
+ /** The start stays when the source changes, rather than following its least value. */
1066
+ fixedStart?: true;
1067
+ /** The end stays when the source changes, rather than following its greatest value. */
1068
+ fixedEnd?: true;
1069
+ };
1070
+ /** Groups by hand: for each cache item of the base, its index in {@link items}. */
1071
+ discrete?: number[];
57
1072
  }
58
1073
  /**
59
1074
  * JSON representation of a pivot table.
@@ -61,7 +1076,528 @@ export declare namespace IPivotTable {
61
1076
  interface JSON {
62
1077
  name?: string;
63
1078
  cacheId: number;
1079
+ /**
1080
+ * The cells the table's body is laid out on, as an A1 range (`A3:C20`): where it is anchored.
1081
+ * Its page fields sit above it.
1082
+ */
1083
+ location: string;
64
1084
  part?: IEmbeddedPart.JSON;
1085
+ /**
1086
+ * For a table with no `fields`: what the format ids its `part` cites named in the file it was
1087
+ * read from.
1088
+ * @internal
1089
+ */
1090
+ partFormats?: PartFormatsJSON;
1091
+ /**
1092
+ * The cells that show a field button, as addresses relative to the table's top-left cell
1093
+ * (`A1` is that cell).
1094
+ *
1095
+ * @remarks
1096
+ * A button belongs to the table, not to the cell's format: Excel drops it from a copied cell.
1097
+ *
1098
+ * @internal
1099
+ */
1100
+ buttons?: string[];
1101
+ /**
1102
+ * One per field of the cache, in the cache's order.
1103
+ *
1104
+ * @remarks
1105
+ * A table is modeled when its markup holds nothing the model does not type yet on the
1106
+ * elements it reads (OLAP hierarchies, item properties, extensions on a field or data field
1107
+ * other than Excel's own repeat labels and show-values-as); it is then written from the model
1108
+ * once it has no `part`.
1109
+ */
1110
+ fields?: PivotFieldJSON[];
1111
+ /** The fields on the row axis, outermost first, by index; `-2` is where the values sit. */
1112
+ rowFields?: number[];
1113
+ /** The fields on the column axis, outermost first, by index; `-2` is where the values sit. */
1114
+ columnFields?: number[];
1115
+ pageFields?: PageFieldJSON[];
1116
+ dataFields?: DataFieldJSON[];
1117
+ /** Shown unless `false`. */
1118
+ rowGrandTotals?: false;
1119
+ /** Shown unless `false`. */
1120
+ columnGrandTotals?: false;
1121
+ /**
1122
+ * The layout of fields added to the table and of the values; absent, compact. Each field
1123
+ * keeps its own ({@link PivotFieldJSON.form}).
1124
+ */
1125
+ form?: PivotForm;
1126
+ /** How far each level of a compact row field is indented, in characters past the first; absent, 0. */
1127
+ indent?: number;
1128
+ /** The caption of the values field; absent, `Values`. */
1129
+ valuesCaption?: string;
1130
+ /** The caption of the grand totals; absent, `Grand Total`. */
1131
+ grandTotalCaption?: string;
1132
+ /** The caption over the row labels in compact form; absent, `Row Labels`. */
1133
+ rowHeaderCaption?: string;
1134
+ /** The caption over the column labels in compact form; absent, `Column Labels`. */
1135
+ columnHeaderCaption?: string;
1136
+ /** Shown in place of an error value when {@link showError} is `true`. */
1137
+ errorCaption?: string;
1138
+ /** An error value shows as {@link errorCaption}. */
1139
+ showError?: true;
1140
+ /** Shown in a crossing no record falls in, unless {@link showEmpty} is `false`. */
1141
+ emptyCaption?: string;
1142
+ /** `false`: a crossing no record falls in shows 0 rather than {@link emptyCaption}. */
1143
+ showEmpty?: false;
1144
+ /** The values are laid out down the rows, or are to be with a second; their position is `-2` in {@link rowFields}. */
1145
+ valuesOnRows?: true;
1146
+ /**
1147
+ * Below two values, where a second puts them among the fields of their axis, counted from 0; absent,
1148
+ * after the last.
1149
+ */
1150
+ valuesPosition?: number;
1151
+ /** A field takes more than one filter; absent, a new filter on a field replaces its last. */
1152
+ multipleFiltersPerField?: true;
1153
+ /** How many page fields sit in a row (or a column) before the next; absent, 0, no wrap. */
1154
+ pageWrap?: number;
1155
+ /** The page fields run across, then down; absent, down, then across. */
1156
+ pageOverThenDown?: true;
1157
+ /** The items' expand/collapse buttons are hidden; absent, shown. */
1158
+ hiddenDrillIndicators?: true;
1159
+ /** The field captions and their buttons are hidden; absent, shown. */
1160
+ hiddenFieldHeaders?: true;
1161
+ /** The table style and which of its parts show; absent, no style. */
1162
+ style?: PivotStyleJSON;
1163
+ /** The label, value and date filters, in the order they apply. */
1164
+ filters?: PivotFilterJSON[];
1165
+ /** `false`: a refresh drops the formats a user put on the table's cells; absent, they follow their areas. */
1166
+ preserveFormatting?: false;
1167
+ /** `false`: a layout leaves the columns' widths alone; absent, it fits the columns the table covers. */
1168
+ autoFitColumns?: false;
1169
+ /** The formats a user put on parts of the table, in the order they apply. */
1170
+ formats?: PivotFormatJSON[];
1171
+ /** The table's conditional formats: which sheet rule applies where in the table. */
1172
+ conditionalFormats?: PivotConditionalFormatJSON[];
1173
+ /** Where the laid-out parts start; absent, not laid out. */
1174
+ header?: PivotHeaderJSON;
1175
+ /** The lines of the rows as last laid out, top to bottom; absent, not laid out. */
1176
+ rowLines?: PivotLineJSON[];
1177
+ /** The lines of the columns as last laid out, left to right; absent, not laid out. */
1178
+ columnLines?: PivotLineJSON[];
1179
+ /** The definition's markup with what is modeled taken out: anything not typed yet. */
1180
+ rest?: string;
1181
+ }
1182
+ /** How a field's items are laid out: compact (absent), outline, or tabular. */
1183
+ type PivotForm = 'outline' | 'tabular';
1184
+ /** The style of a {@link JSON | pivot table}: a pivot table style by name, and which parts of it show. */
1185
+ interface PivotStyleJSON {
1186
+ name?: string;
1187
+ showRowHeaders?: boolean;
1188
+ showColumnHeaders?: boolean;
1189
+ showRowStripes?: boolean;
1190
+ showColumnStripes?: boolean;
1191
+ showLastColumn?: boolean;
1192
+ }
1193
+ /**
1194
+ * A filter of a {@link JSON | pivot table}: which items of a field show.
1195
+ *
1196
+ * @remarks
1197
+ * A label filter tests each item's caption (the Display selector), a date filter its date (the
1198
+ * Date selector, or a time period), and a value or top filter the item's total of a data field,
1199
+ * within each item of the fields outside it.
1200
+ */
1201
+ interface PivotFilterJSON {
1202
+ /** The field filtered, by index. */
1203
+ field: number;
1204
+ /** A value or top filter: the data field whose total is tested, by index into {@link JSON.dataFields}. */
1205
+ dataField?: number;
1206
+ condition: ICondition.JSON;
1207
+ id?: number;
1208
+ /** The order the filter applies in; absent, -1, the order listed. */
1209
+ evalOrder?: number;
1210
+ name?: string;
1211
+ description?: string;
1212
+ /** A date filter that takes whole days, as a timeline sets it. */
1213
+ useWholeDay?: true;
1214
+ }
1215
+ /** A conditional format of a {@link JSON | pivot table}: a sheet rule, by priority, and the areas it applies to. */
1216
+ interface PivotConditionalFormatJSON {
1217
+ /** The sheet rule's priority, as read. */
1218
+ priority: number;
1219
+ /** What the areas select, as OOXML spells it (`selection`, `data`, `field`). */
1220
+ scope?: string;
1221
+ /** Which way the rule runs over the areas, as OOXML spells it (`none`, `all`, `row`, `column`). */
1222
+ type?: string;
1223
+ areas: PivotAreaJSON[];
1224
+ }
1225
+ /** A format on part of a {@link JSON | pivot table}: what it sets, and where. */
1226
+ interface PivotFormatJSON {
1227
+ /** What it sets, as a conditional format's style holds it. */
1228
+ style: ICellStyle.Properties;
1229
+ area: PivotAreaJSON;
1230
+ /** `blank`: the area shows nothing; absent, the style is applied. */
1231
+ action?: 'blank';
1232
+ }
1233
+ /** A part of a {@link JSON | pivot table}, as a format or a conditional format names it. */
1234
+ interface PivotAreaJSON {
1235
+ /** What kind of part, as OOXML spells it; absent, `normal`: the cells the references pick. */
1236
+ type?: 'data' | 'all' | 'origin' | 'button' | 'topEnd' | 'topRight' | 'none';
1237
+ /** The field, by index; `-2` the values. A button's field, or the field whose labels. */
1238
+ field?: number;
1239
+ /** `false`: labels as well as values; absent, values only. */
1240
+ dataOnly?: false;
1241
+ /** Labels only. */
1242
+ labelOnly?: true;
1243
+ /** The grand total row. */
1244
+ grandRow?: true;
1245
+ /** The grand total column. */
1246
+ grandCol?: true;
1247
+ /** `false`: tabular rather than outline positions; absent, outline. */
1248
+ outline?: false;
1249
+ /** A collapsed item's line counts as its subtotal. */
1250
+ collapsedLevelsAreSubtotals?: true;
1251
+ axis?: Axis;
1252
+ /** The field's position on its axis; absent, 0. */
1253
+ fieldPosition?: number;
1254
+ /** The cells picked, one reference per field. */
1255
+ references?: PivotAreaReferenceJSON[];
1256
+ /** The area's attributes not typed yet (`offset`, `cacheIndex`), as markup; absent, none. */
1257
+ rest?: string;
1258
+ }
1259
+ /** The items of one field a {@link PivotAreaJSON} picks. */
1260
+ interface PivotAreaReferenceJSON {
1261
+ /** The field, by index; `-2` the values. */
1262
+ field: number;
1263
+ /** By index into the field's items, or into the data fields for `-2`; absent, all of them. */
1264
+ items?: number[];
1265
+ /** `false`: the items are not selected; absent, they are. */
1266
+ selected?: false;
1267
+ /** The items count by position, not by index. */
1268
+ byPosition?: true;
1269
+ /** The items are relative to the cell. */
1270
+ relative?: true;
1271
+ /** Which of the field's subtotals, as OOXML spells them (`defaultSubtotal`, `sumSubtotal`, ...). */
1272
+ subtotals?: string[];
1273
+ }
1274
+ /**
1275
+ * One field of a {@link JSON | pivot table}: how the table uses a field of its cache.
1276
+ */
1277
+ interface PivotFieldJSON {
1278
+ axis?: Axis;
1279
+ /** The field is summarized by a data field. */
1280
+ dataField?: true;
1281
+ /** The caption shown for the field. */
1282
+ name?: string;
1283
+ /**
1284
+ * The subtotals shown for the field: `default` is the automatic one. Absent, the automatic
1285
+ * subtotal alone; empty, none.
1286
+ */
1287
+ subtotals?: PivotSubtotal[];
1288
+ /** The whole caption of the field's automatic subtotal lines, in place of `<item> Total`. */
1289
+ subtotalCaption?: string;
1290
+ /** The field's items in the table's order, which is state: a refresh keeps it. */
1291
+ items?: PivotItemJSON[];
1292
+ /** How the field's items are laid out; absent, compact. */
1293
+ form?: PivotForm;
1294
+ /** `false`: the field's subtotals sit under its items rather than on their row. */
1295
+ subtotalsOnTop?: false;
1296
+ /** A blank line follows each item. */
1297
+ blankRowAfter?: true;
1298
+ /** Items no record falls in show as well. */
1299
+ showItemsWithNoData?: true;
1300
+ /** Each item's label repeats on every line it spans. */
1301
+ repeatLabels?: true;
1302
+ /** The number format of the items' labels: a format code, or a built-in format's id; absent, General. */
1303
+ numberFormat?: string | number;
1304
+ /**
1305
+ * The items are sorted by label, or by the total of a data field (by index into
1306
+ * {@link JSON.dataFields}); absent, they stay in {@link items}' order.
1307
+ */
1308
+ sort?: {
1309
+ order: 'ascending' | 'descending';
1310
+ dataField?: number;
1311
+ /** Sorted by one line of the other axis rather than by its grand total; absent, the total. */
1312
+ scope?: PivotSortScopeJSON;
1313
+ };
1314
+ /** Items new to the cache show after a refresh while the field is filtered. */
1315
+ includeNewItemsInFilter?: true;
1316
+ /** A page field shows more than one item. */
1317
+ multipleItemSelection?: true;
1318
+ /** The field's markup with what is modeled taken out. */
1319
+ rest?: string;
1320
+ }
1321
+ /**
1322
+ * The line of the other axis a {@link PivotFieldJSON.sort | sort by value} reads: its items, as a
1323
+ * line's path names them.
1324
+ */
1325
+ interface PivotSortScopeJSON {
1326
+ /** The line's items, outermost field of the other axis first; each by index into its field's items. */
1327
+ items: {
1328
+ field: number;
1329
+ item: number;
1330
+ }[];
1331
+ /** The line is its innermost item's subtotal (a `2023 Total` column) rather than the item's own line. */
1332
+ subtotal?: true;
1333
+ }
1334
+ /**
1335
+ * One line of a laid-out {@link JSON | pivot table}'s rows or columns: an item, a subtotal, the
1336
+ * grand total, or a blank row, as Excel stores it in `rowItems` and `colItems`.
1337
+ *
1338
+ * @remarks
1339
+ * A line names its items by index into each axis field's {@link PivotFieldJSON.items}, from the
1340
+ * outermost field in; where the values sit, the index is a data field's. The first
1341
+ * {@link repeat} of them are the line above's and are left out.
1342
+ */
1343
+ interface PivotLineJSON {
1344
+ /** Absent: an item. `default` (or a subtotal function) for a subtotal, `grand`, `blank`. */
1345
+ type?: string;
1346
+ /** How many leading items are the same as the line above's, and so not in {@link items}. */
1347
+ repeat?: number;
1348
+ /** The item indexes after the repeated ones. */
1349
+ items: number[];
1350
+ /** The data field the line shows, by index into {@link JSON.dataFields}; absent, the first. */
1351
+ dataField?: number;
1352
+ }
1353
+ /**
1354
+ * Where a laid-out {@link JSON | pivot table}'s parts start, relative to its location's
1355
+ * top-left cell, as Excel stores them on `location`.
1356
+ */
1357
+ interface PivotHeaderJSON {
1358
+ /** The row of the column items' labels. */
1359
+ firstHeaderRow: number;
1360
+ /** The first row of values. */
1361
+ firstDataRow: number;
1362
+ /** The first column of values. */
1363
+ firstDataCol: number;
1364
+ }
1365
+ /** A subtotal function of a {@link PivotFieldJSON | field}, as OOXML spells it. */
1366
+ type PivotSubtotal = 'default' | 'sum' | 'countA' | 'avg' | 'max' | 'min' | 'product' | 'count' | 'stdDev' | 'stdDevP' | 'var' | 'varP';
1367
+ /**
1368
+ * One item of a {@link PivotFieldJSON | field}: an item of the cache field, or a subtotal or
1369
+ * grand-total line.
1370
+ */
1371
+ interface PivotItemJSON {
1372
+ /** The index of the item in the cache field's items. */
1373
+ item?: number;
1374
+ /** The line it is, when not an item of the cache, as OOXML spells it (`default`, `sum`, `grand`…). */
1375
+ type?: string;
1376
+ hidden?: true;
1377
+ /** Its details are not shown. */
1378
+ collapsed?: true;
1379
+ /** The caption shown in place of the item's value. */
1380
+ name?: string;
1381
+ /** A calculated item: its value is a formula over the field's other items, the cache's. */
1382
+ calculated?: true;
1383
+ /** The item is no longer in the source; kept until a refresh drops it. */
1384
+ missing?: true;
1385
+ }
1386
+ /**
1387
+ * A field on the page axis and the item it shows.
1388
+ */
1389
+ interface PageFieldJSON {
1390
+ /** The field, by index. */
1391
+ field: number;
1392
+ /** The item shown, by index into the field's {@link PivotFieldJSON.items}; absent, all. */
1393
+ item?: number;
1394
+ }
1395
+ /**
1396
+ * A value of a {@link JSON | pivot table}: a field of the cache summarized by a function.
1397
+ */
1398
+ interface DataFieldJSON {
1399
+ name: string;
1400
+ /** The field summarized, by index. */
1401
+ field: number;
1402
+ /** The function, as OOXML spells it; absent, `sum`. */
1403
+ subtotal?: string;
1404
+ /**
1405
+ * How the value is shown, as OOXML spells it (`percentOfTotal`, `difference`,
1406
+ * `percentOfParentRow`, `rankAscending`…); absent, as is.
1407
+ */
1408
+ showDataAs?: string;
1409
+ /** The field `showDataAs` compares against, by index. */
1410
+ baseField?: number;
1411
+ /**
1412
+ * The item of {@link baseField} `showDataAs` compares against: by index, or the one before or
1413
+ * after each item.
1414
+ */
1415
+ baseItem?: number | 'previous' | 'next';
1416
+ /** The number format of its values: a format code, or a built-in format's id; absent, General. */
1417
+ numberFormat?: string | number;
1418
+ }
1419
+ /**
1420
+ * A value of a pivot table: a field summarized by a function.
1421
+ *
1422
+ * @remarks
1423
+ * A view of the table, found by its caption: what is asked of it after the value is deleted, or after
1424
+ * another view has renamed it, throws. Each change lays the table out again from its cache, as one
1425
+ * step that can be undone, and a table that grows over cells that hold anything shows `#SPILL!`.
1426
+ */
1427
+ interface IDataField {
1428
+ /** Returns its caption. */
1429
+ getName(): string;
1430
+ /**
1431
+ * Changes its caption.
1432
+ *
1433
+ * @remarks
1434
+ * Its source's caption is taken, unless that field has been renamed; so is any other field's, any
1435
+ * other value's and the {@link IValuesField | values'}, without regard to case.
1436
+ *
1437
+ * @throws ExpectedError For a caption taken.
1438
+ */
1439
+ setName(name: string, options?: ITransaction.OperationOptions): Promise<void>;
1440
+ /** Returns the field it summarizes. */
1441
+ getField(): IField;
1442
+ /** Returns the function it summarizes by. */
1443
+ getFunction(): IDataField.Function;
1444
+ /**
1445
+ * Changes the function it summarizes by.
1446
+ *
1447
+ * @remarks
1448
+ * Its caption changes too, a caption typed by hand included, as in Excel: what comes before its
1449
+ * first ` of ` takes the function's name, a caption with none becomes the function's name and the
1450
+ * field's (`Average of Sales`), and one that is taken is numbered. Its number format stays. Nothing
1451
+ * changes when the function is the one it has.
1452
+ *
1453
+ * A value over a calculated field takes the function in name alone, as in Excel: its formula
1454
+ * decides what it shows.
1455
+ *
1456
+ * @throws ExpectedError For a function that is none.
1457
+ */
1458
+ setFunction(fn: IDataField.Function, options?: ITransaction.OperationOptions): Promise<void>;
1459
+ /**
1460
+ * Returns the caption it would take with `fn`, as {@link setFunction} gives it; its own when `fn`
1461
+ * is its function already.
1462
+ *
1463
+ * @example
1464
+ * ```ts
1465
+ * value.getName(); // 'Sum of Sales'
1466
+ * value.getCaptionFor('average'); // 'Average of Sales'
1467
+ * ```
1468
+ *
1469
+ * @throws ExpectedError For a function that is none.
1470
+ */
1471
+ getCaptionFor(fn: IDataField.Function): string;
1472
+ /** Returns how it is shown; `null` as it is. */
1473
+ getShowAs(): IDataField.ShowAs | null;
1474
+ /**
1475
+ * Changes how it is shown; `null` shows it as it is.
1476
+ *
1477
+ * @remarks
1478
+ * A kind that reads a base field and is given none reads the one it has, at first the cache's
1479
+ * first; every line shows `#N/A` when that is not on the rows or columns. A new base field starts
1480
+ * at its first item. The base stays when the kind changes, and through `null`.
1481
+ *
1482
+ * The number format changes with the kind, as in Excel. A kind that shows a share takes `0.00%`
1483
+ * unless it reads as a percent already; a rank or an index drops what it has; going from a share to
1484
+ * any other drops a percent format. A format on single cells stays over any of it.
1485
+ *
1486
+ * @example
1487
+ * ```ts
1488
+ * await value.setShowAs({ kind: 'percentOfTotal' });
1489
+ * await value.setShowAs({ kind: 'difference', baseField: 'Year', baseItem: '(previous)' });
1490
+ * await value.setShowAs(null);
1491
+ * ```
1492
+ *
1493
+ * @throws ExpectedError For a kind that is none, or a base field or item that is not the table's.
1494
+ */
1495
+ setShowAs(rule: IDataField.ShowAs | null, options?: ITransaction.OperationOptions): Promise<void>;
1496
+ /** Returns the format code its values show in. */
1497
+ getNumberFormat(): string;
1498
+ /**
1499
+ * Changes the format of its values, over any number format on single cells of them, whose other
1500
+ * formats (a fill) stay.
1501
+ *
1502
+ * @param format A format code, or a built-in format's id.
1503
+ * @throws ExpectedError For a format that does not parse.
1504
+ */
1505
+ setNumberFormat(format: string | number, options?: ITransaction.OperationOptions): Promise<void>;
1506
+ /** Returns its place among the values, counted from 1. */
1507
+ getPosition(): number;
1508
+ /**
1509
+ * Moves it among the values. A sort, a value filter and the formats on it follow it.
1510
+ *
1511
+ * @param position Its place, counted from 1.
1512
+ * @throws ExpectedError For a position that is not among the values.
1513
+ */
1514
+ setPosition(position: number, options?: ITransaction.OperationOptions): Promise<void>;
1515
+ /**
1516
+ * Takes it off the table.
1517
+ *
1518
+ * @remarks
1519
+ * What names it goes too: a sort by it leaves its items in their listed order, and a value filter
1520
+ * and the formats on it are gone for good. Its source stays on any axis it is on. The
1521
+ * {@link IValuesField | values field} goes below two values, and comes back where it was. A table
1522
+ * with nothing left on it is empty again.
1523
+ */
1524
+ delete(options?: ITransaction.OperationOptions): Promise<void>;
1525
+ /** Returns the table it belongs to. */
1526
+ getPivotTable(): IPivotTable;
1527
+ /** For runtime type checking. */
1528
+ readonly isIPivotDataField: true;
1529
+ }
1530
+ /**
1531
+ * Where a table's values sit among the fields of an axis, with two or more of them.
1532
+ *
1533
+ * @remarks
1534
+ * A view of the table. While a table has fewer than two values they sit nowhere, and the table keeps
1535
+ * the axis and the place for the next.
1536
+ */
1537
+ interface IValuesField {
1538
+ /** Returns its caption. */
1539
+ getName(): string;
1540
+ /**
1541
+ * Changes its caption, which no field or value of the table can have, without regard to case.
1542
+ *
1543
+ * @throws ExpectedError For a caption taken.
1544
+ */
1545
+ setName(name: string, options?: ITransaction.OperationOptions): Promise<void>;
1546
+ /** Returns the axis the values are on; `null` once they have gone. */
1547
+ getAxis(): Axis | null;
1548
+ /**
1549
+ * Moves the values to the rows or the columns, as one step that can be undone; `null` deletes every
1550
+ * value.
1551
+ *
1552
+ * @param position Its place, counted from 1, among the axis's fields; absent, after the last, and
1553
+ * nothing when it is on `axis`.
1554
+ * @throws ExpectedError For the page axis, the values, or a position not on the axis.
1555
+ */
1556
+ setAxis(axis: Axis | null, position?: number, options?: ITransaction.OperationOptions): Promise<void>;
1557
+ /** Returns its place among the fields of its axis, counted from 1; `null` once the values have gone. */
1558
+ getPosition(): number | null;
1559
+ /**
1560
+ * Moves it along its axis, as one step that can be undone.
1561
+ *
1562
+ * @param position Its place, counted from 1.
1563
+ * @throws ExpectedError For a position not on the axis, or once the values have gone.
1564
+ */
1565
+ setPosition(position: number, options?: ITransaction.OperationOptions): Promise<void>;
1566
+ /** Returns the table it belongs to. */
1567
+ getPivotTable(): IPivotTable;
1568
+ /** For runtime type checking. */
1569
+ readonly isIPivotValuesField: true;
1570
+ }
1571
+ /** What belongs to {@link IDataField}. */
1572
+ namespace IDataField {
1573
+ /** A function that summarizes a value, as OOXML spells it. */
1574
+ type Function = 'sum' | 'count' | 'average' | 'max' | 'min' | 'product' | 'countNums' | 'stdDev' | 'stdDevp' | 'var' | 'varp';
1575
+ /** How a value can be shown, as OOXML spells it. */
1576
+ type ShowAsKind = 'percentOfTotal' | 'percentOfRow' | 'percentOfCol' | 'index' | 'percentOfParentRow' | 'percentOfParentCol' | 'percentOfParent' | 'runTotal' | 'percentOfRunningTotal' | 'rankAscending' | 'rankDescending' | 'difference' | 'percent' | 'percentDiff';
1577
+ /** How a value is shown. */
1578
+ interface ShowAs {
1579
+ kind: ShowAsKind;
1580
+ /** The field a kind reads across, by caption; absent, the one it has. */
1581
+ baseField?: string;
1582
+ /**
1583
+ * The item of {@link baseField} a kind compares with, by caption, or `(previous)` or `(next)` for
1584
+ * the neighbor of each item; absent, the one it has.
1585
+ */
1586
+ baseItem?: string;
1587
+ }
1588
+ /** A value to add. */
1589
+ interface Input {
1590
+ /** The field to summarize. */
1591
+ field: string;
1592
+ /** Absent, the function's name and the field's (`Sum of Sales`), numbered when taken. */
1593
+ name?: string;
1594
+ /**
1595
+ * Absent, sum for a column of numbers and count for any other.
1596
+ */
1597
+ function?: Function;
1598
+ /** A format code, or a built-in format's id; absent, General. */
1599
+ numberFormat?: string | number;
1600
+ }
65
1601
  }
66
1602
  /**
67
1603
  * `Events` for {@link IPivotTable}.