@shbernal/ts-xlsx 1.3.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -10
- package/dist/bytes.d.ts +24 -0
- package/dist/bytes.js +34 -0
- package/dist/core/address.d.ts +72 -3
- package/dist/core/address.js +50 -10
- package/dist/core/autofilter.d.ts +13 -2
- package/dist/core/autofilter.js +35 -10
- package/dist/core/cell.d.ts +17 -16
- package/dist/core/cell.js +3 -7
- package/dist/core/color-resolution.d.ts +8 -8
- package/dist/core/color-resolution.js +7 -8
- package/dist/core/column.d.ts +8 -9
- package/dist/core/column.js +2 -4
- package/dist/core/comment-thread.d.ts +32 -23
- package/dist/core/comment-thread.js +4 -4
- package/dist/core/conditional-formatting-overlay.d.ts +6 -1
- package/dist/core/conditional-formatting-overlay.js +11 -0
- package/dist/core/conditional-formatting.d.ts +48 -8
- package/dist/core/conditional-formatting.js +88 -0
- package/dist/core/data-validation-overlay.d.ts +12 -1
- package/dist/core/data-validation-overlay.js +21 -2
- package/dist/core/data-validation.d.ts +12 -5
- package/dist/core/data-validation.js +34 -0
- package/dist/core/date.d.ts +3 -3
- package/dist/core/formula.d.ts +6 -6
- package/dist/core/grid-edits.d.ts +16 -0
- package/dist/core/grid-edits.js +29 -11
- package/dist/core/grid-shift.d.ts +19 -0
- package/dist/core/grid-shift.js +8 -0
- package/dist/core/image.d.ts +39 -2
- package/dist/core/image.js +10 -0
- package/dist/core/internal.d.ts +9 -1
- package/dist/core/limits.d.ts +4 -4
- package/dist/core/merge.d.ts +17 -12
- package/dist/core/merge.js +36 -5
- package/dist/core/page-setup.d.ts +20 -6
- package/dist/core/page-setup.js +8 -1
- package/dist/core/pivot-table.d.ts +4 -4
- package/dist/core/pivot-table.js +29 -20
- package/dist/core/preserved.d.ts +3 -3
- package/dist/core/protection.d.ts +7 -4
- package/dist/core/protection.js +20 -14
- package/dist/core/range.d.ts +16 -14
- package/dist/core/range.js +5 -5
- package/dist/core/row-input.d.ts +9 -8
- package/dist/core/row-input.js +12 -10
- package/dist/core/row.d.ts +7 -8
- package/dist/core/row.js +2 -4
- package/dist/core/style.d.ts +41 -14
- package/dist/core/style.js +82 -67
- package/dist/core/table-style.d.ts +9 -9
- package/dist/core/table-style.js +1 -1
- package/dist/core/table.d.ts +53 -51
- package/dist/core/table.js +83 -41
- package/dist/core/theme.d.ts +16 -44
- package/dist/core/theme.js +6 -148
- package/dist/core/value.d.ts +7 -7
- package/dist/core/workbook-protection.d.ts +2 -2
- package/dist/core/workbook-styles.d.ts +26 -0
- package/dist/core/workbook-styles.js +48 -0
- package/dist/core/workbook-theme.d.ts +25 -0
- package/dist/core/workbook-theme.js +49 -0
- package/dist/core/workbook-vba.d.ts +17 -0
- package/dist/core/workbook-vba.js +79 -0
- package/dist/core/workbook.d.ts +133 -87
- package/dist/core/workbook.js +74 -133
- package/dist/core/worksheet-comments.d.ts +17 -0
- package/dist/core/worksheet-comments.js +70 -0
- package/dist/core/worksheet-model.d.ts +4 -4
- package/dist/core/worksheet-model.js +1 -0
- package/dist/core/worksheet-pictures.d.ts +29 -0
- package/dist/core/worksheet-pictures.js +42 -0
- package/dist/core/worksheet.d.ts +100 -79
- package/dist/core/worksheet.js +63 -142
- package/dist/customui/errors.d.ts +1 -1
- package/dist/customui/ribbon.d.ts +3 -3
- package/dist/customui/ribbon.js +24 -23
- package/dist/entries/core.d.ts +7 -7
- package/dist/entries/core.js +1 -1
- package/dist/entries/csv.d.ts +1 -1
- package/dist/entries/node-unavailable.d.ts +15 -0
- package/dist/entries/node-unavailable.js +20 -0
- package/dist/entries/node.d.ts +1 -0
- package/dist/entries/node.js +1 -0
- package/dist/entries/vba.d.ts +1 -1
- package/dist/entries/vba.js +1 -1
- package/dist/entries/xlsx.d.ts +1 -1
- package/dist/entries/xlsx.js +1 -1
- package/dist/errors.d.ts +12 -12
- package/dist/io/csv/read.js +2 -3
- package/dist/io/csv/write.d.ts +19 -4
- package/dist/io/csv/write.js +34 -4
- package/dist/io/opc/errors.d.ts +6 -6
- package/dist/io/opc/inflate.d.ts +1 -1
- package/dist/io/opc/inflate.js +2 -12
- package/dist/io/opc/namespaces.d.ts +1 -1
- package/dist/io/opc/read-opc.d.ts +19 -3
- package/dist/io/opc/read-opc.js +14 -8
- package/dist/io/opc/read-options.d.ts +2 -2
- package/dist/io/opc/rels.d.ts +11 -0
- package/dist/io/opc/rels.js +3 -2
- package/dist/io/opc/sniff-format.d.ts +2 -2
- package/dist/io/style/xf-style.d.ts +44 -7
- package/dist/io/style/xf-style.js +27 -0
- package/dist/io/xlsb/errors.d.ts +1 -1
- package/dist/io/xlsb/formula.d.ts +4 -4
- package/dist/io/xlsb/primitives.d.ts +8 -8
- package/dist/io/xlsb/ptg-functions.d.ts +1 -1
- package/dist/io/xlsb/read-styles.js +2 -20
- package/dist/io/xlsb/read.d.ts +2 -2
- package/dist/io/xlsx/cell-accumulator.d.ts +26 -9
- package/dist/io/xlsx/cell-accumulator.js +89 -46
- package/dist/io/xlsx/cell-value.d.ts +3 -3
- package/dist/io/xlsx/cell-value.js +9 -6
- package/dist/io/xlsx/color-xml.d.ts +1 -1
- package/dist/io/xlsx/color-xml.js +18 -23
- package/dist/io/xlsx/comments.d.ts +5 -5
- package/dist/io/xlsx/comments.js +17 -8
- package/dist/io/xlsx/conditional-formatting.d.ts +4 -4
- package/dist/io/xlsx/conditional-formatting.js +64 -58
- package/dist/io/xlsx/data-validation.d.ts +3 -3
- package/dist/io/xlsx/data-validation.js +35 -33
- package/dist/io/xlsx/errors.d.ts +3 -3
- package/dist/io/xlsx/hyperlinks.d.ts +4 -2
- package/dist/io/xlsx/hyperlinks.js +10 -18
- package/dist/io/xlsx/images.d.ts +1 -1
- package/dist/io/xlsx/images.js +25 -28
- package/dist/io/xlsx/namespaces.d.ts +2 -2
- package/dist/io/xlsx/package-plan.js +5 -2
- package/dist/io/xlsx/read-pivot.js +4 -13
- package/dist/io/xlsx/read-rows.d.ts +13 -13
- package/dist/io/xlsx/read-rows.js +19 -55
- package/dist/io/xlsx/read-shared-strings.js +7 -44
- package/dist/io/xlsx/read-styles.d.ts +3 -3
- package/dist/io/xlsx/read-styles.js +42 -66
- package/dist/io/xlsx/read-worksheet.js +73 -129
- package/dist/io/xlsx/read.d.ts +4 -6
- package/dist/io/xlsx/read.js +104 -142
- package/dist/io/xlsx/rich-runs.d.ts +41 -7
- package/dist/io/xlsx/rich-runs.js +94 -30
- package/dist/io/xlsx/rich-text.d.ts +1 -1
- package/dist/io/xlsx/shared-strings.d.ts +2 -2
- package/dist/io/xlsx/sheet-properties.d.ts +1 -1
- package/dist/io/xlsx/sheet-properties.js +14 -10
- package/dist/io/xlsx/styles.d.ts +9 -22
- package/dist/io/xlsx/styles.js +65 -89
- package/dist/io/xlsx/tables.d.ts +2 -2
- package/dist/io/xlsx/tables.js +20 -25
- package/dist/io/xlsx/theme-xml.d.ts +37 -0
- package/dist/io/xlsx/theme-xml.js +145 -0
- package/dist/io/xlsx/threaded-comments.d.ts +18 -27
- package/dist/io/xlsx/threaded-comments.js +26 -38
- package/dist/io/xlsx/workbook-xml.js +14 -8
- package/dist/io/xlsx/worksheet-xml.d.ts +2 -2
- package/dist/io/xlsx/worksheet-xml.js +40 -48
- package/dist/io/xlsx/write-stream.d.ts +23 -16
- package/dist/io/xlsx/write-stream.js +13 -14
- package/dist/io/xlsx/write.d.ts +8 -7
- package/dist/io/xlsx/write.js +6 -3
- package/dist/io/xlsx/x14-ext.d.ts +1 -1
- package/dist/sha512.d.ts +2 -0
- package/dist/sha512.js +146 -0
- package/dist/vba/bytes.d.ts +11 -0
- package/dist/vba/bytes.js +29 -0
- package/dist/vba/cfb-writer.d.ts +1 -1
- package/dist/vba/cfb.d.ts +1 -1
- package/dist/vba/cfb.js +15 -51
- package/dist/vba/codepage.d.ts +2 -2
- package/dist/vba/dir-records.d.ts +53 -0
- package/dist/vba/dir-records.js +28 -0
- package/dist/vba/errors.d.ts +2 -2
- package/dist/vba/index.d.ts +2 -2
- package/dist/vba/index.js +2 -2
- package/dist/vba/ms-ovba.d.ts +1 -1
- package/dist/vba/ms-ovba.js +1 -3
- package/dist/vba/project-editor.d.ts +9 -9
- package/dist/vba/project-editor.js +6 -44
- package/dist/vba/project.d.ts +5 -5
- package/dist/vba/project.js +3 -28
- package/dist/vba/vba-encoding.d.ts +1 -1
- package/dist/xml/errors.d.ts +1 -1
- package/dist/xml/xml-read.d.ts +98 -9
- package/dist/xml/xml-read.js +70 -0
- package/dist/xml/xml.d.ts +74 -10
- package/dist/xml/xml.js +39 -7
- package/package.json +59 -36
package/dist/core/worksheet.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type AutoFilter } from './autofilter.ts';
|
|
2
2
|
import { Cell } from './cell.ts';
|
|
3
3
|
import { Column } from './column.ts';
|
|
4
|
-
import {
|
|
4
|
+
import type { CommentThread } from './comment-thread.ts';
|
|
5
5
|
import type { ConditionalFormatting } from './conditional-formatting.ts';
|
|
6
6
|
import type { DataValidation, DataValidationEntry } from './data-validation.ts';
|
|
7
|
-
import {
|
|
7
|
+
import type { AnchoredImage, AnchorPoint, ImageAnchor, ImageEditAs } from './image.ts';
|
|
8
8
|
import { INTERNAL } from './internal.ts';
|
|
9
9
|
import type { HeaderFooter, PageBreak, PageMargins, PageSetup, PrintOptions } from './page-setup.ts';
|
|
10
10
|
import { type ParsedPivotTable, PivotTable, type PivotTableOptions } from './pivot-table.ts';
|
|
@@ -15,9 +15,19 @@ import { Row } from './row.ts';
|
|
|
15
15
|
import type { CellStyle, Color, Fill } from './style.ts';
|
|
16
16
|
import { Table, type TableOptions } from './table.ts';
|
|
17
17
|
import type { CellValue } from './value.ts';
|
|
18
|
+
/**
|
|
19
|
+
* Whether a thing Excel can hide is showing: a sheet's tab, or the document window itself.
|
|
20
|
+
*
|
|
21
|
+
* One type for two schema enumerations. `ST_SheetState` and `ST_Visibility` are declared separately
|
|
22
|
+
* in ECMA-376 and carry the same three tokens with the same meanings, and `veryHidden` means the same
|
|
23
|
+
* thing in both: hidden, and not offered in the unhide list.
|
|
24
|
+
*/
|
|
25
|
+
export type Visibility = 'visible' | 'hidden' | 'veryHidden';
|
|
26
|
+
/** Narrow a raw `<sheet state>` or `<workbookView visibility>` token to a known {@link Visibility}. */
|
|
27
|
+
export declare function isVisibility(value: string): value is Visibility;
|
|
18
28
|
export interface WorksheetState {
|
|
19
29
|
/** Sheet visibility, as Excel models it. Defaults to `visible`. */
|
|
20
|
-
readonly state:
|
|
30
|
+
readonly state: Visibility;
|
|
21
31
|
}
|
|
22
32
|
/** Format defaults applied to every row/column that carries no explicit override. */
|
|
23
33
|
export interface WorksheetProperties {
|
|
@@ -39,7 +49,7 @@ export interface OutlineProperties {
|
|
|
39
49
|
/**
|
|
40
50
|
* A worksheet's frozen-pane view. `state` `'frozen'` locks the top `ySplit` rows and left `xSplit`
|
|
41
51
|
* columns in place while the rest scrolls; `'normal'` (the default) has no split and emits no
|
|
42
|
-
* `<pane
|
|
52
|
+
* `<pane>`: writing a normal view leaves no leftover pane markup that would trip Excel's repair
|
|
43
53
|
* prompt. An empty object is a normal view.
|
|
44
54
|
*/
|
|
45
55
|
export interface SheetView {
|
|
@@ -64,12 +74,12 @@ export interface SheetView {
|
|
|
64
74
|
/**
|
|
65
75
|
* Per-column formatting. A column may exist purely to carry these, with no cells. The style
|
|
66
76
|
* facets are *defaults* for the column's cells: a cell that sets a facet of its own wins, but
|
|
67
|
-
* one that leaves a facet unset inherits the column's
|
|
77
|
+
* one that leaves a facet unset inherits the column's, the same precedence Excel applies, and
|
|
68
78
|
* symmetric with how a {@link RowProperties} fill defaults a row's cells.
|
|
69
79
|
*/
|
|
70
80
|
export interface ColumnProperties extends CellStyle {
|
|
71
81
|
/** Stable key naming the column so a keyed-object row (see {@link Worksheet.addRow}) can place a
|
|
72
|
-
* value under it by name rather than position. In-memory only
|
|
82
|
+
* value under it by name rather than position. In-memory only: it is not serialized to OOXML. */
|
|
73
83
|
key?: string;
|
|
74
84
|
/** Column width in character units. */
|
|
75
85
|
width?: number;
|
|
@@ -105,26 +115,34 @@ export interface CellModel extends CellStyle {
|
|
|
105
115
|
note?: string | undefined;
|
|
106
116
|
}
|
|
107
117
|
/**
|
|
108
|
-
* A serialisable snapshot of a worksheet's value and overlay content
|
|
109
|
-
* the column/row/page metadata, and the sheet-level overlays (merges, data
|
|
110
|
-
* formattings, tables, the autofilter, protection). {@link Worksheet.model}
|
|
111
|
-
* it back reproduces that content. The getter and setter cover exactly the
|
|
112
|
-
* `dst.model = src.model` round-trip drops none of it
|
|
113
|
-
* silently lose data, the historical merge-loss failure this contract exists to
|
|
114
|
-
* directions are driven from one field table (`core/worksheet-model.ts`), which the
|
|
115
|
-
* covers every field below, so adding a field here without wiring it fails the build.
|
|
118
|
+
* A serialisable snapshot of a worksheet's value and overlay content: its cells and their styles,
|
|
119
|
+
* the column/row/page metadata, the frozen-pane view, and the sheet-level overlays (merges, data
|
|
120
|
+
* validations, conditional formattings, tables, the autofilter, protection). {@link Worksheet.model}
|
|
121
|
+
* exports one; assigning it back reproduces that content. The getter and setter cover exactly the
|
|
122
|
+
* same fields, so a `dst.model = src.model` round-trip drops none of it: an export field the import
|
|
123
|
+
* ignored would silently lose data, the historical merge-loss failure this contract exists to
|
|
124
|
+
* prevent. Both directions are driven from one field table (`core/worksheet-model.ts`), which the
|
|
125
|
+
* compiler proves covers every field below, so adding a field here without wiring it fails the build.
|
|
126
|
+
*
|
|
127
|
+
* The line between what belongs here and what does not is **workbook-independence**: a field earns
|
|
128
|
+
* its place when its value means the same thing on any sheet of any workbook. That is the test a new
|
|
129
|
+
* field is measured against, and applying it is what admitted the autofilter and the frozen-pane view
|
|
130
|
+
* after each had been omitted for no stated reason (ADR-0005 §2).
|
|
116
131
|
*
|
|
117
|
-
* Out of scope by design: content
|
|
118
|
-
*
|
|
119
|
-
* (their source references a live worksheet),
|
|
120
|
-
*
|
|
121
|
-
*
|
|
132
|
+
* Out of scope by design: content carrying workbook-level identity rather than pure sheet state.
|
|
133
|
+
* That covers anchored and background images (their bytes live on the {@link Workbook}), pivot tables
|
|
134
|
+
* (their source references a live worksheet), threaded comments (their authors are ids into the
|
|
135
|
+
* workbook's {@link Workbook.persons} registry, so a copied conversation would name an author the
|
|
136
|
+
* destination has never heard of), and byte-preserved parts (charts, vector drawings, slicers) kept
|
|
137
|
+
* verbatim for round-tripping. These stay with their source sheet; a model assignment neither copies
|
|
138
|
+
* nor clears them.
|
|
122
139
|
*/
|
|
123
140
|
export interface WorksheetModel {
|
|
124
141
|
state: WorksheetState['state'];
|
|
125
142
|
tabColor: Color | undefined;
|
|
126
143
|
properties: WorksheetProperties;
|
|
127
144
|
outline: OutlineProperties;
|
|
145
|
+
view: SheetView;
|
|
128
146
|
pageSetup: PageSetup;
|
|
129
147
|
printOptions: PrintOptions;
|
|
130
148
|
pageMargins: PageMargins;
|
|
@@ -163,7 +181,7 @@ export declare class Worksheet {
|
|
|
163
181
|
readonly properties: WorksheetProperties;
|
|
164
182
|
/**
|
|
165
183
|
* Outline summary-position flags. Mutate in place: `sheet.outline.summaryBelow = false`. Empty
|
|
166
|
-
* means unset
|
|
184
|
+
* means unset: the writer emits no `<outlinePr>` and a round-trip never fabricates one.
|
|
167
185
|
*/
|
|
168
186
|
readonly outline: OutlineProperties;
|
|
169
187
|
/**
|
|
@@ -173,13 +191,13 @@ export declare class Worksheet {
|
|
|
173
191
|
readonly view: SheetView;
|
|
174
192
|
/**
|
|
175
193
|
* Print-scaling and orientation. Mutate in place: `sheet.pageSetup.fitToPage = true`. Empty means
|
|
176
|
-
* unset
|
|
194
|
+
* unset: the writer emits neither `<pageSetUpPr>` nor `<pageSetup>` and a round-trip never
|
|
177
195
|
* fabricates them.
|
|
178
196
|
*/
|
|
179
197
|
readonly pageSetup: PageSetup;
|
|
180
198
|
/**
|
|
181
199
|
* Print-toggle flags (`<printOptions>`): centring, and whether headings/gridlines print. Mutate in
|
|
182
|
-
* place: `sheet.printOptions.gridLines = true`. Empty means unset
|
|
200
|
+
* place: `sheet.printOptions.gridLines = true`. Empty means unset. The writer emits no element and
|
|
183
201
|
* a round-trip never fabricates one.
|
|
184
202
|
*/
|
|
185
203
|
readonly printOptions: PrintOptions;
|
|
@@ -217,8 +235,8 @@ export declare class Worksheet {
|
|
|
217
235
|
/** Whether a cell has been materialised at the given 1-based position. */
|
|
218
236
|
hasCell(row: number, col: number): boolean;
|
|
219
237
|
/**
|
|
220
|
-
* A handle on a 1-based column: its formatting, its cells, and its values. Cheap and stateless
|
|
221
|
-
*
|
|
238
|
+
* A handle on a 1-based column: its formatting, its cells, and its values. Cheap and stateless.
|
|
239
|
+
* It creates neither cells nor a format record, so asking about a column costs nothing and does
|
|
222
240
|
* not extend the used range. Writing through it (`getColumn(2).width = 12`) is what materialises
|
|
223
241
|
* the record.
|
|
224
242
|
*
|
|
@@ -226,7 +244,7 @@ export declare class Worksheet {
|
|
|
226
244
|
*/
|
|
227
245
|
getColumn(index: number): Column;
|
|
228
246
|
/**
|
|
229
|
-
* A handle on a 1-based row: its formatting, its cells, and its values. Cheap and stateless
|
|
247
|
+
* A handle on a 1-based row: its formatting, its cells, and its values. Cheap and stateless. It
|
|
230
248
|
* creates neither cells nor a format record, so asking about a row costs nothing and does not
|
|
231
249
|
* extend the used range. Writing through it (`getRow(3).height = 20`) is what materialises the
|
|
232
250
|
* record.
|
|
@@ -235,7 +253,7 @@ export declare class Worksheet {
|
|
|
235
253
|
*/
|
|
236
254
|
getRow(number: number): Row;
|
|
237
255
|
/**
|
|
238
|
-
* A handle on a rectangular block of cells
|
|
256
|
+
* A handle on a rectangular block of cells: `getRange('B2:D5')`, or the same block by its
|
|
239
257
|
* inclusive corners as `getRange(2, 2, 5, 4)`. Cheap and stateless like {@link getRow} and
|
|
240
258
|
* {@link getColumn}: it creates no cells and does not extend the used range.
|
|
241
259
|
*
|
|
@@ -254,7 +272,7 @@ export declare class Worksheet {
|
|
|
254
272
|
getRange(reference: string): Range;
|
|
255
273
|
getRange(top: number, left: number, bottom: number, right: number): Range;
|
|
256
274
|
/**
|
|
257
|
-
* The 1-based index of the last row carrying anything
|
|
275
|
+
* The 1-based index of the last row carrying anything (data or its own formatting),
|
|
258
276
|
* or 0 for an empty sheet. Spans gaps: a value in row 5 makes this 5 even if rows 2–4
|
|
259
277
|
* are empty. This is the used-range extent, not a populated-row tally (see
|
|
260
278
|
* {@link actualRowCount}).
|
|
@@ -263,29 +281,29 @@ export declare class Worksheet {
|
|
|
263
281
|
/** The number of rows that hold at least one non-empty cell, ignoring gaps and formatting-only rows. */
|
|
264
282
|
get actualRowCount(): number;
|
|
265
283
|
/**
|
|
266
|
-
* The 1-based index of the last column carrying anything
|
|
267
|
-
* properties
|
|
284
|
+
* The 1-based index of the last column carrying anything (a non-empty cell or its own format
|
|
285
|
+
* properties), or 0 for an empty sheet. The used-range width, mirroring {@link rowCount} for the
|
|
268
286
|
* other axis: a value in column E makes this 5 even if columns B–D are empty.
|
|
269
287
|
*/
|
|
270
288
|
get columnCount(): number;
|
|
271
289
|
/**
|
|
272
|
-
* The sheet's used range as one handle
|
|
273
|
-
* anything
|
|
290
|
+
* The sheet's used range as one handle: `A1` through the last row and column that carry
|
|
291
|
+
* anything, or `undefined` when there is no rectangle to name.
|
|
274
292
|
*
|
|
275
293
|
* This is {@link rowCount} and {@link columnCount} said once, so a caller stops reassembling
|
|
276
294
|
* `A1:${numberToColumn(sheet.columnCount)}${sheet.rowCount}` by hand. That is what an
|
|
277
|
-
* {@link autoFilter} covering the whole sheet wants
|
|
278
|
-
*
|
|
295
|
+
* {@link autoFilter} covering the whole sheet wants (`sheet.autoFilter = sheet.usedRange.address`),
|
|
296
|
+
* and Excel writes exactly that ref for a filter it applies itself. A header-only ref filters
|
|
279
297
|
* nothing, which is the bug this exists to make hard to write.
|
|
280
298
|
*
|
|
281
299
|
* It inherits both counts' definition of *used*, so it spans gaps (a value in `E5` and nothing
|
|
282
|
-
* else still gives `A1:E5`) and includes a line carrying only its own formatting
|
|
300
|
+
* else still gives `A1:E5`) and includes a line carrying only its own formatting: a set column
|
|
283
301
|
* width, an outline level, a merge reaching past the last value. `undefined` therefore means
|
|
284
302
|
* strictly "no rectangle": an empty sheet, or one carrying only row formatting and no columns at
|
|
285
303
|
* all (or the reverse), where an axis has no extent to bound the other against.
|
|
286
304
|
*
|
|
287
|
-
* Not the same thing as the `<dimension>` a written package records. That is the *tight* box
|
|
288
|
-
* top-left at the first used cell
|
|
305
|
+
* Not the same thing as the `<dimension>` a written package records. That is the *tight* box,
|
|
306
|
+
* top-left at the first used cell and formatting-only rows excluded, because Excel writes it to
|
|
289
307
|
* describe where the data is, not what the grid spans. This handle is anchored at `A1`, because
|
|
290
308
|
* a caller asking for the used range means the block to read, style or filter.
|
|
291
309
|
*/
|
|
@@ -312,7 +330,7 @@ export declare class Worksheet {
|
|
|
312
330
|
/** The tables defined on this sheet, in definition order. */
|
|
313
331
|
get tables(): readonly Table[];
|
|
314
332
|
/** The table with the given name (case-sensitive, the identifier Excel uses), or `undefined`.
|
|
315
|
-
* A table read back from a file is fully hydrated
|
|
333
|
+
* A table read back from a file is fully hydrated: its rows can be read and appended to. */
|
|
316
334
|
getTable(name: string): Table | undefined;
|
|
317
335
|
/**
|
|
318
336
|
* Add a pivot table to this (destination) sheet, summarising a source sheet's data. The source is
|
|
@@ -325,7 +343,7 @@ export declare class Worksheet {
|
|
|
325
343
|
/** The pivot tables hosted on this sheet, in definition order. */
|
|
326
344
|
get pivotTables(): readonly PivotTable[];
|
|
327
345
|
/**
|
|
328
|
-
* Pivot tables reconstructed from a loaded package, in the order the reader found them
|
|
346
|
+
* Pivot tables reconstructed from a loaded package, in the order the reader found them: a
|
|
329
347
|
* read-only inspection view (source range, field roles, value field, aggregation). A pivot
|
|
330
348
|
* authored on this sheet via {@link addPivotTable} does not appear here; a pivot loaded from a
|
|
331
349
|
* file does not appear in {@link pivotTables}. The loaded pivots re-emit verbatim through
|
|
@@ -333,13 +351,13 @@ export declare class Worksheet {
|
|
|
333
351
|
*/
|
|
334
352
|
get loadedPivotTables(): readonly ParsedPivotTable[];
|
|
335
353
|
/**
|
|
336
|
-
* Anchor a threaded conversation to a cell
|
|
337
|
-
* replies, and whether the discussion was marked resolved. Distinct from a cell's
|
|
338
|
-
* ({@link Cell.note}), and mutually exclusive with one: Excel refuses to put both on
|
|
339
|
-
* cell carrying both is written back as the conversation alone.
|
|
354
|
+
* Anchor a threaded conversation to a cell. This is Excel's modern review comment: an opening
|
|
355
|
+
* message, its replies, and whether the discussion was marked resolved. Distinct from a cell's
|
|
356
|
+
* legacy note ({@link Cell.note}), and mutually exclusive with one: Excel refuses to put both on
|
|
357
|
+
* one cell, and a cell carrying both is written back as the conversation alone.
|
|
340
358
|
*
|
|
341
359
|
* Every message supplies its own {@link Comment.id} and {@link Comment.date}, and names its author by
|
|
342
|
-
* {@link Comment.personId} into the workbook registry ({@link Workbook.addPerson})
|
|
360
|
+
* {@link Comment.personId} into the workbook registry ({@link Workbook.addPerson}): the writer has no
|
|
343
361
|
* clock and no id generator, so nothing here is invented and the same workbook always serialises to the
|
|
344
362
|
* same bytes. Every id is normalised to the brace-wrapped upper-case GUID form the format requires, so a
|
|
345
363
|
* `crypto.randomUUID()` is accepted as-is.
|
|
@@ -347,7 +365,7 @@ export declare class Worksheet {
|
|
|
347
365
|
* Message ids must be unique **within this sheet**, because that is the scope in which they mean
|
|
348
366
|
* anything: a reply names its thread by the head's id inside the sheet's own part, and the legacy
|
|
349
367
|
* fallback comment binds its cell by the same id inside the sheet's own comments part. Two sheets reusing
|
|
350
|
-
* one id is therefore harmless and is not rejected
|
|
368
|
+
* one id is therefore harmless and is not rejected: Excel's ids happen to be globally unique, but
|
|
351
369
|
* nothing resolves across a part boundary.
|
|
352
370
|
*
|
|
353
371
|
* @throws {SyntaxError} if the anchor does not resolve to a single cell, if any id is not a GUID, if a
|
|
@@ -356,7 +374,7 @@ export declare class Worksheet {
|
|
|
356
374
|
*/
|
|
357
375
|
addCommentThread(thread: CommentThread): void;
|
|
358
376
|
/**
|
|
359
|
-
* The threaded conversations on this sheet
|
|
377
|
+
* The threaded conversations on this sheet: Excel's modern review comments (author, timestamp,
|
|
360
378
|
* replies, resolved state, `@mentions`). Empty for a sheet with none. Distinct from a cell's legacy note
|
|
361
379
|
* ({@link Cell.note}).
|
|
362
380
|
*/
|
|
@@ -399,7 +417,7 @@ export declare class Worksheet {
|
|
|
399
417
|
*/
|
|
400
418
|
addImageAnchor(imageId: number, anchor: ImageAnchor): void;
|
|
401
419
|
/** Drop every anchor of the given workbook image from this sheet. The image stays registered on the
|
|
402
|
-
* workbook
|
|
420
|
+
* workbook (another sheet may still show it), so only this sheet's anchors are removed; the writer
|
|
403
421
|
* then omits any media no sheet anchors any longer. */
|
|
404
422
|
removeImage(imageId: number): void;
|
|
405
423
|
/** The images anchored to this sheet, in the order they were added. */
|
|
@@ -416,11 +434,11 @@ export declare class Worksheet {
|
|
|
416
434
|
get preservedReferences(): readonly PreservedWorksheetReference[];
|
|
417
435
|
/**
|
|
418
436
|
* Merge a range of cells (`"A1:B2"`). A range that overlaps an already-merged region is
|
|
419
|
-
* rejected
|
|
437
|
+
* rejected: Excel forbids overlapping merges and writes such geometry as a corrupt file.
|
|
420
438
|
* Whole-row/column ranges (`"A:A"`) are unbounded, carry no rectangle, and are not overlap-checked.
|
|
421
439
|
*
|
|
422
440
|
* Any value already sitting in a covered non-anchor cell is discarded, keeping only the top-left
|
|
423
|
-
* anchor's
|
|
441
|
+
* anchor's, exactly how Excel collapses a range on merge. Leaving it would emit a populated `<c>`
|
|
424
442
|
* under the `<mergeCell>` ref, the geometry Excel opens with a repair prompt. Covered-cell styles
|
|
425
443
|
* survive (a border spanning the merge is legal), so only the conflicting value is cleared.
|
|
426
444
|
*/
|
|
@@ -428,15 +446,15 @@ export declare class Worksheet {
|
|
|
428
446
|
/** The merged ranges on this sheet, in the order they were added. */
|
|
429
447
|
get merges(): readonly string[];
|
|
430
448
|
/**
|
|
431
|
-
* The sheet's autofilter
|
|
449
|
+
* The sheet's autofilter (its range plus any per-column criteria), or `undefined` when the sheet
|
|
432
450
|
* carries none. Setting one turns on the header-row filter dropdowns Excel draws over the range;
|
|
433
451
|
* the writer emits both the sheet's `<autoFilter>` element and the hidden `_FilterDatabase` defined
|
|
434
452
|
* name Excel derives from it. Setting `undefined` clears the filter.
|
|
435
453
|
*
|
|
436
|
-
* A bare range string is the ergonomic common case
|
|
454
|
+
* A bare range string is the ergonomic common case: `sheet.autoFilter = 'A1:C10'` for dropdowns
|
|
437
455
|
* with no active criteria; pass an {@link AutoFilter} object to narrow columns. Either way the
|
|
438
456
|
* value is normalised on assignment (range to canonical `A1:C10` form) and the getter returns the
|
|
439
|
-
* structured object. The range must be a bounded rectangle
|
|
457
|
+
* structured object. The range must be a bounded rectangle: a whole-row/column reference is not a
|
|
440
458
|
* filterable region and is rejected.
|
|
441
459
|
*/
|
|
442
460
|
get autoFilter(): AutoFilter | undefined;
|
|
@@ -454,7 +472,7 @@ export declare class Worksheet {
|
|
|
454
472
|
* the rule through {@link dataValidationAt}.
|
|
455
473
|
*
|
|
456
474
|
* Pass `{extended: true}` to mark a rule that belongs in the 2009 extension form
|
|
457
|
-
* (`<x14:dataValidation>`)
|
|
475
|
+
* (`<x14:dataValidation>`), the carrier Excel uses for a list source on another sheet and other
|
|
458
476
|
* shapes the standard element cannot express. The reader sets it for a rule found in that form so a
|
|
459
477
|
* round-trip writes it back there instead of silently corrupting the cross-sheet reference.
|
|
460
478
|
*/
|
|
@@ -464,7 +482,7 @@ export declare class Worksheet {
|
|
|
464
482
|
/** The data validations on this sheet, each bound to its target range, in insertion order. */
|
|
465
483
|
get dataValidations(): readonly DataValidationEntry[];
|
|
466
484
|
/**
|
|
467
|
-
* Attach a conditional formatting to a target range. `formatting.ref` is an OOXML `sqref
|
|
485
|
+
* Attach a conditional formatting to a target range. `formatting.ref` is an OOXML `sqref`: one
|
|
468
486
|
* range (`"A1:A10"`), a whole column, or several space-separated areas (`"A1:C1 A3:C3"`) sharing one
|
|
469
487
|
* rule set. The block is stored once against the range, defensively copied so the getter never hands
|
|
470
488
|
* back a reference into the caller's object.
|
|
@@ -481,8 +499,8 @@ export declare class Worksheet {
|
|
|
481
499
|
* Remove `count` rows starting at the 1-based `start`, then insert the given rows in their place.
|
|
482
500
|
* Rows below the edit shift by `inserts.length - count`: a delete pulls the tail up, an insert
|
|
483
501
|
* pushes it down, and doing both at once is a replace. Each inserted row takes either
|
|
484
|
-
* {@link RowInput} shape
|
|
485
|
-
* like {@link addRow}. A `count` larger than the rows present simply clears the tail
|
|
502
|
+
* {@link RowInput} shape, a positional array from column A or a key-addressed object, exactly
|
|
503
|
+
* like {@link addRow}. A `count` larger than the rows present simply clears the tail; it never
|
|
486
504
|
* silently becomes a no-op. Cells carry their full style to the shifted position, and merged ranges
|
|
487
505
|
* shift with the rows they cover.
|
|
488
506
|
*
|
|
@@ -500,19 +518,19 @@ export declare class Worksheet {
|
|
|
500
518
|
/**
|
|
501
519
|
* Append a row of `values` after the last used row, returning the cells it materialised.
|
|
502
520
|
* The append point is {@link rowCount}` + 1`, so the row lands below every row that holds
|
|
503
|
-
* data or its own formatting
|
|
521
|
+
* data or its own formatting, never overwriting existing content, unlike {@link insertRow},
|
|
504
522
|
* which shifts and needs a position. Unlike {@link spliceRows}, appending shifts nothing, so
|
|
505
523
|
* it never disturbs merges or the rows above.
|
|
506
524
|
*
|
|
507
|
-
* A row takes either shape
|
|
508
|
-
* sparse array (`['a', , 'c']`) leaves that column untouched
|
|
509
|
-
*
|
|
525
|
+
* A row takes either shape. A positional array maps its values to columns from A, and a hole in a
|
|
526
|
+
* sparse array (`['a', , 'c']`) leaves that column untouched. A keyed object lands its values
|
|
527
|
+
* under the columns carrying the matching {@link ColumnProperties.key}.
|
|
510
528
|
*/
|
|
511
529
|
addRow(values: RowInput): Cell[];
|
|
512
530
|
/**
|
|
513
531
|
* Append several rows after the last used row in one call, returning the cells materialised
|
|
514
|
-
* for each. The rows stack in order
|
|
515
|
-
* directly below it
|
|
532
|
+
* for each. The rows stack in order: the first lands at {@link rowCount}` + 1`, the next
|
|
533
|
+
* directly below it, so a later row never collides with an earlier one even when both are
|
|
516
534
|
* value-less. Each row is an array or a keyed object independently, so a mixed batch is fine.
|
|
517
535
|
* The bulk form of {@link addRow}.
|
|
518
536
|
*/
|
|
@@ -529,8 +547,8 @@ export declare class Worksheet {
|
|
|
529
547
|
unfreeze(): void;
|
|
530
548
|
/**
|
|
531
549
|
* Copy the row at the 1-based `start`, `options.count` times (default 1). With `options.insert`
|
|
532
|
-
* (the default) the copies are inserted directly after the source, shifting the rows below
|
|
533
|
-
* any merged range there
|
|
550
|
+
* (the default) the copies are inserted directly after the source, shifting the rows below, and
|
|
551
|
+
* any merged range there, down by `count`; otherwise the copies overwrite the rows immediately
|
|
534
552
|
* below without shifting. Each copy is a faithful duplicate of the source's values and per-cell
|
|
535
553
|
* styles, and carries no merge of its own, so a range can be merged onto a duplicated row afterwards.
|
|
536
554
|
*
|
|
@@ -542,7 +560,7 @@ export declare class Worksheet {
|
|
|
542
560
|
}): void;
|
|
543
561
|
/**
|
|
544
562
|
* Remove `count` columns starting at the 1-based `start`, then insert the given columns in their
|
|
545
|
-
* place
|
|
563
|
+
* place: the column analog of {@link spliceRows}. Columns to the right shift by
|
|
546
564
|
* `inserts.length - count`, keeping their values and styles, and a merged range lying wholly to
|
|
547
565
|
* the right of the edit re-anchors to its new columns. Each inserted column is an array of values
|
|
548
566
|
* indexed by row (index 0 → row 1); an empty array inserts a blank column.
|
|
@@ -561,29 +579,32 @@ export declare class Worksheet {
|
|
|
561
579
|
/**
|
|
562
580
|
* Append a column of `values` after the last used column, returning the cells it materialised.
|
|
563
581
|
* The append point is {@link columnCount}` + 1`, so the column lands right of every column that
|
|
564
|
-
* holds data or its own formatting
|
|
582
|
+
* holds data or its own formatting, never overwriting existing content, unlike {@link insertColumn},
|
|
565
583
|
* which shifts and needs a position. Unlike {@link spliceColumns}, appending shifts nothing, so it
|
|
566
584
|
* never disturbs merges or the columns to its left.
|
|
567
585
|
*
|
|
568
586
|
* `values` is an array indexed by row (index 0 → row 1); a hole or an explicit `undefined` leaves
|
|
569
|
-
* that row untouched, mirroring {@link addRow}'s positional-array shape.
|
|
587
|
+
* that row untouched, mirroring {@link addRow}'s positional-array shape. That is the only shape a
|
|
588
|
+
* column takes: the other {@link RowInput} form addresses columns by their
|
|
589
|
+
* {@link ColumnProperties.key}, and a column's values are indexed by *row*, which carries no key,
|
|
590
|
+
* so there is nothing on this axis for a keyed object to name.
|
|
570
591
|
*/
|
|
571
592
|
addColumn(values: CellValue[]): Cell[];
|
|
572
593
|
/**
|
|
573
594
|
* Append several columns after the last used column in one call, returning the cells materialised
|
|
574
|
-
* for each. The columns stack in order
|
|
575
|
-
* directly right of it
|
|
595
|
+
* for each. The columns stack in order: the first lands at {@link columnCount}` + 1`, the next
|
|
596
|
+
* directly right of it, so a later column never collides with an earlier one even when both are
|
|
576
597
|
* value-less. The bulk form of {@link addColumn}.
|
|
577
598
|
*/
|
|
578
599
|
addColumns(columns: CellValue[][]): Cell[][];
|
|
579
600
|
/**
|
|
580
601
|
* A snapshot of this sheet's value and overlay content (see {@link WorksheetModel}). Reading it and
|
|
581
|
-
* assigning it onto another sheet
|
|
582
|
-
* and their styles, column/row metadata, tables, the autofilter, protection,
|
|
583
|
-
* survive, because the getter emits and the setter consumes exactly the same
|
|
584
|
-
* (`name`, `id`) is not part of the model and is never touched by assignment; nor
|
|
585
|
-
* that carry workbook-level identity (images, pivots,
|
|
586
|
-
* {@link WorksheetModel} for that boundary.
|
|
602
|
+
* assigning it onto another sheet (`dst.model = src.model`) reproduces the source: merges, cells
|
|
603
|
+
* and their styles, column/row metadata, tables, the autofilter, protection, the frozen-pane view,
|
|
604
|
+
* and the page setup all survive, because the getter emits and the setter consumes exactly the same
|
|
605
|
+
* fields. Identity (`name`, `id`) is not part of the model and is never touched by assignment; nor
|
|
606
|
+
* are attached parts that carry workbook-level identity (images, pivots, threaded comments,
|
|
607
|
+
* byte-preserved charts/drawings). See {@link WorksheetModel} for that boundary.
|
|
587
608
|
*/
|
|
588
609
|
get model(): WorksheetModel;
|
|
589
610
|
set model(model: WorksheetModel);
|
|
@@ -602,7 +623,7 @@ export declare class Worksheet {
|
|
|
602
623
|
/** The sheet's protection, or `undefined` if the sheet is unprotected. */
|
|
603
624
|
get protection(): SheetProtection | undefined;
|
|
604
625
|
/**
|
|
605
|
-
* The codec's channel into this sheet
|
|
626
|
+
* The codec's channel into this sheet. See `core/internal.ts` for why these are not public
|
|
606
627
|
* methods. Declared last so every private field it closes over is already in scope.
|
|
607
628
|
*/
|
|
608
629
|
readonly [INTERNAL]: WorksheetInternals;
|
|
@@ -623,7 +644,7 @@ export interface WorksheetInternals {
|
|
|
623
644
|
*/
|
|
624
645
|
evictRow(number: number): void;
|
|
625
646
|
/**
|
|
626
|
-
* Register a pivot table reconstructed from a loaded package
|
|
647
|
+
* Register a pivot table reconstructed from a loaded package: the reader's counterpart to
|
|
627
648
|
* {@link Worksheet.addPivotTable}. This records an inspectable, read-only view of a pivot the
|
|
628
649
|
* reader parsed from its OOXML parts; the pivot itself round-trips by byte-preservation, so
|
|
629
650
|
* registering it here only makes it visible via {@link Worksheet.loadedPivotTables} and never
|
|
@@ -635,7 +656,7 @@ export interface WorksheetInternals {
|
|
|
635
656
|
* replacing any already held. Their authors and mentioned people are already resolved against the
|
|
636
657
|
* workbook registry, so a thread arrives self-contained.
|
|
637
658
|
*
|
|
638
|
-
* Not authoring
|
|
659
|
+
* Not authoring: {@link Worksheet.addCommentThread} is that, and validates the anchor. These
|
|
639
660
|
* threads are what a re-write emits, so what the reader hands over is what the file will say.
|
|
640
661
|
*/
|
|
641
662
|
restoreCommentThreads(threads: readonly CommentThread[]): void;
|
|
@@ -646,7 +667,7 @@ export interface WorksheetInternals {
|
|
|
646
667
|
*/
|
|
647
668
|
addPreservedReference(reference: PreservedWorksheetReference): void;
|
|
648
669
|
/**
|
|
649
|
-
* Reinstate an already-derived protection state
|
|
670
|
+
* Reinstate an already-derived protection state: the deserialization counterpart to
|
|
650
671
|
* {@link Worksheet.protect}. A loaded `<sheetProtection>` carries its credential in finished agile
|
|
651
672
|
* form (algorithm, hash, salt, spin count) with no recoverable plaintext password, so the reader
|
|
652
673
|
* restores that credential verbatim rather than re-hashing.
|
|
@@ -655,7 +676,7 @@ export interface WorksheetInternals {
|
|
|
655
676
|
/**
|
|
656
677
|
* Materialise the cell at an exact 1-based position, creating it on first access. Unlike
|
|
657
678
|
* {@link Worksheet.getCell} this performs no merge resolution: the cell returned is the one at
|
|
658
|
-
* `(row, col)` even when a merged region covers it. Loading content is where that matters
|
|
679
|
+
* `(row, col)` even when a merged region covers it. Loading content is where that matters: a
|
|
659
680
|
* model or a parsed file states where each value sits, and routing a covered value to its region
|
|
660
681
|
* master mid-load would move it.
|
|
661
682
|
*/
|