@ex-grid/sheet-xlsx 0.0.0-stage → 0.2.0-beta.3
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 +21 -0
- package/README.md +28 -2
- package/dist/index.d.ts +368 -0
- package/dist/index.js +2708 -0
- package/dist/index.js.map +7 -0
- package/package.json +27 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AkiraMisawa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ex-grid/sheet-xlsx
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An ExSheet Workbook opened from and saved to .xlsx, as ExSheet.Xlsx opens and saves it, over @ex-grid/data-xlsx: constants, Formulas, Cell Formats and column widths carried, everything that would change a Value refused by name, and what else the file held listed in an Open Report.
|
|
4
|
+
|
|
5
|
+
It is one of the packages of the ExGrid family: Excel-like grids, sheets, pivot tables and charts for reading
|
|
6
|
+
money and risk numbers, published to npm under `@ex-grid` and to NuGet for Blazor, at one shared version.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install @ex-grid/sheet-xlsx
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
It depends on exactly the version of `@ex-grid/data-xlsx` and `@ex-grid/sheet-engine` it was built with, so upgrade the family's packages together.
|
|
15
|
+
|
|
16
|
+
## Documentation
|
|
17
|
+
|
|
18
|
+
[ExSheet on the documentation site](https://akiramisawa.github.io/ex-grid/exsheet/xlsx), read for React with the switch at the top, and every
|
|
19
|
+
version's [Release Notes](https://akiramisawa.github.io/ex-grid/release-notes).
|
|
20
|
+
|
|
21
|
+
> **The API may still change.** While the version is `0.x`, it may change from one version to the next; each
|
|
22
|
+
> version's Release Notes say what changed. A prerelease, a version with a suffix such as `-rc.1`, passed every
|
|
23
|
+
> test layer in CI on the commit it was built from. A version without a suffix is published only once the
|
|
24
|
+
> project's [Definition of Done](https://github.com/AkiraMisawa/ex-grid/blob/main/docs/definition-of-done.md) is
|
|
25
|
+
> signed off on it.
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { Culture } from '@ex-grid/sheet-engine';
|
|
2
|
+
import { Workbook } from '@ex-grid/sheet-engine';
|
|
3
|
+
import type { WorkbookDocument } from '@ex-grid/sheet-engine';
|
|
4
|
+
import { XlsxError } from '@ex-grid/data-xlsx';
|
|
5
|
+
import { XlsxReadOptions } from '@ex-grid/data-xlsx';
|
|
6
|
+
import { XlsxRefusal } from '@ex-grid/data-xlsx';
|
|
7
|
+
|
|
8
|
+
/** The longest Formula Excel holds, in characters, without its `=`. */
|
|
9
|
+
export declare const maxFormulaLength = 8192;
|
|
10
|
+
|
|
11
|
+
/** The most rows a Linked Table written as an Excel Table holds: a worksheet's 1,048,576, less its header's. */
|
|
12
|
+
export declare const maxLinkedTableRows: number;
|
|
13
|
+
|
|
14
|
+
/** The longest text a cell of Excel holds, in characters. */
|
|
15
|
+
export declare const maxTextLength = 32767;
|
|
16
|
+
|
|
17
|
+
/** One thing the file held that was not carried (ADR-0330 §4). */
|
|
18
|
+
export declare interface NotCarried {
|
|
19
|
+
/** What it is. */
|
|
20
|
+
readonly kind: NotCarriedKind;
|
|
21
|
+
/** The Sheet it was on, or `null` for what the workbook as a whole held. */
|
|
22
|
+
readonly sheet: string | null;
|
|
23
|
+
/** What names it more closely, where something does: a defined name, the first cell of rich text or of a format not
|
|
24
|
+
* carried (a cell as `B7`, columns as `B:C`, rows as `5:5`), an element's name; otherwise `null`. */
|
|
25
|
+
readonly detail: string | null;
|
|
26
|
+
/** One sentence an application can show as it stands. */
|
|
27
|
+
readonly description: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** What kind of thing an `OpenReport` says was not carried (ADR-0330 §4). */
|
|
31
|
+
export declare type NotCarriedKind =
|
|
32
|
+
/** A worksheet that is hidden: it opens shown (ADR-0331 §4). */
|
|
33
|
+
'hiddenSheet'
|
|
34
|
+
/** A sheet that is not a worksheet — a chart sheet, a dialog or macro sheet — which holds no cells. */
|
|
35
|
+
| 'chartSheet'
|
|
36
|
+
/** A defined name, which no Formula carried reads; `detail` is its name, and `sheet` the sheet it is local to, or `null`
|
|
37
|
+
* for a name of the whole workbook. */
|
|
38
|
+
| 'definedName'
|
|
39
|
+
/** Rows given heights of their own. */
|
|
40
|
+
| 'rowHeights'
|
|
41
|
+
/** Rows that are hidden: they open shown. */
|
|
42
|
+
| 'hiddenRows'
|
|
43
|
+
/** Columns that are hidden: they open shown. */
|
|
44
|
+
| 'hiddenColumns'
|
|
45
|
+
/** Panes frozen in the Sheet's view. */
|
|
46
|
+
| 'frozenPanes'
|
|
47
|
+
/** Merged cells: each cell is carried on its own. */
|
|
48
|
+
| 'mergedCells'
|
|
49
|
+
/** Conditional formatting. */
|
|
50
|
+
| 'conditionalFormatting'
|
|
51
|
+
/** Data validation. */
|
|
52
|
+
| 'dataValidation'
|
|
53
|
+
/** Notes and comments. */
|
|
54
|
+
| 'notesAndComments'
|
|
55
|
+
/** Hyperlinks: the cells' text is carried. */
|
|
56
|
+
| 'hyperlinks'
|
|
57
|
+
/** Pictures, charts, shapes and controls drawn over the Sheet. */
|
|
58
|
+
| 'picturesAndCharts'
|
|
59
|
+
/** The Sheet's protection. */
|
|
60
|
+
| 'protection'
|
|
61
|
+
/** Print settings beyond Excel's defaults: margins, a page set-up of its own, headers and footers with text, page breaks,
|
|
62
|
+
* printed gridlines or headings, a fit to pages, a print area or print titles. */
|
|
63
|
+
| 'printSettings'
|
|
64
|
+
/** An AutoFilter, and the sort state it keeps. */
|
|
65
|
+
| 'autoFilter'
|
|
66
|
+
/** The structure of an Excel Table that no Formula reads: its cells are carried. */
|
|
67
|
+
| 'excelTable'
|
|
68
|
+
/** The Sheet's tab colour. */
|
|
69
|
+
| 'sheetProperties'
|
|
70
|
+
/** Rich-text runs inside cells: the text is carried, the runs' own formatting is not. */
|
|
71
|
+
| 'richText'
|
|
72
|
+
/** A PivotTable: the cells it shows are carried as constants, the PivotTable is not. */
|
|
73
|
+
| 'pivotTables'
|
|
74
|
+
/** Links to other workbooks that no Formula carried reads. */
|
|
75
|
+
| 'externalLinks'
|
|
76
|
+
/** Connections to outside data, and the queries that read through them. */
|
|
77
|
+
| 'dataConnections'
|
|
78
|
+
/** Slicers and timelines. */
|
|
79
|
+
| 'slicers'
|
|
80
|
+
/** View settings that change how the Sheet looks: hidden gridlines, headings or zeros, Formulas shown, right to left, a
|
|
81
|
+
* zoom, a page layout. */
|
|
82
|
+
| 'view'
|
|
83
|
+
/** Anything else a worksheet holds; `detail` names its element, as `customSheetViews`. */
|
|
84
|
+
| 'other'
|
|
85
|
+
/** Colours that name the workbook's theme: each is carried as the RGB value the file's theme gives it, and the link to the
|
|
86
|
+
* theme is not, so another theme does not recolour them (ADR-0330 §8). Said once, of the whole workbook. */
|
|
87
|
+
| 'themeColours'
|
|
88
|
+
/** A typeface or a size other than the workbook's own font's: the cells open in the Sheet's one font (ADR-0071). */
|
|
89
|
+
| 'fontNamesAndSizes'
|
|
90
|
+
/** Vertical alignment other than bottom. */
|
|
91
|
+
| 'verticalAlignment'
|
|
92
|
+
/** Wrapped, indented, rotated or shrunk text. */
|
|
93
|
+
| 'textLayout'
|
|
94
|
+
/** A horizontal alignment a Sheet does not have — fill, justify, distributed, centred across the selection: the cells open
|
|
95
|
+
* aligned as General. */
|
|
96
|
+
| 'horizontalAlignment'
|
|
97
|
+
/** A double or accounting underline: the cells open with a single underline. */
|
|
98
|
+
| 'underline'
|
|
99
|
+
/** A pattern or gradient fill, or a solid one of no colour: the cells open with no Fill. */
|
|
100
|
+
| 'patternFills'
|
|
101
|
+
/** Diagonal borders: the cells keep their four sides. */
|
|
102
|
+
| 'diagonalBorders'
|
|
103
|
+
/** A default column width of the Sheet's own: its columns without a width of their own open at the default width. */
|
|
104
|
+
| 'defaultColumnWidth';
|
|
105
|
+
|
|
106
|
+
/** What reading an .xlsx returns beside the Workbook Document (ADR-0330 §5). */
|
|
107
|
+
export declare class OpenReport {
|
|
108
|
+
/**
|
|
109
|
+
* What the file held that changes how a Sheet looks, or what else the file held, and that ExSheet did not carry
|
|
110
|
+
* (ADR-0330 §4's "Not carried"), in the workbook's order: what the workbook holds first, then each Sheet's in turn. Saving
|
|
111
|
+
* the Workbook again will not keep any of it.
|
|
112
|
+
*/
|
|
113
|
+
readonly notCarried: readonly NotCarried[];
|
|
114
|
+
/**
|
|
115
|
+
* The cells whose Formula names a function outside ExSheet's declared set (`DeclaredFunction`), in Sheet order and then
|
|
116
|
+
* row by row: each is carried, and shows `#NAME?` (ADR-0047, ADR-0330 §4).
|
|
117
|
+
*/
|
|
118
|
+
readonly unsupportedFunctions: readonly UnsupportedFunctionCell[];
|
|
119
|
+
/** @internal */
|
|
120
|
+
constructor(notCarried: readonly NotCarried[], unsupportedFunctions: readonly UnsupportedFunctionCell[]);
|
|
121
|
+
/** Whether the file was carried whole: nothing left behind, and every function it names supported. */
|
|
122
|
+
get isEmpty(): boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Reads the workbook in `file` into a Workbook Document under `culture`, with its Open Report, or refuses it by name
|
|
127
|
+
* (`XlsxOpenError`). The read goes a batch of cells at a time, reporting progress and yielding between slices as `options`
|
|
128
|
+
* says, so a browser keeps painting while a large file is read.
|
|
129
|
+
*
|
|
130
|
+
* @param file - The file's bytes.
|
|
131
|
+
* @param culture - The Workbook's culture, declared by the application as a CSV's encoding is (ADR-0330 §7): how typing is
|
|
132
|
+
* read and Values are shown from here on. No Value read from the file depends on it, and nothing in the file is taken for
|
|
133
|
+
* it. A locale the engine holds no data for throws a `RangeError` before the file is read.
|
|
134
|
+
* @param options - The file layer's limits, progress, pacing and cancellation (ADR-0330 §9); its defaults when left out. An
|
|
135
|
+
* aborted `signal` is looked at between slices, and a cancelled read opens nothing.
|
|
136
|
+
* @returns The Workbook Document and its Open Report.
|
|
137
|
+
* @throws XlsxOpenError - The workbook is refused, and nothing opens.
|
|
138
|
+
*/
|
|
139
|
+
export declare function openXlsxWorkbook(file: Uint8Array | ArrayBuffer | Blob, culture: Culture | string, options?: XlsxReadOptions): Promise<XlsxOpenResult>;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Writes `workbook` as it stands as an .xlsx, or refuses it by name (`XlsxSaveError`), returning nothing.
|
|
143
|
+
*
|
|
144
|
+
* The Workbook's snapshot is taken before the write first yields — every Sheet's document, every Value it shows, its spills
|
|
145
|
+
* and each Linked Table's rows — and the file is built from that snapshot while yielding (ADR-0330 §9): the file is the
|
|
146
|
+
* Workbook as it stood when the call was made, and the Workbook may change once the returned promise is under way. A Linked
|
|
147
|
+
* Table's worksheet is written for Excel, and is not read back as a Linked Table (ADR-0330 §6): opened again, it is a
|
|
148
|
+
* worksheet of the table's cells.
|
|
149
|
+
*
|
|
150
|
+
* @param workbook - The Workbook.
|
|
151
|
+
* @param options - What the write may produce, and how it paces itself; the defaults when left out.
|
|
152
|
+
* @returns The file, as a Blob of the spreadsheet's media type.
|
|
153
|
+
* @throws XlsxSaveError - The Workbook is refused, and nothing was written.
|
|
154
|
+
* @throws RangeError - `maxUncompressedBytes` lies outside 1 to `defaultMaxUncompressedBytes`, or `maxCells` is not a number.
|
|
155
|
+
*/
|
|
156
|
+
export declare function saveXlsxWorkbook(workbook: Workbook, options?: XlsxSaveOptions): Promise<Blob>;
|
|
157
|
+
|
|
158
|
+
/** A cell whose Formula names a function ExSheet does not support (ADR-0330 §4, §5): the Formula is carried, and shows
|
|
159
|
+
* `#NAME?`. */
|
|
160
|
+
export declare interface UnsupportedFunctionCell {
|
|
161
|
+
/** The Sheet's name. */
|
|
162
|
+
readonly sheet: string;
|
|
163
|
+
/** The cell, as `B7`. */
|
|
164
|
+
readonly cell: string;
|
|
165
|
+
/** The functions it names that are not supported, in the Formula's order. */
|
|
166
|
+
readonly functions: readonly string[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** A workbook refused by name, and nothing opened (ADR-0330 §4). */
|
|
170
|
+
export declare class XlsxOpenError extends Error {
|
|
171
|
+
/** Why the workbook was refused. */
|
|
172
|
+
readonly reason: XlsxOpenRefusal;
|
|
173
|
+
/** The name of the Sheet the refusal met, or `undefined` when it is not about one Sheet. */
|
|
174
|
+
readonly sheet: string | undefined;
|
|
175
|
+
/** The cell the refusal met, as `B7`, or `undefined` when it is not about one cell. */
|
|
176
|
+
readonly cell: string | undefined;
|
|
177
|
+
/** What the cell held — a Formula's text with its `=`, or a constant — or `undefined` when the refusal is not about one
|
|
178
|
+
* cell. */
|
|
179
|
+
readonly held: string | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* A refusal naming what it met.
|
|
182
|
+
* @param reason - Why the workbook is refused.
|
|
183
|
+
* @param message - What was wrong, as a sentence that follows the Sheet and the cell.
|
|
184
|
+
* @param where - The Sheet, the cell and what the cell held, as far as it is about one.
|
|
185
|
+
* @param options - What caused it, when it was another error.
|
|
186
|
+
*/
|
|
187
|
+
constructor(reason: XlsxOpenRefusal, message: string, where?: XlsxOpenPlace, options?: ErrorOptions);
|
|
188
|
+
/** Why the file layer refused the file, when `reason` is `file`; otherwise `undefined`. */
|
|
189
|
+
get fileRefusal(): XlsxRefusal | undefined;
|
|
190
|
+
/** The file layer's refusal, with its Sheet and cell. @internal */
|
|
191
|
+
static fromFile(e: XlsxError): XlsxOpenError;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Where an open's refusal met what it refuses, as far as it is about one Sheet and cell. */
|
|
195
|
+
export declare interface XlsxOpenPlace {
|
|
196
|
+
/** The name of the Sheet it met. */
|
|
197
|
+
readonly sheet?: string | undefined;
|
|
198
|
+
/** The cell it met, as `B7`. */
|
|
199
|
+
readonly cell?: string | undefined;
|
|
200
|
+
/** What the cell held, as a Formula's text with its `=` or a constant's. */
|
|
201
|
+
readonly held?: string | undefined;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Why a workbook was refused, and nothing opened (ADR-0330 §4): what it held would change a Value, or the number a cell
|
|
206
|
+
* shows, or it is not a file that can be read faithfully.
|
|
207
|
+
*/
|
|
208
|
+
export declare type XlsxOpenRefusal =
|
|
209
|
+
/** The file layer refused the file: not a plain .xlsx, damaged, or past a limit. `XlsxOpenError.fileRefusal` says why. */
|
|
210
|
+
'file'
|
|
211
|
+
/** A Formula the engine cannot read: a syntax it does not implement (an array constant, the union operator, `@`), or a
|
|
212
|
+
* What-If data table. */
|
|
213
|
+
| 'unreadableFormula'
|
|
214
|
+
/** A Formula reads a defined name, which ExSheet does not define, so it would show `#NAME?` where Excel shows a Value. */
|
|
215
|
+
| 'definedName'
|
|
216
|
+
/** A Formula reads another workbook, which ExSheet cannot reach. */
|
|
217
|
+
| 'otherWorkbook'
|
|
218
|
+
/** A Formula reads an Excel Table, which ExSheet does not read yet (ADR-0330 §6). */
|
|
219
|
+
| 'excelTable'
|
|
220
|
+
/** A legacy array formula (Ctrl+Shift+Enter), whose cells Excel computes as one, and ExSheet would spill otherwise. */
|
|
221
|
+
| 'legacyArrayFormula'
|
|
222
|
+
/** A constant a cell cannot hold in ExSheet, such as an Error Value the engine does not read. */
|
|
223
|
+
| 'unreadableConstant'
|
|
224
|
+
/** A worksheet's name is not one a Sheet can have, or the workbook holds no worksheet at all. */
|
|
225
|
+
| 'sheets'
|
|
226
|
+
/**
|
|
227
|
+
* A cell, a row or a column takes a Number Format the engine does not read, or a built-in one whose code follows the
|
|
228
|
+
* computer's locale and that the file does not spell out: shown in General instead, a date would show as a serial, or a
|
|
229
|
+
* currency lose its symbol (ADR-0330 §4). `XlsxOpenError.held` is the format's code as the file spells it, or
|
|
230
|
+
* `Number Format N`, naming its id, where the file spells none.
|
|
231
|
+
*/
|
|
232
|
+
| 'numberFormat';
|
|
233
|
+
|
|
234
|
+
/** A Workbook Document read from an .xlsx, and its Open Report (ADR-0330 §5). */
|
|
235
|
+
export declare interface XlsxOpenResult {
|
|
236
|
+
/** The Workbook Document: every worksheet a Sheet, in the file's order, the one shown shown. */
|
|
237
|
+
readonly document: WorkbookDocument;
|
|
238
|
+
/** What was not carried, and the cells naming functions ExSheet does not support. */
|
|
239
|
+
readonly report: OpenReport;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** A Workbook not written, refused by name (ADR-0330 §6). */
|
|
243
|
+
export declare class XlsxSaveError extends Error {
|
|
244
|
+
/** Why the Workbook was not written. */
|
|
245
|
+
readonly reason: XlsxSaveRefusal;
|
|
246
|
+
/** The name of the Sheet the refusal met, or `undefined` when it is not about one Sheet. */
|
|
247
|
+
readonly sheet: string | undefined;
|
|
248
|
+
/** The cell the refusal met, as `B7`, or `undefined` when it is not about one cell. */
|
|
249
|
+
readonly cell: string | undefined;
|
|
250
|
+
/** What the cell held — a Formula's text with its `=` — or `undefined`. */
|
|
251
|
+
readonly held: string | undefined;
|
|
252
|
+
/**
|
|
253
|
+
* A refusal naming what it met.
|
|
254
|
+
* @param reason - Why the Workbook is not written.
|
|
255
|
+
* @param message - What was wrong, as a sentence that follows the Sheet and the cell.
|
|
256
|
+
* @param where - The Sheet, the cell and what the cell held, as far as it is about one.
|
|
257
|
+
*/
|
|
258
|
+
constructor(reason: XlsxSaveRefusal, message: string, where?: XlsxSavePlace);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* What a write may produce, and how it paces itself (ADR-0330 §6, §9). Beyond either limit the Workbook is refused by name,
|
|
263
|
+
* never written in part. The write takes its snapshot of the Workbook before it first yields, then builds the file from it in
|
|
264
|
+
* slices sized by time, yielding between them so that a browser keeps painting, and reports its progress after each, as a
|
|
265
|
+
* read does. A key left out takes the default its comment names.
|
|
266
|
+
*/
|
|
267
|
+
export declare interface XlsxSaveOptions {
|
|
268
|
+
/**
|
|
269
|
+
* The cells the whole workbook may write, every worksheet counted, each element a cell: the Sheets' own cells, the cells an
|
|
270
|
+
* array spills into, the cells of no value written where a formatted row crosses a formatted column, a Linked Table's cells
|
|
271
|
+
* and its header's, and each row a row format writes, which is an element of its own whether or not it holds a cell (a row
|
|
272
|
+
* format over every row writes 1,048,576). `defaultMaxCells` when left out, the most a file is read with by default, so
|
|
273
|
+
* that what is written opens again. Beyond it the write is refused by name (`tooManyCells`) before anything is written.
|
|
274
|
+
*/
|
|
275
|
+
readonly maxCells?: number;
|
|
276
|
+
/**
|
|
277
|
+
* The uncompressed bytes the file's parts may hold together: 1 to `defaultMaxUncompressedBytes`, which it is when left
|
|
278
|
+
* out, the most a file is read with by default. Beyond it the write is refused by name (`tooLarge`).
|
|
279
|
+
*/
|
|
280
|
+
readonly maxUncompressedBytes?: number;
|
|
281
|
+
/** Told how far the write has come after every slice, and once more when every element is written. */
|
|
282
|
+
readonly onProgress?: (progress: XlsxSaveProgress) => void;
|
|
283
|
+
/** How long one slice works, in milliseconds, before the write yields; 30 when left out, a read's. A slice always does
|
|
284
|
+
* some work, so 0 yields after every batch. */
|
|
285
|
+
readonly sliceBudgetMs?: number;
|
|
286
|
+
/** What the write awaits between slices; a macrotask (`setTimeout(…, 0)`) when left out, as a read's. */
|
|
287
|
+
readonly yield?: () => Promise<void>;
|
|
288
|
+
/** Cancels the write: it rejects with the signal's reason, looked at between slices. Cancelled, it writes nothing. */
|
|
289
|
+
readonly signal?: AbortSignal;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Where a save's refusal met what it refuses, as far as it is about one Sheet and cell. */
|
|
293
|
+
export declare interface XlsxSavePlace {
|
|
294
|
+
/** The name of the Sheet it met. */
|
|
295
|
+
readonly sheet?: string | undefined;
|
|
296
|
+
/** The cell it met, as `B7`. */
|
|
297
|
+
readonly cell?: string | undefined;
|
|
298
|
+
/** What the cell held, as a Formula's text with its `=`. */
|
|
299
|
+
readonly held?: string | undefined;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** How far a write has come (`XlsxSaveOptions.onProgress`): the Workbook's snapshot being planned, then the worksheets being
|
|
303
|
+
* written. */
|
|
304
|
+
export declare interface XlsxSaveProgress {
|
|
305
|
+
/** The index of the worksheet being written, in the file's order, from zero, a Linked Table's after the Sheets'; -1 while
|
|
306
|
+
* the snapshot is planned: its cells counted against the limit and checked. */
|
|
307
|
+
readonly sheet: number;
|
|
308
|
+
/** The worksheets the file holds: one for each Sheet and one for each Linked Table. */
|
|
309
|
+
readonly sheets: number;
|
|
310
|
+
/** The elements written so far, counted as `maxCells` counts them; 0 while the snapshot is planned. */
|
|
311
|
+
readonly elements: number;
|
|
312
|
+
/** The elements the file writes, counted as `maxCells` counts them; 0 while the snapshot is planned. */
|
|
313
|
+
readonly totalElements: number;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Why a Workbook was not written, and nothing was (ADR-0330 §6): what it holds cannot be written as a file Excel reads with
|
|
318
|
+
* the Values the user saw, or would make a file too large to open again.
|
|
319
|
+
*/
|
|
320
|
+
export declare type XlsxSaveRefusal =
|
|
321
|
+
/**
|
|
322
|
+
* A Linked Table cannot be written as an Excel Table on a worksheet of its name, holding its rows as they stand
|
|
323
|
+
* (ADR-0330 §6): it has not answered (every Formula that reads it shows `#GETTING_DATA`), it holds no rows (an Excel Table
|
|
324
|
+
* holds at least one, and its Formulas would answer otherwise over one empty row), it holds more rows than a worksheet's
|
|
325
|
+
* 1,048,576 less its header's or more columns than its 16,384, or its name is already a Sheet's or is one a worksheet
|
|
326
|
+
* cannot have (longer than 31 characters, holding `\`, or `History`). Or a cell shows `#GETTING_DATA`. The refusal names
|
|
327
|
+
* the table, and a cell's refusal the Sheet and the cell.
|
|
328
|
+
*/
|
|
329
|
+
'linkedTable'
|
|
330
|
+
/**
|
|
331
|
+
* A cell shows `#CIRC!`: it is part of a circular reference, or depends on one. A file holds only Excel's Error Values, and
|
|
332
|
+
* Excel shows 0 there, which ExSheet refuses to show (ADR-0047); no Value the file can hold is the one the user saw.
|
|
333
|
+
*/
|
|
334
|
+
| 'circularReference'
|
|
335
|
+
/**
|
|
336
|
+
* A Formula that cannot be written as Excel stores it, or as Excel takes it: its text is longer than Excel's 8,192
|
|
337
|
+
* characters, holds a text constant longer than 255, nests its calls deeper than 64 levels or makes one with more than 255
|
|
338
|
+
* arguments; it holds half of a surrogate pair, which a file cannot carry; it reads a Sheet the Workbook does not have
|
|
339
|
+
* (Excel would read another workbook's); it calls a name a `LET` binds or a `LAMBDA` takes, which ExSheet reads as an
|
|
340
|
+
* unknown function and Excel would call; it reads, by a structured reference, a Linked Table or a column the Workbook does
|
|
341
|
+
* not declare, or a column whose name begins or ends with a space or holds `@`, a tab, a line break or one of
|
|
342
|
+
* `, : . " { } $ ^ & * + = - < > /`, whose form Excel has not been seen to write; it reads a Linked Table's name as a name
|
|
343
|
+
* of its own (`=SUM(Positions)`), which ExSheet shows as `#NAME?` and Excel would read as the table; or it does not read
|
|
344
|
+
* back as the Formula it is.
|
|
345
|
+
*/
|
|
346
|
+
| 'formula'
|
|
347
|
+
/**
|
|
348
|
+
* A cell's text is longer than the 32,767 characters a cell of Excel holds, or holds half of a surrogate pair, which a file
|
|
349
|
+
* cannot carry; or a Sheet's name holds a character a worksheet's name cannot carry in a file: a control character below
|
|
350
|
+
* U+0020, U+FFFE or U+FFFF, or half of a surrogate pair. The refusal then names the Sheet and no cell.
|
|
351
|
+
*/
|
|
352
|
+
| 'text'
|
|
353
|
+
/**
|
|
354
|
+
* The workbook would write more elements than `XlsxSaveOptions.maxCells`, which counts each cell written and each row a
|
|
355
|
+
* row format writes. A Sheet formatted on many rows and many columns writes a cell wherever a formatted row crosses a
|
|
356
|
+
* formatted column that records a part the row does not, and a row format writes a row element for every row it covers,
|
|
357
|
+
* holding a cell or not. The default limit is the cells a file is read with (`defaultMaxCells`); the reader counts cells
|
|
358
|
+
* only, so a file within it opens again, and rows are counted here so that a row format over every row is bounded too.
|
|
359
|
+
*/
|
|
360
|
+
| 'tooManyCells'
|
|
361
|
+
/**
|
|
362
|
+
* The workbook would hold more uncompressed bytes than `XlsxSaveOptions.maxUncompressedBytes`: by default, more than a
|
|
363
|
+
* file is read with (`defaultMaxUncompressedBytes`), so it would not open again. The refusal names the Sheet whose
|
|
364
|
+
* worksheet went past it, when one did.
|
|
365
|
+
*/
|
|
366
|
+
| 'tooLarge';
|
|
367
|
+
|
|
368
|
+
export { }
|