@dukelib/sheets 0.1.4
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 -0
- package/index.d.ts +850 -0
- package/index.js +584 -0
- package/package.json +61 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,850 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/** Statistics from calculating a workbook. */
|
|
4
|
+
export declare class CalculationStats {
|
|
5
|
+
/** Number of formulas found */
|
|
6
|
+
get formulaCount(): number
|
|
7
|
+
/** Number of cells calculated */
|
|
8
|
+
get cellsCalculated(): number
|
|
9
|
+
/** Number of errors encountered */
|
|
10
|
+
get errors(): number
|
|
11
|
+
/** Number of circular references detected */
|
|
12
|
+
get circularReferences(): number
|
|
13
|
+
/** Number of volatile cells (e.g., NOW(), RAND()) */
|
|
14
|
+
get volatileCells(): number
|
|
15
|
+
/** Whether iterative calculation converged */
|
|
16
|
+
get converged(): boolean
|
|
17
|
+
/** Number of iterations performed */
|
|
18
|
+
get iterations(): number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Represents a cell value in a spreadsheet.
|
|
23
|
+
*
|
|
24
|
+
* Cell values can be one of several types:
|
|
25
|
+
* - Empty (null/undefined)
|
|
26
|
+
* - Number
|
|
27
|
+
* - Text (string)
|
|
28
|
+
* - Boolean
|
|
29
|
+
* - Error (like "#DIV/0!")
|
|
30
|
+
* - Formula cached results are exposed as regular cell values; formula text lives on Worksheet accessors
|
|
31
|
+
*/
|
|
32
|
+
export declare class CellValue {
|
|
33
|
+
/** Check if the cell is empty */
|
|
34
|
+
get isEmpty(): boolean
|
|
35
|
+
/** Check if the cell contains a number */
|
|
36
|
+
get isNumber(): boolean
|
|
37
|
+
/** Check if the cell contains text */
|
|
38
|
+
get isText(): boolean
|
|
39
|
+
/** Check if the cell contains a boolean */
|
|
40
|
+
get isBoolean(): boolean
|
|
41
|
+
/** Check if the cell contains an error */
|
|
42
|
+
get isError(): boolean
|
|
43
|
+
/** Get the value as a number, or null if not a number */
|
|
44
|
+
asNumber(): number | null
|
|
45
|
+
/** Get the value as text, or null if not text */
|
|
46
|
+
asText(): string | null
|
|
47
|
+
/** Get the value as a boolean, or null if not a boolean */
|
|
48
|
+
asBoolean(): boolean | null
|
|
49
|
+
/** Get the error string, or null if not an error */
|
|
50
|
+
asError(): string | null
|
|
51
|
+
/** Convert to a JavaScript native value (number, string, boolean, or null) */
|
|
52
|
+
toJs(): number | string | boolean | null
|
|
53
|
+
/** Get string representation of the cell value */
|
|
54
|
+
toString(): string
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A workbook containing one or more worksheets.
|
|
59
|
+
*
|
|
60
|
+
* This is the main entry point for working with spreadsheet files.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const wb = new Workbook();
|
|
65
|
+
* const sheet = wb.getSheet(0);
|
|
66
|
+
* sheet.setCell("A1", 10);
|
|
67
|
+
* sheet.setCell("A2", 20);
|
|
68
|
+
* sheet.setFormula("A3", "=A1+A2");
|
|
69
|
+
* wb.calculate();
|
|
70
|
+
* console.log(sheet.getCalculatedValue("A3").asNumber()); // 30
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare class Workbook {
|
|
74
|
+
/** Whether the workbook has no worksheets. */
|
|
75
|
+
get isEmpty(): boolean
|
|
76
|
+
/** The index of the active (selected) worksheet. */
|
|
77
|
+
get activeSheet(): number
|
|
78
|
+
/** Get the index of a worksheet by name, or null if not found. */
|
|
79
|
+
sheetIndex(name: string): number | null
|
|
80
|
+
/** Workbook-level settings (date system, protection, etc.). */
|
|
81
|
+
get settings(): JsWorkbookSettings
|
|
82
|
+
/** Get all named ranges defined in the workbook. */
|
|
83
|
+
get namedRanges(): Array<JsNamedRange>
|
|
84
|
+
/** Create a new empty workbook with one worksheet */
|
|
85
|
+
constructor()
|
|
86
|
+
/**
|
|
87
|
+
* Open a workbook from a file
|
|
88
|
+
*
|
|
89
|
+
* Supported formats:
|
|
90
|
+
* - `.xlsx` (Excel 2007+)
|
|
91
|
+
* - `.xls` (Legacy Excel)
|
|
92
|
+
* - `.csv` (Comma-separated values)
|
|
93
|
+
*
|
|
94
|
+
* @param path - Path to the file
|
|
95
|
+
*/
|
|
96
|
+
static open(path: string): Workbook
|
|
97
|
+
/**
|
|
98
|
+
* Load a workbook from XLSX bytes (Buffer/Uint8Array)
|
|
99
|
+
*
|
|
100
|
+
* @param data - The XLSX file content as a Buffer
|
|
101
|
+
*/
|
|
102
|
+
static fromXlsxBytes(data: Buffer): Workbook
|
|
103
|
+
/**
|
|
104
|
+
* Load a workbook from a CSV string
|
|
105
|
+
*
|
|
106
|
+
* @param csv - The CSV content as a string
|
|
107
|
+
*/
|
|
108
|
+
static fromCsvString(csv: string): Workbook
|
|
109
|
+
/**
|
|
110
|
+
* Load a workbook from bytes (Buffer/Uint8Array), auto-detecting the format.
|
|
111
|
+
*
|
|
112
|
+
* Supports XLSX and XLS formats. The format is detected from magic bytes.
|
|
113
|
+
*
|
|
114
|
+
* @param data - The file content as a Buffer
|
|
115
|
+
*/
|
|
116
|
+
static fromBytes(data: Buffer): Workbook
|
|
117
|
+
/**
|
|
118
|
+
* Save the workbook to a file
|
|
119
|
+
*
|
|
120
|
+
* The format is determined by the file extension:
|
|
121
|
+
* - `.xlsx` for Excel format
|
|
122
|
+
* - `.csv` for CSV format (first sheet only)
|
|
123
|
+
*
|
|
124
|
+
* @param path - Path to save to
|
|
125
|
+
*/
|
|
126
|
+
save(path: string): void
|
|
127
|
+
/** Save the workbook as a CSV string (first sheet only) */
|
|
128
|
+
saveCsvString(): string
|
|
129
|
+
/** Get the number of worksheets */
|
|
130
|
+
get sheetCount(): number
|
|
131
|
+
/** Get a list of all worksheet names */
|
|
132
|
+
get sheetNames(): Array<string>
|
|
133
|
+
/**
|
|
134
|
+
* Get a worksheet by index (number) or name (string)
|
|
135
|
+
*
|
|
136
|
+
* @param indexOrName - Either a zero-based index or a sheet name
|
|
137
|
+
* @throws Error if index out of range or name not found
|
|
138
|
+
*/
|
|
139
|
+
getSheet(indexOrName: number | string): Worksheet
|
|
140
|
+
/**
|
|
141
|
+
* Add a new worksheet with the given name
|
|
142
|
+
*
|
|
143
|
+
* @param name - Name for the new worksheet
|
|
144
|
+
* @returns Index of the new worksheet
|
|
145
|
+
*/
|
|
146
|
+
addSheet(name: string): number
|
|
147
|
+
/**
|
|
148
|
+
* Remove a worksheet by index
|
|
149
|
+
*
|
|
150
|
+
* @param index - Zero-based index of the worksheet to remove
|
|
151
|
+
*/
|
|
152
|
+
removeSheet(index: number): void
|
|
153
|
+
/**
|
|
154
|
+
* Calculate all formulas in the workbook
|
|
155
|
+
*
|
|
156
|
+
* @returns Statistics about the calculation
|
|
157
|
+
*/
|
|
158
|
+
calculate(): CalculationStats
|
|
159
|
+
/**
|
|
160
|
+
* Calculate with custom options for iterative calculation
|
|
161
|
+
*
|
|
162
|
+
* @param iterative - Enable iterative calculation for circular references
|
|
163
|
+
* @param maxIterations - Maximum iterations (default 100)
|
|
164
|
+
* @param maxChange - Convergence threshold (default 0.001)
|
|
165
|
+
* @param mode - Calculation mode: "exact", "multipass", or "auto" (default "auto")
|
|
166
|
+
* @param autoThreshold - Formula count threshold for auto mode (default 50000)
|
|
167
|
+
*/
|
|
168
|
+
calculateWithOptions(iterative?: boolean | undefined | null, maxIterations?: number | undefined | null, maxChange?: number | undefined | null, mode?: string | undefined | null, autoThreshold?: number | undefined | null): CalculationStats
|
|
169
|
+
/**
|
|
170
|
+
* Define a named range
|
|
171
|
+
*
|
|
172
|
+
* @param name - Name for the range (e.g., "TaxRate")
|
|
173
|
+
* @param refersTo - What the name refers to (e.g., "Sheet1!$A$1" or "0.05")
|
|
174
|
+
*/
|
|
175
|
+
defineName(name: string, refersTo: string): void
|
|
176
|
+
/**
|
|
177
|
+
* Get a named range definition
|
|
178
|
+
*
|
|
179
|
+
* @param name - Name to look up
|
|
180
|
+
* @returns The refers_to string, or null if not found
|
|
181
|
+
*/
|
|
182
|
+
getNamedRange(name: string): string | null
|
|
183
|
+
/**
|
|
184
|
+
* Save the workbook to a file asynchronously (non-blocking).
|
|
185
|
+
*
|
|
186
|
+
* @param path - Path to save to
|
|
187
|
+
* @returns Promise<void>
|
|
188
|
+
*/
|
|
189
|
+
saveAsync(path: string): Promise<unknown>
|
|
190
|
+
/**
|
|
191
|
+
* Calculate all formulas asynchronously (non-blocking).
|
|
192
|
+
*
|
|
193
|
+
* @returns Promise<CalculationStats>
|
|
194
|
+
*/
|
|
195
|
+
calculateAsync(): Promise<unknown>
|
|
196
|
+
/**
|
|
197
|
+
* Calculate with custom options asynchronously (non-blocking).
|
|
198
|
+
*
|
|
199
|
+
* @param iterative - Enable iterative calculation for circular references
|
|
200
|
+
* @param maxIterations - Maximum iterations (default 100)
|
|
201
|
+
* @param maxChange - Convergence threshold (default 0.001)
|
|
202
|
+
* @returns Promise<CalculationStats>
|
|
203
|
+
*/
|
|
204
|
+
calculateWithOptionsAsync(iterative?: boolean | undefined | null, maxIterations?: number | undefined | null, maxChange?: number | undefined | null, mode?: string | undefined | null, autoThreshold?: number | undefined | null): Promise<unknown>
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* A worksheet within a workbook.
|
|
209
|
+
*
|
|
210
|
+
* Worksheets contain cells organized in rows and columns. Each cell can
|
|
211
|
+
* contain a value (number, text, boolean) or a formula.
|
|
212
|
+
*/
|
|
213
|
+
export declare class Worksheet {
|
|
214
|
+
/** Sheet visibility: "visible", "hidden", or "veryHidden". */
|
|
215
|
+
get visibility(): string
|
|
216
|
+
/** Whether the worksheet is selected. */
|
|
217
|
+
get isSelected(): boolean
|
|
218
|
+
/** Zoom scale percentage, or null if default. */
|
|
219
|
+
get zoomScale(): number | null
|
|
220
|
+
/** Sheet tab color, or null if default. */
|
|
221
|
+
get tabColor(): JsColor | null
|
|
222
|
+
/** Whether the worksheet has no cells. */
|
|
223
|
+
get isEmpty(): boolean
|
|
224
|
+
/** Total number of cells with data. */
|
|
225
|
+
get cellCount(): number
|
|
226
|
+
/** Sheet view selections. */
|
|
227
|
+
get selections(): Array<JsSelection>
|
|
228
|
+
/** Get the resolved style for a cell by address (e.g., "A1"). */
|
|
229
|
+
getCellStyle(address: string): JsStyle | null
|
|
230
|
+
/** Get the resolved style for a cell by row/col (0-based). */
|
|
231
|
+
getCellStyleAt(row: number, col: number): JsStyle | null
|
|
232
|
+
/** Get the display-formatted value of a cell (e.g., "$1,234.56"). */
|
|
233
|
+
getFormattedValue(address: string): string
|
|
234
|
+
/** Get the display-formatted value by row/col (0-based). */
|
|
235
|
+
getFormattedValueAt(row: number, col: number): string
|
|
236
|
+
/** Default row height in points. */
|
|
237
|
+
get defaultRowHeight(): number
|
|
238
|
+
/** Default column width in character units. */
|
|
239
|
+
get defaultColumnWidth(): number
|
|
240
|
+
/** Whether a row is hidden. */
|
|
241
|
+
isRowHidden(row: number): boolean
|
|
242
|
+
/** Whether a column is hidden. */
|
|
243
|
+
isColumnHidden(col: number): boolean
|
|
244
|
+
/** Get the outline (grouping) level of a row. */
|
|
245
|
+
getRowOutlineLevel(row: number): number
|
|
246
|
+
/** Get the outline (grouping) level of a column. */
|
|
247
|
+
getColumnOutlineLevel(col: number): number
|
|
248
|
+
/** Whether a row group is collapsed. */
|
|
249
|
+
isRowCollapsed(row: number): boolean
|
|
250
|
+
/** Whether a column group is collapsed. */
|
|
251
|
+
isColumnCollapsed(col: number): boolean
|
|
252
|
+
/** Freeze pane settings, or null if no freeze panes. */
|
|
253
|
+
get freezePanes(): JsFreezePanes | null
|
|
254
|
+
/** Split pane settings, or null if no split panes. */
|
|
255
|
+
get splitPanes(): JsSplitPanes | null
|
|
256
|
+
/** Get the hyperlink on a cell, or null if none. */
|
|
257
|
+
getHyperlink(address: string): JsHyperlink | null
|
|
258
|
+
/** Get the hyperlink on a cell by row/col (0-based), or null if none. */
|
|
259
|
+
getHyperlinkAt(row: number, col: number): JsHyperlink | null
|
|
260
|
+
/** Number of hyperlinks in the worksheet. */
|
|
261
|
+
get hyperlinkCount(): number
|
|
262
|
+
/** Get all hyperlinks as an array of `{ address, hyperlink }`. */
|
|
263
|
+
get hyperlinks(): Array<JsHyperlinkEntry>
|
|
264
|
+
/** Get the comment on a cell by address, or null if none. */
|
|
265
|
+
getComment(address: string): JsComment | null
|
|
266
|
+
/** Get the comment on a cell by row/col (0-based), or null if none. */
|
|
267
|
+
getCommentAt(row: number, col: number): JsComment | null
|
|
268
|
+
/** Whether a cell has a comment (by address). */
|
|
269
|
+
hasComment(address: string): boolean
|
|
270
|
+
/** Whether a cell has a comment (by row/col). */
|
|
271
|
+
hasCommentAt(row: number, col: number): boolean
|
|
272
|
+
/** Number of comments in the worksheet. */
|
|
273
|
+
get commentCount(): number
|
|
274
|
+
/** Get all comments as an array of `{ row, col, comment }`. */
|
|
275
|
+
get comments(): Array<JsCommentEntry>
|
|
276
|
+
/** List of distinct comment authors. */
|
|
277
|
+
get commentAuthors(): Array<string>
|
|
278
|
+
/** Get all tables in the worksheet. */
|
|
279
|
+
get tables(): Array<JsTable>
|
|
280
|
+
/** Get a table by name, or null if not found. */
|
|
281
|
+
getTableByName(name: string): JsTable | null
|
|
282
|
+
/** Number of tables in the worksheet. */
|
|
283
|
+
get tableCount(): number
|
|
284
|
+
/** Get all data validation rules. */
|
|
285
|
+
get dataValidations(): Array<JsDataValidation>
|
|
286
|
+
/** Number of data validation rules. */
|
|
287
|
+
get dataValidationCount(): number
|
|
288
|
+
/** Get all conditional formatting rules. */
|
|
289
|
+
get conditionalFormats(): Array<JsConditionalFormatRule>
|
|
290
|
+
/** Number of conditional formatting rules. */
|
|
291
|
+
get conditionalFormatCount(): number
|
|
292
|
+
/** The auto-filter on this worksheet, or null if none. */
|
|
293
|
+
get autoFilter(): JsAutoFilter | null
|
|
294
|
+
/** Sheet protection settings, or null if unprotected. */
|
|
295
|
+
get protection(): JsSheetProtection | null
|
|
296
|
+
/** Page setup / print settings. */
|
|
297
|
+
get pageSetup(): JsPageSetup
|
|
298
|
+
/** Print area range string, or null if not set. */
|
|
299
|
+
get printArea(): string | null
|
|
300
|
+
/** Repeat rows at top of each printed page as `[startRow, endRow]`, or null. */
|
|
301
|
+
get repeatRows(): Array<number> | null
|
|
302
|
+
/** Repeat columns at left of each printed page as `[startCol, endCol]`, or null. */
|
|
303
|
+
get repeatCols(): Array<number> | null
|
|
304
|
+
/** Manual row page breaks. */
|
|
305
|
+
get rowBreaks(): Array<JsPageBreak>
|
|
306
|
+
/** Manual column page breaks. */
|
|
307
|
+
get colBreaks(): Array<JsPageBreak>
|
|
308
|
+
/** Get the formula text of a cell by row/col (0-based), or null if not a formula cell. */
|
|
309
|
+
getFormulaAt(row: number, col: number): string | null
|
|
310
|
+
/** Get the number of formula cells in this worksheet. */
|
|
311
|
+
get formulaCount(): number
|
|
312
|
+
/** Get all formula cells as an array of `{ row, col, formula }`. */
|
|
313
|
+
get formulaCells(): Array<JsFormulaCell>
|
|
314
|
+
/** Whether a cell is a spill target (receives a spilled value from a dynamic array formula). */
|
|
315
|
+
isSpillTarget(row: number, col: number): boolean
|
|
316
|
+
/** Whether a cell is the source of a spill (has a dynamic array formula with results). */
|
|
317
|
+
isSpillSource(row: number, col: number): boolean
|
|
318
|
+
/** Get the source cell of a spill target, or null if not a spill target. */
|
|
319
|
+
getSpillSource(row: number, col: number): JsSpillSource | null
|
|
320
|
+
/** Whether the worksheet uses the 1904 date system. */
|
|
321
|
+
get date1904(): boolean
|
|
322
|
+
/** Get all merged regions as structured objects with start/end row/col. */
|
|
323
|
+
get mergedRegions(): Array<JsMergedRegion>
|
|
324
|
+
/**
|
|
325
|
+
* Get the merge span for a cell if it is the top-left origin of a merged region.
|
|
326
|
+
*
|
|
327
|
+
* Returns `{ rowSpan, colSpan }` if the cell is a merge origin, or null otherwise.
|
|
328
|
+
*/
|
|
329
|
+
getMergeSpan(row: number, col: number): JsMergeSpan | null
|
|
330
|
+
/** Whether a cell is a non-origin member of a merged region (should be skipped when rendering). */
|
|
331
|
+
isMergedSecondary(row: number, col: number): boolean
|
|
332
|
+
/** Get the worksheet name */
|
|
333
|
+
get name(): string
|
|
334
|
+
/**
|
|
335
|
+
* Set a cell value by address (e.g., "A1", "B2")
|
|
336
|
+
*
|
|
337
|
+
* The value can be:
|
|
338
|
+
* - `null` or `undefined` (clears the cell)
|
|
339
|
+
* - `number` (numeric value)
|
|
340
|
+
* - `string` (text)
|
|
341
|
+
* - `boolean`
|
|
342
|
+
*/
|
|
343
|
+
setCell(address: string, value?: number | string | boolean | undefined | null): void
|
|
344
|
+
/**
|
|
345
|
+
* Set a formula in a cell
|
|
346
|
+
*
|
|
347
|
+
* @param address - Cell address (e.g., "A1")
|
|
348
|
+
* @param formula - Formula string (e.g., "=SUM(A1:A10)")
|
|
349
|
+
*/
|
|
350
|
+
setFormula(address: string, formula: string): void
|
|
351
|
+
/** Get the raw cell value (not calculated) */
|
|
352
|
+
getCell(address: string): CellValue
|
|
353
|
+
/** Get the raw cell value by row/col (0-based). */
|
|
354
|
+
getCellAt(row: number, col: number): CellValue
|
|
355
|
+
/**
|
|
356
|
+
* Get the calculated value of a cell
|
|
357
|
+
*
|
|
358
|
+
* For formulas, this returns the computed result.
|
|
359
|
+
* For regular values, returns the value itself.
|
|
360
|
+
*/
|
|
361
|
+
getCalculatedValue(address: string): CellValue
|
|
362
|
+
/** Get the calculated value of a cell by row/col (0-based). */
|
|
363
|
+
getCalculatedValueAt(row: number, col: number): CellValue
|
|
364
|
+
/**
|
|
365
|
+
* Get the used range as `{ minRow, minCol, maxRow, maxCol }` or null
|
|
366
|
+
* if the worksheet is empty.
|
|
367
|
+
*/
|
|
368
|
+
get usedRange(): UsedRange | null
|
|
369
|
+
/** Set the height of a row in points */
|
|
370
|
+
setRowHeight(row: number, height: number): void
|
|
371
|
+
/** Set the width of a column in character units */
|
|
372
|
+
setColumnWidth(col: number, width: number): void
|
|
373
|
+
/** Get the row height in points, or null if not explicitly set */
|
|
374
|
+
getRowHeight(row: number): number | null
|
|
375
|
+
/** Get the column width in character units, or null if not explicitly set */
|
|
376
|
+
getColumnWidth(col: number): number | null
|
|
377
|
+
/** Merge cells in a range (e.g., "A1:C3") */
|
|
378
|
+
mergeCells(rangeStr: string): void
|
|
379
|
+
/** Unmerge cells in a range */
|
|
380
|
+
unmergeCells(rangeStr: string): boolean
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Load a workbook from XLSX bytes asynchronously (non-blocking).
|
|
385
|
+
*
|
|
386
|
+
* @param data - The XLSX file content as a Buffer
|
|
387
|
+
* @returns Promise<Workbook>
|
|
388
|
+
*/
|
|
389
|
+
export declare function fromXlsxBytesAsync(data: Buffer): Promise<unknown>
|
|
390
|
+
|
|
391
|
+
/** Text alignment settings. */
|
|
392
|
+
export interface JsAlignment {
|
|
393
|
+
horizontal: string
|
|
394
|
+
vertical: string
|
|
395
|
+
wrapText: boolean
|
|
396
|
+
shrinkToFit: boolean
|
|
397
|
+
indent: number
|
|
398
|
+
/** Rotation in degrees (-90 to 90, or 255 for vertical text). */
|
|
399
|
+
rotation: number
|
|
400
|
+
readingOrder: string
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/** A standalone auto-filter on a worksheet. */
|
|
404
|
+
export interface JsAutoFilter {
|
|
405
|
+
/** Range string the filter covers (e.g., `"A1:D10"`). */
|
|
406
|
+
range: string
|
|
407
|
+
filterColumns: Array<JsFilterColumn>
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** A single border edge (line style + color). */
|
|
411
|
+
export interface JsBorderEdge {
|
|
412
|
+
/**
|
|
413
|
+
* One of: `"none"`, `"thin"`, `"medium"`, `"thick"`, `"dashed"`, `"dotted"`,
|
|
414
|
+
* `"double"`, `"hair"`, `"mediumDashed"`, `"dashDot"`, `"mediumDashDot"`,
|
|
415
|
+
* `"dashDotDot"`, `"mediumDashDotDot"`, `"slantDashDot"`.
|
|
416
|
+
*/
|
|
417
|
+
style: string
|
|
418
|
+
color: JsColor
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Cell border style. */
|
|
422
|
+
export interface JsBorderStyle {
|
|
423
|
+
left?: JsBorderEdge
|
|
424
|
+
right?: JsBorderEdge
|
|
425
|
+
top?: JsBorderEdge
|
|
426
|
+
bottom?: JsBorderEdge
|
|
427
|
+
diagonal?: JsBorderEdge
|
|
428
|
+
/** One of: `"none"`, `"down"`, `"up"`, `"both"`. */
|
|
429
|
+
diagonalDirection: string
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** Cell protection settings. */
|
|
433
|
+
export interface JsCellProtection {
|
|
434
|
+
locked: boolean
|
|
435
|
+
hidden: boolean
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Color representation. The `colorType` field indicates the variant:
|
|
440
|
+
* `"auto"`, `"rgb"`, `"argb"`, `"theme"`, or `"indexed"`.
|
|
441
|
+
* The `hex` field always contains the resolved 6- or 8-char hex string.
|
|
442
|
+
*/
|
|
443
|
+
export interface JsColor {
|
|
444
|
+
colorType: string
|
|
445
|
+
/** Resolved hex string (6 or 8 chars, no `#` prefix). */
|
|
446
|
+
hex: string
|
|
447
|
+
r?: number
|
|
448
|
+
g?: number
|
|
449
|
+
b?: number
|
|
450
|
+
a?: number
|
|
451
|
+
/** Theme color index (0–9), present when `colorType === "theme"`. */
|
|
452
|
+
themeIndex?: number
|
|
453
|
+
/** Tint percentage (-100 to 100), present when `colorType === "theme"`. */
|
|
454
|
+
tint?: number
|
|
455
|
+
/** Palette index, present when `colorType === "indexed"`. */
|
|
456
|
+
paletteIndex?: number
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/** A cell comment/note. */
|
|
460
|
+
export interface JsComment {
|
|
461
|
+
author: string
|
|
462
|
+
text: string
|
|
463
|
+
visible: boolean
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** A comment with its cell address. */
|
|
467
|
+
export interface JsCommentEntry {
|
|
468
|
+
row: number
|
|
469
|
+
col: number
|
|
470
|
+
comment: JsComment
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** A conditional formatting rule. */
|
|
474
|
+
export interface JsConditionalFormatRule {
|
|
475
|
+
/**
|
|
476
|
+
* The type of rule: `"cellIs"`, `"expression"`, `"colorScale"`, `"dataBar"`,
|
|
477
|
+
* `"iconSet"`, `"top10"`, `"aboveAverage"`, `"containsText"`, `"beginsWith"`,
|
|
478
|
+
* `"endsWith"`, `"duplicateValues"`, `"uniqueValues"`, `"containsBlanks"`,
|
|
479
|
+
* `"notContainsBlanks"`, `"containsErrors"`, `"notContainsErrors"`, `"timePeriod"`.
|
|
480
|
+
*/
|
|
481
|
+
ruleType: string
|
|
482
|
+
/** Ranges this rule applies to (as range strings). */
|
|
483
|
+
ranges: Array<string>
|
|
484
|
+
/** Lower number = higher priority. */
|
|
485
|
+
priority: number
|
|
486
|
+
stopIfTrue: boolean
|
|
487
|
+
/** Operator (present for `cellIs` rules). */
|
|
488
|
+
operator?: string
|
|
489
|
+
/** Formula/value (present for `cellIs`, `expression` rules). */
|
|
490
|
+
formula1?: string
|
|
491
|
+
formula2?: string
|
|
492
|
+
/** Text value (present for `containsText`, `beginsWith`, `endsWith`). */
|
|
493
|
+
text?: string
|
|
494
|
+
/** Rank for top/bottom N rules. */
|
|
495
|
+
rank?: number
|
|
496
|
+
/** Whether the top/bottom N rule uses percentages. */
|
|
497
|
+
percent?: boolean
|
|
498
|
+
/** Whether it's a "bottom N" rule (vs top N). */
|
|
499
|
+
bottom?: boolean
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/** A data validation rule. */
|
|
503
|
+
export interface JsDataValidation {
|
|
504
|
+
/**
|
|
505
|
+
* The type of validation: `"none"`, `"whole"`, `"decimal"`, `"list"`,
|
|
506
|
+
* `"date"`, `"time"`, `"textLength"`, `"custom"`.
|
|
507
|
+
*/
|
|
508
|
+
validationType: string
|
|
509
|
+
/** Ranges this validation applies to (as range strings). */
|
|
510
|
+
ranges: Array<string>
|
|
511
|
+
allowBlank: boolean
|
|
512
|
+
showDropdown: boolean
|
|
513
|
+
showInputMessage: boolean
|
|
514
|
+
inputTitle?: string
|
|
515
|
+
inputMessage?: string
|
|
516
|
+
showErrorAlert: boolean
|
|
517
|
+
/** `"stop"`, `"warning"`, or `"information"`. */
|
|
518
|
+
errorStyle: string
|
|
519
|
+
errorTitle?: string
|
|
520
|
+
errorMessage?: string
|
|
521
|
+
/**
|
|
522
|
+
* Operator (present for numeric/date/time/textLength validations):
|
|
523
|
+
* `"between"`, `"notBetween"`, `"equal"`, `"notEqual"`, `"greaterThan"`,
|
|
524
|
+
* `"lessThan"`, `"greaterThanOrEqual"`, `"lessThanOrEqual"`.
|
|
525
|
+
*/
|
|
526
|
+
operator?: string
|
|
527
|
+
/** First value/formula (present for most validation types). */
|
|
528
|
+
value1?: string
|
|
529
|
+
/** Second value/formula (present for `between`/`notBetween`). */
|
|
530
|
+
value2?: string
|
|
531
|
+
/** List source string (present when `validationType === "list"`). */
|
|
532
|
+
listSource?: string
|
|
533
|
+
/** Custom formula (present when `validationType === "custom"`). */
|
|
534
|
+
formula?: string
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Fill/background style. The `fillType` field indicates the variant:
|
|
539
|
+
* `"none"`, `"solid"`, `"pattern"`, or `"gradient"`.
|
|
540
|
+
*/
|
|
541
|
+
export interface JsFillStyle {
|
|
542
|
+
fillType: string
|
|
543
|
+
/** Solid fill color (present when `fillType === "solid"`). */
|
|
544
|
+
color?: JsColor
|
|
545
|
+
/** Pattern type string (present when `fillType === "pattern"`). */
|
|
546
|
+
pattern?: string
|
|
547
|
+
/** Pattern foreground color. */
|
|
548
|
+
foreground?: JsColor
|
|
549
|
+
/** Pattern background color. */
|
|
550
|
+
background?: JsColor
|
|
551
|
+
/** Gradient type: `"linear"` or `"path"` (present when `fillType === "gradient"`). */
|
|
552
|
+
gradientType?: string
|
|
553
|
+
/** Gradient angle in degrees. */
|
|
554
|
+
angle?: number
|
|
555
|
+
/** Gradient color stops. */
|
|
556
|
+
stops?: Array<JsGradientStop>
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/** A filter on a single column. */
|
|
560
|
+
export interface JsFilterColumn {
|
|
561
|
+
colId: number
|
|
562
|
+
hiddenButton: boolean
|
|
563
|
+
showButton: boolean
|
|
564
|
+
/** The type of filter: `"values"`, `"custom"`, `"top10"`, `"dynamic"`, or `"color"`. */
|
|
565
|
+
filterType: string
|
|
566
|
+
/** Values for a discrete value filter (present when `filterType === "values"`). */
|
|
567
|
+
values?: Array<string>
|
|
568
|
+
/** Include blanks (present when `filterType === "values"`). */
|
|
569
|
+
blank?: boolean
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/** Font style settings. */
|
|
573
|
+
export interface JsFontStyle {
|
|
574
|
+
name: string
|
|
575
|
+
size: number
|
|
576
|
+
bold: boolean
|
|
577
|
+
italic: boolean
|
|
578
|
+
/** One of: `"none"`, `"single"`, `"double"`, `"singleAccounting"`, `"doubleAccounting"`. */
|
|
579
|
+
underline: string
|
|
580
|
+
strikethrough: boolean
|
|
581
|
+
color: JsColor
|
|
582
|
+
/** One of: `"baseline"`, `"superscript"`, `"subscript"`. */
|
|
583
|
+
verticalAlign: string
|
|
584
|
+
family?: number
|
|
585
|
+
charset?: number
|
|
586
|
+
scheme?: string
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/** A formula cell with address. */
|
|
590
|
+
export interface JsFormulaCell {
|
|
591
|
+
row: number
|
|
592
|
+
col: number
|
|
593
|
+
formula: string
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/** Freeze pane settings. */
|
|
597
|
+
export interface JsFreezePanes {
|
|
598
|
+
/** First unfrozen row. */
|
|
599
|
+
row: number
|
|
600
|
+
/** First unfrozen column. */
|
|
601
|
+
col: number
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/** Gradient color stop. */
|
|
605
|
+
export interface JsGradientStop {
|
|
606
|
+
position: number
|
|
607
|
+
color: JsColor
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/** A hyperlink attached to a cell. */
|
|
611
|
+
export interface JsHyperlink {
|
|
612
|
+
/** Target URL (external) or cell reference (internal). */
|
|
613
|
+
target: string
|
|
614
|
+
/** Display text (shown in cell; `null` means cell value is used). */
|
|
615
|
+
display?: string
|
|
616
|
+
/** Tooltip shown on hover. */
|
|
617
|
+
tooltip?: string
|
|
618
|
+
/** Location within target (e.g., sheet reference for internal links). */
|
|
619
|
+
location?: string
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/** A hyperlink with its cell address. */
|
|
623
|
+
export interface JsHyperlinkEntry {
|
|
624
|
+
address: string
|
|
625
|
+
hyperlink: JsHyperlink
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/** A merged cell region with structured coordinates. */
|
|
629
|
+
export interface JsMergedRegion {
|
|
630
|
+
startRow: number
|
|
631
|
+
startCol: number
|
|
632
|
+
endRow: number
|
|
633
|
+
endCol: number
|
|
634
|
+
/** The range as an A1-style string (e.g., "A1:C3"). */
|
|
635
|
+
range: string
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/** The row/column span of a merged region's origin cell. */
|
|
639
|
+
export interface JsMergeSpan {
|
|
640
|
+
rowSpan: number
|
|
641
|
+
colSpan: number
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/** A named range definition. */
|
|
645
|
+
export interface JsNamedRange {
|
|
646
|
+
name: string
|
|
647
|
+
/** `"workbook"` or `"sheet"`. */
|
|
648
|
+
scope: string
|
|
649
|
+
/** Sheet index when `scope === "sheet"`. */
|
|
650
|
+
sheetIndex?: number
|
|
651
|
+
/** The formula/reference the name refers to. */
|
|
652
|
+
refersTo: string
|
|
653
|
+
comment?: string
|
|
654
|
+
hidden: boolean
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Number format. The `formatType` field indicates the variant:
|
|
659
|
+
* `"general"`, `"builtin"`, or `"custom"`.
|
|
660
|
+
*/
|
|
661
|
+
export interface JsNumberFormat {
|
|
662
|
+
formatType: string
|
|
663
|
+
/** Built-in format ID (present when `formatType === "builtin"`). */
|
|
664
|
+
id?: number
|
|
665
|
+
/** The resolved format string (always present). */
|
|
666
|
+
formatString: string
|
|
667
|
+
/** Whether this format represents a date/time. */
|
|
668
|
+
isDateFormat: boolean
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/** A manual page break (row or column). */
|
|
672
|
+
export interface JsPageBreak {
|
|
673
|
+
/** Row index (for row breaks) or column index (for col breaks), 0-based. */
|
|
674
|
+
id: number
|
|
675
|
+
min: number
|
|
676
|
+
max: number
|
|
677
|
+
/** Whether this is a manual break. */
|
|
678
|
+
manual: boolean
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/** Page setup / print settings. */
|
|
682
|
+
export interface JsPageSetup {
|
|
683
|
+
/** Paper size (1 = Letter, 9 = A4, etc.). */
|
|
684
|
+
paperSize: number
|
|
685
|
+
/** `"portrait"` or `"landscape"`. */
|
|
686
|
+
orientation: string
|
|
687
|
+
/** Scale percentage (10–400). */
|
|
688
|
+
scale: number
|
|
689
|
+
fitToWidth?: number
|
|
690
|
+
fitToHeight?: number
|
|
691
|
+
topMargin: number
|
|
692
|
+
bottomMargin: number
|
|
693
|
+
leftMargin: number
|
|
694
|
+
rightMargin: number
|
|
695
|
+
headerMargin: number
|
|
696
|
+
footerMargin: number
|
|
697
|
+
printGridlines: boolean
|
|
698
|
+
printHeadings: boolean
|
|
699
|
+
oddHeader?: string
|
|
700
|
+
oddFooter?: string
|
|
701
|
+
evenHeader?: string
|
|
702
|
+
evenFooter?: string
|
|
703
|
+
firstHeader?: string
|
|
704
|
+
firstFooter?: string
|
|
705
|
+
differentOddEven: boolean
|
|
706
|
+
differentFirst: boolean
|
|
707
|
+
scaleWithDoc: boolean
|
|
708
|
+
alignWithMargins: boolean
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/** A single run of rich text. */
|
|
712
|
+
export interface JsRichTextRun {
|
|
713
|
+
text: string
|
|
714
|
+
font?: JsRunFont
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/** Font properties for a rich text run (all fields optional — unset inherits cell style). */
|
|
718
|
+
export interface JsRunFont {
|
|
719
|
+
bold?: boolean
|
|
720
|
+
italic?: boolean
|
|
721
|
+
size?: number
|
|
722
|
+
color?: JsColor
|
|
723
|
+
name?: string
|
|
724
|
+
underline?: string
|
|
725
|
+
strikethrough?: boolean
|
|
726
|
+
verticalAlign?: string
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/** A selection within a sheet view. */
|
|
730
|
+
export interface JsSelection {
|
|
731
|
+
pane?: string
|
|
732
|
+
activeCell?: string
|
|
733
|
+
sqref?: string
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/** Sheet protection settings. */
|
|
737
|
+
export interface JsSheetProtection {
|
|
738
|
+
protected: boolean
|
|
739
|
+
selectLockedCells: boolean
|
|
740
|
+
selectUnlockedCells: boolean
|
|
741
|
+
formatCells: boolean
|
|
742
|
+
formatColumns: boolean
|
|
743
|
+
formatRows: boolean
|
|
744
|
+
insertColumns: boolean
|
|
745
|
+
insertRows: boolean
|
|
746
|
+
insertHyperlinks: boolean
|
|
747
|
+
deleteColumns: boolean
|
|
748
|
+
deleteRows: boolean
|
|
749
|
+
sort: boolean
|
|
750
|
+
autoFilter: boolean
|
|
751
|
+
pivotTables: boolean
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/** A cell with address and value. */
|
|
755
|
+
export interface JsSpillSource {
|
|
756
|
+
row: number
|
|
757
|
+
col: number
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/** Split pane settings. */
|
|
761
|
+
export interface JsSplitPanes {
|
|
762
|
+
xSplit: number
|
|
763
|
+
ySplit: number
|
|
764
|
+
topLeftRow?: number
|
|
765
|
+
topLeftCol?: number
|
|
766
|
+
activePane?: string
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Complete cell style including font, fill, border, alignment, number format,
|
|
771
|
+
* and protection settings.
|
|
772
|
+
*/
|
|
773
|
+
export interface JsStyle {
|
|
774
|
+
font: JsFontStyle
|
|
775
|
+
fill: JsFillStyle
|
|
776
|
+
border: JsBorderStyle
|
|
777
|
+
alignment: JsAlignment
|
|
778
|
+
numberFormat: JsNumberFormat
|
|
779
|
+
protection: JsCellProtection
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/** An Excel table (ListObject). */
|
|
783
|
+
export interface JsTable {
|
|
784
|
+
id: number
|
|
785
|
+
name: string
|
|
786
|
+
displayName: string
|
|
787
|
+
/** Range string (e.g., `"A1:D10"`). */
|
|
788
|
+
reference: string
|
|
789
|
+
columns: Array<JsTableColumn>
|
|
790
|
+
styleInfo?: JsTableStyleInfo
|
|
791
|
+
headerRowCount: number
|
|
792
|
+
totalsRowCount: number
|
|
793
|
+
totalsRowShown: boolean
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/** A column within a table. */
|
|
797
|
+
export interface JsTableColumn {
|
|
798
|
+
id: number
|
|
799
|
+
name: string
|
|
800
|
+
/**
|
|
801
|
+
* One of: `"average"`, `"count"`, `"countNums"`, `"max"`, `"min"`,
|
|
802
|
+
* `"sum"`, `"stdDev"`, `"var"`, `"custom"`, `"none"`, or `null`.
|
|
803
|
+
*/
|
|
804
|
+
totalsRowFunction?: string
|
|
805
|
+
totalsRowFormula?: string
|
|
806
|
+
totalsRowLabel?: string
|
|
807
|
+
calculatedColumnFormula?: string
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/** Table style configuration. */
|
|
811
|
+
export interface JsTableStyleInfo {
|
|
812
|
+
name?: string
|
|
813
|
+
showFirstColumn: boolean
|
|
814
|
+
showLastColumn: boolean
|
|
815
|
+
showRowStripes: boolean
|
|
816
|
+
showColumnStripes: boolean
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/** Workbook-level settings. */
|
|
820
|
+
export interface JsWorkbookSettings {
|
|
821
|
+
/** Whether the 1904 date system is used (macOS default). */
|
|
822
|
+
date1904: boolean
|
|
823
|
+
/** Whether the workbook structure is protected. */
|
|
824
|
+
protected: boolean
|
|
825
|
+
/** Calculate formulas on open. */
|
|
826
|
+
calcOnOpen: boolean
|
|
827
|
+
theme?: string
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Open a workbook from a file asynchronously (non-blocking).
|
|
832
|
+
*
|
|
833
|
+
* Runs file I/O and parsing on the libuv thread pool so the
|
|
834
|
+
* Node.js event loop is not blocked.
|
|
835
|
+
*
|
|
836
|
+
* @param path - Path to the file
|
|
837
|
+
* @returns Promise<Workbook>
|
|
838
|
+
*/
|
|
839
|
+
export declare function openAsync(path: string): Promise<unknown>
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* The used range of a worksheet, describing the bounding box of all cells
|
|
843
|
+
* that contain data.
|
|
844
|
+
*/
|
|
845
|
+
export interface UsedRange {
|
|
846
|
+
minRow: number
|
|
847
|
+
minCol: number
|
|
848
|
+
maxRow: number
|
|
849
|
+
maxCol: number
|
|
850
|
+
}
|