sheetnext 0.2.0 → 0.2.2

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.
@@ -1,2998 +0,0 @@
1
- # Core API Details
2
-
3
- > Last updated: 2026-02-28
4
-
5
- ## 📦 安装与初始化
6
-
7
- ### 使用 npm 安装
8
-
9
- ```bash
10
- npm install sheetnext
11
- ```
12
-
13
- ```html
14
- <!-- 放置编辑器的容器 -->
15
- <div id="SNContainer" style="width:100vw;height:100vh;padding:0 7px 7px"></div>
16
- ```
17
-
18
- ```javascript
19
- import SheetNext from 'sheetnext';
20
- import 'sheetnext.css';
21
-
22
- const SN = new SheetNext(document.querySelector('#SNContainer'));
23
- ```
24
-
25
- ### 浏览器直接引入(UMD)
26
-
27
- ```html
28
- <!DOCTYPE html>
29
- <html lang="zh-CN">
30
- <head>
31
- <meta charset="UTF-8">
32
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
33
- <title>SheetNext Demo</title>
34
- <link rel="stylesheet" href="dist/sheetnext.css">
35
- </head>
36
- <body>
37
- <div id="SNContainer" style="width:100vw;height:100vh;padding:0 7px 7px"></div>
38
- <script src="dist/sheetnext.umd.js"></script>
39
- <script>
40
- const SN = new SheetNext(document.querySelector('#SNContainer'));
41
- </script>
42
- </body>
43
- </html>
44
- ```
45
-
46
- ## 📐 类型约定(开发约束)
47
-
48
- > 本节作为 API 细节文档统一前置约束,调用前建议先阅读。
49
-
50
- ### 坐标与区域(0-based)
51
-
52
- **字段含义**:`r` = row(行),`c` = column(列),`s` = start(起始),`e` = end(结束)
53
-
54
- | 类型 | 说明 | 示例 |
55
- | --- | --- | --- |
56
- | CellNum | 单元格数字坐标 | `{r: 0, c: 0}` |
57
- | CellStr | 单元格字符串地址 | `"A1"`、`"B2"` |
58
- | CellRef | `CellNum | CellStr` | `{r:0,c:0}` 或 `"A1"` |
59
- | RangeNum | 区域数字坐标 | `{s:{r:0,c:0}, e:{r:2,c:2}}` |
60
- | RangeStr | 区域字符串地址 | `"A1:C3"`、`"A:B"`、`"1:2"` |
61
- | RangeRef | `RangeNum | RangeStr` | 支持数字或字符串格式 |
62
-
63
- > `r = 0` 表示第 1 行,`c = 0` 表示第 A 列。
64
-
65
- ### 样式对象 Style
66
-
67
- - `font`: `name | size | color | bold | italic | underline | strike`
68
- - `fill`: `type | pattern | fgColor`
69
- - `alignment`: `horizontal | vertical | wrapText | textRotation | indent`
70
- - `border`: `left | right | top | bottom`(每个方向含 `style` 与 `color`)
71
- - `numFmt`: 数字格式字符串(如 `#,##0.00`、`yyyy-mm-dd`、`0.00%`)
72
- - `protection`: `locked | hidden`
73
-
74
- ### 参数约束
75
-
76
- - 优先使用文档声明类型,避免传入未定义字段。
77
- - 涉及区域参数时,优先保证起始/结束坐标合法且边界有序。
78
- - 涉及样式写入时,建议最小变更(仅传需要改动的字段)。
79
-
80
- ## 枚举类型
81
-
82
- > 通过 `SN.Enum.XXX` 访问,或按需导入 `import { XXX } from 'sheetnext/enum'`
83
-
84
- ### EventPriority
85
- - 事件优先级(越小越先执行)
86
-
87
- | Key | Value | Description |
88
- | --- | --- | --- |
89
- | SYSTEM | -2000 | 系统内部 |
90
- | PROTECTION | -1000 | 保护检查 |
91
- | PLUGIN | -500 | 插件 |
92
- | NORMAL | 0 | 默认 |
93
- | LATE | 500 | 后置处理 |
94
- | AUDIT | 1000 | 审计日志 |
95
-
96
- ### PasteMode
97
- - 粘贴模式
98
-
99
- | Value | Description |
100
- | --- | --- |
101
- | all | 全部(默认) |
102
- | value | 仅值 |
103
- | formula | 仅公式 |
104
- | format | 仅格式 |
105
- | noBorder | 无边框 |
106
- | colWidth | 列宽 |
107
- | comment | 批注 |
108
- | validation | 数据验证 |
109
- | transpose | 转置 |
110
- | valueNumberFormat | 值和数字格式 |
111
- | allMergeConditional | 全部使用源主题 |
112
- | formulaNumberFormat | 公式和数字格式 |
113
-
114
- ### PasteOperation
115
- - 运算粘贴模式
116
-
117
- | Value | Description |
118
- | --- | --- |
119
- | none | 无 |
120
- | add | 加 |
121
- | sub | 减 |
122
- | mul | 乘 |
123
- | div | 除 |
124
-
125
- ### AnchorType
126
- - 图纸锚点类型
127
-
128
- | Value | Description |
129
- | --- | --- |
130
- | twoCell | 随单元格移动和缩放 |
131
- | oneCell | 仅随单元格移动 |
132
- | absolute | 固定位置 |
133
-
134
- ### DrawingType
135
- - 图纸类型
136
-
137
- | Value | Description |
138
- | --- | --- |
139
- | chart | - |
140
- | image | - |
141
- | shape | - |
142
- | slicer | - |
143
-
144
- ### ValidationType
145
- - 数据验证类型
146
-
147
- | Value | Description |
148
- | --- | --- |
149
- | list | 下拉列表 |
150
- | whole | 整数 |
151
- | decimal | 小数 |
152
- | date | 日期 |
153
- | time | 时间 |
154
- | textLength | 文本长度 |
155
- | custom | 自定义公式 |
156
-
157
- ### ValidationOperator
158
- - 数据验证操作符
159
-
160
- | Value | Description |
161
- | --- | --- |
162
- | between | 介于 |
163
- | notBetween | 未介于 |
164
- | equal | 等于 |
165
- | notEqual | 不等于 |
166
- | greaterThan | 大于 |
167
- | greaterThanOrEqual | 大于等于 |
168
- | lessThan | 小于 |
169
- | lessThanOrEqual | 小于等于 |
170
-
171
- ### FilterOperator
172
- - 筛选条件操作符
173
-
174
- | Value | Description |
175
- | --- | --- |
176
- | equal | 等于 |
177
- | notEqual | 不等于 |
178
- | greaterThan | 大于 |
179
- | greaterThanOrEqual | 大于等于 |
180
- | lessThan | 小于 |
181
- | lessThanOrEqual | 小于等于 |
182
- | beginsWith | 开头是 |
183
- | endsWith | 结尾是 |
184
- | contains | 包含 |
185
- | notContains | 不包含 |
186
-
187
- ### CFType
188
- - 条件格式类型
189
-
190
- | Value | Description |
191
- | --- | --- |
192
- | cellIs | 单元格值 |
193
- | containsText | 包含文本 |
194
- | timePeriod | 发生日期 |
195
- | top10 | 前/后 N 项 |
196
- | aboveAverage | 高于/低于平均值 |
197
- | duplicateValues | 重复值 |
198
- | uniqueValues | 唯一值 |
199
- | dataBar | 数据条 |
200
- | colorScale | 色阶 |
201
- | iconSet | 图标集 |
202
- | expression | 公式 |
203
-
204
- ### SortOrder
205
- - 排序方向
206
-
207
- | Value | Description |
208
- | --- | --- |
209
- | asc | 升序 |
210
- | desc | 降序 |
211
-
212
- ### HorizontalAlign
213
- - 对齐方式 - 水平
214
-
215
- | Value | Description |
216
- | --- | --- |
217
- | left | - |
218
- | center | - |
219
- | right | - |
220
- | justify | 两端对齐 |
221
- | fill | 填充 |
222
- | distributed | 分散对齐 |
223
-
224
- ### VerticalAlign
225
- - 对齐方式 - 垂直
226
-
227
- | Value | Description |
228
- | --- | --- |
229
- | top | - |
230
- | center | - |
231
- | bottom | - |
232
- | justify | - |
233
- | distributed | - |
234
-
235
- ### BorderStyle
236
- - 边框样式
237
-
238
- | Value | Description |
239
- | --- | --- |
240
- | none | - |
241
- | thin | - |
242
- | medium | - |
243
- | thick | - |
244
- | dashed | - |
245
- | dotted | - |
246
- | double | - |
247
-
248
- ## AI/AI.js
249
-
250
- ### AI
251
- - AI 助手模块 - Tool Calling 架构
252
-
253
- #### Constructor
254
- **Parameters**
255
- | Name | Type | Required | Default | Description |
256
- | --- | --- | --- | --- | --- |
257
- | SN | Object | Yes | - | SheetNext 主实例 |
258
- | option | Object | Yes | - | AI 配置 |
259
- | option.AI_URL | string | Yes | - | 中转服务器地址 |
260
- | option.AI_TOKEN | string | No | - | 认证令牌 |
261
-
262
- #### Methods
263
- ##### `chatInput(con)`
264
-
265
- **Parameters**
266
- | Name | Type | Required | Default | Description |
267
- | --- | --- | --- | --- | --- |
268
- | con | - | Yes | - | - |
269
-
270
- ##### `clearChat()`
271
-
272
- ##### `async conversation(p, joinChat = true)`
273
-
274
- **Parameters**
275
- | Name | Type | Required | Default | Description |
276
- | --- | --- | --- | --- | --- |
277
- | p | - | Yes | - | - |
278
- | joinChat | boolean | No | true | - |
279
-
280
- ##### `handleFileChange(event)`
281
-
282
- **Parameters**
283
- | Name | Type | Required | Default | Description |
284
- | --- | --- | --- | --- | --- |
285
- | event | - | Yes | - | - |
286
-
287
- ##### Events (via `SN.Event`)
288
-
289
- | Event | Timing | Notes |
290
- | --- | --- | --- |
291
- | `beforeAIRequest` | Before request is sent | Async hook, supports `e.cancel(reason)` |
292
- | `aiRequestStart` | Request started | Includes request metadata |
293
- | `aiRequestChunk` | Streaming chunk received | Fired for each parsed SSE chunk |
294
- | `afterAIRequest` | Request succeeded | Async hook with final result |
295
- | `aiRequestError` | Request failed | Async hook with error and status |
296
- | `aiRequestFinally` | Always after request ends | Async hook for cleanup/metrics |
297
-
298
- ##### `async screenshot(addresses = [])`
299
-
300
- **Parameters**
301
- | Name | Type | Required | Default | Description |
302
- | --- | --- | --- | --- | --- |
303
- | addresses | Array | No | [] | - |
304
-
305
- ##### `sendInfo(info)`
306
-
307
- **Parameters**
308
- | Name | Type | Required | Default | Description |
309
- | --- | --- | --- | --- | --- |
310
- | info | - | Yes | - | - |
311
-
312
- ## AutoFilter/AutoFilter.js
313
-
314
- ### AutoFilter
315
-
316
- #### Constructor
317
- **Parameters**
318
- | Name | Type | Required | Default | Description |
319
- | --- | --- | --- | --- | --- |
320
- | sheet | Sheet | Yes | - | 所属工作表 |
321
-
322
- #### Props
323
- | Name | Type | Static | Default | Description |
324
- | --- | --- | --- | --- | --- |
325
- | sheet | Sheet | No | sheet | 所属工作表 |
326
-
327
- #### Get/Set
328
- | Name | Type | Mode | Static | Description |
329
- | --- | --- | --- | --- | --- |
330
- | ref | string \| null | get/set | No | 获取/设置默认(sheet)筛选范围 |
331
- | sortState | {colIndex: number, order: 'asc' \| 'desc'} \| null | get/set | No | 默认(sheet)作用域排序状态 |
332
-
333
- #### Get
334
- | Name | Type | Static | Description |
335
- | --- | --- | --- | --- |
336
- | activeScopeId | string | No | 当前激活作用域 ID |
337
- | columns | Map<number, Object> | No | 默认(sheet)作用域筛选条件 |
338
- | enabled | boolean | No | 默认(sheet)作用域是否启用 |
339
- | hasActiveFilters | boolean | No | 默认(sheet)作用域是否有生效筛选 |
340
- | headerRow | number | No | 默认(sheet)作用域表头行 |
341
- | range | {s: {r: number, c: number}, e: {r: number, c: number}} \| null | No | 默认(sheet)作用域范围 |
342
-
343
- #### Methods
344
- ##### `buildXml(scopeId = this._defaultScopeId): Object | null`
345
- - 构建指定作用域 XML;默认导出 sheet 作用域
346
-
347
- **Parameters**
348
- | Name | Type | Required | Default | Description |
349
- | --- | --- | --- | --- | --- |
350
- | scopeId | string | No | this._defaultScopeId | - |
351
-
352
- **Returns**
353
- - Type: `Object | null`
354
-
355
- ##### `clear(scopeId = this._defaultScopeId)`
356
- - 完全清除筛选(包含范围)
357
-
358
- **Parameters**
359
- | Name | Type | Required | Default | Description |
360
- | --- | --- | --- | --- | --- |
361
- | scopeId | string | No | this._defaultScopeId | - |
362
-
363
- ##### `clearAllFilters(scopeId = null)`
364
- - 清除筛选条件(保留范围)
365
-
366
- **Parameters**
367
- | Name | Type | Required | Default | Description |
368
- | --- | --- | --- | --- | --- |
369
- | scopeId | string | No | null | - |
370
-
371
- ##### `clearColumnFilter(colIndex, scopeId = null)`
372
- - 清除某列筛选
373
-
374
- **Parameters**
375
- | Name | Type | Required | Default | Description |
376
- | --- | --- | --- | --- | --- |
377
- | colIndex | number | Yes | - | - |
378
- | scopeId | string | No | null | - |
379
-
380
- ##### `getColumnFilter(colIndex, scopeId = null): Object | null`
381
-
382
- **Parameters**
383
- | Name | Type | Required | Default | Description |
384
- | --- | --- | --- | --- | --- |
385
- | colIndex | number | Yes | - | - |
386
- | scopeId | string \| null | No | null | - |
387
-
388
- **Returns**
389
- - Type: `Object | null`
390
- - Get filter config for column in scope.
391
-
392
- ##### `getColumnValues(colIndex, scopeId = null): Array<{value: any, text: string, count: number, isEmpty: boolean}>`
393
- - 获取某列的所有唯一值(用于筛选面板)
394
-
395
- **Parameters**
396
- | Name | Type | Required | Default | Description |
397
- | --- | --- | --- | --- | --- |
398
- | colIndex | number | Yes | - | - |
399
- | scopeId | string | No | null | - |
400
-
401
- **Returns**
402
- - Type: `Array<{value: any, text: string, count: number, isEmpty: boolean}>`
403
-
404
- ##### `getEnabledScopes(): Array<{scopeId:string,ownerType:string,ownerId:string | null,range:{s:{r:number,c:number},e:{r:number,c:number}},headerRow:number}>`
405
-
406
- **Returns**
407
- - Type: `Array<{scopeId:string,ownerType:string,ownerId:string | null,range:{s:{r:number,c:number},e:{r:number,c:number}},headerRow:number}>`
408
- - List enabled scopes sorted by range.
409
-
410
- ##### `getScopeHeaderRow(scopeId = null): number`
411
-
412
- **Parameters**
413
- | Name | Type | Required | Default | Description |
414
- | --- | --- | --- | --- | --- |
415
- | scopeId | string \| null | No | null | - |
416
-
417
- **Returns**
418
- - Type: `number`
419
- - Get header row index of scope.
420
-
421
- ##### `getScopeRange(scopeId = null): {s:{r:number,c:number},e:{r:number,c:number}} | null`
422
-
423
- **Parameters**
424
- | Name | Type | Required | Default | Description |
425
- | --- | --- | --- | --- | --- |
426
- | scopeId | string \| null | No | null | - |
427
-
428
- **Returns**
429
- - Type: `{s:{r:number,c:number},e:{r:number,c:number}} | null`
430
- - Get range of scope.
431
-
432
- ##### `getSortOrder(colIndex, scopeId = null)`
433
- - 获取排序状态
434
-
435
- **Parameters**
436
- | Name | Type | Required | Default | Description |
437
- | --- | --- | --- | --- | --- |
438
- | colIndex | number | Yes | - | - |
439
- | scopeId | string | No | null | - |
440
-
441
- ##### `getTableScopeId(tableId): string`
442
-
443
- **Parameters**
444
- | Name | Type | Required | Default | Description |
445
- | --- | --- | --- | --- | --- |
446
- | tableId | string | Yes | - | - |
447
-
448
- **Returns**
449
- - Type: `string`
450
- - Build table scope id from table id.
451
-
452
- ##### `hasActiveFiltersInScope(scopeId = null): boolean`
453
-
454
- **Parameters**
455
- | Name | Type | Required | Default | Description |
456
- | --- | --- | --- | --- | --- |
457
- | scopeId | string \| null | No | null | - |
458
-
459
- **Returns**
460
- - Type: `boolean`
461
- - Check whether scope has active column filters.
462
-
463
- ##### `hasAnyActiveFilters(): boolean`
464
-
465
- **Returns**
466
- - Type: `boolean`
467
- - Check whether any scope has active filters.
468
-
469
- ##### `hasFilter(colIndex, scopeId = null)`
470
- - 判断列是否有筛选
471
-
472
- **Parameters**
473
- | Name | Type | Required | Default | Description |
474
- | --- | --- | --- | --- | --- |
475
- | colIndex | number | Yes | - | - |
476
- | scopeId | string | No | null | - |
477
-
478
- ##### `isColumnInRange(colIndex, scopeId = null)`
479
- - 判断某列是否在筛选范围内
480
-
481
- **Parameters**
482
- | Name | Type | Required | Default | Description |
483
- | --- | --- | --- | --- | --- |
484
- | colIndex | number | Yes | - | - |
485
- | scopeId | string | No | null | - |
486
-
487
- ##### `isHeaderRow(rowIndex, scopeId = null)`
488
- - 判断某行是否是表头行
489
-
490
- **Parameters**
491
- | Name | Type | Required | Default | Description |
492
- | --- | --- | --- | --- | --- |
493
- | rowIndex | number | Yes | - | - |
494
- | scopeId | string | No | null | - |
495
-
496
- ##### `isRowFilteredHidden(rowIndex): boolean`
497
- - 行是否因筛选被隐藏
498
-
499
- **Parameters**
500
- | Name | Type | Required | Default | Description |
501
- | --- | --- | --- | --- | --- |
502
- | rowIndex | number | Yes | - | - |
503
-
504
- **Returns**
505
- - Type: `boolean`
506
-
507
- ##### `isScopeEnabled(scopeId = null): boolean`
508
-
509
- **Parameters**
510
- | Name | Type | Required | Default | Description |
511
- | --- | --- | --- | --- | --- |
512
- | scopeId | string \| null | No | null | - |
513
-
514
- **Returns**
515
- - Type: `boolean`
516
- - Check whether scope range is enabled.
517
-
518
- ##### `parse(xmlObj)`
519
- - 从 worksheet AutoFilter 解析默认作用域
520
-
521
- **Parameters**
522
- | Name | Type | Required | Default | Description |
523
- | --- | --- | --- | --- | --- |
524
- | xmlObj | Object | Yes | - | - |
525
-
526
- ##### `parseScope(scopeId, autoFilterXml, options = {})`
527
- - 将指定作用域的筛选状态解析到内存(主要用于 table 导入)
528
-
529
- **Parameters**
530
- | Name | Type | Required | Default | Description |
531
- | --- | --- | --- | --- | --- |
532
- | scopeId | string | Yes | - | - |
533
- | autoFilterXml | Object | Yes | - | - |
534
- | options | {range?: Object, restoreHiddenRowsFromSheet?: boolean, ownerType?: string, ownerId?: string} | No | {} | - |
535
-
536
- ##### `registerTableScope(table, options = {}): string | null`
537
-
538
- **Parameters**
539
- | Name | Type | Required | Default | Description |
540
- | --- | --- | --- | --- | --- |
541
- | table | Object | Yes | - | - |
542
- | options | Object | No | {} | - |
543
-
544
- **Returns**
545
- - Type: `string | null`
546
- - Register or update filter scope for table.
547
-
548
- ##### `setActiveScope(scopeId): string`
549
-
550
- **Parameters**
551
- | Name | Type | Required | Default | Description |
552
- | --- | --- | --- | --- | --- |
553
- | scopeId | string \| null | Yes | - | - |
554
-
555
- **Returns**
556
- - Type: `string`
557
- - Set active scope id when scope exists.
558
-
559
- ##### `setColumnFilter(colIndex, filter, scopeId = null)`
560
- - 设置列筛选条件
561
-
562
- **Parameters**
563
- | Name | Type | Required | Default | Description |
564
- | --- | --- | --- | --- | --- |
565
- | colIndex | number | Yes | - | - |
566
- | filter | Object | Yes | - | - |
567
- | scopeId | string | No | null | - |
568
-
569
- ##### `setRange(range, scopeId = this._defaultScopeId)`
570
- - 设置筛选范围(默认 sheet scope;可指定 scopeId)
571
-
572
- **Parameters**
573
- | Name | Type | Required | Default | Description |
574
- | --- | --- | --- | --- | --- |
575
- | range | {s: {r: number, c: number}, e: {r: number, c: number}} | Yes | - | - |
576
- | scopeId | string | No | this._defaultScopeId | - |
577
-
578
- ##### `setSortState(colIndex, order, scopeId = null)`
579
- - 设置排序状态
580
-
581
- **Parameters**
582
- | Name | Type | Required | Default | Description |
583
- | --- | --- | --- | --- | --- |
584
- | colIndex | number | Yes | - | - |
585
- | order | 'asc' \| 'desc' | Yes | - | - |
586
- | scopeId | string | No | null | - |
587
-
588
- ##### `unregisterTableScope(tableId, options = {}): void`
589
-
590
- **Parameters**
591
- | Name | Type | Required | Default | Description |
592
- | --- | --- | --- | --- | --- |
593
- | tableId | string | Yes | - | - |
594
- | options | {silent?:boolean} | No | {} | - |
595
-
596
- **Returns**
597
- - Unregister table scope and refresh view state.
598
-
599
- ## Cell/Cell.js
600
-
601
- ### Cell
602
- - 单元格类
603
-
604
- #### Constructor
605
- **Parameters**
606
- | Name | Type | Required | Default | Description |
607
- | --- | --- | --- | --- | --- |
608
- | xmlObj | Object | Yes | - | 单元格 XML 对象 |
609
- | row | Row | Yes | - | 行对象 |
610
- | cIndex | number | Yes | - | 列索引 |
611
-
612
- #### Props
613
- | Name | Type | Static | Default | Description |
614
- | --- | --- | --- | --- | --- |
615
- | cIndex | number | No | cIndex | 列索引 |
616
- | isMerged | boolean | No | false | 是否为合并单元格 |
617
- | master | {r:number, c:number} \| null | No | null | 合并单元格主单元格引用 |
618
- | row | Row | No | row | 所属行 |
619
-
620
- #### Get/Set
621
- | Name | Type | Mode | Static | Description |
622
- | --- | --- | --- | --- | --- |
623
- | alignment | Object | get/set | No | 对齐方式 |
624
- | border | Object | get/set | No | 边框样式 |
625
- | dataValidation | Object \| null | get/set | No | 数据验证配置 |
626
- | editVal | string | get/set | No | 编辑值或公式 |
627
- | fill | Object | get/set | No | 填充样式 |
628
- | font | Object | get/set | No | 字体样式 |
629
- | hyperlink | Object \| null | get/set | No | 超链接配置 |
630
- | numFmt | string \| undefined | get/set | No | 数字格式 |
631
- | protection | {locked: boolean, hidden: boolean} | get/set | No | 单元格保护配置 |
632
- | richText | Array \| null | get/set | No | 富文本 runs 数组 |
633
- | style | Object | get/set | No | 单元格样式 |
634
- | type | string | get/set | No | 单元格类型 |
635
-
636
- #### Get
637
- | Name | Type | Static | Description |
638
- | --- | --- | --- | --- |
639
- | accountingData | Object \| undefined | No | 获取会计格式结构化数据(供渲染使用) |
640
- | buildXml | Object | No | 构建单元格 XML |
641
- | calcVal | any | No | 计算值 |
642
- | horizontalAlign | string | No | 计算后的水平对齐方式 |
643
- | isFormula | boolean | No | 是否为公式 |
644
- | isLocked | boolean | No | 是否锁定 |
645
- | isSpillRef | boolean | No | 是否是 spill 引用单元格 |
646
- | isSpillSource | boolean | No | 是否是 spill 源单元格 |
647
- | showVal | string | No | 显示值 |
648
- | spillArray | Array[] \| null | No | 获取完整的 spill 数组结果 |
649
- | validData | boolean | No | 数据验证结果 |
650
- | verticalAlign | string | No | 计算后的垂直对齐方式 |
651
-
652
- ## CF/CF.js
653
-
654
- ### CF
655
- - CF 条件格式管理器<br>负责解析、存储和管理 Excel 条件格式规则
656
-
657
- #### Constructor
658
- **Parameters**
659
- | Name | Type | Required | Default | Description |
660
- | --- | --- | --- | --- | --- |
661
- | sheet | Sheet | Yes | - | 所属工作表 |
662
-
663
- #### Props
664
- | Name | Type | Static | Default | Description |
665
- | --- | --- | --- | --- | --- |
666
- | rules | Array<CFRule> | No | [] | - |
667
- | sheet | Sheet | No | sheet | - |
668
-
669
- #### Methods
670
- ##### `add(config = {}): CFRule`
671
- - 添加条件格式规则
672
-
673
- **Parameters**
674
- | Name | Type | Required | Default | Description |
675
- | --- | --- | --- | --- | --- |
676
- | config | Object | No | {} | 规则配置 |
677
- | config.rangeRef | string | Yes | - | 应用范围 "A1:D10" |
678
- | config.type | string | Yes | - | 规则类型 (colorScale/dataBar/iconSet/cellIs/expression/top10/aboveAverage/duplicateValues/containsText/timePeriod/containsBlanks/containsErrors) |
679
-
680
- **Returns**
681
- - Type: `CFRule`
682
- - 创建的规则
683
-
684
- ##### `clearAllCache(): void`
685
- - 清除所有缓存
686
-
687
- ##### `clearRangeCache(sqref): void`
688
- - 清除指定范围的缓存
689
-
690
- **Parameters**
691
- | Name | Type | Required | Default | Description |
692
- | --- | --- | --- | --- | --- |
693
- | sqref | string | Yes | - | 范围 |
694
-
695
- ##### `get(index): CFRule | null`
696
- - 获取规则
697
-
698
- **Parameters**
699
- | Name | Type | Required | Default | Description |
700
- | --- | --- | --- | --- | --- |
701
- | index | number | Yes | - | 规则索引 |
702
-
703
- **Returns**
704
- - Type: `CFRule | null`
705
-
706
- ##### `getAll(): Array<CFRule>`
707
- - 获取所有规则
708
-
709
- **Returns**
710
- - Type: `Array<CFRule>`
711
-
712
- ##### `getDxfId(dxf): number`
713
- - 获取dxf样式索引(用于导出)
714
-
715
- **Parameters**
716
- | Name | Type | Required | Default | Description |
717
- | --- | --- | --- | --- | --- |
718
- | dxf | Object | Yes | - | 差异化样式对象 |
719
-
720
- **Returns**
721
- - Type: `number`
722
- - dxfId
723
-
724
- ##### `getDxfList(): Array`
725
- - 获取dxf样式列表(用于导出styles.xml)
726
-
727
- **Returns**
728
- - Type: `Array`
729
-
730
- ##### `getFormat(r, c): Object | null`
731
- - 获取单元格的条件格式
732
-
733
- **Parameters**
734
- | Name | Type | Required | Default | Description |
735
- | --- | --- | --- | --- | --- |
736
- | r | number | Yes | - | 行索引 |
737
- | c | number | Yes | - | 列索引 |
738
-
739
- **Returns**
740
- - Type: `Object | null`
741
- - 格式对象
742
-
743
- ##### `parse(xmlObj): void`
744
- - 从 xmlObj 解析条件格式数据
745
-
746
- **Parameters**
747
- | Name | Type | Required | Default | Description |
748
- | --- | --- | --- | --- | --- |
749
- | xmlObj | Object | Yes | - | Sheet 的 XML 对象 |
750
-
751
- ##### `remove(index): boolean`
752
- - 删除条件格式规则
753
-
754
- **Parameters**
755
- | Name | Type | Required | Default | Description |
756
- | --- | --- | --- | --- | --- |
757
- | index | number | Yes | - | 规则索引 |
758
-
759
- **Returns**
760
- - Type: `boolean`
761
-
762
- ##### `toXmlObject(): Array`
763
- - 导出为worksheet XML节点数组
764
-
765
- **Returns**
766
- - Type: `Array`
767
-
768
- ## Col/Col.js
769
-
770
- ### Col
771
- - 列对象
772
-
773
- #### Constructor
774
- **Parameters**
775
- | Name | Type | Required | Default | Description |
776
- | --- | --- | --- | --- | --- |
777
- | xmlObj | Object | Yes | - | 列 XML 数据 |
778
- | sheet | Sheet | Yes | - | 所属工作表 |
779
- | cIndex | number | Yes | - | 列索引 |
780
-
781
- #### Props
782
- | Name | Type | Static | Default | Description |
783
- | --- | --- | --- | --- | --- |
784
- | cIndex | number | No | cIndex | 列索引 |
785
- | sheet | Sheet | No | sheet | 所属工作表 |
786
-
787
- #### Get/Set
788
- | Name | Type | Mode | Static | Description |
789
- | --- | --- | --- | --- | --- |
790
- | alignment | Object | get/set | No | 对齐样式 |
791
- | border | Object | get/set | No | 边框样式 |
792
- | collapsed | boolean | get/set | No | 大纲折叠标记 |
793
- | fill | Object | get/set | No | 填充样式 |
794
- | font | Object | get/set | No | 字体样式 |
795
- | hidden | boolean | get/set | No | 是否隐藏 |
796
- | numFmt | string \| undefined | get/set | No | 数字格式 |
797
- | outlineLevel | number | get/set | No | 大纲层级(0-7) |
798
- | style | Object | get/set | No | 列样式 |
799
- | width | number | get/set | No | 列宽(像素) |
800
-
801
- #### Get
802
- | Name | Type | Static | Description |
803
- | --- | --- | --- | --- |
804
- | cells | Array<Cell> | No | 获取列内所有单元格 |
805
-
806
- ## Comment/Comment.js
807
-
808
- ### Comment
809
- - Comment 批注管理器<br>高性能设计:Map索引(cellRef -> CommentItem)+ O(1)查找<br>架构参考:完全复刻 Drawing 的设计模式
810
-
811
- #### Constructor
812
- **Parameters**
813
- | Name | Type | Required | Default | Description |
814
- | --- | --- | --- | --- | --- |
815
- | sheet | - | Yes | - | - |
816
-
817
- #### Props
818
- | Name | Type | Static | Default | Description |
819
- | --- | --- | --- | --- | --- |
820
- | map | Map<string, CommentItem> | No | new Map() | - |
821
- | sheet | Sheet | No | sheet | - |
822
-
823
- #### Methods
824
- ##### `add(config = {}): CommentItem`
825
- - 添加批注
826
-
827
- **Parameters**
828
- | Name | Type | Required | Default | Description |
829
- | --- | --- | --- | --- | --- |
830
- | config | Object | No | {} | {cellRef, author, text, visible, ...} |
831
-
832
- **Returns**
833
- - Type: `CommentItem`
834
-
835
- ##### `clearCache()`
836
- - 清除所有批注的位置缓存(视图变化时调用)
837
-
838
- ##### `get(cellRef): CommentItem | null`
839
- - 获取批注
840
-
841
- **Parameters**
842
- | Name | Type | Required | Default | Description |
843
- | --- | --- | --- | --- | --- |
844
- | cellRef | string | Yes | - | 单元格引用 "A1" |
845
-
846
- **Returns**
847
- - Type: `CommentItem | null`
848
-
849
- ##### `getAll(): CommentItem[]`
850
- - 获取所有批注列表
851
-
852
- **Returns**
853
- - Type: `CommentItem[]`
854
-
855
- ##### `parse(xmlObj)`
856
- - 从 xmlObj 解析批注数据(从 Excel 文件导入)
857
-
858
- **Parameters**
859
- | Name | Type | Required | Default | Description |
860
- | --- | --- | --- | --- | --- |
861
- | xmlObj | Object | Yes | - | Sheet 的 XML 对象 |
862
-
863
- ##### `remove(cellRef): boolean`
864
- - 删除批注
865
-
866
- **Parameters**
867
- | Name | Type | Required | Default | Description |
868
- | --- | --- | --- | --- | --- |
869
- | cellRef | string | Yes | - | 单元格引用 "A1" |
870
-
871
- **Returns**
872
- - Type: `boolean`
873
-
874
- ##### `toXmlObject(): Object | null`
875
- - 导出为XML对象(用于Excel导出)<br>将线程批注转换为普通批注格式
876
-
877
- **Returns**
878
- - Type: `Object | null`
879
-
880
- ## Drawing/Drawing.js
881
-
882
- ### Drawing
883
- - Drawing manager - CRUD, XML parse & export
884
-
885
- #### Constructor
886
- **Parameters**
887
- | Name | Type | Required | Default | Description |
888
- | --- | --- | --- | --- | --- |
889
- | sheet | Sheet | Yes | - | - |
890
-
891
- #### Props
892
- | Name | Type | Static | Default | Description |
893
- | --- | --- | --- | --- | --- |
894
- | map | Map<string, DrawingItem> | No | new Map() | - |
895
- | sheet | - | No | sheet | - |
896
-
897
- #### Methods
898
- ##### `addChart(chartOption, options?): DrawingItem`
899
-
900
- **Parameters**
901
- | Name | Type | Required | Default | Description |
902
- | --- | --- | --- | --- | --- |
903
- | chartOption | Object | Yes | - | - |
904
- | options | DrawingOptions | No | - | - |
905
-
906
- **Returns**
907
- - Type: `DrawingItem`
908
-
909
- ##### `addImage(imageBase64, options?): DrawingItem`
910
-
911
- **Parameters**
912
- | Name | Type | Required | Default | Description |
913
- | --- | --- | --- | --- | --- |
914
- | imageBase64 | string | Yes | - | - |
915
- | options | DrawingOptions | No | - | - |
916
-
917
- **Returns**
918
- - Type: `DrawingItem`
919
-
920
- ##### `addShape(shapeType, options?): DrawingItem`
921
-
922
- **Parameters**
923
- | Name | Type | Required | Default | Description |
924
- | --- | --- | --- | --- | --- |
925
- | shapeType | string | Yes | - | - |
926
- | options | DrawingOptions | No | - | - |
927
-
928
- **Returns**
929
- - Type: `DrawingItem`
930
-
931
- ##### `get(id): DrawingItem | null`
932
-
933
- **Parameters**
934
- | Name | Type | Required | Default | Description |
935
- | --- | --- | --- | --- | --- |
936
- | id | string | Yes | - | - |
937
-
938
- **Returns**
939
- - Type: `DrawingItem | null`
940
-
941
- ##### `getAll(): DrawingItem[]`
942
-
943
- **Returns**
944
- - Type: `DrawingItem[]`
945
-
946
- ##### `getByCell(cellRef): DrawingItem[]`
947
-
948
- **Parameters**
949
- | Name | Type | Required | Default | Description |
950
- | --- | --- | --- | --- | --- |
951
- | cellRef | Object \| string | Yes | - | - |
952
-
953
- **Returns**
954
- - Type: `DrawingItem[]`
955
-
956
- ##### `remove(id)`
957
-
958
- **Parameters**
959
- | Name | Type | Required | Default | Description |
960
- | --- | --- | --- | --- | --- |
961
- | id | string | Yes | - | - |
962
-
963
- ## Formula/Formula.js
964
-
965
- ### Formula
966
- - 公式计算器
967
-
968
- ## IO/IO.js
969
-
970
- ### IO
971
-
972
- #### Constructor
973
- **Parameters**
974
- | Name | Type | Required | Default | Description |
975
- | --- | --- | --- | --- | --- |
976
- | SN | import("../Workbook/Workbook.js").default | Yes | - | - |
977
-
978
- #### Methods
979
- ##### `export(type)`
980
-
981
- **Parameters**
982
- | Name | Type | Required | Default | Description |
983
- | --- | --- | --- | --- | --- |
984
- | type | 'XLSX' \| 'CSV' \| 'JSON' \| 'HTML' | Yes | - | - |
985
-
986
- ##### `exportAllImage()`
987
-
988
- ##### `getData(): Promise<Object>`
989
-
990
- **Returns**
991
- - Type: `Promise<Object>`
992
-
993
- ##### `async import(file): Promise<void>`
994
-
995
- **Parameters**
996
- | Name | Type | Required | Default | Description |
997
- | --- | --- | --- | --- | --- |
998
- | file | File | Yes | - | - |
999
-
1000
- **Returns**
1001
- - Type: `Promise<void>`
1002
- - Import from xlsx/csv/json file.
1003
-
1004
- ##### `async importFromUrl(fileUrl): Promise<void>`
1005
-
1006
- **Parameters**
1007
- | Name | Type | Required | Default | Description |
1008
- | --- | --- | --- | --- | --- |
1009
- | fileUrl | string | Yes | - | - |
1010
-
1011
- **Returns**
1012
- - Type: `Promise<void>`
1013
-
1014
- ##### `setData(data): boolean`
1015
-
1016
- **Parameters**
1017
- | Name | Type | Required | Default | Description |
1018
- | --- | --- | --- | --- | --- |
1019
- | data | Object | Yes | - | - |
1020
-
1021
- **Returns**
1022
- - Type: `boolean`
1023
-
1024
- ## Layout/Layout.js
1025
-
1026
- ### Layout
1027
- - 布局与工具栏管理
1028
-
1029
- #### Constructor
1030
- **Parameters**
1031
- | Name | Type | Required | Default | Description |
1032
- | --- | --- | --- | --- | --- |
1033
- | SN | Object | Yes | - | SheetNext instance. |
1034
- | options | Object | No | {} | Layout options. |
1035
- | options.menuRight | function | No | - | Callback `(defaultHTML: string) => string` to customize the top-right menu HTML. |
1036
- | options.menuList | function | No | - | Callback `(config: Array) => Array` to customize menu tab config. |
1037
-
1038
- #### Props
1039
- | Name | Type | Static | Default | Description |
1040
- | --- | --- | --- | --- | --- |
1041
- | chatWindowOffsetX | number | No | 0 | 聊天窗口拖拽偏移 X |
1042
- | chatWindowOffsetY | number | No | 0 | 聊天窗口拖拽偏移 Y |
1043
- | menuConfig | Object | No | MenuConfig.initDefaultMenuConfig(SN, options) | 菜单配置 |
1044
- | myModal | Object \| null | No | null | 通用弹窗实例 |
1045
- | SN | Object | No | SN | SheetNext 主实例 |
1046
- | StateSync | StateSync | No | new StateSync(SN) | 状态同步器 |
1047
- | toast | Object \| null | No | null | Toast 实例 |
1048
-
1049
- #### Get/Set
1050
- | Name | Type | Mode | Static | Description |
1051
- | --- | --- | --- | --- | --- |
1052
- | showAIChat | boolean | get/set | No | 是否显示 AI 聊天入口 |
1053
- | showAIChatWindow | boolean | get/set | No | 是否显示 AI 聊天窗口 |
1054
- | showFormulaBar | boolean | get/set | No | 是否显示公式栏 |
1055
- | showMenuBar | boolean | get/set | No | 是否显示菜单栏 |
1056
- | showPivotPanel | boolean | get/set | No | 是否显示透视表字段面板 |
1057
- | showSheetTabBar | boolean | get/set | No | 是否显示工作表标签栏 |
1058
- | showStats | boolean | get/set | No | 是否显示统计栏 |
1059
- | showToolbar | boolean | get/set | No | 是否显示工具栏 |
1060
-
1061
- #### Get
1062
- | Name | Type | Static | Description |
1063
- | --- | --- | --- | --- |
1064
- | isSmallWindow | boolean | No | 是否为小窗口 |
1065
- | isToolbarModeLocked | - | No | - |
1066
- | minimalToolbarTextEnabled | - | No | - |
1067
- | toolbarMode | - | No | - |
1068
-
1069
- #### Methods
1070
- ##### `autoOpenPivotPanel(pt): void`
1071
- - 自动打开透视表字段面板(点击透视表区域时调用)<br>如果用户手动关闭过,则不自动打开
1072
-
1073
- **Parameters**
1074
- | Name | Type | Required | Default | Description |
1075
- | --- | --- | --- | --- | --- |
1076
- | pt | PivotTable | Yes | - | 透视表实例 |
1077
-
1078
- ##### `closePivotPanel(): void`
1079
- - 关闭透视表字段面板(点击透视表区域外时调用)<br>不会设置手动关闭标记
1080
-
1081
- ##### `handleAllResize()`
1082
- - 处理所有resize相关的逻辑
1083
-
1084
- ##### `initColorComponents(scope?)`
1085
- - Initialize color components.
1086
-
1087
- **Parameters**
1088
- | Name | Type | Required | Default | Description |
1089
- | --- | --- | --- | --- | --- |
1090
- | scope | Element | No | - | Optional scope. |
1091
-
1092
- ##### `initDragEvents()`
1093
- - 初始化拖拽事件
1094
-
1095
- ##### `initEventListeners()`
1096
- - Initialize all event listeners.
1097
-
1098
- ##### `initResizeObserver()`
1099
- - 初始化ResizeObserver
1100
-
1101
- ##### `openPivotPanel(pt): void`
1102
- - 打开透视表字段面板(用户手动调用,如工具栏按钮)
1103
-
1104
- **Parameters**
1105
- | Name | Type | Required | Default | Description |
1106
- | --- | --- | --- | --- | --- |
1107
- | pt | PivotTable | Yes | - | 透视表实例 |
1108
-
1109
- ##### `refreshActiveButtons(): void`
1110
- - 刷新工具栏中带有 active getter 的按钮状态<br>用于格式刷等切换按钮的双向绑定
1111
-
1112
- ##### `refreshToolbar(): void`
1113
- - 统一刷新工具栏状态(面板切换、API修改后调用)<br>整合:样式状态 + checkbox + active按钮
1114
-
1115
- ##### `removeLoading()`
1116
- - Remove loading animation.
1117
-
1118
- ##### `scrollSheetTabs(dir): void`
1119
- - 滚动工作表标签
1120
-
1121
- **Parameters**
1122
- | Name | Type | Required | Default | Description |
1123
- | --- | --- | --- | --- | --- |
1124
- | dir | number | Yes | - | 滚动方向(1 或 -1) |
1125
-
1126
- ##### `throttleResize()`
1127
- - 节流处理resize事件
1128
-
1129
- ##### `toggleMinimalToolbar(enabled)`
1130
-
1131
- **Parameters**
1132
- | Name | Type | Required | Default | Description |
1133
- | --- | --- | --- | --- | --- |
1134
- | enabled | - | Yes | - | - |
1135
-
1136
- ##### `toggleMinimalToolbarText(enabled)`
1137
-
1138
- **Parameters**
1139
- | Name | Type | Required | Default | Description |
1140
- | --- | --- | --- | --- | --- |
1141
- | enabled | - | Yes | - | - |
1142
-
1143
- ##### `togglePivotPanel(pt): boolean`
1144
- - 切换透视表字段面板显示
1145
-
1146
- **Parameters**
1147
- | Name | Type | Required | Default | Description |
1148
- | --- | --- | --- | --- | --- |
1149
- | pt | PivotTable | Yes | - | 透视表实例 |
1150
-
1151
- **Returns**
1152
- - Type: `boolean`
1153
- - 是否显示
1154
-
1155
- ##### `updateCanvasSize()`
1156
- - 更新Canvas尺寸
1157
-
1158
- ##### `updateContextualToolbar(context): void`
1159
- - 更新上下文工具栏(根据选择内容显示/隐藏上下文选项卡)
1160
-
1161
- **Parameters**
1162
- | Name | Type | Required | Default | Description |
1163
- | --- | --- | --- | --- | --- |
1164
- | context | Object | Yes | - | 上下文信息 { type: 'table'\|'pivotTable'\|'chart'\|null, data: any, autoSwitch: boolean }<br> - autoSwitch: 是否自动切换到上下文选项卡(默认false,只显示不切换) |
1165
-
1166
- ## License/License.js
1167
-
1168
- ### License
1169
- - License 授权管理类 (Ed25519)
1170
-
1171
- #### Constructor
1172
- **Parameters**
1173
- | Name | Type | Required | Default | Description |
1174
- | --- | --- | --- | --- | --- |
1175
- | sheetNext | Object | Yes | - | SheetNext 主实例 |
1176
- | licenseKey | string | Yes | - | 授权码 |
1177
-
1178
- #### Props
1179
- | Name | Type | Static | Default | Description |
1180
- | --- | --- | --- | --- | --- |
1181
- | publicKey | string | No | 'ISuSucIeA0p8Lftf0YHGogmXqDFvLtEFE46XsoB1R9s=' | Ed25519 公钥(32 字节 Base64) |
1182
- | sheetNext | Object | No | sheetNext | SheetNext 主实例 |
1183
-
1184
- #### Get
1185
- | Name | Type | Static | Description |
1186
- | --- | --- | --- | --- |
1187
- | isActivated | boolean | No | 是否已激活授权 |
1188
- | isServiceActive | boolean | No | 服务包是否在有效期内 |
1189
-
1190
- #### Methods
1191
- ##### `async activate(licenseKey): Promise<void>`
1192
- - 激活授权
1193
-
1194
- **Parameters**
1195
- | Name | Type | Required | Default | Description |
1196
- | --- | --- | --- | --- | --- |
1197
- | licenseKey | string | Yes | - | 授权码 |
1198
-
1199
- **Returns**
1200
- - Type: `Promise<void>`
1201
-
1202
- ##### `base64Decode(str): string`
1203
- - Base64 解码(支持 UTF-8)
1204
-
1205
- **Parameters**
1206
- | Name | Type | Required | Default | Description |
1207
- | --- | --- | --- | --- | --- |
1208
- | str | string | Yes | - | Base64 字符串 |
1209
-
1210
- **Returns**
1211
- - Type: `string`
1212
-
1213
- ##### `getInfo(): {domains: string[], serviceExpireDate: string, daysLeft: number, isServiceActive: boolean} | null`
1214
-
1215
- **Returns**
1216
- - Type: `{domains: string[], serviceExpireDate: string, daysLeft: number, isServiceActive: boolean} | null`
1217
-
1218
- ##### `async verifySignature(data, signatureBase64): Promise<boolean>`
1219
- - 验证 Ed25519 签名(使用 Web Crypto API)
1220
-
1221
- **Parameters**
1222
- | Name | Type | Required | Default | Description |
1223
- | --- | --- | --- | --- | --- |
1224
- | data | string | Yes | - | 原始数据字符串 |
1225
- | signatureBase64 | string | Yes | - | Base64 签名 |
1226
-
1227
- **Returns**
1228
- - Type: `Promise<boolean>`
1229
-
1230
- ## PivotTable/PivotTable.js
1231
-
1232
- ### PivotTable
1233
- - 透视表管理器<br>负责透视表的增删改查
1234
-
1235
- #### Constructor
1236
- **Parameters**
1237
- | Name | Type | Required | Default | Description |
1238
- | --- | --- | --- | --- | --- |
1239
- | sheet | Sheet | Yes | - | - |
1240
-
1241
- #### Props
1242
- | Name | Type | Static | Default | Description |
1243
- | --- | --- | --- | --- | --- |
1244
- | map | Map<string, PivotTableItem> | No | new Map() | - |
1245
- | sheet | Sheet | No | sheet | - |
1246
-
1247
- #### Get
1248
- | Name | Type | Static | Description |
1249
- | --- | --- | --- | --- |
1250
- | size | number | No | - |
1251
-
1252
- #### Methods
1253
- ##### `add(config): PivotTable`
1254
- - 添加透视表
1255
-
1256
- **Parameters**
1257
- | Name | Type | Required | Default | Description |
1258
- | --- | --- | --- | --- | --- |
1259
- | config | Object | Yes | - | 配置对象 |
1260
- | config.sourceSheet | Sheet | Yes | - | 源工作表 |
1261
- | config.sourceRangeRef | string | Yes | - | 源数据范围 |
1262
- | config.cellRef | string \| Object | Yes | - | 目标单元格 |
1263
-
1264
- **Returns**
1265
- - Type: `PivotTable`
1266
-
1267
- ##### `forEach(callback)`
1268
- - 遍历所有透视表
1269
-
1270
- **Parameters**
1271
- | Name | Type | Required | Default | Description |
1272
- | --- | --- | --- | --- | --- |
1273
- | callback | Function | Yes | - | - |
1274
-
1275
- ##### `get(name): PivotTable | null`
1276
- - 获取透视表
1277
-
1278
- **Parameters**
1279
- | Name | Type | Required | Default | Description |
1280
- | --- | --- | --- | --- | --- |
1281
- | name | string | Yes | - | - |
1282
-
1283
- **Returns**
1284
- - Type: `PivotTable | null`
1285
-
1286
- ##### `getAll(): Array<PivotTable>`
1287
- - 获取所有透视表
1288
-
1289
- **Returns**
1290
- - Type: `Array<PivotTable>`
1291
-
1292
- ##### `refreshAll()`
1293
- - 刷新所有透视表
1294
-
1295
- ##### `remove(name)`
1296
- - 删除透视表
1297
-
1298
- **Parameters**
1299
- | Name | Type | Required | Default | Description |
1300
- | --- | --- | --- | --- | --- |
1301
- | name | string | Yes | - | 透视表名称 |
1302
-
1303
- ## Print/Print.js
1304
-
1305
- ### Print
1306
- - 打印设置与渲染
1307
-
1308
- #### Constructor
1309
- **Parameters**
1310
- | Name | Type | Required | Default | Description |
1311
- | --- | --- | --- | --- | --- |
1312
- | SN | Object | Yes | - | SheetNext 主实例 |
1313
-
1314
- #### Props
1315
- | Name | Type | Static | Default | Description |
1316
- | --- | --- | --- | --- | --- |
1317
- | SN | Object | No | SN | SheetNext 主实例 |
1318
-
1319
- #### Methods
1320
- ##### `applySettingsToWorksheet(sheet, ws): void`
1321
- - 应用打印设置到 worksheet XML
1322
-
1323
- **Parameters**
1324
- | Name | Type | Required | Default | Description |
1325
- | --- | --- | --- | --- | --- |
1326
- | sheet | Sheet | Yes | - | 工作表 |
1327
- | ws | Object | Yes | - | worksheet XML 对象 |
1328
-
1329
- ##### `bindPreviewEvents(bodyEl, pages, layout): void`
1330
- - 绑定预览交互事件
1331
-
1332
- **Parameters**
1333
- | Name | Type | Required | Default | Description |
1334
- | --- | --- | --- | --- | --- |
1335
- | bodyEl | HTMLElement | Yes | - | 弹窗 body |
1336
- | pages | Array<Object> | Yes | - | 页面数据 |
1337
- | layout | Object | Yes | - | 布局信息 |
1338
-
1339
- ##### `buildCellAddress(sheet, cell): string`
1340
- - 构建带工作表名的单元格地址
1341
-
1342
- **Parameters**
1343
- | Name | Type | Required | Default | Description |
1344
- | --- | --- | --- | --- | --- |
1345
- | sheet | Sheet | Yes | - | 工作表 |
1346
- | cell | {r: number, c: number} | Yes | - | 单元格坐标 |
1347
-
1348
- **Returns**
1349
- - Type: `string`
1350
-
1351
- ##### `buildLayout(sheet, settings, options = {}): Object`
1352
- - 构建分页布局信息
1353
-
1354
- **Parameters**
1355
- | Name | Type | Required | Default | Description |
1356
- | --- | --- | --- | --- | --- |
1357
- | sheet | Sheet | Yes | - | 工作表 |
1358
- | settings | Object | Yes | - | 打印设置 |
1359
- | options | Object | No | {} | - |
1360
-
1361
- **Returns**
1362
- - Type: `Object`
1363
-
1364
- ##### `buildPreviewHtml(pages, layout): string`
1365
- - 构建预览 HTML
1366
-
1367
- **Parameters**
1368
- | Name | Type | Required | Default | Description |
1369
- | --- | --- | --- | --- | --- |
1370
- | pages | Array<Object> | Yes | - | 页面数据 |
1371
- | layout | Object | Yes | - | 布局信息 |
1372
-
1373
- **Returns**
1374
- - Type: `string`
1375
-
1376
- ##### `buildPreviewPageHtml(page, layout, pageIndex = 0, pageCount = 1): string`
1377
- - 构建单页预览 HTML
1378
-
1379
- **Parameters**
1380
- | Name | Type | Required | Default | Description |
1381
- | --- | --- | --- | --- | --- |
1382
- | page | Object | Yes | - | 页面数据 |
1383
- | layout | Object | Yes | - | 布局信息 |
1384
- | pageIndex | number | No | 0 | - |
1385
- | pageCount | number | No | 1 | - |
1386
-
1387
- **Returns**
1388
- - Type: `string`
1389
-
1390
- ##### `buildPrintHtml(pages, layout): string`
1391
- - 构建打印 HTML
1392
-
1393
- **Parameters**
1394
- | Name | Type | Required | Default | Description |
1395
- | --- | --- | --- | --- | --- |
1396
- | pages | Array<Object> | Yes | - | 页面数据 |
1397
- | layout | Object | Yes | - | 布局信息 |
1398
-
1399
- **Returns**
1400
- - Type: `string`
1401
-
1402
- ##### `buildSegments(start, end, sizeGetter, maxSize, forcedStarts = []): Array<{s: number, e: number}>`
1403
- - 构建分页区段
1404
-
1405
- **Parameters**
1406
- | Name | Type | Required | Default | Description |
1407
- | --- | --- | --- | --- | --- |
1408
- | start | number | Yes | - | 起始索引 |
1409
- | end | number | Yes | - | 结束索引 |
1410
- | sizeGetter | Function | Yes | - | 获取尺寸方法 |
1411
- | maxSize | number | Yes | - | 最大尺寸 |
1412
- | forcedStarts | Array | No | [] | - |
1413
-
1414
- **Returns**
1415
- - Type: `Array<{s: number, e: number}>`
1416
-
1417
- ##### `async captureRange(sheet, range, width, height, settings): Promise<string>`
1418
- - 截图指定范围
1419
-
1420
- **Parameters**
1421
- | Name | Type | Required | Default | Description |
1422
- | --- | --- | --- | --- | --- |
1423
- | sheet | Sheet | Yes | - | 工作表 |
1424
- | range | {s: {r: number, c: number}, e: {r: number, c: number}} | Yes | - | 范围 |
1425
- | width | number | Yes | - | 宽度 |
1426
- | height | number | Yes | - | 高度 |
1427
- | settings | Object | Yes | - | 打印设置 |
1428
-
1429
- **Returns**
1430
- - Type: `Promise<string>`
1431
-
1432
- ##### `clearPrintArea(sheet = this.SN.activeSheet): void`
1433
- - 清空打印区域
1434
-
1435
- **Parameters**
1436
- | Name | Type | Required | Default | Description |
1437
- | --- | --- | --- | --- | --- |
1438
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1439
-
1440
- ##### `createDefaultSettings(): Object`
1441
- - 创建默认打印设置
1442
-
1443
- **Returns**
1444
- - Type: `Object`
1445
-
1446
- ##### `ensureSettings(sheet = this.SN.activeSheet): Object | null`
1447
- - 获取并确保工作表的打印设置
1448
-
1449
- **Parameters**
1450
- | Name | Type | Required | Default | Description |
1451
- | --- | --- | --- | --- | --- |
1452
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1453
-
1454
- **Returns**
1455
- - Type: `Object | null`
1456
-
1457
- ##### `getColSize(sheet, c): number`
1458
- - 获取列宽(像素)
1459
-
1460
- **Parameters**
1461
- | Name | Type | Required | Default | Description |
1462
- | --- | --- | --- | --- | --- |
1463
- | sheet | Sheet | Yes | - | 工作表 |
1464
- | c | number | Yes | - | 列索引 |
1465
-
1466
- **Returns**
1467
- - Type: `number`
1468
-
1469
- ##### `getMarginPixels(margins = DEFAULT_MARGINS): {left: number, right: number, top: number, bottom: number}`
1470
- - 计算边距像素值
1471
-
1472
- **Parameters**
1473
- | Name | Type | Required | Default | Description |
1474
- | --- | --- | --- | --- | --- |
1475
- | margins | Object | No | DEFAULT_MARGINS | 边距配置 |
1476
-
1477
- **Returns**
1478
- - Type: `{left: number, right: number, top: number, bottom: number}`
1479
-
1480
- ##### `getPageBreakGuides(sheet = this.SN.activeSheet): {range:Object,rowBreaks:Array<{index:number,manual:boolean}>,colBreaks:Array<{index:number,manual:boolean}>} | null`
1481
- - 获取分页辅助线信息(用于画布显示)
1482
-
1483
- **Parameters**
1484
- | Name | Type | Required | Default | Description |
1485
- | --- | --- | --- | --- | --- |
1486
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1487
-
1488
- **Returns**
1489
- - Type: `{range:Object,rowBreaks:Array<{index:number,manual:boolean}>,colBreaks:Array<{index:number,manual:boolean}>} | null`
1490
-
1491
- ##### `getPaperDefinition(settings): Object`
1492
- - 获取纸张定义
1493
-
1494
- **Parameters**
1495
- | Name | Type | Required | Default | Description |
1496
- | --- | --- | --- | --- | --- |
1497
- | settings | Object | Yes | - | 打印设置 |
1498
-
1499
- **Returns**
1500
- - Type: `Object`
1501
-
1502
- ##### `getPrintRange(sheet, settings): {s: {r: number, c: number}, e: {r: number, c: number}}`
1503
- - 获取实际打印范围
1504
-
1505
- **Parameters**
1506
- | Name | Type | Required | Default | Description |
1507
- | --- | --- | --- | --- | --- |
1508
- | sheet | Sheet | Yes | - | 工作表 |
1509
- | settings | Object | Yes | - | 打印设置 |
1510
-
1511
- **Returns**
1512
- - Type: `{s: {r: number, c: number}, e: {r: number, c: number}}`
1513
-
1514
- ##### `getRangeSize(sheet, range, includeHeadings): {width: number, height: number}`
1515
- - 获取范围尺寸
1516
-
1517
- **Parameters**
1518
- | Name | Type | Required | Default | Description |
1519
- | --- | --- | --- | --- | --- |
1520
- | sheet | Sheet | Yes | - | 工作表 |
1521
- | range | {s: {r: number, c: number}, e: {r: number, c: number}} | Yes | - | 范围 |
1522
- | includeHeadings | boolean | Yes | - | 是否包含行列头 |
1523
-
1524
- **Returns**
1525
- - Type: `{width: number, height: number}`
1526
-
1527
- ##### `getRowSize(sheet, r): number`
1528
- - 获取行高(像素)
1529
-
1530
- **Parameters**
1531
- | Name | Type | Required | Default | Description |
1532
- | --- | --- | --- | --- | --- |
1533
- | sheet | Sheet | Yes | - | 工作表 |
1534
- | r | number | Yes | - | 行索引 |
1535
-
1536
- **Returns**
1537
- - Type: `number`
1538
-
1539
- ##### `getSettings(sheet = this.SN.activeSheet): Object | null`
1540
- - 获取打印设置(深拷贝)
1541
-
1542
- **Parameters**
1543
- | Name | Type | Required | Default | Description |
1544
- | --- | --- | --- | --- | --- |
1545
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1546
-
1547
- **Returns**
1548
- - Type: `Object | null`
1549
-
1550
- ##### `getUsedRange(sheet): {s: {r: number, c: number}, e: {r: number, c: number}}`
1551
- - 获取已使用区域
1552
-
1553
- **Parameters**
1554
- | Name | Type | Required | Default | Description |
1555
- | --- | --- | --- | --- | --- |
1556
- | sheet | Sheet | Yes | - | 工作表 |
1557
-
1558
- **Returns**
1559
- - Type: `{s: {r: number, c: number}, e: {r: number, c: number}}`
1560
-
1561
- ##### `initSheetPrintSettings(sheet): Object`
1562
- - 初始化工作表打印设置
1563
-
1564
- **Parameters**
1565
- | Name | Type | Required | Default | Description |
1566
- | --- | --- | --- | --- | --- |
1567
- | sheet | Sheet | Yes | - | 工作表 |
1568
-
1569
- **Returns**
1570
- - Type: `Object`
1571
-
1572
- ##### `insertPageBreak(cell = sheet.activeCell, sheet = this.SN.activeSheet): {row:boolean, col:boolean} | null`
1573
- - 在当前活动单元格插入手动分页符
1574
-
1575
- **Parameters**
1576
- | Name | Type | Required | Default | Description |
1577
- | --- | --- | --- | --- | --- |
1578
- | cell | {r:number, c:number} | No | sheet.activeCell | 单元格位置 |
1579
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1580
-
1581
- **Returns**
1582
- - Type: `{row:boolean, col:boolean} | null`
1583
-
1584
- ##### `normalizeRange(range, sheet): {s: {r: number, c: number}, e: {r: number, c: number}} | null`
1585
- - 规范化范围对象
1586
-
1587
- **Parameters**
1588
- | Name | Type | Required | Default | Description |
1589
- | --- | --- | --- | --- | --- |
1590
- | range | string \| Object \| null | Yes | - | 范围 |
1591
- | sheet | Sheet | Yes | - | 工作表 |
1592
-
1593
- **Returns**
1594
- - Type: `{s: {r: number, c: number}, e: {r: number, c: number}} | null`
1595
-
1596
- ##### `async preview(options = {}): Promise<void>`
1597
- - 打印预览
1598
-
1599
- **Parameters**
1600
- | Name | Type | Required | Default | Description |
1601
- | --- | --- | --- | --- | --- |
1602
- | options | Object | No | {} | 预览选项 |
1603
-
1604
- **Returns**
1605
- - Type: `Promise<void>`
1606
-
1607
- ##### `async print(options = {}): Promise<void>`
1608
- - 打印
1609
-
1610
- **Parameters**
1611
- | Name | Type | Required | Default | Description |
1612
- | --- | --- | --- | --- | --- |
1613
- | options | Object | No | {} | 打印选项 |
1614
-
1615
- **Returns**
1616
- - Type: `Promise<void>`
1617
-
1618
- ##### `readSettingsFromXml(xmlObj, sheet = null): Object`
1619
- - 从 XML 读取打印设置
1620
-
1621
- **Parameters**
1622
- | Name | Type | Required | Default | Description |
1623
- | --- | --- | --- | --- | --- |
1624
- | xmlObj | Object | Yes | - | worksheet XML 对象 |
1625
- | sheet | null | No | null | - |
1626
-
1627
- **Returns**
1628
- - Type: `Object`
1629
-
1630
- ##### `async renderPages(sheet, settings, layout): Promise<Array<Object>>`
1631
- - 渲染所有页面
1632
-
1633
- **Parameters**
1634
- | Name | Type | Required | Default | Description |
1635
- | --- | --- | --- | --- | --- |
1636
- | sheet | Sheet | Yes | - | 工作表 |
1637
- | settings | Object | Yes | - | 打印设置 |
1638
- | layout | Object | Yes | - | 布局信息 |
1639
-
1640
- **Returns**
1641
- - Type: `Promise<Array<Object>>`
1642
-
1643
- ##### `setPageMargins(margins, sheet = this.SN.activeSheet): Object | null`
1644
- - 设置页边距
1645
-
1646
- **Parameters**
1647
- | Name | Type | Required | Default | Description |
1648
- | --- | --- | --- | --- | --- |
1649
- | margins | Object | Yes | - | 边距配置 |
1650
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1651
-
1652
- **Returns**
1653
- - Type: `Object | null`
1654
-
1655
- ##### `setPageSetup(setup, sheet = this.SN.activeSheet): Object | null`
1656
- - 设置页面配置
1657
-
1658
- **Parameters**
1659
- | Name | Type | Required | Default | Description |
1660
- | --- | --- | --- | --- | --- |
1661
- | setup | Object | Yes | - | 页面设置 |
1662
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1663
-
1664
- **Returns**
1665
- - Type: `Object | null`
1666
-
1667
- ##### `setPrintArea(range, sheet = this.SN.activeSheet): Object | null`
1668
- - 设置打印区域
1669
-
1670
- **Parameters**
1671
- | Name | Type | Required | Default | Description |
1672
- | --- | --- | --- | --- | --- |
1673
- | range | string \| Object | Yes | - | 区域 |
1674
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1675
-
1676
- **Returns**
1677
- - Type: `Object | null`
1678
-
1679
- ##### `setPrintOptions(options, sheet = this.SN.activeSheet): Object | null`
1680
- - 设置打印选项
1681
-
1682
- **Parameters**
1683
- | Name | Type | Required | Default | Description |
1684
- | --- | --- | --- | --- | --- |
1685
- | options | Object | Yes | - | 打印选项 |
1686
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1687
-
1688
- **Returns**
1689
- - Type: `Object | null`
1690
-
1691
- ##### `setPrintTitles(titles, sheet = this.SN.activeSheet): void`
1692
- - 设置打印标题行/列
1693
-
1694
- **Parameters**
1695
- | Name | Type | Required | Default | Description |
1696
- | --- | --- | --- | --- | --- |
1697
- | titles | {rows?: string \| number[] \| {s:number,e:number} \| null, cols?: string \| number[] \| {s:number,e:number} \| null} | Yes | - | 标题配置 |
1698
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1699
-
1700
- ##### `setSettings(partial, sheet = this.SN.activeSheet): Object | null`
1701
- - 合并更新打印设置
1702
-
1703
- **Parameters**
1704
- | Name | Type | Required | Default | Description |
1705
- | --- | --- | --- | --- | --- |
1706
- | partial | Object | Yes | - | 部分设置 |
1707
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1708
-
1709
- **Returns**
1710
- - Type: `Object | null`
1711
-
1712
- ##### `toggleGridlines(on, sheet = this.SN.activeSheet): void`
1713
- - 切换打印网格线
1714
-
1715
- **Parameters**
1716
- | Name | Type | Required | Default | Description |
1717
- | --- | --- | --- | --- | --- |
1718
- | on | boolean | Yes | - | 是否启用 |
1719
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1720
-
1721
- ##### `toggleHeadings(on, sheet = this.SN.activeSheet): void`
1722
- - 切换打印行列头
1723
-
1724
- **Parameters**
1725
- | Name | Type | Required | Default | Description |
1726
- | --- | --- | --- | --- | --- |
1727
- | on | boolean | Yes | - | 是否启用 |
1728
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1729
-
1730
- ##### `toggleShowPageBreaks(on, sheet = this.SN.activeSheet): void`
1731
- - 显示/隐藏分页符辅助线
1732
-
1733
- **Parameters**
1734
- | Name | Type | Required | Default | Description |
1735
- | --- | --- | --- | --- | --- |
1736
- | on | boolean | Yes | - | 是否显示 |
1737
- | sheet | Sheet | No | this.SN.activeSheet | 工作表 |
1738
-
1739
- ## Row/Row.js
1740
-
1741
- ### Row
1742
- - 行对象
1743
-
1744
- #### Constructor
1745
- **Parameters**
1746
- | Name | Type | Required | Default | Description |
1747
- | --- | --- | --- | --- | --- |
1748
- | xmlObj | Object | Yes | - | 行 XML 数据 |
1749
- | sheet | Sheet | Yes | - | 所属工作表 |
1750
- | rIndex | number | Yes | - | 行索引 |
1751
-
1752
- #### Props
1753
- | Name | Type | Static | Default | Description |
1754
- | --- | --- | --- | --- | --- |
1755
- | cells | Array<Cell> | No | [] | 行内单元格数组 |
1756
- | rIndex | number | No | rIndex | 行索引 |
1757
- | sheet | Sheet | No | sheet | 所属工作表 |
1758
-
1759
- #### Get/Set
1760
- | Name | Type | Mode | Static | Description |
1761
- | --- | --- | --- | --- | --- |
1762
- | alignment | Object | get/set | No | 对齐样式 |
1763
- | border | Object | get/set | No | 边框样式 |
1764
- | collapsed | boolean | get/set | No | 大纲折叠标记 |
1765
- | fill | Object | get/set | No | 填充样式 |
1766
- | font | Object | get/set | No | 字体样式 |
1767
- | height | number | get/set | No | 行高(像素) |
1768
- | hidden | boolean | get/set | No | 是否隐藏 |
1769
- | numFmt | string \| undefined | get/set | No | 数字格式 |
1770
- | outlineLevel | number | get/set | No | 大纲层级(0-7) |
1771
- | style | Object | get/set | No | 行样式 |
1772
-
1773
- #### Methods
1774
- ##### `init(): void`
1775
- - 初始化行内单元格
1776
-
1777
- ## Sheet/Sheet.js
1778
-
1779
- ### Sheet
1780
-
1781
- #### Constructor
1782
- **Parameters**
1783
- | Name | Type | Required | Default | Description |
1784
- | --- | --- | --- | --- | --- |
1785
- | meta | Object | Yes | - | - |
1786
- | SN | SheetNext | Yes | - | - |
1787
-
1788
- #### Props
1789
- | Name | Type | Static | Default | Description |
1790
- | --- | --- | --- | --- | --- |
1791
- | AutoFilter | AutoFilter | No | new AutoFilter(this) | - |
1792
- | Canvas | - | No | SN.Canvas | - |
1793
- | CF | null | No | null | - |
1794
- | cols | Col[] | No | [] | - |
1795
- | Comment | Comment | No | new Comment(this) | - |
1796
- | Drawing | null | No | null | - |
1797
- | initialized | boolean | No | false | - |
1798
- | merges | RangeNum[] | No | [] | - |
1799
- | outlinePr | Object | No | { | - |
1800
- | PivotTable | null | No | null | - |
1801
- | printSettings | Object | No | null | - |
1802
- | protection | Object | No | new SheetProtection(this) | - |
1803
- | rId | string | No | meta['_$r:id'] | - |
1804
- | rows | Row[] | No | [] | - |
1805
- | showGridLines | boolean | No | true | - |
1806
- | showPageBreaks | boolean | No | false | - |
1807
- | showRowColHeaders | boolean | No | true | - |
1808
- | Slicer | null | No | null | - |
1809
- | SN | - | No | SN | - |
1810
- | Sparkline | null | No | null | - |
1811
- | Table | Table | No | new Table(this) | - |
1812
- | Utils | - | No | SN.Utils | - |
1813
- | vi | Object | No | null | - |
1814
- | views | Object[] | No | [{ pane: {} }] | - |
1815
-
1816
- #### Get/Set
1817
- | Name | Type | Mode | Static | Description |
1818
- | --- | --- | --- | --- | --- |
1819
- | activeAreas | RangeNum[] | get/set | No | - |
1820
- | activeCell | CellNum | get/set | No | - |
1821
- | defaultColWidth | number | get/set | No | - |
1822
- | defaultRowHeight | number | get/set | No | - |
1823
- | frozenCols | number | get/set | No | - |
1824
- | frozenRows | number | get/set | No | - |
1825
- | headHeight | number | get/set | No | - |
1826
- | hidden | boolean | get/set | No | - |
1827
- | indexWidth | number | get/set | No | - |
1828
- | name | string | get/set | No | - |
1829
- | viewStart | CellNum | get/set | No | - |
1830
- | zoom | number | get/set | No | - |
1831
-
1832
- #### Get
1833
- | Name | Type | Static | Description |
1834
- | --- | --- | --- | --- |
1835
- | colCount | number | No | - |
1836
- | rowCount | number | No | - |
1837
-
1838
- #### Methods
1839
- ##### `addCols(c, number = 1)`
1840
- - 插入列
1841
-
1842
- **Parameters**
1843
- | Name | Type | Required | Default | Description |
1844
- | --- | --- | --- | --- | --- |
1845
- | c | Number | Yes | - | 插入位置的列索引 |
1846
- | number | Number | No | 1 | 插入的列数 |
1847
-
1848
- ##### `addRows(r, number = 1)`
1849
- - 插入行
1850
-
1851
- **Parameters**
1852
- | Name | Type | Required | Default | Description |
1853
- | --- | --- | --- | --- | --- |
1854
- | r | Number | Yes | - | 插入位置的行索引 |
1855
- | number | Number | No | 1 | 插入的行数 |
1856
-
1857
- ##### `applyBrush(targetArea): boolean`
1858
-
1859
- **Parameters**
1860
- | Name | Type | Required | Default | Description |
1861
- | --- | --- | --- | --- | --- |
1862
- | targetArea | RangeNum | Yes | - | - |
1863
-
1864
- **Returns**
1865
- - Type: `boolean`
1866
-
1867
- ##### `areaHaveMerge(area): Boolean`
1868
- - 检测区域中是否存在合并的单元格
1869
-
1870
- **Parameters**
1871
- | Name | Type | Required | Default | Description |
1872
- | --- | --- | --- | --- | --- |
1873
- | area | Object | Yes | - | 区域对象 |
1874
-
1875
- **Returns**
1876
- - Type: `Boolean`
1877
- - 是否存在合并单元格
1878
-
1879
- ##### `areasBorder(position, options, area = this.activeAreas)`
1880
-
1881
- **Parameters**
1882
- | Name | Type | Required | Default | Description |
1883
- | --- | --- | --- | --- | --- |
1884
- | position | string | Yes | - | - |
1885
- | options | Object \| null | Yes | - | - |
1886
- | area | Array | No | this.activeAreas | - |
1887
-
1888
- ##### `cancelBrush(): boolean`
1889
-
1890
- **Returns**
1891
- - Type: `boolean`
1892
-
1893
- ##### `clearClipboard()`
1894
- - 清除剪贴板
1895
-
1896
- ##### `clearDataValidation(range)`
1897
-
1898
- **Parameters**
1899
- | Name | Type | Required | Default | Description |
1900
- | --- | --- | --- | --- | --- |
1901
- | range | - | Yes | - | - |
1902
-
1903
- ##### `consolidate(ranges, options = {})`
1904
-
1905
- **Parameters**
1906
- | Name | Type | Required | Default | Description |
1907
- | --- | --- | --- | --- | --- |
1908
- | ranges | - | Yes | - | - |
1909
- | options | Object | No | {} | - |
1910
-
1911
- ##### `copy(area = null, isCut = false)`
1912
- - 复制区域数据
1913
-
1914
- **Parameters**
1915
- | Name | Type | Required | Default | Description |
1916
- | --- | --- | --- | --- | --- |
1917
- | area | Object | No | null | 复制区域 { s: {r, c}, e: {r, c} } |
1918
- | isCut | boolean | No | false | 是否剪切 |
1919
-
1920
- ##### `cut(area = null)`
1921
- - 剪切区域数据
1922
-
1923
- **Parameters**
1924
- | Name | Type | Required | Default | Description |
1925
- | --- | --- | --- | --- | --- |
1926
- | area | Object | No | null | 剪切区域 |
1927
-
1928
- ##### `delCols(c, number = 1)`
1929
- - 删除列
1930
-
1931
- **Parameters**
1932
- | Name | Type | Required | Default | Description |
1933
- | --- | --- | --- | --- | --- |
1934
- | c | Number | Yes | - | 删除起始位置的列索引 |
1935
- | number | Number | No | 1 | 删除的列数 |
1936
-
1937
- ##### `delRows(r, number = 1)`
1938
- - 删除行
1939
-
1940
- **Parameters**
1941
- | Name | Type | Required | Default | Description |
1942
- | --- | --- | --- | --- | --- |
1943
- | r | Number | Yes | - | 删除起始位置的行索引 |
1944
- | number | Number | No | 1 | 删除的行数 |
1945
-
1946
- ##### `eachCells(ranges, callback, options = {})`
1947
-
1948
- **Parameters**
1949
- | Name | Type | Required | Default | Description |
1950
- | --- | --- | --- | --- | --- |
1951
- | ranges | RangeRef \| RangeRef[] | Yes | - | - |
1952
- | callback | (r:number,c:number,area:RangeNum)=>void | Yes | - | - |
1953
- | options | {reverse?:boolean,sparse?:boolean} | No | {} | - |
1954
-
1955
- ##### `flashFill(range, options = {})`
1956
-
1957
- **Parameters**
1958
- | Name | Type | Required | Default | Description |
1959
- | --- | --- | --- | --- | --- |
1960
- | range | - | Yes | - | - |
1961
- | options | Object | No | {} | - |
1962
-
1963
- ##### `getAreaInviewInfo(area): Object`
1964
- - 获取区域在可见视图中的信息
1965
-
1966
- **Parameters**
1967
- | Name | Type | Required | Default | Description |
1968
- | --- | --- | --- | --- | --- |
1969
- | area | Object | Yes | - | 区域对象 |
1970
-
1971
- **Returns**
1972
- - Type: `Object`
1973
- - 包含位置和尺寸信息的对象
1974
-
1975
- ##### `getCell(r, c?): Cell`
1976
-
1977
- **Parameters**
1978
- | Name | Type | Required | Default | Description |
1979
- | --- | --- | --- | --- | --- |
1980
- | r | number \| string | Yes | - | - |
1981
- | c | number | No | - | - |
1982
-
1983
- **Returns**
1984
- - Type: `Cell`
1985
-
1986
- ##### `getCellInViewInfo(rowIndex, colIndex, posMerge = true): Object`
1987
- - 获取单元格在可见视图中的信息
1988
-
1989
- **Parameters**
1990
- | Name | Type | Required | Default | Description |
1991
- | --- | --- | --- | --- | --- |
1992
- | rowIndex | Number | Yes | - | 行索引 |
1993
- | colIndex | Number | Yes | - | 列索引 |
1994
- | posMerge | Boolean | No | true | 是否处理合并单元格 |
1995
-
1996
- **Returns**
1997
- - Type: `Object`
1998
- - 包含位置和尺寸信息的对象
1999
-
2000
- ##### `getClipboardData()`
2001
- - 获取当前剪贴板数据
2002
-
2003
- ##### `getCol(c): Col`
2004
-
2005
- **Parameters**
2006
- | Name | Type | Required | Default | Description |
2007
- | --- | --- | --- | --- | --- |
2008
- | c | number | Yes | - | - |
2009
-
2010
- **Returns**
2011
- - Type: `Col`
2012
-
2013
- ##### `getColIndexByScrollLeft(scrollLeft): Number`
2014
- - 根据水平滚动像素位置找到对应列索引
2015
-
2016
- **Parameters**
2017
- | Name | Type | Required | Default | Description |
2018
- | --- | --- | --- | --- | --- |
2019
- | scrollLeft | Number | Yes | - | 滚动像素位置 |
2020
-
2021
- **Returns**
2022
- - Type: `Number`
2023
- - 列索引
2024
-
2025
- ##### `getRow(r): Row`
2026
-
2027
- **Parameters**
2028
- | Name | Type | Required | Default | Description |
2029
- | --- | --- | --- | --- | --- |
2030
- | r | number | Yes | - | - |
2031
-
2032
- **Returns**
2033
- - Type: `Row`
2034
-
2035
- ##### `getRowIndexByScrollTop(scrollTop): Number`
2036
- - 根据垂直滚动像素位置找到对应行索引
2037
-
2038
- **Parameters**
2039
- | Name | Type | Required | Default | Description |
2040
- | --- | --- | --- | --- | --- |
2041
- | scrollTop | Number | Yes | - | 滚动像素位置 |
2042
-
2043
- **Returns**
2044
- - Type: `Number`
2045
- - 行索引
2046
-
2047
- ##### `getScrollLeft(colIndex): Number`
2048
- - 获取指定列之前所有列的宽度总和
2049
-
2050
- **Parameters**
2051
- | Name | Type | Required | Default | Description |
2052
- | --- | --- | --- | --- | --- |
2053
- | colIndex | Number | Yes | - | 列索引 |
2054
-
2055
- **Returns**
2056
- - Type: `Number`
2057
- - 宽度总和
2058
-
2059
- ##### `getScrollTop(rowIndex): Number`
2060
- - 获取指定行之前所有行的高度总和
2061
-
2062
- **Parameters**
2063
- | Name | Type | Required | Default | Description |
2064
- | --- | --- | --- | --- | --- |
2065
- | rowIndex | Number | Yes | - | 行索引 |
2066
-
2067
- **Returns**
2068
- - Type: `Number`
2069
- - 高度总和
2070
-
2071
- ##### `getTotalHeight(): Number`
2072
- - 获取所有行的总高度(缓存优化)
2073
-
2074
- **Returns**
2075
- - Type: `Number`
2076
- - 总高度
2077
-
2078
- ##### `getTotalWidth(): Number`
2079
- - 获取所有列的总宽度(缓存优化)
2080
-
2081
- **Returns**
2082
- - Type: `Number`
2083
- - 总宽度
2084
-
2085
- ##### `groupCols(range, options = {})`
2086
-
2087
- **Parameters**
2088
- | Name | Type | Required | Default | Description |
2089
- | --- | --- | --- | --- | --- |
2090
- | range | - | Yes | - | - |
2091
- | options | Object | No | {} | - |
2092
-
2093
- ##### `groupRows(range, options = {})`
2094
-
2095
- **Parameters**
2096
- | Name | Type | Required | Default | Description |
2097
- | --- | --- | --- | --- | --- |
2098
- | range | - | Yes | - | - |
2099
- | options | Object | No | {} | - |
2100
-
2101
- ##### `hasClipboardData()`
2102
- - 检查是否有剪贴板数据
2103
-
2104
- ##### `hyperlinkJump()`
2105
- - Jump to hyperlink target of active cell.
2106
-
2107
- ##### `insertTable(arr, pos, options = {})`
2108
- - 从指定位置开始,插入一个表
2109
-
2110
- **Parameters**
2111
- | Name | Type | Required | Default | Description |
2112
- | --- | --- | --- | --- | --- |
2113
- | arr | Array | Yes | - | 表格数据数组 |
2114
- | pos | Object \| String | Yes | - | 插入位置 |
2115
- | options | Object | No | {} | 配置选项 {align, border, width, height, background, color} |
2116
-
2117
- ##### `mergeCells(areas = null, mode = 'default')`
2118
- - 合并单元格,支持多种模式
2119
-
2120
- **Parameters**
2121
- | Name | Type | Required | Default | Description |
2122
- | --- | --- | --- | --- | --- |
2123
- | areas | Array \| Object \| String \| null | No | null | 区域,默认取 activeAreas |
2124
- | mode | String | No | 'default' | 模式: 'default'\|'center'\|'content'\|'same' |
2125
-
2126
- ##### `moveArea(moveArea, targetArea): boolean`
2127
-
2128
- **Parameters**
2129
- | Name | Type | Required | Default | Description |
2130
- | --- | --- | --- | --- | --- |
2131
- | moveArea | Object \| string | Yes | - | - |
2132
- | targetArea | Object \| string | Yes | - | - |
2133
-
2134
- **Returns**
2135
- - Type: `boolean`
2136
-
2137
- ##### `paddingArea(oArea = this.Canvas.lastPadding.oArea, targetArea = this.Canvas.lastPadding.targetArea, type = 'order')`
2138
-
2139
- **Parameters**
2140
- | Name | Type | Required | Default | Description |
2141
- | --- | --- | --- | --- | --- |
2142
- | oArea | Object \| string | No | this.Canvas.lastPadding.oArea | - |
2143
- | targetArea | Object \| string | No | this.Canvas.lastPadding.targetArea | - |
2144
- | type | string | No | 'order' | Fill area with series/copy/format. |
2145
-
2146
- ##### `paste(targetArea = null, options = {})`
2147
- - 粘贴数据到目标区域
2148
-
2149
- **Parameters**
2150
- | Name | Type | Required | Default | Description |
2151
- | --- | --- | --- | --- | --- |
2152
- | targetArea | Object | No | null | 目标区域起始位置 { r, c } 或完整区域 |
2153
- | options | Object | No | {} | 粘贴选项 |
2154
- | options.mode | string | Yes | - | 粘贴模式 (PasteMode) |
2155
- | options.operation | string | Yes | - | 运算模式 (PasteOperation) |
2156
- | options.skipBlanks | boolean | Yes | - | 跳过空单元格 |
2157
- | options.transpose | boolean | Yes | - | 转置 |
2158
- | options.externalData | Object | Yes | - | 外部剪贴板数据(从系统剪贴板解析) |
2159
-
2160
- ##### `rangeSort(sortKeys, range?)`
2161
-
2162
- **Parameters**
2163
- | Name | Type | Required | Default | Description |
2164
- | --- | --- | --- | --- | --- |
2165
- | sortKeys | Array<{col:string \| number, order?:string, customOrder?:Array}> | Yes | - | - |
2166
- | range | RangeRef | No | - | - |
2167
-
2168
- ##### `rangeStrToNum(range): RangeNum`
2169
-
2170
- **Parameters**
2171
- | Name | Type | Required | Default | Description |
2172
- | --- | --- | --- | --- | --- |
2173
- | range | RangeStr | Yes | - | - |
2174
-
2175
- **Returns**
2176
- - Type: `RangeNum`
2177
-
2178
- ##### `setBrush(keep = false)`
2179
-
2180
- **Parameters**
2181
- | Name | Type | Required | Default | Description |
2182
- | --- | --- | --- | --- | --- |
2183
- | keep | boolean | No | false | - |
2184
-
2185
- ##### `setDataValidation(range, rule)`
2186
-
2187
- **Parameters**
2188
- | Name | Type | Required | Default | Description |
2189
- | --- | --- | --- | --- | --- |
2190
- | range | - | Yes | - | - |
2191
- | rule | - | Yes | - | - |
2192
-
2193
- ##### `showAllHidCols()`
2194
-
2195
- ##### `showAllHidRows()`
2196
-
2197
- ##### `subtotal(range, options = {})`
2198
-
2199
- **Parameters**
2200
- | Name | Type | Required | Default | Description |
2201
- | --- | --- | --- | --- | --- |
2202
- | range | - | Yes | - | - |
2203
- | options | Object | No | {} | - |
2204
-
2205
- ##### `textToColumns(range, options = {})`
2206
-
2207
- **Parameters**
2208
- | Name | Type | Required | Default | Description |
2209
- | --- | --- | --- | --- | --- |
2210
- | range | - | Yes | - | - |
2211
- | options | Object | No | {} | - |
2212
-
2213
- ##### `ungroupCols(range, options = {})`
2214
-
2215
- **Parameters**
2216
- | Name | Type | Required | Default | Description |
2217
- | --- | --- | --- | --- | --- |
2218
- | range | - | Yes | - | - |
2219
- | options | Object | No | {} | - |
2220
-
2221
- ##### `ungroupRows(range, options = {})`
2222
-
2223
- **Parameters**
2224
- | Name | Type | Required | Default | Description |
2225
- | --- | --- | --- | --- | --- |
2226
- | range | - | Yes | - | - |
2227
- | options | Object | No | {} | - |
2228
-
2229
- ##### `unMergeCells(cellAd = null)`
2230
- - 解除合并,传入单元格地址或区域,默认取 activeAreas
2231
-
2232
- **Parameters**
2233
- | Name | Type | Required | Default | Description |
2234
- | --- | --- | --- | --- | --- |
2235
- | cellAd | Object \| String \| null | No | null | 单元格地址或区域 |
2236
-
2237
- ##### `zoomIn(step = 0.1): number`
2238
-
2239
- **Parameters**
2240
- | Name | Type | Required | Default | Description |
2241
- | --- | --- | --- | --- | --- |
2242
- | step | number | No | 0.1 | - |
2243
-
2244
- **Returns**
2245
- - Type: `number`
2246
-
2247
- ##### `zoomOut(step = 0.1): number`
2248
-
2249
- **Parameters**
2250
- | Name | Type | Required | Default | Description |
2251
- | --- | --- | --- | --- | --- |
2252
- | step | number | No | 0.1 | - |
2253
-
2254
- **Returns**
2255
- - Type: `number`
2256
-
2257
- ##### `zoomToSelection(): number`
2258
-
2259
- **Returns**
2260
- - Type: `number`
2261
- - Zoom to fit the selected area.
2262
-
2263
- ## Slicer/Slicer.js
2264
-
2265
- ### Slicer
2266
- - 切片器管理器<br>负责切片器的增删改查
2267
-
2268
- #### Constructor
2269
- **Parameters**
2270
- | Name | Type | Required | Default | Description |
2271
- | --- | --- | --- | --- | --- |
2272
- | sheet | Sheet | Yes | - | - |
2273
-
2274
- #### Props
2275
- | Name | Type | Static | Default | Description |
2276
- | --- | --- | --- | --- | --- |
2277
- | map | Map<string, SlicerItem> | No | new Map() | - |
2278
- | sheet | Sheet | No | sheet | - |
2279
-
2280
- #### Get
2281
- | Name | Type | Static | Description |
2282
- | --- | --- | --- | --- |
2283
- | size | number | No | - |
2284
-
2285
- #### Methods
2286
- ##### `add(config): Slicer`
2287
- - 添加切片器
2288
-
2289
- **Parameters**
2290
- | Name | Type | Required | Default | Description |
2291
- | --- | --- | --- | --- | --- |
2292
- | config | Object | Yes | - | 配置对象 |
2293
-
2294
- **Returns**
2295
- - Type: `Slicer`
2296
-
2297
- ##### `forEach(callback)`
2298
- - 遍历所有切片器
2299
-
2300
- **Parameters**
2301
- | Name | Type | Required | Default | Description |
2302
- | --- | --- | --- | --- | --- |
2303
- | callback | Function | Yes | - | - |
2304
-
2305
- ##### `get(id): Slicer | null`
2306
- - 获取切片器
2307
-
2308
- **Parameters**
2309
- | Name | Type | Required | Default | Description |
2310
- | --- | --- | --- | --- | --- |
2311
- | id | string | Yes | - | - |
2312
-
2313
- **Returns**
2314
- - Type: `Slicer | null`
2315
-
2316
- ##### `getAll(): Array<Slicer>`
2317
- - 获取所有切片器
2318
-
2319
- **Returns**
2320
- - Type: `Array<Slicer>`
2321
-
2322
- ##### `remove(id)`
2323
- - 删除切片器
2324
-
2325
- **Parameters**
2326
- | Name | Type | Required | Default | Description |
2327
- | --- | --- | --- | --- | --- |
2328
- | id | string | Yes | - | - |
2329
-
2330
- ## Sparkline/Sparkline.js
2331
-
2332
- ### Sparkline
2333
- - 迷你图管理器
2334
-
2335
- #### Constructor
2336
- **Parameters**
2337
- | Name | Type | Required | Default | Description |
2338
- | --- | --- | --- | --- | --- |
2339
- | sheet | Sheet | Yes | - | 所属工作表 |
2340
-
2341
- #### Props
2342
- | Name | Type | Static | Default | Description |
2343
- | --- | --- | --- | --- | --- |
2344
- | groups | Array<Object> | No | [] | 迷你图组列表 |
2345
- | map | Map<string, SparklineItem> | No | new Map() | 按位置索引的迷你图 Map: "R:C" -> SparklineItem |
2346
- | sheet | Sheet | No | sheet | 所属工作表 |
2347
-
2348
- #### Methods
2349
- ##### `add(config): SparklineItem | null`
2350
- - 添加迷你图
2351
-
2352
- **Parameters**
2353
- | Name | Type | Required | Default | Description |
2354
- | --- | --- | --- | --- | --- |
2355
- | config | Object | Yes | - | 配置对象 |
2356
- | config.cellRef | string \| Object | Yes | - | 单元格引用 "A1" 或 {r, c} |
2357
- | config.formula | string | Yes | - | 数据范围公式 |
2358
- | config.type | string | No | 'line' | 迷你图类型 |
2359
- | config.colors | Object | No | {} | 颜色配置 |
2360
-
2361
- **Returns**
2362
- - Type: `SparklineItem | null`
2363
-
2364
- ##### `clearAllCache()`
2365
- - 清除所有缓存
2366
-
2367
- ##### `clearCache(cellRefOrRow, c?)`
2368
- - 清除指定迷你图的缓存
2369
-
2370
- **Parameters**
2371
- | Name | Type | Required | Default | Description |
2372
- | --- | --- | --- | --- | --- |
2373
- | cellRefOrRow | string \| Object \| number | Yes | - | 单元格引用 "A1"/{r,c} 或行索引 |
2374
- | c | number | No | - | 列索引(仅在第一个参数为行索引时使用) |
2375
-
2376
- ##### `get(cellRef): SparklineItem | null`
2377
- - 根据单元格位置获取迷你图
2378
-
2379
- **Parameters**
2380
- | Name | Type | Required | Default | Description |
2381
- | --- | --- | --- | --- | --- |
2382
- | cellRef | string \| Object | Yes | - | 单元格引用 "A1" 或 {r, c} |
2383
-
2384
- **Returns**
2385
- - Type: `SparklineItem | null`
2386
-
2387
- ##### `getAll(): Array<SparklineItem>`
2388
- - 获取所有迷你图实例
2389
-
2390
- **Returns**
2391
- - Type: `Array<SparklineItem>`
2392
-
2393
- ##### `parse(xmlObj)`
2394
- - 从 xmlObj 解析迷你图数据
2395
-
2396
- **Parameters**
2397
- | Name | Type | Required | Default | Description |
2398
- | --- | --- | --- | --- | --- |
2399
- | xmlObj | Object | Yes | - | Sheet 的 XML 对象 |
2400
-
2401
- ##### `remove(cellRef): boolean`
2402
- - 删除迷你图
2403
-
2404
- **Parameters**
2405
- | Name | Type | Required | Default | Description |
2406
- | --- | --- | --- | --- | --- |
2407
- | cellRef | string \| Object | Yes | - | 单元格引用 "A1" 或 {r, c} |
2408
-
2409
- **Returns**
2410
- - Type: `boolean`
2411
-
2412
- ##### `toXmlObj(): Object | null`
2413
- - 导出为 XML 对象结构
2414
-
2415
- **Returns**
2416
- - Type: `Object | null`
2417
-
2418
- ## Table/Table.js
2419
-
2420
- ### Table
2421
-
2422
- #### Constructor
2423
- **Parameters**
2424
- | Name | Type | Required | Default | Description |
2425
- | --- | --- | --- | --- | --- |
2426
- | sheet | Sheet | Yes | - | - |
2427
-
2428
- #### Props
2429
- | Name | Type | Static | Default | Description |
2430
- | --- | --- | --- | --- | --- |
2431
- | sheet | Sheet | No | sheet | - |
2432
-
2433
- #### Get
2434
- | Name | Type | Static | Description |
2435
- | --- | --- | --- | --- |
2436
- | size | - | No | 表格数量 |
2437
-
2438
- #### Methods
2439
- ##### `add(options = {}): TableItem`
2440
- - 添加/创建新表格
2441
-
2442
- **Parameters**
2443
- | Name | Type | Required | Default | Description |
2444
- | --- | --- | --- | --- | --- |
2445
- | options | Object | No | {} | - |
2446
-
2447
- **Returns**
2448
- - Type: `TableItem`
2449
-
2450
- ##### `createFromSelection(area, options = {}): TableItem`
2451
- - 从选区创建表格
2452
-
2453
- **Parameters**
2454
- | Name | Type | Required | Default | Description |
2455
- | --- | --- | --- | --- | --- |
2456
- | area | Object | Yes | - | { s: {r, c}, e: {r, c} } |
2457
- | options | Object | No | {} | - |
2458
-
2459
- **Returns**
2460
- - Type: `TableItem`
2461
-
2462
- ##### `forEach(callback)`
2463
- - 遍历所有表格
2464
-
2465
- **Parameters**
2466
- | Name | Type | Required | Default | Description |
2467
- | --- | --- | --- | --- | --- |
2468
- | callback | Function | Yes | - | - |
2469
-
2470
- ##### `fromJSON(jsonArray)`
2471
- - 从 JSON 恢复
2472
-
2473
- **Parameters**
2474
- | Name | Type | Required | Default | Description |
2475
- | --- | --- | --- | --- | --- |
2476
- | jsonArray | Array | Yes | - | - |
2477
-
2478
- ##### `get(id): TableItem | null`
2479
- - 根据ID获取表格
2480
-
2481
- **Parameters**
2482
- | Name | Type | Required | Default | Description |
2483
- | --- | --- | --- | --- | --- |
2484
- | id | string | Yes | - | - |
2485
-
2486
- **Returns**
2487
- - Type: `TableItem | null`
2488
-
2489
- ##### `getAll(): TableItem[]`
2490
-
2491
- **Returns**
2492
- - Type: `TableItem[]`
2493
-
2494
- ##### `getByName(name): TableItem | null`
2495
- - 根据名称获取表格
2496
-
2497
- **Parameters**
2498
- | Name | Type | Required | Default | Description |
2499
- | --- | --- | --- | --- | --- |
2500
- | name | string | Yes | - | - |
2501
-
2502
- **Returns**
2503
- - Type: `TableItem | null`
2504
-
2505
- ##### `getTableAt(row, col): TableItem | null`
2506
- - 获取包含指定单元格的表格
2507
-
2508
- **Parameters**
2509
- | Name | Type | Required | Default | Description |
2510
- | --- | --- | --- | --- | --- |
2511
- | row | number | Yes | - | - |
2512
- | col | number | Yes | - | - |
2513
-
2514
- **Returns**
2515
- - Type: `TableItem | null`
2516
-
2517
- ##### `remove(id): boolean`
2518
- - 删除表格
2519
-
2520
- **Parameters**
2521
- | Name | Type | Required | Default | Description |
2522
- | --- | --- | --- | --- | --- |
2523
- | id | string | Yes | - | 表格ID |
2524
-
2525
- **Returns**
2526
- - Type: `boolean`
2527
-
2528
- ##### `removeByName(name): boolean`
2529
- - 根据名称删除表格
2530
-
2531
- **Parameters**
2532
- | Name | Type | Required | Default | Description |
2533
- | --- | --- | --- | --- | --- |
2534
- | name | string | Yes | - | - |
2535
-
2536
- **Returns**
2537
- - Type: `boolean`
2538
-
2539
- ##### `toJSON()`
2540
- - 转为 JSON 数组
2541
-
2542
- ## UndoRedo/UndoRedo.js
2543
-
2544
- ### UndoRedo
2545
-
2546
- #### Constructor
2547
- **Parameters**
2548
- | Name | Type | Required | Default | Description |
2549
- | --- | --- | --- | --- | --- |
2550
- | SN | import('../Workbook/Workbook.js').default | Yes | - | - |
2551
-
2552
- #### Props
2553
- | Name | Type | Static | Default | Description |
2554
- | --- | --- | --- | --- | --- |
2555
- | maxStack | number | No | 50 | - |
2556
-
2557
- #### Get
2558
- | Name | Type | Static | Description |
2559
- | --- | --- | --- | --- |
2560
- | canRedo | boolean | No | - |
2561
- | canUndo | boolean | No | - |
2562
-
2563
- #### Methods
2564
- ##### `add(action): void`
2565
-
2566
- **Parameters**
2567
- | Name | Type | Required | Default | Description |
2568
- | --- | --- | --- | --- | --- |
2569
- | action | {undo: Function, redo: Function, activeCell?: {r:number,c:number}} | Yes | - | - |
2570
-
2571
- **Returns**
2572
- - Add undo action into current transaction.
2573
-
2574
- ##### `begin(name = ''): void`
2575
-
2576
- **Parameters**
2577
- | Name | Type | Required | Default | Description |
2578
- | --- | --- | --- | --- | --- |
2579
- | name | string | No | '' | - |
2580
-
2581
- **Returns**
2582
- - Begin a manual undo transaction.
2583
-
2584
- ##### `clear(): void`
2585
-
2586
- **Returns**
2587
- - Clear undo/redo stacks and pending transaction.
2588
-
2589
- ##### `commit(): void`
2590
-
2591
- **Returns**
2592
- - Commit current manual transaction.
2593
-
2594
- ##### `redo(): boolean`
2595
-
2596
- **Returns**
2597
- - Type: `boolean`
2598
-
2599
- ##### `undo(): boolean`
2600
-
2601
- **Returns**
2602
- - Type: `boolean`
2603
-
2604
- ## Utils/Utils.js
2605
-
2606
- ### Utils
2607
-
2608
- #### Constructor
2609
- **Parameters**
2610
- | Name | Type | Required | Default | Description |
2611
- | --- | --- | --- | --- | --- |
2612
- | SN | SheetNext | Yes | - | - |
2613
-
2614
- #### Methods
2615
- ##### `cellNumToStr(cellNum): string`
2616
-
2617
- **Parameters**
2618
- | Name | Type | Required | Default | Description |
2619
- | --- | --- | --- | --- | --- |
2620
- | cellNum | {c:number,r:number} | Yes | - | - |
2621
-
2622
- **Returns**
2623
- - Type: `string`
2624
-
2625
- ##### `cellStrToNum(cellStr): {c:number,r:number} | undefined`
2626
-
2627
- **Parameters**
2628
- | Name | Type | Required | Default | Description |
2629
- | --- | --- | --- | --- | --- |
2630
- | cellStr | string | Yes | - | - |
2631
-
2632
- **Returns**
2633
- - Type: `{c:number,r:number} | undefined`
2634
-
2635
- ##### `charToNum(name): number`
2636
-
2637
- **Parameters**
2638
- | Name | Type | Required | Default | Description |
2639
- | --- | --- | --- | --- | --- |
2640
- | name | string | Yes | - | - |
2641
-
2642
- **Returns**
2643
- - Type: `number`
2644
-
2645
- ##### `debounce(func, wait): Function`
2646
-
2647
- **Parameters**
2648
- | Name | Type | Required | Default | Description |
2649
- | --- | --- | --- | --- | --- |
2650
- | func | Function | Yes | - | - |
2651
- | wait | number | Yes | - | - |
2652
-
2653
- **Returns**
2654
- - Type: `Function`
2655
- - Create a debounced function.
2656
-
2657
- ##### `decodeEntities(encodedString): string`
2658
-
2659
- **Parameters**
2660
- | Name | Type | Required | Default | Description |
2661
- | --- | --- | --- | --- | --- |
2662
- | encodedString | string | Yes | - | - |
2663
-
2664
- **Returns**
2665
- - Type: `string`
2666
- - Decode HTML entities to plain text.
2667
-
2668
- ##### `async downloadImageToBase64(imageUrl): Promise<string | undefined>`
2669
-
2670
- **Parameters**
2671
- | Name | Type | Required | Default | Description |
2672
- | --- | --- | --- | --- | --- |
2673
- | imageUrl | string | Yes | - | - |
2674
-
2675
- **Returns**
2676
- - Type: `Promise<string | undefined>`
2677
- - Fetch image URL and return base64 data URL.
2678
-
2679
- ##### `emuToPx(emu): number`
2680
-
2681
- **Parameters**
2682
- | Name | Type | Required | Default | Description |
2683
- | --- | --- | --- | --- | --- |
2684
- | emu | number | Yes | - | - |
2685
-
2686
- **Returns**
2687
- - Type: `number`
2688
- - Convert EMU to pixels.
2689
-
2690
- ##### `getFillFormula(formula, originalRow, originalCol, targetRow, targetCol): string`
2691
-
2692
- **Parameters**
2693
- | Name | Type | Required | Default | Description |
2694
- | --- | --- | --- | --- | --- |
2695
- | formula | string | Yes | - | - |
2696
- | originalRow | number | Yes | - | - |
2697
- | originalCol | number | Yes | - | - |
2698
- | targetRow | number | Yes | - | - |
2699
- | targetCol | number | Yes | - | - |
2700
-
2701
- **Returns**
2702
- - Type: `string`
2703
- - Build fill formula by shifting relative refs only.
2704
-
2705
- ##### `modal(options = {}): Promise<{bodyEl: HTMLElement} | null>`
2706
-
2707
- **Parameters**
2708
- | Name | Type | Required | Default | Description |
2709
- | --- | --- | --- | --- | --- |
2710
- | options | Object | No | {} | - |
2711
-
2712
- **Returns**
2713
- - Type: `Promise<{bodyEl: HTMLElement} | null>`
2714
- - Open common modal panel.
2715
-
2716
- ##### `numToChar(num): string`
2717
-
2718
- **Parameters**
2719
- | Name | Type | Required | Default | Description |
2720
- | --- | --- | --- | --- | --- |
2721
- | num | number | Yes | - | - |
2722
-
2723
- **Returns**
2724
- - Type: `string`
2725
-
2726
- ##### `objToArr(obj): Array<any>`
2727
-
2728
- **Parameters**
2729
- | Name | Type | Required | Default | Description |
2730
- | --- | --- | --- | --- | --- |
2731
- | obj | any | Yes | - | - |
2732
-
2733
- **Returns**
2734
- - Type: `Array<any>`
2735
- - Normalize any value to array.
2736
-
2737
- ##### `pxToEmu(px): number`
2738
-
2739
- **Parameters**
2740
- | Name | Type | Required | Default | Description |
2741
- | --- | --- | --- | --- | --- |
2742
- | px | number | Yes | - | - |
2743
-
2744
- **Returns**
2745
- - Type: `number`
2746
- - Convert pixels to EMU.
2747
-
2748
- ##### `rangeNumToStr(obj, absolute = false): string`
2749
-
2750
- **Parameters**
2751
- | Name | Type | Required | Default | Description |
2752
- | --- | --- | --- | --- | --- |
2753
- | obj | {s:{r:number,c:number},e:{r:number,c:number}} | Yes | - | - |
2754
- | absolute | boolean | No | false | - |
2755
-
2756
- **Returns**
2757
- - Type: `string`
2758
-
2759
- ##### `rgbToHex(rgb): string`
2760
-
2761
- **Parameters**
2762
- | Name | Type | Required | Default | Description |
2763
- | --- | --- | --- | --- | --- |
2764
- | rgb | string | Yes | - | - |
2765
-
2766
- **Returns**
2767
- - Type: `string`
2768
- - Convert rgb() string to hex color.
2769
-
2770
- ##### `sortObjectInPlace(obj, keyOrder): void`
2771
-
2772
- **Parameters**
2773
- | Name | Type | Required | Default | Description |
2774
- | --- | --- | --- | --- | --- |
2775
- | obj | Object | Yes | - | - |
2776
- | keyOrder | Array<string> | Yes | - | - |
2777
-
2778
- **Returns**
2779
- - Reorder object keys in-place.
2780
-
2781
- ##### `toast(message): void`
2782
-
2783
- **Parameters**
2784
- | Name | Type | Required | Default | Description |
2785
- | --- | --- | --- | --- | --- |
2786
- | message | any | Yes | - | - |
2787
-
2788
- **Returns**
2789
- - Show toast message.
2790
-
2791
- ## Workbook/Workbook.js
2792
-
2793
- ### SheetNext
2794
-
2795
- #### Constructor
2796
- - Create workbook instance.
2797
-
2798
- **Parameters**
2799
- | Name | Type | Required | Default | Description |
2800
- | --- | --- | --- | --- | --- |
2801
- | dom | HTMLElement | Yes | - | Editor container element. |
2802
- | options | SheetNextInitOptions | No | {} | Initialization options. |
2803
- | options.licenseKey | string | No | - | License key. |
2804
- | options.locale | string | No | 'en-US' | Initial locale (e.g. 'en-US', 'zh-CN'). |
2805
- | options.locales | Object<string, Object> | No | - | Extra locale packs keyed by locale code. |
2806
- | options.menuRight | function | No | - | Callback `(defaultHTML: string) => string`. Receives the default right-menu HTML, return modified HTML. |
2807
- | options.menuList | function | No | - | Callback `(config: Array<{key: string, labelKey: string, groups: Array, contextual?: boolean}>) => Array`. Receives the default toolbar panel config array, return modified array. |
2808
- | options.AI_URL | string | No | - | AI relay endpoint URL. |
2809
- | options.AI_TOKEN | string | No | - | Optional bearer token for AI relay endpoint. |
2810
-
2811
- #### Props
2812
- | Name | Type | Static | Default | Description |
2813
- | --- | --- | --- | --- | --- |
2814
- | Action | Action | No | new Action(this) | - |
2815
- | AI | AI | No | new AI(this, options) | - |
2816
- | calcMode | 'auto' \| 'manual' | No | 'auto' | - |
2817
- | Canvas | Canvas | No | new Canvas(this) | - |
2818
- | containerDom | - | No | dom | - |
2819
- | DependencyGraph | DependencyGraph | No | new DependencyGraph(this) | - |
2820
- | Event | EventEmitter | No | new EventEmitter() | - |
2821
- | Formula | Formula | No | new Formula(this) | - |
2822
- | I18n | - | No | this._createI18n(options) | - |
2823
- | IO | IO | No | new IO(this) | - |
2824
- | Layout | Layout | No | new Layout(this, options) | - |
2825
- | License | License | No | new License(this, options.licenseKey) | - |
2826
- | namespace | string | No | this._setupGlobalNamespace() | - |
2827
- | Print | Print | No | new Print(this) | - |
2828
- | properties | Object | No | {} | - |
2829
- | sheets | Sheet[] | No | [] | - |
2830
- | UndoRedo | UndoRedo | No | new UndoRedo(this) | - |
2831
- | Utils | Utils | No | new Utils(this) | - |
2832
- | Xml | Xml | No | new Xml(this) | - |
2833
-
2834
- #### Get/Set
2835
- | Name | Type | Mode | Static | Description |
2836
- | --- | --- | --- | --- | --- |
2837
- | activeSheet | Sheet | get/set | No | - |
2838
- | readOnly | boolean | get/set | No | - |
2839
- | workbookName | string | get/set | No | - |
2840
-
2841
- #### Get
2842
- | Name | Type | Static | Description |
2843
- | --- | --- | --- | --- |
2844
- | locale | string | No | - |
2845
-
2846
- #### Methods
2847
- ##### `addSheet(sheetName?): Sheet | null`
2848
-
2849
- **Parameters**
2850
- | Name | Type | Required | Default | Description |
2851
- | --- | --- | --- | --- | --- |
2852
- | sheetName | string | No | - | - |
2853
-
2854
- **Returns**
2855
- - Type: `Sheet | null`
2856
-
2857
- ##### `delSheet(name)`
2858
-
2859
- **Parameters**
2860
- | Name | Type | Required | Default | Description |
2861
- | --- | --- | --- | --- | --- |
2862
- | name | string | Yes | - | - |
2863
-
2864
- ##### `static getLocale(locale): Object | undefined`
2865
-
2866
- **Parameters**
2867
- | Name | Type | Required | Default | Description |
2868
- | --- | --- | --- | --- | --- |
2869
- | locale | string | Yes | - | - |
2870
-
2871
- **Returns**
2872
- - Type: `Object | undefined`
2873
-
2874
- ##### `getSheet(sheetName): Sheet | null`
2875
-
2876
- **Parameters**
2877
- | Name | Type | Required | Default | Description |
2878
- | --- | --- | --- | --- | --- |
2879
- | sheetName | string | Yes | - | - |
2880
-
2881
- **Returns**
2882
- - Type: `Sheet | null`
2883
-
2884
- ##### `recalculate(currentSheetOnly = false)`
2885
-
2886
- **Parameters**
2887
- | Name | Type | Required | Default | Description |
2888
- | --- | --- | --- | --- | --- |
2889
- | currentSheetOnly | boolean | No | false | - |
2890
-
2891
- ##### `static registerLocale(locale, messages): typeof SheetNext`
2892
-
2893
- **Parameters**
2894
- | Name | Type | Required | Default | Description |
2895
- | --- | --- | --- | --- | --- |
2896
- | locale | string | Yes | - | - |
2897
- | messages | Object | Yes | - | - |
2898
-
2899
- **Returns**
2900
- - Type: `typeof SheetNext`
2901
-
2902
- ##### `setLocale(locale)`
2903
-
2904
- **Parameters**
2905
- | Name | Type | Required | Default | Description |
2906
- | --- | --- | --- | --- | --- |
2907
- | locale | string | Yes | - | - |
2908
-
2909
- ##### `t(key, params = {}): string`
2910
-
2911
- **Parameters**
2912
- | Name | Type | Required | Default | Description |
2913
- | --- | --- | --- | --- | --- |
2914
- | key | string | Yes | - | - |
2915
- | params | Record<string, any> | No | {} | - |
2916
-
2917
- **Returns**
2918
- - Type: `string`
2919
-
2920
- ## Xml/Xml.js
2921
-
2922
- ### Xml
2923
- - Xml 解析与构建器
2924
-
2925
- #### Constructor
2926
- **Parameters**
2927
- | Name | Type | Required | Default | Description |
2928
- | --- | --- | --- | --- | --- |
2929
- | SN | Object | Yes | - | SheetNext 主实例 |
2930
- | obj | Object | No | - | XML 对象 |
2931
-
2932
- #### Props
2933
- | Name | Type | Static | Default | Description |
2934
- | --- | --- | --- | --- | --- |
2935
- | obj | Object | No | obj ?? JSON.parse(JSON.stringify(snXml)) | XML 对象 |
2936
- | objTp | Object | No | snXml | XML 模板 |
2937
- | sharedStringsObj | Object | No | {} // 共享字符串去重对象清空 | 共享字符串去重对象 |
2938
- | SN | Object | No | SN | SheetNext 主实例 |
2939
- | Utils | Utils | No | SN.Utils | 工具方法集合 |
2940
-
2941
- #### Get
2942
- | Name | Type | Static | Description |
2943
- | --- | --- | --- | --- |
2944
- | clrScheme | Object | No | 当前文件主题配色 |
2945
- | clrSchemeTp | Object | No | 主题模板配色 |
2946
- | override | Array | No | 覆盖关系 |
2947
- | relationship | Array | No | 关系集合 |
2948
- | sheets | Array | No | 所有工作表信息 |
2949
- | sst | Object | No | 共享字符串表 |
2950
- | styleSheet | Object | No | 样式表 |
2951
-
2952
- #### Methods
2953
- ##### `addSheet(sheetName, ops): void`
2954
- - 添加工作表
2955
-
2956
- **Parameters**
2957
- | Name | Type | Required | Default | Description |
2958
- | --- | --- | --- | --- | --- |
2959
- | sheetName | string | Yes | - | 工作表名称 |
2960
- | ops | Object | Yes | - | 初始化参数 |
2961
-
2962
- ##### `getRelsByTarget(targetPath, create = false): Object`
2963
- - 根据关系 target 路径获取 .rels 中的关系数组
2964
-
2965
- **Parameters**
2966
- | Name | Type | Required | Default | Description |
2967
- | --- | --- | --- | --- | --- |
2968
- | targetPath | string | Yes | - | 目标路径 |
2969
- | create | boolean | No | false | 是否在不存在时创建 |
2970
-
2971
- **Returns**
2972
- - Type: `Object`
2973
-
2974
- ##### `getWsRelsFileTarget(sheetRId, fileRId): string | null`
2975
- - 根据工作表依赖文件中的 RId 获取目标路径
2976
-
2977
- **Parameters**
2978
- | Name | Type | Required | Default | Description |
2979
- | --- | --- | --- | --- | --- |
2980
- | sheetRId | string | Yes | - | 工作表 RId |
2981
- | fileRId | string | Yes | - | 依赖文件 RId |
2982
-
2983
- **Returns**
2984
- - Type: `string | null`
2985
-
2986
- ##### `resetStyle(): void`
2987
- - 重置样式表
2988
-
2989
- ##### `resolveHyperlinkById(rId): Object | null`
2990
- - 根据 RId 解析超链接
2991
-
2992
- **Parameters**
2993
- | Name | Type | Required | Default | Description |
2994
- | --- | --- | --- | --- | --- |
2995
- | rId | string | Yes | - | 关系 Id |
2996
-
2997
- **Returns**
2998
- - Type: `Object | null`