documonster 0.18.1 → 0.18.2

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * documonster v0.18.1
2
+ * documonster v0.18.2
3
3
  * Zero-dependency TypeScript toolkit for Excel, Word, PDF, CSV, Markdown, XML & ZIP — one API across Node.js, Bun & browsers.
4
4
  * (c) 2025 cjnoname
5
5
  * Released under the Apache-2.0 License
@@ -199,6 +199,24 @@ export interface PivotTable {
199
199
  cacheDefinition?: ParsedCacheDefinition;
200
200
  /** Cache records for loaded pivot tables */
201
201
  cacheRecords?: ParsedCacheRecords;
202
+ /** Caption of the data field, shown with two or more data items. */
203
+ dataCaption?: string;
204
+ /** Caption for grand totals. */
205
+ grandTotalCaption?: string;
206
+ /** Header caption over the row labels (compact layout). */
207
+ rowHeaderCaption?: string;
208
+ /** Header caption over the column labels (compact layout). */
209
+ colHeaderCaption?: string;
210
+ /** Whether `errorCaption` replaces error values. */
211
+ showError?: string;
212
+ /** String shown in place of an error value. */
213
+ errorCaption?: string;
214
+ /** Whether `missingCaption` is shown for empty values. */
215
+ showMissing?: string;
216
+ /** String shown for an empty value. */
217
+ missingCaption?: string;
218
+ /** User-defined string associated with the table. */
219
+ tag?: string;
202
220
  /** Root chartFormat attribute used by pivot charts. */
203
221
  chartFormat?: number;
204
222
  /** Chart format entries used by pivot charts. */
@@ -107,6 +107,22 @@ export interface PivotViewModel {
107
107
  }[];
108
108
  /** The caption above the data-field column when there are two or more data items. */
109
109
  readonly dataCaption: string;
110
+ /** `irstGrand`: a user-defined grand-total caption. Absent means the application's own. */
111
+ readonly grandTotalCaption?: string;
112
+ /** `fDisplayErrorString`: show `errorCaption` in place of an error value. */
113
+ readonly showError?: boolean;
114
+ /** `irstErrorString`. */
115
+ readonly errorCaption?: string;
116
+ /** `fDisplayNullString`: show `missingCaption` for an empty value. Defaults to true, as XLSX's `showMissing`. */
117
+ readonly showMissing?: boolean;
118
+ /** `irstNullString`. */
119
+ readonly missingCaption?: string;
120
+ /** `irstTag`. */
121
+ readonly tag?: string;
122
+ /** `irstRwHdrName`: the row header caption in compact layout. */
123
+ readonly rowHeaderCaption?: string;
124
+ /** `irstColHdrName`: the column header caption in compact layout. */
125
+ readonly colHeaderCaption?: string;
110
126
  }
111
127
  /**
112
128
  * `pivotTable{n}.bin`.
@@ -33,6 +33,8 @@ interface PivotTableRenderModel {
33
33
  * Items can reference a shared item index (x attribute) or indicate a subtotal type (t attribute).
34
34
  */
35
35
  interface PivotFieldItem {
36
+ /** User caption — the name the item was renamed to in Excel */
37
+ n?: string;
36
38
  /** Shared item index (maps to cacheField sharedItems) */
37
39
  x?: number;
38
40
  /** Item type: "default" for subtotals, "sum", "count", "avg", "max", "min", "grand", etc. */
@@ -49,6 +51,10 @@ interface PivotFieldItem {
49
51
  c?: string;
50
52
  /** Drill across flag */
51
53
  d?: string;
54
+ /** Value-is-string flag (OLAP) */
55
+ s?: string;
56
+ /** Expanded flag (OLAP) */
57
+ e?: string;
52
58
  }
53
59
  /**
54
60
  * Parsed pivot field
@@ -69,6 +75,18 @@ interface ParsedPivotField {
69
75
  multipleItemSelectionAllowed?: boolean;
70
76
  /** Bag of additional attributes not individually modeled (for roundtrip preservation) */
71
77
  extraAttrs?: Record<string, string>;
78
+ /** Preserved field-level `<extLst>` XML (e.g. x14:pivotField fillDownLabels) */
79
+ extLstXml?: string;
80
+ }
81
+ /**
82
+ * Parsed data field (value field). Extends the public shape with what a
83
+ * loaded file carries but the builder never produces.
84
+ */
85
+ interface ParsedDataField extends DataField {
86
+ /** Attributes not individually modeled, e.g. `showDataAs` (for roundtrip preservation) */
87
+ extraAttrs?: Record<string, string>;
88
+ /** Preserved field-level `<extLst>` XML (e.g. x14:dataField pivotShowAs) */
89
+ extLstXml?: string;
72
90
  }
73
91
  /**
74
92
  * Parsed page field (report filter)
@@ -78,6 +96,10 @@ interface ParsedPageField {
78
96
  item?: number;
79
97
  hier?: number;
80
98
  name?: string;
99
+ /** Display caption of the hierarchy (OLAP) */
100
+ cap?: string;
101
+ /** Preserved field-level `<extLst>` XML */
102
+ extLstXml?: string;
81
103
  }
82
104
  /**
83
105
  * Parsed pivot table model (loaded from file)
@@ -98,7 +120,7 @@ interface ParsedPivotTableModel {
98
120
  rowFields: number[];
99
121
  colFields: number[];
100
122
  pageFields: ParsedPageField[];
101
- dataFields: DataField[];
123
+ dataFields: ParsedDataField[];
102
124
  applyNumberFormats?: string;
103
125
  applyBorderFormats?: string;
104
126
  applyFontFormats?: string;
@@ -135,6 +157,17 @@ interface ParsedPivotTableModel {
135
157
  showMissing?: string;
136
158
  missingCaption?: string;
137
159
  grandTotalCaption?: string;
160
+ /** Header caption over the row labels in compact layout */
161
+ rowHeaderCaption?: string;
162
+ /** Header caption over the column labels in compact layout */
163
+ colHeaderCaption?: string;
164
+ /** User-defined string associated with the table */
165
+ tag?: string;
166
+ /**
167
+ * Root attributes not individually modeled — showHeaders, pageStyle,
168
+ * mc:Ignorable, … — preserved verbatim for roundtrip.
169
+ */
170
+ extraRootAttrs?: Record<string, string>;
138
171
  rowItems?: RowColItem[];
139
172
  colItems?: RowColItem[];
140
173
  hasColFields?: boolean;
@@ -174,9 +207,16 @@ declare class PivotTableXform extends BaseXform<ParsedPivotTableModel | null> {
174
207
  private currentRowItem;
175
208
  private currentColItem;
176
209
  private currentChartFormat;
177
- private pivotAreaXmlBuffer;
178
- private autoSortScopeXmlBuffer;
210
+ private currentDataField;
211
+ private currentPageField;
179
212
  private extLstCollector;
213
+ /**
214
+ * Verbatim capture of a subtree that belongs to the element being parsed —
215
+ * a field's own `<extLst>`, a pivotField's `<autoSortScope>`, a chartFormat's
216
+ * `<pivotArea>`. `commit` receives the XML once the subtree closes.
217
+ */
218
+ private nestedCollector;
219
+ private nestedCommit;
180
220
  private formatsCollector;
181
221
  private conditionalFormatsCollector;
182
222
  private filtersCollector;
@@ -217,6 +257,8 @@ declare class PivotTableXform extends BaseXform<ParsedPivotTableModel | null> {
217
257
  private renderPivotFieldLoaded;
218
258
  parseOpen(node: ParseOpenTag): boolean;
219
259
  parseText(text: string): void;
260
+ /** Begin capturing the subtree rooted at `name`; `commit` receives it when it closes. */
261
+ private startNested;
220
262
  /** Feed a close-tag to a collector; if it completes, store the result on the model. */
221
263
  private tryCloseCollector;
222
264
  parseClose(name: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "documonster",
3
- "version": "0.18.1",
3
+ "version": "0.18.2",
4
4
  "description": "Zero-dependency TypeScript toolkit for Excel, Word, PDF, CSV, Markdown, XML & ZIP — one API across Node.js, Bun & browsers.",
5
5
  "keywords": [
6
6
  "archive",