@shbernal/ts-xlsx 1.0.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/LICENSE +23 -0
- package/README.md +230 -0
- package/dist/core/address.d.ts +49 -0
- package/dist/core/address.js +125 -0
- package/dist/core/autofilter.d.ts +55 -0
- package/dist/core/autofilter.js +48 -0
- package/dist/core/cell.d.ts +132 -0
- package/dist/core/cell.js +249 -0
- package/dist/core/color-resolution.d.ts +58 -0
- package/dist/core/color-resolution.js +170 -0
- package/dist/core/column.d.ts +87 -0
- package/dist/core/column.js +167 -0
- package/dist/core/comment-thread.d.ts +116 -0
- package/dist/core/comment-thread.js +62 -0
- package/dist/core/conditional-formatting-overlay.d.ts +15 -0
- package/dist/core/conditional-formatting-overlay.js +24 -0
- package/dist/core/conditional-formatting.d.ts +70 -0
- package/dist/core/conditional-formatting.js +35 -0
- package/dist/core/containers.d.ts +2 -0
- package/dist/core/containers.js +25 -0
- package/dist/core/data-validation-overlay.d.ts +28 -0
- package/dist/core/data-validation-overlay.js +56 -0
- package/dist/core/data-validation.d.ts +38 -0
- package/dist/core/data-validation.js +13 -0
- package/dist/core/date.d.ts +25 -0
- package/dist/core/date.js +58 -0
- package/dist/core/formula.d.ts +49 -0
- package/dist/core/formula.js +319 -0
- package/dist/core/grid-edits.d.ts +22 -0
- package/dist/core/grid-edits.js +206 -0
- package/dist/core/image.d.ts +76 -0
- package/dist/core/image.js +65 -0
- package/dist/core/internal.d.ts +11 -0
- package/dist/core/internal.js +29 -0
- package/dist/core/merge.d.ts +13 -0
- package/dist/core/merge.js +26 -0
- package/dist/core/modern-functions.d.ts +1 -0
- package/dist/core/modern-functions.js +165 -0
- package/dist/core/page-setup.d.ts +94 -0
- package/dist/core/page-setup.js +6 -0
- package/dist/core/pivot-table.d.ts +113 -0
- package/dist/core/pivot-table.js +249 -0
- package/dist/core/preserved.d.ts +58 -0
- package/dist/core/preserved.js +5 -0
- package/dist/core/protection.d.ts +67 -0
- package/dist/core/protection.js +68 -0
- package/dist/core/range.d.ts +112 -0
- package/dist/core/range.js +283 -0
- package/dist/core/row.d.ts +73 -0
- package/dist/core/row.js +135 -0
- package/dist/core/style.d.ts +246 -0
- package/dist/core/style.js +125 -0
- package/dist/core/table-style.d.ts +67 -0
- package/dist/core/table-style.js +90 -0
- package/dist/core/table.d.ts +194 -0
- package/dist/core/table.js +291 -0
- package/dist/core/theme.d.ts +90 -0
- package/dist/core/theme.js +272 -0
- package/dist/core/value.d.ts +115 -0
- package/dist/core/value.js +144 -0
- package/dist/core/workbook-protection.d.ts +27 -0
- package/dist/core/workbook-protection.js +25 -0
- package/dist/core/workbook.d.ts +528 -0
- package/dist/core/workbook.js +732 -0
- package/dist/core/worksheet-model.d.ts +34 -0
- package/dist/core/worksheet-model.js +100 -0
- package/dist/core/worksheet.d.ts +647 -0
- package/dist/core/worksheet.js +1025 -0
- package/dist/customui/errors.d.ts +15 -0
- package/dist/customui/errors.js +15 -0
- package/dist/customui/index.d.ts +2 -0
- package/dist/customui/index.js +7 -0
- package/dist/customui/ribbon.d.ts +86 -0
- package/dist/customui/ribbon.js +180 -0
- package/dist/entries/core.d.ts +23 -0
- package/dist/entries/core.js +20 -0
- package/dist/entries/csv.d.ts +2 -0
- package/dist/entries/csv.js +6 -0
- package/dist/entries/customui.d.ts +1 -0
- package/dist/entries/customui.js +3 -0
- package/dist/entries/errors.d.ts +7 -0
- package/dist/entries/errors.js +20 -0
- package/dist/entries/vba.d.ts +2 -0
- package/dist/entries/vba.js +7 -0
- package/dist/entries/xlsb.d.ts +1 -0
- package/dist/entries/xlsb.js +7 -0
- package/dist/entries/xlsx.d.ts +5 -0
- package/dist/entries/xlsx.js +18 -0
- package/dist/errors.d.ts +65 -0
- package/dist/errors.js +66 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +19 -0
- package/dist/io/csv/read.d.ts +15 -0
- package/dist/io/csv/read.js +113 -0
- package/dist/io/csv/write.d.ts +28 -0
- package/dist/io/csv/write.js +124 -0
- package/dist/io/opc/errors.d.ts +46 -0
- package/dist/io/opc/errors.js +49 -0
- package/dist/io/opc/inflate.d.ts +15 -0
- package/dist/io/opc/inflate.js +91 -0
- package/dist/io/opc/namespaces.d.ts +18 -0
- package/dist/io/opc/namespaces.js +18 -0
- package/dist/io/opc/part-paths.d.ts +4 -0
- package/dist/io/opc/part-paths.js +35 -0
- package/dist/io/opc/read-opc.d.ts +24 -0
- package/dist/io/opc/read-opc.js +153 -0
- package/dist/io/opc/read-options.d.ts +10 -0
- package/dist/io/opc/read-options.js +7 -0
- package/dist/io/opc/rels.d.ts +15 -0
- package/dist/io/opc/rels.js +28 -0
- package/dist/io/opc/sniff-format.d.ts +27 -0
- package/dist/io/opc/sniff-format.js +92 -0
- package/dist/io/style/xf-style.d.ts +47 -0
- package/dist/io/style/xf-style.js +95 -0
- package/dist/io/xlsb/errors.d.ts +15 -0
- package/dist/io/xlsb/errors.js +15 -0
- package/dist/io/xlsb/formula.d.ts +48 -0
- package/dist/io/xlsb/formula.js +398 -0
- package/dist/io/xlsb/primitives.d.ts +86 -0
- package/dist/io/xlsb/primitives.js +230 -0
- package/dist/io/xlsb/ptg-functions.d.ts +16 -0
- package/dist/io/xlsb/ptg-functions.js +659 -0
- package/dist/io/xlsb/read-shared-strings.d.ts +2 -0
- package/dist/io/xlsb/read-shared-strings.js +22 -0
- package/dist/io/xlsb/read-styles.d.ts +4 -0
- package/dist/io/xlsb/read-styles.js +386 -0
- package/dist/io/xlsb/read-worksheet.d.ts +9 -0
- package/dist/io/xlsb/read-worksheet.js +301 -0
- package/dist/io/xlsb/read.d.ts +20 -0
- package/dist/io/xlsb/read.js +199 -0
- package/dist/io/xlsb/record-stream.d.ts +14 -0
- package/dist/io/xlsb/record-stream.js +56 -0
- package/dist/io/xlsb/record-types.d.ts +55 -0
- package/dist/io/xlsb/record-types.js +73 -0
- package/dist/io/xlsx/cell-accumulator.d.ts +25 -0
- package/dist/io/xlsx/cell-accumulator.js +172 -0
- package/dist/io/xlsx/cell-value.d.ts +32 -0
- package/dist/io/xlsx/cell-value.js +85 -0
- package/dist/io/xlsx/comments.d.ts +74 -0
- package/dist/io/xlsx/comments.js +243 -0
- package/dist/io/xlsx/conditional-formatting.d.ts +32 -0
- package/dist/io/xlsx/conditional-formatting.js +464 -0
- package/dist/io/xlsx/data-validation.d.ts +20 -0
- package/dist/io/xlsx/data-validation.js +258 -0
- package/dist/io/xlsx/edit-vba.d.ts +23 -0
- package/dist/io/xlsx/edit-vba.js +139 -0
- package/dist/io/xlsx/errors.d.ts +17 -0
- package/dist/io/xlsx/errors.js +17 -0
- package/dist/io/xlsx/hyperlinks.d.ts +42 -0
- package/dist/io/xlsx/hyperlinks.js +139 -0
- package/dist/io/xlsx/images.d.ts +34 -0
- package/dist/io/xlsx/images.js +218 -0
- package/dist/io/xlsx/namespaces.d.ts +55 -0
- package/dist/io/xlsx/namespaces.js +55 -0
- package/dist/io/xlsx/package-plan.d.ts +103 -0
- package/dist/io/xlsx/package-plan.js +168 -0
- package/dist/io/xlsx/pivot-read.d.ts +5 -0
- package/dist/io/xlsx/pivot-read.js +134 -0
- package/dist/io/xlsx/pivot.d.ts +12 -0
- package/dist/io/xlsx/pivot.js +141 -0
- package/dist/io/xlsx/read-rows.d.ts +85 -0
- package/dist/io/xlsx/read-rows.js +286 -0
- package/dist/io/xlsx/read-styles.d.ts +8 -0
- package/dist/io/xlsx/read-styles.js +551 -0
- package/dist/io/xlsx/read-worksheet.d.ts +4 -0
- package/dist/io/xlsx/read-worksheet.js +528 -0
- package/dist/io/xlsx/read.d.ts +32 -0
- package/dist/io/xlsx/read.js +680 -0
- package/dist/io/xlsx/relationships.d.ts +33 -0
- package/dist/io/xlsx/relationships.js +47 -0
- package/dist/io/xlsx/rich-runs.d.ts +13 -0
- package/dist/io/xlsx/rich-runs.js +59 -0
- package/dist/io/xlsx/rich-text.d.ts +7 -0
- package/dist/io/xlsx/rich-text.js +23 -0
- package/dist/io/xlsx/shared-formulas.d.ts +6 -0
- package/dist/io/xlsx/shared-formulas.js +52 -0
- package/dist/io/xlsx/shared-strings-read.d.ts +2 -0
- package/dist/io/xlsx/shared-strings-read.js +70 -0
- package/dist/io/xlsx/shared-strings.d.ts +17 -0
- package/dist/io/xlsx/shared-strings.js +50 -0
- package/dist/io/xlsx/sheet-properties.d.ts +13 -0
- package/dist/io/xlsx/sheet-properties.js +211 -0
- package/dist/io/xlsx/styles.d.ts +138 -0
- package/dist/io/xlsx/styles.js +821 -0
- package/dist/io/xlsx/tables.d.ts +9 -0
- package/dist/io/xlsx/tables.js +208 -0
- package/dist/io/xlsx/threaded-comments.d.ts +102 -0
- package/dist/io/xlsx/threaded-comments.js +308 -0
- package/dist/io/xlsx/workbook-xml.d.ts +12 -0
- package/dist/io/xlsx/workbook-xml.js +353 -0
- package/dist/io/xlsx/worksheet-xml.d.ts +86 -0
- package/dist/io/xlsx/worksheet-xml.js +643 -0
- package/dist/io/xlsx/write-stream.d.ts +171 -0
- package/dist/io/xlsx/write-stream.js +399 -0
- package/dist/io/xlsx/write.d.ts +81 -0
- package/dist/io/xlsx/write.js +396 -0
- package/dist/io/xlsx/x14-ext.d.ts +9 -0
- package/dist/io/xlsx/x14-ext.js +12 -0
- package/dist/vba/cfb-writer.d.ts +19 -0
- package/dist/vba/cfb-writer.js +277 -0
- package/dist/vba/cfb.d.ts +16 -0
- package/dist/vba/cfb.js +324 -0
- package/dist/vba/codepage.d.ts +18 -0
- package/dist/vba/codepage.js +87 -0
- package/dist/vba/errors.d.ts +24 -0
- package/dist/vba/errors.js +24 -0
- package/dist/vba/index.d.ts +5 -0
- package/dist/vba/index.js +15 -0
- package/dist/vba/ms-ovba.d.ts +12 -0
- package/dist/vba/ms-ovba.js +176 -0
- package/dist/vba/project-editor.d.ts +62 -0
- package/dist/vba/project-editor.js +377 -0
- package/dist/vba/project.d.ts +45 -0
- package/dist/vba/project.js +160 -0
- package/dist/vba/vba-encoding.d.ts +14 -0
- package/dist/vba/vba-encoding.js +39 -0
- package/dist/xml/errors.d.ts +15 -0
- package/dist/xml/errors.js +15 -0
- package/dist/xml/xml-read.d.ts +107 -0
- package/dist/xml/xml-read.js +283 -0
- package/dist/xml/xml.d.ts +41 -0
- package/dist/xml/xml.js +86 -0
- package/package.json +117 -0
|
@@ -0,0 +1,647 @@
|
|
|
1
|
+
import { type AutoFilter } from './autofilter.ts';
|
|
2
|
+
import { Cell } from './cell.ts';
|
|
3
|
+
import { Column } from './column.ts';
|
|
4
|
+
import { type CommentThread } from './comment-thread.ts';
|
|
5
|
+
import type { ConditionalFormatting } from './conditional-formatting.ts';
|
|
6
|
+
import type { DataValidation, DataValidationEntry } from './data-validation.ts';
|
|
7
|
+
import { type AnchoredImage, type AnchorPoint, type ImageAnchor, type ImageEditAs } from './image.ts';
|
|
8
|
+
import { INTERNAL } from './internal.ts';
|
|
9
|
+
import type { HeaderFooter, PageBreak, PageMargins, PageSetup, PrintOptions } from './page-setup.ts';
|
|
10
|
+
import { type ParsedPivotTable, PivotTable, type PivotTableOptions } from './pivot-table.ts';
|
|
11
|
+
import type { PreservedWorksheetReference } from './preserved.ts';
|
|
12
|
+
import { type SheetProtection, type SheetProtectionOptions } from './protection.ts';
|
|
13
|
+
import { Range } from './range.ts';
|
|
14
|
+
import { Row } from './row.ts';
|
|
15
|
+
import type { CellStyle, Color, Fill } from './style.ts';
|
|
16
|
+
import { Table, type TableOptions } from './table.ts';
|
|
17
|
+
import type { CellValue } from './value.ts';
|
|
18
|
+
export interface WorksheetState {
|
|
19
|
+
/** Sheet visibility, as Excel models it. Defaults to `visible`. */
|
|
20
|
+
readonly state: 'visible' | 'hidden' | 'veryHidden';
|
|
21
|
+
}
|
|
22
|
+
/** Format defaults applied to every row/column that carries no explicit override. */
|
|
23
|
+
export interface WorksheetProperties {
|
|
24
|
+
/** Height, in points, for rows with no explicit height. */
|
|
25
|
+
defaultRowHeight?: number;
|
|
26
|
+
/** Width, in character units, for columns with no explicit width. */
|
|
27
|
+
defaultColWidth?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Placement of an outline's summary rows/columns. Excel's defaults are summary *below* the detail
|
|
31
|
+
* rows and *right* of the detail columns; setting either to `false` inverts that placement so an
|
|
32
|
+
* author who groups upward gets a file that honours it. An unset flag is omitted from the written
|
|
33
|
+
* `<outlinePr>`, and an empty object emits no `<outlinePr>` at all.
|
|
34
|
+
*/
|
|
35
|
+
export interface OutlineProperties {
|
|
36
|
+
summaryBelow?: boolean;
|
|
37
|
+
summaryRight?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A worksheet's frozen-pane view. `state` `'frozen'` locks the top `ySplit` rows and left `xSplit`
|
|
41
|
+
* columns in place while the rest scrolls; `'normal'` (the default) has no split and emits no
|
|
42
|
+
* `<pane>` — writing a normal view leaves no leftover pane markup that would trip Excel's repair
|
|
43
|
+
* prompt. An empty object is a normal view.
|
|
44
|
+
*/
|
|
45
|
+
export interface SheetView {
|
|
46
|
+
/** Freeze state. Absent or `'normal'` means no split. */
|
|
47
|
+
state?: 'normal' | 'frozen';
|
|
48
|
+
/** Number of columns frozen at the left; `0`/absent freezes no columns. */
|
|
49
|
+
xSplit?: number;
|
|
50
|
+
/** Number of rows frozen at the top; `0`/absent freezes no rows. */
|
|
51
|
+
ySplit?: number;
|
|
52
|
+
/** The cell anchoring the bottom-right scrolling pane; defaults to the first unfrozen cell. */
|
|
53
|
+
topLeftCell?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Per-column formatting. A column may exist purely to carry these, with no cells. The style
|
|
57
|
+
* facets are *defaults* for the column's cells: a cell that sets a facet of its own wins, but
|
|
58
|
+
* one that leaves a facet unset inherits the column's — the same precedence Excel applies, and
|
|
59
|
+
* symmetric with how a {@link RowProperties} fill defaults a row's cells.
|
|
60
|
+
*/
|
|
61
|
+
export interface ColumnProperties extends CellStyle {
|
|
62
|
+
/** Stable key naming the column so a keyed-object row (see {@link Worksheet.addRow}) can place a
|
|
63
|
+
* value under it by name rather than position. In-memory only — it is not serialized to OOXML. */
|
|
64
|
+
key?: string;
|
|
65
|
+
/** Column width in character units. */
|
|
66
|
+
width?: number;
|
|
67
|
+
/** Whether the column is hidden. */
|
|
68
|
+
hidden?: boolean;
|
|
69
|
+
/** Outline (grouping) depth; 0 or absent means ungrouped. */
|
|
70
|
+
outlineLevel?: number;
|
|
71
|
+
/** Whether this column is the collapsed summary of an outline group. */
|
|
72
|
+
collapsed?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/** A row handed to {@link Worksheet.addRow}: a positional array of cell values (a hole or `undefined`
|
|
75
|
+
* leaves that column untouched), or an object keyed by column {@link ColumnProperties.key} whose
|
|
76
|
+
* values land under the matching columns. */
|
|
77
|
+
export type RowInput = (CellValue | undefined)[] | Record<string, CellValue>;
|
|
78
|
+
/** Per-row formatting. A row may exist purely to carry these, with no cells. */
|
|
79
|
+
export interface RowProperties {
|
|
80
|
+
/** Row height in points. */
|
|
81
|
+
height?: number;
|
|
82
|
+
/** Whether the row is hidden. */
|
|
83
|
+
hidden?: boolean;
|
|
84
|
+
/** Outline (grouping) depth; 0 or absent means ungrouped. */
|
|
85
|
+
outlineLevel?: number;
|
|
86
|
+
/** Whether this row is the collapsed summary of an outline group. */
|
|
87
|
+
collapsed?: boolean;
|
|
88
|
+
/** Background fill applied to the row's cells that carry no fill of their own. */
|
|
89
|
+
fill?: Fill;
|
|
90
|
+
}
|
|
91
|
+
/** One materialised cell in a {@link WorksheetModel}: its position, value, and per-cell style facets. */
|
|
92
|
+
export interface CellModel extends CellStyle {
|
|
93
|
+
readonly row: number;
|
|
94
|
+
readonly col: number;
|
|
95
|
+
value: CellValue;
|
|
96
|
+
note?: string | undefined;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A serialisable snapshot of a worksheet's value and overlay content — its cells and their styles,
|
|
100
|
+
* the column/row/page metadata, and the sheet-level overlays (merges, data validations, conditional
|
|
101
|
+
* formattings, tables, the autofilter, protection). {@link Worksheet.model} exports one; assigning
|
|
102
|
+
* it back reproduces that content. The getter and setter cover exactly the same fields, so a
|
|
103
|
+
* `dst.model = src.model` round-trip drops none of it — an export field the import ignored would
|
|
104
|
+
* silently lose data, the historical merge-loss failure this contract exists to prevent. Both
|
|
105
|
+
* directions are driven from one field table (`core/worksheet-model.ts`), which the compiler proves
|
|
106
|
+
* covers every field below, so adding a field here without wiring it fails the build.
|
|
107
|
+
*
|
|
108
|
+
* Out of scope by design: content that carries workbook-level identity rather than pure sheet
|
|
109
|
+
* state — anchored and background images (their bytes live on the {@link Workbook}), pivot tables
|
|
110
|
+
* (their source references a live worksheet), and byte-preserved parts (charts, vector drawings,
|
|
111
|
+
* slicers) kept verbatim for round-tripping. These stay with their source sheet; a model assignment
|
|
112
|
+
* neither copies nor clears them.
|
|
113
|
+
*/
|
|
114
|
+
export interface WorksheetModel {
|
|
115
|
+
state: WorksheetState['state'];
|
|
116
|
+
tabColor: Color | undefined;
|
|
117
|
+
properties: WorksheetProperties;
|
|
118
|
+
outline: OutlineProperties;
|
|
119
|
+
pageSetup: PageSetup;
|
|
120
|
+
printOptions: PrintOptions;
|
|
121
|
+
pageMargins: PageMargins;
|
|
122
|
+
headerFooter: HeaderFooter;
|
|
123
|
+
rowBreaks: PageBreak[];
|
|
124
|
+
columnBreaks: PageBreak[];
|
|
125
|
+
columns: {
|
|
126
|
+
index: number;
|
|
127
|
+
properties: ColumnProperties;
|
|
128
|
+
}[];
|
|
129
|
+
rows: {
|
|
130
|
+
number: number;
|
|
131
|
+
properties: RowProperties;
|
|
132
|
+
}[];
|
|
133
|
+
cells: CellModel[];
|
|
134
|
+
merges: string[];
|
|
135
|
+
dataValidations: DataValidationEntry[];
|
|
136
|
+
conditionalFormattings: ConditionalFormatting[];
|
|
137
|
+
tables: TableOptions[];
|
|
138
|
+
autoFilter: AutoFilter | undefined;
|
|
139
|
+
protection: SheetProtection | undefined;
|
|
140
|
+
}
|
|
141
|
+
export declare class Worksheet {
|
|
142
|
+
#private;
|
|
143
|
+
readonly name: string;
|
|
144
|
+
/** 1-based workbook-assigned id, stable for the sheet's lifetime. */
|
|
145
|
+
readonly id: number;
|
|
146
|
+
state: WorksheetState['state'];
|
|
147
|
+
/**
|
|
148
|
+
* Colour of the sheet's tab, as an ARGB/theme {@link Color}. `undefined` leaves the tab its
|
|
149
|
+
* default colour; the writer emits no `<tabColor>` for an uncoloured sheet, so a round-trip
|
|
150
|
+
* never fabricates one.
|
|
151
|
+
*/
|
|
152
|
+
tabColor: Color | undefined;
|
|
153
|
+
/** Sheet-level format defaults. Mutate in place: `sheet.properties.defaultRowHeight = 20`. */
|
|
154
|
+
readonly properties: WorksheetProperties;
|
|
155
|
+
/**
|
|
156
|
+
* Outline summary-position flags. Mutate in place: `sheet.outline.summaryBelow = false`. Empty
|
|
157
|
+
* means unset — the writer emits no `<outlinePr>` and a round-trip never fabricates one.
|
|
158
|
+
*/
|
|
159
|
+
readonly outline: OutlineProperties;
|
|
160
|
+
/**
|
|
161
|
+
* The sheet's frozen-pane view. Empty (a normal view) emits no `<pane>`. Use {@link freeze} and
|
|
162
|
+
* {@link unfreeze} for the common cases, or mutate in place for finer control.
|
|
163
|
+
*/
|
|
164
|
+
readonly view: SheetView;
|
|
165
|
+
/**
|
|
166
|
+
* Print-scaling and orientation. Mutate in place: `sheet.pageSetup.fitToPage = true`. Empty means
|
|
167
|
+
* unset — the writer emits neither `<pageSetUpPr>` nor `<pageSetup>` and a round-trip never
|
|
168
|
+
* fabricates them.
|
|
169
|
+
*/
|
|
170
|
+
readonly pageSetup: PageSetup;
|
|
171
|
+
/**
|
|
172
|
+
* Print-toggle flags (`<printOptions>`): centring, and whether headings/gridlines print. Mutate in
|
|
173
|
+
* place: `sheet.printOptions.gridLines = true`. Empty means unset — the writer emits no element and
|
|
174
|
+
* a round-trip never fabricates one.
|
|
175
|
+
*/
|
|
176
|
+
readonly printOptions: PrintOptions;
|
|
177
|
+
/** Print margins. Mutate in place: `sheet.pageMargins.left = 0.5`. Empty means unset. */
|
|
178
|
+
readonly pageMargins: PageMargins;
|
|
179
|
+
/** Page header/footer text. Mutate in place: `sheet.headerFooter.oddHeader = '&C&"..."'`. */
|
|
180
|
+
readonly headerFooter: HeaderFooter;
|
|
181
|
+
/**
|
|
182
|
+
* Manual horizontal page breaks (`<rowBreaks>`): each break's `id` is a row the print layout splits
|
|
183
|
+
* before. Mutate in place: `sheet.rowBreaks.push({id: 3})`. Empty means no manual row breaks and the
|
|
184
|
+
* writer emits no `<rowBreaks>` element.
|
|
185
|
+
*/
|
|
186
|
+
readonly rowBreaks: PageBreak[];
|
|
187
|
+
/**
|
|
188
|
+
* Manual vertical page breaks (`<colBreaks>`): each break's `id` is a column the print layout splits
|
|
189
|
+
* before. Mutate in place: `sheet.columnBreaks.push({id: 3})`. Empty means no manual column breaks and
|
|
190
|
+
* the writer emits no `<colBreaks>` element.
|
|
191
|
+
*/
|
|
192
|
+
readonly columnBreaks: PageBreak[];
|
|
193
|
+
constructor(name: string, id: number, state?: WorksheetState['state']);
|
|
194
|
+
/**
|
|
195
|
+
* Get the cell at an A1 reference, creating it on first access. The reference must
|
|
196
|
+
* name both a column and a row (`"B3"`); a whole-row or whole-column reference is
|
|
197
|
+
* not a cell and is rejected.
|
|
198
|
+
*
|
|
199
|
+
* Addressing a cell covered by a merged region resolves to that region's master
|
|
200
|
+
* (top-left) cell, mirroring how a spreadsheet treats the merge as one cell: a value
|
|
201
|
+
* or style written through a covered address lands on the master, and reading a
|
|
202
|
+
* covered address returns the master's. Only the master ever holds an independent
|
|
203
|
+
* value, so the serialized sheet stays well-formed (no stray value on a covered cell).
|
|
204
|
+
*
|
|
205
|
+
* @throws {SyntaxError} if the reference does not resolve to a single cell.
|
|
206
|
+
*/
|
|
207
|
+
getCell(reference: string): Cell;
|
|
208
|
+
/** Whether a cell has been materialised at the given 1-based position. */
|
|
209
|
+
hasCell(row: number, col: number): boolean;
|
|
210
|
+
/**
|
|
211
|
+
* A handle on a 1-based column: its formatting, its cells, and its values. Cheap and stateless —
|
|
212
|
+
* it creates neither cells nor a format record, so asking about a column costs nothing and does
|
|
213
|
+
* not extend the used range. Writing through it (`getColumn(2).width = 12`) is what materialises
|
|
214
|
+
* the record.
|
|
215
|
+
*
|
|
216
|
+
* @throws {RangeError} if the index is not a positive integer.
|
|
217
|
+
*/
|
|
218
|
+
getColumn(index: number): Column;
|
|
219
|
+
/**
|
|
220
|
+
* A handle on a 1-based row: its formatting, its cells, and its values. Cheap and stateless — it
|
|
221
|
+
* creates neither cells nor a format record, so asking about a row costs nothing and does not
|
|
222
|
+
* extend the used range. Writing through it (`getRow(3).height = 20`) is what materialises the
|
|
223
|
+
* record.
|
|
224
|
+
*
|
|
225
|
+
* @throws {RangeError} if the number is not a positive integer.
|
|
226
|
+
*/
|
|
227
|
+
getRow(number: number): Row;
|
|
228
|
+
/**
|
|
229
|
+
* A handle on a rectangular block of cells — `getRange('B2:D5')`, or the same block by its
|
|
230
|
+
* inclusive corners as `getRange(2, 2, 5, 4)`. Cheap and stateless like {@link getRow} and
|
|
231
|
+
* {@link getColumn}: it creates no cells and does not extend the used range.
|
|
232
|
+
*
|
|
233
|
+
* Corners are stated **first and last, inclusive**, in either order, never as a start and a count.
|
|
234
|
+
* That is the convention for every range-shaped accessor here, so the three axes cannot disagree
|
|
235
|
+
* about what a pair of numbers means.
|
|
236
|
+
*
|
|
237
|
+
* A whole-row (`'1:1'`) or whole-column (`'A:A'`) reference is refused rather than accepted as a
|
|
238
|
+
* million-cell block: OOXML states a whole-axis default in one attribute, and {@link getRow} /
|
|
239
|
+
* {@link getColumn} are how you write it.
|
|
240
|
+
*
|
|
241
|
+
* @throws {SyntaxError} if the reference is unparseable, names another worksheet, or leaves an
|
|
242
|
+
* axis unbounded.
|
|
243
|
+
* @throws {RangeError} if a numeric corner is not a positive integer within the sheet's bounds.
|
|
244
|
+
*/
|
|
245
|
+
getRange(reference: string): Range;
|
|
246
|
+
getRange(top: number, left: number, bottom: number, right: number): Range;
|
|
247
|
+
/**
|
|
248
|
+
* The 1-based index of the last row carrying anything — data or its own formatting —
|
|
249
|
+
* or 0 for an empty sheet. Spans gaps: a value in row 5 makes this 5 even if rows 2–4
|
|
250
|
+
* are empty. This is the used-range extent, not a populated-row tally (see
|
|
251
|
+
* {@link actualRowCount}).
|
|
252
|
+
*/
|
|
253
|
+
get rowCount(): number;
|
|
254
|
+
/** The number of rows that hold at least one non-empty cell, ignoring gaps and formatting-only rows. */
|
|
255
|
+
get actualRowCount(): number;
|
|
256
|
+
/**
|
|
257
|
+
* The 1-based index of the last column carrying anything — a non-empty cell or its own format
|
|
258
|
+
* properties — or 0 for an empty sheet. The used-range width, mirroring {@link rowCount} for the
|
|
259
|
+
* other axis: a value in column E makes this 5 even if columns B–D are empty.
|
|
260
|
+
*/
|
|
261
|
+
get columnCount(): number;
|
|
262
|
+
/** The columns carrying format properties, as handles, in ascending index order. */
|
|
263
|
+
columns(): IterableIterator<Column>;
|
|
264
|
+
/**
|
|
265
|
+
* The rows to serialise, as handles, in ascending row order: the union of rows holding cells and
|
|
266
|
+
* rows holding only metadata (a hidden or grouped row need carry no data). Mirrors how OOXML
|
|
267
|
+
* serialises (`<row>` wrapping `<c>`) and is the writer's row surface.
|
|
268
|
+
*
|
|
269
|
+
* A handle yields its cells only when asked, so a pass that reads nothing but row attributes
|
|
270
|
+
* never assembles a cell array it will not look at.
|
|
271
|
+
*/
|
|
272
|
+
rows(): IterableIterator<Row>;
|
|
273
|
+
/**
|
|
274
|
+
* Define a table over a range of this sheet. The table's shape invariants (a legal
|
|
275
|
+
* name, at least one column, at least one row) are enforced here; conflicts with the
|
|
276
|
+
* rest of the sheet (e.g. an overlapping merge) are the writer's concern.
|
|
277
|
+
*
|
|
278
|
+
* @throws {@link AuthoringError} if the name, columns, or geometry are invalid.
|
|
279
|
+
*/
|
|
280
|
+
addTable(options: TableOptions): Table;
|
|
281
|
+
/** The tables defined on this sheet, in definition order. */
|
|
282
|
+
get tables(): readonly Table[];
|
|
283
|
+
/** The table with the given name (case-sensitive, the identifier Excel uses), or `undefined`.
|
|
284
|
+
* A table read back from a file is fully hydrated — its rows can be read and appended to. */
|
|
285
|
+
getTable(name: string): Table | undefined;
|
|
286
|
+
/**
|
|
287
|
+
* Add a pivot table to this (destination) sheet, summarising a source sheet's data. The source is
|
|
288
|
+
* read once, now, so the pivot is a snapshot: later edits to the source do not change it. The
|
|
289
|
+
* supported shape (one summed value field, at least one row and column field) is enforced here.
|
|
290
|
+
*
|
|
291
|
+
* @throws {@link AuthoringError} if the metric, fields, or source shape are unsupported.
|
|
292
|
+
*/
|
|
293
|
+
addPivotTable(options: PivotTableOptions): PivotTable;
|
|
294
|
+
/** The pivot tables hosted on this sheet, in definition order. */
|
|
295
|
+
get pivotTables(): readonly PivotTable[];
|
|
296
|
+
/**
|
|
297
|
+
* Pivot tables reconstructed from a loaded package, in the order the reader found them — a
|
|
298
|
+
* read-only inspection view (source range, field roles, value field, aggregation). A pivot
|
|
299
|
+
* authored on this sheet via {@link addPivotTable} does not appear here; a pivot loaded from a
|
|
300
|
+
* file does not appear in {@link pivotTables}. The loaded pivots re-emit verbatim through
|
|
301
|
+
* byte-preservation, so this collection is never itself serialised.
|
|
302
|
+
*/
|
|
303
|
+
get loadedPivotTables(): readonly ParsedPivotTable[];
|
|
304
|
+
/**
|
|
305
|
+
* Anchor a threaded conversation to a cell — Excel's modern review comment: an opening message, its
|
|
306
|
+
* replies, and whether the discussion was marked resolved. Distinct from a cell's legacy note
|
|
307
|
+
* ({@link Cell.note}), and mutually exclusive with one: Excel refuses to put both on one cell, and a
|
|
308
|
+
* cell carrying both is written back as the conversation alone.
|
|
309
|
+
*
|
|
310
|
+
* Every message supplies its own {@link Comment.id} and {@link Comment.date}, and names its author by
|
|
311
|
+
* {@link Comment.personId} into the workbook registry ({@link Workbook.addPerson}) — the writer has no
|
|
312
|
+
* clock and no id generator, so nothing here is invented and the same workbook always serialises to the
|
|
313
|
+
* same bytes. Every id is normalised to the brace-wrapped upper-case GUID form the format requires, so a
|
|
314
|
+
* `crypto.randomUUID()` is accepted as-is.
|
|
315
|
+
*
|
|
316
|
+
* Message ids must be unique **within this sheet**, because that is the scope in which they mean
|
|
317
|
+
* anything: a reply names its thread by the head's id inside the sheet's own part, and the legacy
|
|
318
|
+
* fallback comment binds its cell by the same id inside the sheet's own comments part. Two sheets reusing
|
|
319
|
+
* one id is therefore harmless and is not rejected — Excel's ids happen to be globally unique, but
|
|
320
|
+
* nothing resolves across a part boundary.
|
|
321
|
+
*
|
|
322
|
+
* @throws {SyntaxError} if the anchor does not resolve to a single cell, if any id is not a GUID, if a
|
|
323
|
+
* message id is already used on this sheet, or if a mention's span is not a whole number the wire can
|
|
324
|
+
* express.
|
|
325
|
+
*/
|
|
326
|
+
addCommentThread(thread: CommentThread): void;
|
|
327
|
+
/**
|
|
328
|
+
* The threaded conversations on this sheet — Excel's modern review comments (author, timestamp,
|
|
329
|
+
* replies, resolved state, `@mentions`). Empty for a sheet with none. Distinct from a cell's legacy note
|
|
330
|
+
* ({@link Cell.note}).
|
|
331
|
+
*/
|
|
332
|
+
get commentThreads(): readonly CommentThread[];
|
|
333
|
+
/**
|
|
334
|
+
* The conversation anchored to a cell, or `undefined` when that cell carries none. The reference is
|
|
335
|
+
* canonicalized, so an absolute `"$B$2"` finds the same thread as `"B2"`; it names the *anchor* cell,
|
|
336
|
+
* so a cell merely covered by the anchor's merged region is not a match.
|
|
337
|
+
*
|
|
338
|
+
* @throws {SyntaxError} if the reference does not resolve to a single cell.
|
|
339
|
+
*/
|
|
340
|
+
commentThreadAt(reference: string): CommentThread | undefined;
|
|
341
|
+
/**
|
|
342
|
+
* Anchor a workbook image (the id returned by {@link Workbook.addImage}) to this sheet. Two shapes:
|
|
343
|
+
*
|
|
344
|
+
* - **Two-cell**: `{tl, br}` spans the rectangle from the top-left grid point to the bottom-right,
|
|
345
|
+
* reflowing as the spanned cells resize. `editAs` (`oneCell` by default) tunes how it follows.
|
|
346
|
+
* - **One-cell**: `{tl, ext}` pins the image at `tl` at a fixed pixel size that the grid never
|
|
347
|
+
* resizes. `ext` is in pixels and converts to EMUs internally.
|
|
348
|
+
*
|
|
349
|
+
* Grid points are 0-based (`{col: 0, row: 0}` is cell A1). A later row/column splice re-pins the
|
|
350
|
+
* anchor to the same logical position.
|
|
351
|
+
*/
|
|
352
|
+
addImage(imageId: number, anchor: {
|
|
353
|
+
readonly tl: AnchorPoint;
|
|
354
|
+
readonly br: AnchorPoint;
|
|
355
|
+
readonly editAs?: ImageEditAs;
|
|
356
|
+
}): void;
|
|
357
|
+
addImage(imageId: number, anchor: {
|
|
358
|
+
readonly tl: AnchorPoint;
|
|
359
|
+
readonly ext: {
|
|
360
|
+
readonly width: number;
|
|
361
|
+
readonly height: number;
|
|
362
|
+
};
|
|
363
|
+
}): void;
|
|
364
|
+
/**
|
|
365
|
+
* Anchor an image with a pre-built model anchor in the model's own units (EMUs). This is the
|
|
366
|
+
* low-level primitive {@link addImage} builds on and the reader uses to re-pin an image parsed from
|
|
367
|
+
* a drawing part without a lossy pixel round-trip.
|
|
368
|
+
*/
|
|
369
|
+
addImageAnchor(imageId: number, anchor: ImageAnchor): void;
|
|
370
|
+
/** Drop every anchor of the given workbook image from this sheet. The image stays registered on the
|
|
371
|
+
* workbook — another sheet may still show it — so only this sheet's anchors are removed; the writer
|
|
372
|
+
* then omits any media no sheet anchors any longer. */
|
|
373
|
+
removeImage(imageId: number): void;
|
|
374
|
+
/** The images anchored to this sheet, in the order they were added. */
|
|
375
|
+
get images(): readonly AnchoredImage[];
|
|
376
|
+
/** Set this sheet's background image to a workbook image (the id {@link Workbook.addImage} returned).
|
|
377
|
+
* The picture tiles behind the whole grid; it is not anchored to any cell. Passing a new id replaces
|
|
378
|
+
* the previous background. */
|
|
379
|
+
addBackgroundImage(imageId: number): void;
|
|
380
|
+
/** Remove this sheet's background image, if any. The image stays registered on the workbook. */
|
|
381
|
+
removeBackgroundImage(): void;
|
|
382
|
+
/** The workbook image id set as this sheet's background, or `undefined` when it has none. */
|
|
383
|
+
get backgroundImageId(): number | undefined;
|
|
384
|
+
/** The worksheet-level references to unmodeled package content preserved for round-tripping. */
|
|
385
|
+
get preservedReferences(): readonly PreservedWorksheetReference[];
|
|
386
|
+
/**
|
|
387
|
+
* Merge a range of cells (`"A1:B2"`). A range that overlaps an already-merged region is
|
|
388
|
+
* rejected — Excel forbids overlapping merges and writes such geometry as a corrupt file.
|
|
389
|
+
* Whole-row/column ranges (`"A:A"`) are unbounded, carry no rectangle, and are not overlap-checked.
|
|
390
|
+
*
|
|
391
|
+
* Any value already sitting in a covered non-anchor cell is discarded, keeping only the top-left
|
|
392
|
+
* anchor's — exactly how Excel collapses a range on merge. Leaving it would emit a populated `<c>`
|
|
393
|
+
* under the `<mergeCell>` ref, the geometry Excel opens with a repair prompt. Covered-cell styles
|
|
394
|
+
* survive (a border spanning the merge is legal), so only the conflicting value is cleared.
|
|
395
|
+
*/
|
|
396
|
+
mergeCells(range: string): void;
|
|
397
|
+
/** The merged ranges on this sheet, in the order they were added. */
|
|
398
|
+
get merges(): readonly string[];
|
|
399
|
+
/**
|
|
400
|
+
* The sheet's autofilter — its range plus any per-column criteria — or `undefined` when the sheet
|
|
401
|
+
* carries none. Setting one turns on the header-row filter dropdowns Excel draws over the range;
|
|
402
|
+
* the writer emits both the sheet's `<autoFilter>` element and the hidden `_FilterDatabase` defined
|
|
403
|
+
* name Excel derives from it. Setting `undefined` clears the filter.
|
|
404
|
+
*
|
|
405
|
+
* A bare range string is the ergonomic common case — `sheet.autoFilter = 'A1:C10'` for dropdowns
|
|
406
|
+
* with no active criteria; pass an {@link AutoFilter} object to narrow columns. Either way the
|
|
407
|
+
* value is normalised on assignment (range to canonical `A1:C10` form) and the getter returns the
|
|
408
|
+
* structured object. The range must be a bounded rectangle — a whole-row/column reference is not a
|
|
409
|
+
* filterable region and is rejected.
|
|
410
|
+
*/
|
|
411
|
+
get autoFilter(): AutoFilter | undefined;
|
|
412
|
+
set autoFilter(filter: string | AutoFilter | undefined);
|
|
413
|
+
/**
|
|
414
|
+
* Remove a merged range previously added with {@link mergeCells}, returning whether a merge with
|
|
415
|
+
* that exact range string existed. The covering rectangle is dropped alongside it, so a cell the
|
|
416
|
+
* merge had masked addresses independently again. The inverse of {@link mergeCells}.
|
|
417
|
+
*/
|
|
418
|
+
unmergeCells(range: string): boolean;
|
|
419
|
+
/**
|
|
420
|
+
* Attach a data validation to a target range (`"B2:B20"`, a whole column `"B2:B1048576"`, or a
|
|
421
|
+
* space-separated `sqref` of several ranges). The rule is stored once against the range, not copied
|
|
422
|
+
* per covered cell, so a whole-column dropdown stays a single entry. A cell inside the range reports
|
|
423
|
+
* the rule through {@link dataValidationAt}.
|
|
424
|
+
*
|
|
425
|
+
* Pass `{extended: true}` to mark a rule that belongs in the 2009 extension form
|
|
426
|
+
* (`<x14:dataValidation>`) — the carrier Excel uses for a list source on another sheet and other
|
|
427
|
+
* shapes the standard element cannot express. The reader sets it for a rule found in that form so a
|
|
428
|
+
* round-trip writes it back there instead of silently corrupting the cross-sheet reference.
|
|
429
|
+
*/
|
|
430
|
+
addDataValidation(sqref: string, rule: DataValidation, options?: {
|
|
431
|
+
extended?: boolean;
|
|
432
|
+
}): void;
|
|
433
|
+
/** The data validations on this sheet, each bound to its target range, in insertion order. */
|
|
434
|
+
get dataValidations(): readonly DataValidationEntry[];
|
|
435
|
+
/**
|
|
436
|
+
* Attach a conditional formatting to a target range. `formatting.ref` is an OOXML `sqref` — one
|
|
437
|
+
* range (`"A1:A10"`), a whole column, or several space-separated areas (`"A1:C1 A3:C3"`) sharing one
|
|
438
|
+
* rule set. The block is stored once against the range, defensively copied so the getter never hands
|
|
439
|
+
* back a reference into the caller's object.
|
|
440
|
+
*/
|
|
441
|
+
addConditionalFormatting(formatting: ConditionalFormatting): void;
|
|
442
|
+
/** The conditional formattings on this sheet, each bound to its target range, in insertion order. */
|
|
443
|
+
get conditionalFormattings(): readonly ConditionalFormatting[];
|
|
444
|
+
/**
|
|
445
|
+
* The validation covering a cell, or `undefined` when none does. The first added rule whose range
|
|
446
|
+
* contains the cell wins, mirroring how a spreadsheet resolves overlapping validations.
|
|
447
|
+
*/
|
|
448
|
+
dataValidationAt(reference: string): DataValidation | undefined;
|
|
449
|
+
/**
|
|
450
|
+
* Remove `count` rows starting at the 1-based `start`, then insert the given rows in their place.
|
|
451
|
+
* Rows below the edit shift by `inserts.length - count`: a delete pulls the tail up, an insert
|
|
452
|
+
* pushes it down, and doing both at once is a replace. Each inserted row takes either
|
|
453
|
+
* {@link RowInput} shape — a positional array from column A, or a key-addressed object — exactly
|
|
454
|
+
* like {@link addRow}. A `count` larger than the rows present simply clears the tail — it never
|
|
455
|
+
* silently becomes a no-op. Cells carry their full style to the shifted position, and merged ranges
|
|
456
|
+
* shift with the rows they cover.
|
|
457
|
+
*
|
|
458
|
+
* @throws {RangeError} if `start` is not a positive integer or `count` is negative.
|
|
459
|
+
*/
|
|
460
|
+
spliceRows(start: number, count: number, ...inserts: RowInput[]): void;
|
|
461
|
+
/**
|
|
462
|
+
* Insert one row of `values` at the 1-based `pos`, shifting the rows at and below it down by one.
|
|
463
|
+
* `values` takes either {@link RowInput} shape (positional array or keyed object), like
|
|
464
|
+
* {@link addRow}. Shorthand for {@link spliceRows}`(pos, 0, values)`.
|
|
465
|
+
*
|
|
466
|
+
* @throws {RangeError} if `pos` is not a positive integer.
|
|
467
|
+
*/
|
|
468
|
+
insertRow(pos: number, values: RowInput): void;
|
|
469
|
+
/**
|
|
470
|
+
* Append a row of `values` after the last used row, returning the cells it materialised.
|
|
471
|
+
* The append point is {@link rowCount}` + 1`, so the row lands below every row that holds
|
|
472
|
+
* data or its own formatting — never overwriting existing content, unlike {@link insertRow},
|
|
473
|
+
* which shifts and needs a position. Unlike {@link spliceRows}, appending shifts nothing, so
|
|
474
|
+
* it never disturbs merges or the rows above.
|
|
475
|
+
*
|
|
476
|
+
* A row takes either shape: a positional array whose values map to columns from A — a hole in a
|
|
477
|
+
* sparse array (`['a', , 'c']`) leaves that column untouched — or a keyed object whose values
|
|
478
|
+
* land under the columns carrying the matching {@link ColumnProperties.key}.
|
|
479
|
+
*/
|
|
480
|
+
addRow(values: RowInput): Cell[];
|
|
481
|
+
/**
|
|
482
|
+
* Append several rows after the last used row in one call, returning the cells materialised
|
|
483
|
+
* for each. The rows stack in order — the first lands at {@link rowCount}` + 1`, the next
|
|
484
|
+
* directly below it — so a later row never collides with an earlier one even when both are
|
|
485
|
+
* value-less. Each row is an array or a keyed object independently, so a mixed batch is fine.
|
|
486
|
+
* The bulk form of {@link addRow}.
|
|
487
|
+
*/
|
|
488
|
+
addRows(rows: RowInput[]): Cell[][];
|
|
489
|
+
/**
|
|
490
|
+
* Freeze the top `ySplit` rows and left `xSplit` columns in place; the rest of the sheet scrolls
|
|
491
|
+
* beneath them. `freeze(1)` pins a header row; `freeze(0, 1)` pins the first column. Passing both
|
|
492
|
+
* zero clears the freeze (equivalent to {@link unfreeze}).
|
|
493
|
+
*
|
|
494
|
+
* @throws {RangeError} if either split is a negative or non-integer count.
|
|
495
|
+
*/
|
|
496
|
+
freeze(ySplit?: number, xSplit?: number): void;
|
|
497
|
+
/** Clear any frozen split, returning the sheet to a normal (fully scrolling) view. */
|
|
498
|
+
unfreeze(): void;
|
|
499
|
+
/**
|
|
500
|
+
* Copy the row at the 1-based `start`, `options.count` times (default 1). With `options.insert`
|
|
501
|
+
* (the default) the copies are inserted directly after the source, shifting the rows below — and
|
|
502
|
+
* any merged range there — down by `count`; otherwise the copies overwrite the rows immediately
|
|
503
|
+
* below without shifting. Each copy is a faithful duplicate of the source's values and per-cell
|
|
504
|
+
* styles, and carries no merge of its own, so a range can be merged onto a duplicated row afterwards.
|
|
505
|
+
*
|
|
506
|
+
* @throws {RangeError} if `start` is not a positive integer or `count` is negative.
|
|
507
|
+
*/
|
|
508
|
+
duplicateRow(start: number, options?: {
|
|
509
|
+
count?: number;
|
|
510
|
+
insert?: boolean;
|
|
511
|
+
}): void;
|
|
512
|
+
/**
|
|
513
|
+
* Remove `count` columns starting at the 1-based `start`, then insert the given columns in their
|
|
514
|
+
* place — the column analog of {@link spliceRows}. Columns to the right shift by
|
|
515
|
+
* `inserts.length - count`, keeping their values and styles, and a merged range lying wholly to
|
|
516
|
+
* the right of the edit re-anchors to its new columns. Each inserted column is an array of values
|
|
517
|
+
* indexed by row (index 0 → row 1); an empty array inserts a blank column.
|
|
518
|
+
*
|
|
519
|
+
* @throws {RangeError} if `start` is not a positive integer or `count` is negative.
|
|
520
|
+
*/
|
|
521
|
+
spliceColumns(start: number, count: number, ...inserts: CellValue[][]): void;
|
|
522
|
+
/**
|
|
523
|
+
* Insert one column of `values` at the 1-based `pos`, shifting the columns at and right of it over
|
|
524
|
+
* by one. `values` is an array of values indexed by row (index 0 → row 1), like
|
|
525
|
+
* {@link addColumn}. Shorthand for {@link spliceColumns}`(pos, 0, values)`.
|
|
526
|
+
*
|
|
527
|
+
* @throws {RangeError} if `pos` is not a positive integer.
|
|
528
|
+
*/
|
|
529
|
+
insertColumn(pos: number, values: CellValue[]): void;
|
|
530
|
+
/**
|
|
531
|
+
* Append a column of `values` after the last used column, returning the cells it materialised.
|
|
532
|
+
* The append point is {@link columnCount}` + 1`, so the column lands right of every column that
|
|
533
|
+
* holds data or its own formatting — never overwriting existing content, unlike {@link insertColumn},
|
|
534
|
+
* which shifts and needs a position. Unlike {@link spliceColumns}, appending shifts nothing, so it
|
|
535
|
+
* never disturbs merges or the columns to its left.
|
|
536
|
+
*
|
|
537
|
+
* `values` is an array indexed by row (index 0 → row 1); a hole or an explicit `undefined` leaves
|
|
538
|
+
* that row untouched, mirroring {@link addRow}'s positional-array shape.
|
|
539
|
+
*/
|
|
540
|
+
addColumn(values: CellValue[]): Cell[];
|
|
541
|
+
/**
|
|
542
|
+
* Append several columns after the last used column in one call, returning the cells materialised
|
|
543
|
+
* for each. The columns stack in order — the first lands at {@link columnCount}` + 1`, the next
|
|
544
|
+
* directly right of it — so a later column never collides with an earlier one even when both are
|
|
545
|
+
* value-less. The bulk form of {@link addColumn}.
|
|
546
|
+
*/
|
|
547
|
+
addColumns(columns: CellValue[][]): Cell[][];
|
|
548
|
+
/**
|
|
549
|
+
* A snapshot of this sheet's value and overlay content (see {@link WorksheetModel}). Reading it and
|
|
550
|
+
* assigning it onto another sheet — `dst.model = src.model` — reproduces the source: merges, cells
|
|
551
|
+
* and their styles, column/row metadata, tables, the autofilter, protection, and the page setup all
|
|
552
|
+
* survive, because the getter emits and the setter consumes exactly the same fields. Identity
|
|
553
|
+
* (`name`, `id`) is not part of the model and is never touched by assignment; nor are attached parts
|
|
554
|
+
* that carry workbook-level identity (images, pivots, byte-preserved charts/drawings) — see
|
|
555
|
+
* {@link WorksheetModel} for that boundary.
|
|
556
|
+
*/
|
|
557
|
+
get model(): WorksheetModel;
|
|
558
|
+
set model(model: WorksheetModel);
|
|
559
|
+
/**
|
|
560
|
+
* Protect the sheet, making the per-cell `locked`/`hidden` flags enforceable. Without a
|
|
561
|
+
* password the protection is a soft lock any consumer can lift; with one, the password is
|
|
562
|
+
* salted and hashed on the spot (the plaintext is never retained) so lifting the protection
|
|
563
|
+
* requires re-supplying it. `options` names which operations stay available to a user while
|
|
564
|
+
* the sheet is protected; anything unspecified falls to Excel's default for that operation.
|
|
565
|
+
*
|
|
566
|
+
* Re-protecting replaces any prior protection; {@link unprotect} clears it.
|
|
567
|
+
*/
|
|
568
|
+
protect(password?: string, options?: SheetProtectionOptions): void;
|
|
569
|
+
/** Remove any protection previously set by {@link protect}. */
|
|
570
|
+
unprotect(): void;
|
|
571
|
+
/** The sheet's protection, or `undefined` if the sheet is unprotected. */
|
|
572
|
+
get protection(): SheetProtection | undefined;
|
|
573
|
+
/**
|
|
574
|
+
* The codec's channel into this sheet — see `core/internal.ts` for why these are not public
|
|
575
|
+
* methods. Declared last so every private field it closes over is already in scope.
|
|
576
|
+
*/
|
|
577
|
+
readonly [INTERNAL]: WorksheetInternals;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* What the library's own machinery may do to a `Worksheet` that an author may not: reinstate state
|
|
581
|
+
* read from a file, place a cell where a file or model says rather than where addressing would put
|
|
582
|
+
* it, and release a row the streaming writer has finished with. Reached as `sheet[INTERNAL]`; see
|
|
583
|
+
* `core/internal.ts`.
|
|
584
|
+
*/
|
|
585
|
+
export interface WorksheetInternals {
|
|
586
|
+
/**
|
|
587
|
+
* Drop a row's materialised cells and format properties, releasing its cell graph. The streaming
|
|
588
|
+
* writer calls this the moment a row is serialised so peak memory stays bounded to the rows still
|
|
589
|
+
* in flight rather than the whole sheet. Row *numbering* is the caller's concern: eviction lowers
|
|
590
|
+
* {@link Worksheet.rowCount}, so an append-driven producer must track its own high-water mark
|
|
591
|
+
* rather than lean on this sheet's used range.
|
|
592
|
+
*/
|
|
593
|
+
evictRow(number: number): void;
|
|
594
|
+
/**
|
|
595
|
+
* Register a pivot table reconstructed from a loaded package — the reader's counterpart to
|
|
596
|
+
* {@link Worksheet.addPivotTable}. This records an inspectable, read-only view of a pivot the
|
|
597
|
+
* reader parsed from its OOXML parts; the pivot itself round-trips by byte-preservation, so
|
|
598
|
+
* registering it here only makes it visible via {@link Worksheet.loadedPivotTables} and never
|
|
599
|
+
* affects what the writer emits.
|
|
600
|
+
*/
|
|
601
|
+
addLoadedPivotTable(pivot: ParsedPivotTable): void;
|
|
602
|
+
/**
|
|
603
|
+
* Reinstate the threaded conversations read from a file, in the order the reader found them,
|
|
604
|
+
* replacing any already held. Their authors and mentioned people are already resolved against the
|
|
605
|
+
* workbook registry, so a thread arrives self-contained.
|
|
606
|
+
*
|
|
607
|
+
* Not authoring — {@link Worksheet.addCommentThread} is that, and validates the anchor. These
|
|
608
|
+
* threads are what a re-write emits, so what the reader hands over is what the file will say.
|
|
609
|
+
*/
|
|
610
|
+
restoreCommentThreads(threads: readonly CommentThread[]): void;
|
|
611
|
+
/**
|
|
612
|
+
* Record a worksheet-level reference to package content the model does not interpret, so the writer
|
|
613
|
+
* re-emits it verbatim. Called by the reader when it meets a `<drawing>` holding only vector shapes
|
|
614
|
+
* or a `<legacyDrawingHF>` header/footer image.
|
|
615
|
+
*/
|
|
616
|
+
addPreservedReference(reference: PreservedWorksheetReference): void;
|
|
617
|
+
/**
|
|
618
|
+
* Reinstate an already-derived protection state — the deserialization counterpart to
|
|
619
|
+
* {@link Worksheet.protect}. A loaded `<sheetProtection>` carries its credential in finished agile
|
|
620
|
+
* form (algorithm, hash, salt, spin count) with no recoverable plaintext password, so the reader
|
|
621
|
+
* restores that credential verbatim rather than re-hashing.
|
|
622
|
+
*/
|
|
623
|
+
restoreProtection(protection: SheetProtection): void;
|
|
624
|
+
/**
|
|
625
|
+
* Materialise the cell at an exact 1-based position, creating it on first access. Unlike
|
|
626
|
+
* {@link Worksheet.getCell} this performs no merge resolution: the cell returned is the one at
|
|
627
|
+
* `(row, col)` even when a merged region covers it. Loading content is where that matters — a
|
|
628
|
+
* model or a parsed file states where each value sits, and routing a covered value to its region
|
|
629
|
+
* master mid-load would move it.
|
|
630
|
+
*/
|
|
631
|
+
cellAt(row: number, col: number): Cell;
|
|
632
|
+
/**
|
|
633
|
+
* The store behind a {@link Row} or {@link Column} handle. These six exist because the handles are
|
|
634
|
+
* views rather than records: they hold a sheet and a position, and every read and write goes
|
|
635
|
+
* through here to the one authoritative map. `…PropertiesOf` never fabricates, so reading a row
|
|
636
|
+
* cannot extend the used range; `ensure…` is what a write calls, so the record appears exactly
|
|
637
|
+
* when a value is set.
|
|
638
|
+
*/
|
|
639
|
+
rowPropertiesOf(number: number): RowProperties | undefined;
|
|
640
|
+
ensureRowProperties(number: number): RowProperties;
|
|
641
|
+
/** The row's materialised cells in ascending column order. */
|
|
642
|
+
rowCells(number: number): Cell[];
|
|
643
|
+
columnPropertiesOf(index: number): ColumnProperties | undefined;
|
|
644
|
+
ensureColumnProperties(index: number): ColumnProperties;
|
|
645
|
+
/** The column's materialised cells in ascending row order. */
|
|
646
|
+
columnCells(index: number): Cell[];
|
|
647
|
+
}
|