@cj-tech-master/excelts 1.4.5 → 1.5.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/dist/browser/excelts.iife.js +454 -159
- package/dist/browser/excelts.iife.js.map +1 -1
- package/dist/browser/excelts.iife.min.js +28 -28
- package/dist/cjs/doc/anchor.js +25 -11
- package/dist/cjs/doc/cell.js +75 -43
- package/dist/cjs/doc/column.js +74 -22
- package/dist/cjs/doc/defined-names.js +53 -7
- package/dist/cjs/doc/image.js +11 -8
- package/dist/cjs/doc/range.js +64 -28
- package/dist/cjs/doc/row.js +72 -31
- package/dist/cjs/doc/table.js +3 -5
- package/dist/cjs/doc/workbook.js +30 -6
- package/dist/cjs/doc/worksheet.js +165 -41
- package/dist/cjs/utils/sheet-utils.js +3 -1
- package/dist/cjs/utils/unzip/extract.js +30 -82
- package/dist/cjs/utils/unzip/index.js +18 -2
- package/dist/cjs/utils/unzip/zip-parser.js +458 -0
- package/dist/esm/doc/anchor.js +25 -11
- package/dist/esm/doc/cell.js +75 -43
- package/dist/esm/doc/column.js +74 -22
- package/dist/esm/doc/defined-names.js +53 -7
- package/dist/esm/doc/image.js +11 -8
- package/dist/esm/doc/range.js +64 -28
- package/dist/esm/doc/row.js +72 -31
- package/dist/esm/doc/table.js +3 -5
- package/dist/esm/doc/workbook.js +30 -6
- package/dist/esm/doc/worksheet.js +165 -41
- package/dist/esm/utils/sheet-utils.js +3 -1
- package/dist/esm/utils/unzip/extract.js +28 -82
- package/dist/esm/utils/unzip/index.js +17 -2
- package/dist/esm/utils/unzip/zip-parser.js +451 -0
- package/dist/types/doc/anchor.d.ts +14 -7
- package/dist/types/doc/cell.d.ts +78 -37
- package/dist/types/doc/column.d.ts +72 -36
- package/dist/types/doc/defined-names.d.ts +11 -8
- package/dist/types/doc/image.d.ts +29 -12
- package/dist/types/doc/pivot-table.d.ts +1 -1
- package/dist/types/doc/range.d.ts +15 -4
- package/dist/types/doc/row.d.ts +78 -40
- package/dist/types/doc/table.d.ts +21 -36
- package/dist/types/doc/workbook.d.ts +54 -34
- package/dist/types/doc/worksheet.d.ts +255 -83
- package/dist/types/stream/xlsx/worksheet-reader.d.ts +3 -5
- package/dist/types/types.d.ts +86 -26
- package/dist/types/utils/col-cache.d.ts +11 -8
- package/dist/types/utils/unzip/extract.d.ts +16 -14
- package/dist/types/utils/unzip/index.d.ts +15 -1
- package/dist/types/utils/unzip/zip-parser.d.ts +92 -0
- package/package.json +1 -1
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { Worksheet } from "./worksheet.js";
|
|
2
|
-
import { DefinedNames } from "./defined-names.js";
|
|
1
|
+
import { Worksheet, type WorksheetModel } from "./worksheet.js";
|
|
2
|
+
import { DefinedNames, type DefinedNameModel } from "./defined-names.js";
|
|
3
3
|
import { XLSX } from "../xlsx/xlsx.js";
|
|
4
4
|
import { CSV } from "../csv/csv.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import type { PivotTable } from "./pivot-table.js";
|
|
6
|
+
import type { AddWorksheetOptions, CalculationProperties, Image, WorkbookProperties, WorkbookView, Buffer as ExcelBuffer } from "../types.js";
|
|
7
|
+
interface WorkbookMedia {
|
|
8
|
+
type: string;
|
|
9
|
+
extension: string;
|
|
10
|
+
filename?: string;
|
|
11
|
+
buffer?: ExcelBuffer;
|
|
12
|
+
base64?: string;
|
|
13
|
+
name?: string;
|
|
10
14
|
}
|
|
11
15
|
interface WorkbookModel {
|
|
12
16
|
creator?: string;
|
|
@@ -14,11 +18,11 @@ interface WorkbookModel {
|
|
|
14
18
|
lastPrinted?: Date;
|
|
15
19
|
created: Date;
|
|
16
20
|
modified: Date;
|
|
17
|
-
properties:
|
|
21
|
+
properties: Partial<WorkbookProperties>;
|
|
18
22
|
worksheets: WorksheetModel[];
|
|
19
23
|
sheets?: WorksheetModel[];
|
|
20
|
-
definedNames:
|
|
21
|
-
views:
|
|
24
|
+
definedNames: DefinedNameModel[];
|
|
25
|
+
views: WorkbookView[];
|
|
22
26
|
company: string;
|
|
23
27
|
manager: string;
|
|
24
28
|
title: string;
|
|
@@ -29,17 +33,10 @@ interface WorkbookModel {
|
|
|
29
33
|
language?: string;
|
|
30
34
|
revision?: number;
|
|
31
35
|
contentStatus?: string;
|
|
32
|
-
themes?:
|
|
33
|
-
media:
|
|
34
|
-
pivotTables:
|
|
35
|
-
calcProperties:
|
|
36
|
-
}
|
|
37
|
-
interface AddWorksheetOptions {
|
|
38
|
-
properties?: any;
|
|
39
|
-
views?: any[];
|
|
40
|
-
pageSetup?: any;
|
|
41
|
-
headerFooter?: any;
|
|
42
|
-
[key: string]: any;
|
|
36
|
+
themes?: unknown;
|
|
37
|
+
media: WorkbookMedia[];
|
|
38
|
+
pivotTables: PivotTable[];
|
|
39
|
+
calcProperties: Partial<CalculationProperties>;
|
|
43
40
|
}
|
|
44
41
|
declare class Workbook {
|
|
45
42
|
category: string;
|
|
@@ -49,38 +46,61 @@ declare class Workbook {
|
|
|
49
46
|
keywords: string;
|
|
50
47
|
manager: string;
|
|
51
48
|
modified: Date;
|
|
52
|
-
properties:
|
|
53
|
-
calcProperties:
|
|
54
|
-
_worksheets
|
|
49
|
+
properties: Partial<WorkbookProperties>;
|
|
50
|
+
calcProperties: Partial<CalculationProperties>;
|
|
51
|
+
private _worksheets;
|
|
55
52
|
subject: string;
|
|
56
53
|
title: string;
|
|
57
|
-
views:
|
|
58
|
-
media:
|
|
59
|
-
pivotTables:
|
|
60
|
-
_definedNames
|
|
54
|
+
views: WorkbookView[];
|
|
55
|
+
media: WorkbookMedia[];
|
|
56
|
+
pivotTables: PivotTable[];
|
|
57
|
+
private _definedNames;
|
|
61
58
|
creator?: string;
|
|
62
59
|
lastModifiedBy?: string;
|
|
63
60
|
lastPrinted?: Date;
|
|
64
61
|
language?: string;
|
|
65
62
|
revision?: number;
|
|
66
63
|
contentStatus?: string;
|
|
67
|
-
_themes
|
|
68
|
-
_xlsx
|
|
69
|
-
_csv
|
|
64
|
+
private _themes?;
|
|
65
|
+
private _xlsx?;
|
|
66
|
+
private _csv?;
|
|
70
67
|
constructor();
|
|
68
|
+
/**
|
|
69
|
+
* xlsx file format operations
|
|
70
|
+
*/
|
|
71
71
|
get xlsx(): XLSX;
|
|
72
|
+
/**
|
|
73
|
+
* csv file format operations
|
|
74
|
+
*/
|
|
72
75
|
get csv(): CSV;
|
|
73
76
|
get nextId(): number;
|
|
77
|
+
/**
|
|
78
|
+
* Add a new worksheet and return a reference to it
|
|
79
|
+
*/
|
|
74
80
|
addWorksheet(name?: string, options?: AddWorksheetOptions): Worksheet;
|
|
75
81
|
removeWorksheetEx(worksheet: Worksheet): void;
|
|
76
82
|
removeWorksheet(id: number | string): void;
|
|
83
|
+
/**
|
|
84
|
+
* Fetch sheet by name or id
|
|
85
|
+
*/
|
|
77
86
|
getWorksheet(id?: number | string): Worksheet | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Return a clone of worksheets in order
|
|
89
|
+
*/
|
|
78
90
|
get worksheets(): Worksheet[];
|
|
79
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Iterate over all sheets.
|
|
93
|
+
*
|
|
94
|
+
* Note: `workbook.worksheets.forEach` will still work but this is better.
|
|
95
|
+
*/
|
|
96
|
+
eachSheet(callback: (sheet: Worksheet, id: number) => void): void;
|
|
80
97
|
get definedNames(): DefinedNames;
|
|
81
98
|
clearThemes(): void;
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Add Image to Workbook and return the id
|
|
101
|
+
*/
|
|
102
|
+
addImage(image: Image): number;
|
|
103
|
+
getImage(id: number | string): WorkbookMedia | undefined;
|
|
84
104
|
get model(): WorkbookModel;
|
|
85
105
|
set model(value: WorkbookModel);
|
|
86
106
|
}
|
|
@@ -1,22 +1,49 @@
|
|
|
1
|
-
import { Range } from "./range.js";
|
|
2
|
-
import { Row } from "./row.js";
|
|
3
|
-
import {
|
|
1
|
+
import { Range, type RangeInput } from "./range.js";
|
|
2
|
+
import { Row, type RowModel } from "./row.js";
|
|
3
|
+
import { Column, type ColumnModel, type ColumnDefn } from "./column.js";
|
|
4
|
+
import type { Cell, FormulaResult } from "./cell.js";
|
|
5
|
+
import { Image, type ImageModel } from "./image.js";
|
|
6
|
+
import { Table, type TableModel } from "./table.js";
|
|
4
7
|
import { DataValidations } from "./data-validations.js";
|
|
5
|
-
import type
|
|
8
|
+
import { type PivotTable, type PivotTableModel } from "./pivot-table.js";
|
|
9
|
+
import type { Workbook } from "./workbook.js";
|
|
10
|
+
import type { AddImageRange, AutoFilter, CellValue, ConditionalFormattingOptions, DataValidation, RowBreak, RowValues, TableProperties, WorksheetProperties, WorksheetView } from "../types.js";
|
|
11
|
+
type DataValidationModel = {
|
|
12
|
+
[address: string]: DataValidation | undefined;
|
|
13
|
+
};
|
|
14
|
+
interface SheetProtection {
|
|
15
|
+
sheet?: boolean;
|
|
16
|
+
objects?: boolean;
|
|
17
|
+
scenarios?: boolean;
|
|
18
|
+
selectLockedCells?: boolean;
|
|
19
|
+
selectUnlockedCells?: boolean;
|
|
20
|
+
formatCells?: boolean;
|
|
21
|
+
formatColumns?: boolean;
|
|
22
|
+
formatRows?: boolean;
|
|
23
|
+
insertColumns?: boolean;
|
|
24
|
+
insertRows?: boolean;
|
|
25
|
+
insertHyperlinks?: boolean;
|
|
26
|
+
deleteColumns?: boolean;
|
|
27
|
+
deleteRows?: boolean;
|
|
28
|
+
sort?: boolean;
|
|
29
|
+
autoFilter?: boolean;
|
|
30
|
+
pivotTables?: boolean;
|
|
31
|
+
algorithmName?: string;
|
|
32
|
+
hashValue?: string;
|
|
33
|
+
saltValue?: string;
|
|
34
|
+
spinCount?: number;
|
|
35
|
+
}
|
|
6
36
|
interface WorksheetOptions {
|
|
7
|
-
workbook?:
|
|
37
|
+
workbook?: Workbook;
|
|
8
38
|
id?: number;
|
|
9
39
|
orderNo?: number;
|
|
10
40
|
name?: string;
|
|
11
41
|
state?: string;
|
|
12
|
-
properties?:
|
|
13
|
-
pageSetup?:
|
|
14
|
-
headerFooter?:
|
|
15
|
-
views?:
|
|
16
|
-
autoFilter?:
|
|
17
|
-
}
|
|
18
|
-
interface EachRowOptions {
|
|
19
|
-
includeEmpty?: boolean;
|
|
42
|
+
properties?: Partial<WorksheetProperties>;
|
|
43
|
+
pageSetup?: Partial<PageSetup>;
|
|
44
|
+
headerFooter?: Partial<HeaderFooter>;
|
|
45
|
+
views?: Partial<WorksheetView>[];
|
|
46
|
+
autoFilter?: AutoFilter | null;
|
|
20
47
|
}
|
|
21
48
|
interface PageSetupMargins {
|
|
22
49
|
left: number;
|
|
@@ -47,7 +74,6 @@ interface PageSetup {
|
|
|
47
74
|
horizontalCentered: boolean;
|
|
48
75
|
verticalCentered: boolean;
|
|
49
76
|
rowBreaks: RowBreak[];
|
|
50
|
-
colBreaks: any;
|
|
51
77
|
printTitlesRow?: string;
|
|
52
78
|
printTitlesColumn?: string;
|
|
53
79
|
}
|
|
@@ -64,117 +90,263 @@ interface HeaderFooter {
|
|
|
64
90
|
interface WorksheetModel {
|
|
65
91
|
id: number;
|
|
66
92
|
name: string;
|
|
67
|
-
dataValidations:
|
|
68
|
-
properties:
|
|
93
|
+
dataValidations: DataValidationModel;
|
|
94
|
+
properties: Partial<WorksheetProperties>;
|
|
69
95
|
state: string;
|
|
70
96
|
pageSetup: PageSetup;
|
|
71
97
|
headerFooter: HeaderFooter;
|
|
72
98
|
rowBreaks: RowBreak[];
|
|
73
|
-
views:
|
|
74
|
-
autoFilter:
|
|
75
|
-
media:
|
|
76
|
-
sheetProtection:
|
|
77
|
-
tables:
|
|
78
|
-
pivotTables:
|
|
79
|
-
conditionalFormattings:
|
|
80
|
-
cols?:
|
|
81
|
-
rows?:
|
|
99
|
+
views: Partial<WorksheetView>[];
|
|
100
|
+
autoFilter: AutoFilter | null;
|
|
101
|
+
media: ImageModel[];
|
|
102
|
+
sheetProtection: SheetProtection | null;
|
|
103
|
+
tables: TableModel[];
|
|
104
|
+
pivotTables: PivotTable[];
|
|
105
|
+
conditionalFormattings: ConditionalFormattingOptions[];
|
|
106
|
+
cols?: ColumnModel[];
|
|
107
|
+
rows?: RowModel[];
|
|
82
108
|
dimensions?: Range;
|
|
83
109
|
merges?: string[];
|
|
84
110
|
mergeCells?: string[];
|
|
85
111
|
}
|
|
86
112
|
declare class Worksheet {
|
|
87
|
-
_workbook
|
|
113
|
+
private _workbook;
|
|
88
114
|
id: number;
|
|
89
115
|
orderNo: number;
|
|
90
|
-
_name
|
|
116
|
+
private _name;
|
|
91
117
|
state: string;
|
|
92
|
-
_rows
|
|
93
|
-
_columns
|
|
94
|
-
_keys
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
[key: string]: Range;
|
|
99
|
-
};
|
|
100
|
-
rowBreaks: any[];
|
|
101
|
-
properties: any;
|
|
118
|
+
private _rows;
|
|
119
|
+
private _columns;
|
|
120
|
+
private _keys;
|
|
121
|
+
private _merges;
|
|
122
|
+
rowBreaks: RowBreak[];
|
|
123
|
+
properties: Partial<WorksheetProperties>;
|
|
102
124
|
pageSetup: PageSetup;
|
|
103
125
|
headerFooter: HeaderFooter;
|
|
104
126
|
dataValidations: DataValidations;
|
|
105
|
-
views:
|
|
106
|
-
autoFilter:
|
|
107
|
-
_media
|
|
108
|
-
sheetProtection:
|
|
127
|
+
views: Partial<WorksheetView>[];
|
|
128
|
+
autoFilter: AutoFilter | null;
|
|
129
|
+
private _media;
|
|
130
|
+
sheetProtection: SheetProtection | null;
|
|
109
131
|
tables: {
|
|
110
132
|
[key: string]: Table;
|
|
111
133
|
};
|
|
112
|
-
pivotTables:
|
|
113
|
-
conditionalFormattings:
|
|
114
|
-
_headerRowCount
|
|
134
|
+
pivotTables: PivotTable[];
|
|
135
|
+
conditionalFormattings: ConditionalFormattingOptions[];
|
|
136
|
+
private _headerRowCount?;
|
|
115
137
|
constructor(options: WorksheetOptions);
|
|
116
138
|
get name(): string;
|
|
117
139
|
set name(name: string | undefined);
|
|
118
|
-
|
|
140
|
+
/**
|
|
141
|
+
* The workbook that contains this worksheet
|
|
142
|
+
*/
|
|
143
|
+
get workbook(): Workbook;
|
|
144
|
+
/**
|
|
145
|
+
* When you're done with this worksheet, call this to remove from workbook
|
|
146
|
+
*/
|
|
119
147
|
destroy(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Get the bounding range of the cells in this worksheet
|
|
150
|
+
*/
|
|
120
151
|
get dimensions(): Range;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Get the current columns array
|
|
154
|
+
*/
|
|
155
|
+
get columns(): Column[];
|
|
156
|
+
/**
|
|
157
|
+
* Add column headers and define column keys and widths.
|
|
158
|
+
*
|
|
159
|
+
* Note: these column structures are a workbook-building convenience only,
|
|
160
|
+
* apart from the column width, they will not be fully persisted.
|
|
161
|
+
*/
|
|
162
|
+
set columns(value: ColumnDefn[]);
|
|
163
|
+
getColumnKey(key: string): Column | undefined;
|
|
164
|
+
setColumnKey(key: string, value: Column): void;
|
|
125
165
|
deleteColumnKey(key: string): void;
|
|
126
|
-
eachColumnKey(f: (column:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
166
|
+
eachColumnKey(f: (column: Column, key: string) => void): void;
|
|
167
|
+
/**
|
|
168
|
+
* Access an individual column by key, letter and 1-based column number
|
|
169
|
+
*/
|
|
170
|
+
getColumn(c: string | number): Column;
|
|
171
|
+
/**
|
|
172
|
+
* Cut one or more columns (columns to the right are shifted left)
|
|
173
|
+
* and optionally insert more
|
|
174
|
+
*
|
|
175
|
+
* If column properties have been defined, they will be cut or moved accordingly
|
|
176
|
+
*
|
|
177
|
+
* Known Issue: If a splice causes any merged cells to move, the results may be unpredictable
|
|
178
|
+
*
|
|
179
|
+
* Also: If the worksheet has more rows than values in the column inserts,
|
|
180
|
+
* the rows will still be shifted as if the values existed
|
|
181
|
+
*/
|
|
182
|
+
spliceColumns(start: number, count: number, ...inserts: CellValue[][]): void;
|
|
183
|
+
/**
|
|
184
|
+
* Get the last column in a worksheet
|
|
185
|
+
*/
|
|
186
|
+
get lastColumn(): Column;
|
|
187
|
+
/**
|
|
188
|
+
* The total column size of the document. Equal to the maximum cell count from all of the rows
|
|
189
|
+
*/
|
|
130
190
|
get columnCount(): number;
|
|
191
|
+
/**
|
|
192
|
+
* A count of the number of columns that have values
|
|
193
|
+
*/
|
|
131
194
|
get actualColumnCount(): number;
|
|
132
195
|
_commitRow(row: Row): void;
|
|
133
196
|
get _lastRowNumber(): number;
|
|
134
197
|
get _nextRow(): number;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Get the last editable row in a worksheet (or undefined if there are none)
|
|
200
|
+
*/
|
|
201
|
+
get lastRow(): Row | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* Tries to find and return row for row number, else undefined
|
|
204
|
+
*
|
|
205
|
+
* @param r - The 1-indexed row number
|
|
206
|
+
*/
|
|
207
|
+
findRow(r: number): Row | undefined;
|
|
208
|
+
/**
|
|
209
|
+
* Tries to find and return rows for row number start and length, else undefined
|
|
210
|
+
*
|
|
211
|
+
* @param start - The 1-indexed starting row number
|
|
212
|
+
* @param length - The length of the expected array
|
|
213
|
+
*/
|
|
214
|
+
findRows(start: number, length: number): (Row | undefined)[];
|
|
215
|
+
/**
|
|
216
|
+
* The total row size of the document. Equal to the row number of the last row that has values.
|
|
217
|
+
*/
|
|
138
218
|
get rowCount(): number;
|
|
219
|
+
/**
|
|
220
|
+
* A count of the number of rows that have values. If a mid-document row is empty, it will not be included in the count.
|
|
221
|
+
*/
|
|
139
222
|
get actualRowCount(): number;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
223
|
+
/**
|
|
224
|
+
* Get or create row by 1-based index
|
|
225
|
+
*/
|
|
226
|
+
getRow(r: number): Row;
|
|
227
|
+
/**
|
|
228
|
+
* Get or create rows by 1-based index
|
|
229
|
+
*/
|
|
230
|
+
getRows(start: number, length: number): Row[] | undefined;
|
|
231
|
+
/**
|
|
232
|
+
* Add a couple of Rows by key-value, after the last current row, using the column keys,
|
|
233
|
+
* or add a row by contiguous Array (assign to columns A, B & C)
|
|
234
|
+
*/
|
|
235
|
+
addRow(value: RowValues, style?: string): Row;
|
|
236
|
+
/**
|
|
237
|
+
* Add multiple rows by providing an array of arrays or key-value pairs
|
|
238
|
+
*/
|
|
239
|
+
addRows(value: RowValues[], style?: string): Row[];
|
|
240
|
+
/**
|
|
241
|
+
* Insert a Row by key-value, at the position (shifting down all rows from position),
|
|
242
|
+
* using the column keys, or add a row by contiguous Array (assign to columns A, B & C)
|
|
243
|
+
*/
|
|
244
|
+
insertRow(pos: number, value: RowValues, style?: string): Row;
|
|
245
|
+
/**
|
|
246
|
+
* Insert multiple rows at position (shifting down all rows from position)
|
|
247
|
+
* by providing an array of arrays or key-value pairs
|
|
248
|
+
*/
|
|
249
|
+
insertRows(pos: number, values: RowValues[], style?: string): Row[] | undefined;
|
|
146
250
|
_setStyleOption(pos: number, style?: string): void;
|
|
147
251
|
_copyStyle(src: number, dest: number, styleEmpty?: boolean): void;
|
|
252
|
+
/**
|
|
253
|
+
* Duplicate rows and insert new rows
|
|
254
|
+
*/
|
|
148
255
|
duplicateRow(rowNum: number, count: number, insert?: boolean): void;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Cut one or more rows (rows below are shifted up)
|
|
258
|
+
* and optionally insert more
|
|
259
|
+
*
|
|
260
|
+
* Known Issue: If a splice causes any merged cells to move, the results may be unpredictable
|
|
261
|
+
*/
|
|
262
|
+
spliceRows(start: number, count: number, ...inserts: RowValues[]): void;
|
|
263
|
+
/**
|
|
264
|
+
* Iterate over all rows that have values in a worksheet
|
|
265
|
+
*/
|
|
266
|
+
eachRow(callback: (row: Row, rowNumber: number) => void): void;
|
|
267
|
+
/**
|
|
268
|
+
* Iterate over all rows (including empty rows) in a worksheet
|
|
269
|
+
*/
|
|
270
|
+
eachRow(opt: {
|
|
271
|
+
includeEmpty?: boolean;
|
|
272
|
+
}, callback: (row: Row, rowNumber: number) => void): void;
|
|
273
|
+
/**
|
|
274
|
+
* Return all rows as sparse array
|
|
275
|
+
*/
|
|
276
|
+
getSheetValues(): CellValue[][];
|
|
277
|
+
/**
|
|
278
|
+
* Returns the cell at [r,c] or address given by r. If not found, return undefined
|
|
279
|
+
*/
|
|
280
|
+
findCell(r: number | string, c?: number): Cell | undefined;
|
|
281
|
+
/**
|
|
282
|
+
* Get or create cell at [r,c] or address given by r
|
|
283
|
+
*/
|
|
284
|
+
getCell(r: number | string, c?: number): Cell;
|
|
285
|
+
/**
|
|
286
|
+
* Merge cells, either:
|
|
287
|
+
*
|
|
288
|
+
* tlbr string, e.g. `'A4:B5'`
|
|
289
|
+
*
|
|
290
|
+
* tl string, br string, e.g. `'G10', 'H11'`
|
|
291
|
+
*
|
|
292
|
+
* t, l, b, r numbers, e.g. `10,11,12,13`
|
|
293
|
+
*/
|
|
294
|
+
mergeCells(...cells: RangeInput[]): void;
|
|
295
|
+
mergeCellsWithoutStyle(...cells: RangeInput[]): void;
|
|
157
296
|
_mergeCellsInternal(dimensions: Range, ignoreStyle?: boolean): void;
|
|
158
|
-
_unMergeMaster(master:
|
|
297
|
+
_unMergeMaster(master: Cell): void;
|
|
159
298
|
get hasMerges(): boolean;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
299
|
+
/**
|
|
300
|
+
* Scan the range and if any cell is part of a merge, un-merge the group.
|
|
301
|
+
* Note this function can affect multiple merges and merge-blocks are
|
|
302
|
+
* atomic - either they're all merged or all un-merged.
|
|
303
|
+
*/
|
|
304
|
+
unMergeCells(...cells: RangeInput[]): void;
|
|
305
|
+
fillFormula(range: string, formula: string, results?: FormulaResult[][] | FormulaResult[] | ((row: number, col: number) => FormulaResult | undefined), shareType?: string): void;
|
|
306
|
+
/**
|
|
307
|
+
* Using the image id from `Workbook.addImage`,
|
|
308
|
+
* embed an image within the worksheet to cover a range
|
|
309
|
+
*/
|
|
310
|
+
addImage(imageId: string | number, range: AddImageRange): void;
|
|
311
|
+
getImages(): Image[];
|
|
312
|
+
/**
|
|
313
|
+
* Using the image id from `Workbook.addImage`, set the background to the worksheet
|
|
314
|
+
*/
|
|
315
|
+
addBackgroundImage(imageId: string | number): void;
|
|
316
|
+
getBackgroundImageId(): string | undefined;
|
|
317
|
+
/**
|
|
318
|
+
* Protect the worksheet with optional password and options
|
|
319
|
+
*/
|
|
320
|
+
protect(password?: string, options?: Partial<SheetProtection>): Promise<void>;
|
|
167
321
|
unprotect(): void;
|
|
168
|
-
|
|
322
|
+
/**
|
|
323
|
+
* Add a new table and return a reference to it
|
|
324
|
+
*/
|
|
325
|
+
addTable(model: TableProperties): Table;
|
|
326
|
+
/**
|
|
327
|
+
* Fetch table by name
|
|
328
|
+
*/
|
|
169
329
|
getTable(name: string): Table;
|
|
330
|
+
/**
|
|
331
|
+
* Delete table by name
|
|
332
|
+
*/
|
|
170
333
|
removeTable(name: string): void;
|
|
334
|
+
/**
|
|
335
|
+
* Fetch all tables in the worksheet
|
|
336
|
+
*/
|
|
171
337
|
getTables(): Table[];
|
|
172
|
-
addPivotTable(model:
|
|
173
|
-
|
|
174
|
-
|
|
338
|
+
addPivotTable(model: PivotTableModel): PivotTable;
|
|
339
|
+
/**
|
|
340
|
+
* Add conditional formatting rules
|
|
341
|
+
*/
|
|
342
|
+
addConditionalFormatting(cf: ConditionalFormattingOptions): void;
|
|
343
|
+
/**
|
|
344
|
+
* Delete conditional formatting rules
|
|
345
|
+
*/
|
|
346
|
+
removeConditionalFormatting(filter: number | ((value: ConditionalFormattingOptions, index: number, array: ConditionalFormattingOptions[]) => boolean)): void;
|
|
175
347
|
get model(): WorksheetModel;
|
|
176
348
|
_parseRows(model: WorksheetModel): void;
|
|
177
349
|
_parseMergeCells(model: WorksheetModel): void;
|
|
178
350
|
set model(value: WorksheetModel);
|
|
179
351
|
}
|
|
180
|
-
export { Worksheet };
|
|
352
|
+
export { Worksheet, type WorksheetModel };
|
|
@@ -12,11 +12,9 @@ declare class WorksheetReader extends EventEmitter {
|
|
|
12
12
|
options: any;
|
|
13
13
|
name: string;
|
|
14
14
|
state?: string;
|
|
15
|
-
_columns
|
|
16
|
-
_keys
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
_dimensions: any;
|
|
15
|
+
private _columns;
|
|
16
|
+
private _keys;
|
|
17
|
+
private _dimensions;
|
|
20
18
|
hyperlinks?: {
|
|
21
19
|
[key: string]: any;
|
|
22
20
|
};
|