@canvas-components/xlsx-table 0.0.0-stage → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2157 @@
1
+ import { ExportTableColumn } from '@canvas-components/utils';
2
+
3
+ /**
4
+ * 单元格地址,内部 0 基索引。
5
+ */
6
+ interface XlsxCellAddress {
7
+ rowIndex: number;
8
+ columnIndex: number;
9
+ }
10
+ /**
11
+ * 矩形选区,内部 0 基索引。
12
+ */
13
+ interface XlsxCellRange {
14
+ startRowIndex: number;
15
+ startColumnIndex: number;
16
+ endRowIndex: number;
17
+ endColumnIndex: number;
18
+ }
19
+ /**
20
+ * 列名工具:0 -> A, 25 -> Z, 26 -> AA。
21
+ */
22
+ declare function columnIndexToName(columnIndex: number): string;
23
+ /**
24
+ * 列名转索引:A -> 0, Z -> 25, AA -> 26。
25
+ */
26
+ declare function columnNameToIndex(name: string): number;
27
+ /**
28
+ * 生成内部 cell key。
29
+ */
30
+ declare function getCellKey(rowIndex: number, columnIndex: number): string;
31
+ /**
32
+ * 解析 cell key。
33
+ */
34
+ declare function parseCellKey(key: string): XlsxCellAddress | null;
35
+ /**
36
+ * 地址转 A1 文本。
37
+ */
38
+ declare function addressToA1(address: XlsxCellAddress): string;
39
+ /**
40
+ * 归一化矩形选区。
41
+ */
42
+ declare function normalizeRange(range: XlsxCellRange): XlsxCellRange;
43
+
44
+ type XlsxCellValue = string | number | boolean | Date | null;
45
+ type XlsxCellType = "text" | "number" | "money" | "percent" | "date" | "datetime" | "boolean";
46
+ type XlsxCellBorderLineStyle = "solid" | "dashed" | "dotted";
47
+ interface XlsxCellBorderLine {
48
+ color: string;
49
+ width: number;
50
+ style: XlsxCellBorderLineStyle;
51
+ }
52
+ interface XlsxCellBorders {
53
+ top?: XlsxCellBorderLine;
54
+ right?: XlsxCellBorderLine;
55
+ bottom?: XlsxCellBorderLine;
56
+ left?: XlsxCellBorderLine;
57
+ diagonalDown?: XlsxCellBorderLine;
58
+ }
59
+ type XlsxCellBorderPreset = "all" | "outer" | "inner" | "horizontal" | "vertical" | "left" | "right" | "top" | "bottom" | "diagonal-down" | "none";
60
+ interface XlsxCellStyle {
61
+ backgroundColor?: string;
62
+ color?: string;
63
+ fontFamily?: string;
64
+ fontSize?: number;
65
+ fontWeight?: string;
66
+ fontStyle?: "normal" | "italic";
67
+ textDecoration?: "underline" | "line-through";
68
+ textAlign?: CanvasTextAlign;
69
+ verticalAlign?: "top" | "middle" | "bottom";
70
+ border?: XlsxCellBorders;
71
+ }
72
+ interface XlsxCell {
73
+ value?: XlsxCellValue;
74
+ formula?: string;
75
+ displayValue?: string;
76
+ type?: XlsxCellType;
77
+ style?: XlsxCellStyle;
78
+ meta?: Record<string, unknown>;
79
+ }
80
+ interface XlsxRowConfig {
81
+ height?: number;
82
+ hidden?: boolean;
83
+ filtered?: boolean;
84
+ }
85
+ interface XlsxColumnConfig {
86
+ width?: number;
87
+ hidden?: boolean;
88
+ }
89
+ interface XlsxFrozenPane {
90
+ rows?: number;
91
+ columns?: number;
92
+ }
93
+ type XlsxSortDirection = "asc" | "desc";
94
+ interface XlsxSheetSortState {
95
+ columnIndex: number;
96
+ direction: XlsxSortDirection;
97
+ /** 当前排序范围的起始行。 */
98
+ startRowIndex?: number;
99
+ /** 当前排序范围的结束行。 */
100
+ endRowIndex?: number;
101
+ /** 当前各行在排序前对应的原始行索引。 */
102
+ originalRowIndexes?: number[];
103
+ }
104
+ type XlsxFilterValue = string | number | boolean | null;
105
+ type XlsxFilterConditionOperator = "none" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "between" | "notBetween" | "startsWith" | "notStartsWith" | "endsWith" | "notEndsWith" | "includes" | "notIncludes" | "blank" | "notBlank";
106
+ type XlsxFilterConditionRelation = "and" | "or";
107
+ interface XlsxFilterCondition {
108
+ operator: XlsxFilterConditionOperator;
109
+ value?: string;
110
+ secondValue?: string;
111
+ }
112
+ interface XlsxColumnFilterState {
113
+ columnIndex: number;
114
+ values: XlsxFilterValue[];
115
+ includeBlank?: boolean;
116
+ includeNonBlank?: boolean;
117
+ condition?: XlsxFilterCondition;
118
+ secondCondition?: XlsxFilterCondition;
119
+ conditionRelation?: XlsxFilterConditionRelation;
120
+ }
121
+ interface XlsxSheetFilterState {
122
+ columns: Record<number, XlsxColumnFilterState>;
123
+ }
124
+ interface XlsxMergedRange extends XlsxCellRange {
125
+ }
126
+ interface XlsxSheet {
127
+ id: string;
128
+ name: string;
129
+ rowCount: number;
130
+ columnCount: number;
131
+ rows?: Record<number, XlsxRowConfig>;
132
+ columns?: Record<number, XlsxColumnConfig>;
133
+ cells?: Record<string, XlsxCell>;
134
+ frozen?: XlsxFrozenPane;
135
+ sort?: XlsxSheetSortState;
136
+ filter?: XlsxSheetFilterState;
137
+ merges?: XlsxMergedRange[];
138
+ }
139
+ /**
140
+ * workbook 级命名区域。
141
+ */
142
+ interface XlsxNamedRange {
143
+ /** 名称:字母/下划线开头;大小写不敏感唯一。 */
144
+ name: string;
145
+ /** 锚定 sheet。 */
146
+ sheetId: string;
147
+ /** 单格或矩形区域。 */
148
+ range: XlsxCellRange;
149
+ comment?: string;
150
+ }
151
+ interface XlsxWorkbook {
152
+ id?: string;
153
+ version?: number;
154
+ sheets: XlsxSheet[];
155
+ activeSheetId?: string;
156
+ meta?: Record<string, unknown>;
157
+ /** workbook 级命名区域。 */
158
+ namedRanges?: XlsxNamedRange[];
159
+ }
160
+ interface XlsxCollaborator {
161
+ id: string;
162
+ name?: string;
163
+ color?: string;
164
+ avatar?: string;
165
+ }
166
+ interface XlsxRemoteSelection {
167
+ user: XlsxCollaborator;
168
+ sheetId: string;
169
+ activeCell: XlsxCellAddress | null;
170
+ ranges: XlsxCellRange[];
171
+ updatedAt: number;
172
+ }
173
+
174
+ /**
175
+ * xlsx-table 主题。
176
+ */
177
+ interface XlsxTableTheme {
178
+ backgroundColor: string;
179
+ borderColor: string;
180
+ textColor: string;
181
+ mutedTextColor: string;
182
+ headerBackgroundColor: string;
183
+ headerTextColor: string;
184
+ gridLineColor: string;
185
+ hoverBackgroundColor: string;
186
+ selectionBackgroundColor: string;
187
+ selectionBorderColor: string;
188
+ activeBorderColor: string;
189
+ /** 冻结行列分隔线颜色。 */
190
+ freezeLineColor: string;
191
+ emptyBackgroundColor: string;
192
+ emptyTextColor: string;
193
+ fontFamily: string;
194
+ fontSize: number;
195
+ headerFontWeight: string;
196
+ }
197
+ declare const defaultXlsxTableTheme: XlsxTableTheme;
198
+ declare function resolveXlsxTableTheme(theme?: Partial<XlsxTableTheme>): XlsxTableTheme;
199
+
200
+ /**
201
+ * 编辑器在视口/宿主中的矩形。
202
+ */
203
+ interface XlsxEditorRect {
204
+ x: number;
205
+ y: number;
206
+ width: number;
207
+ height: number;
208
+ }
209
+ /**
210
+ * 编辑导航方向。
211
+ */
212
+ type XlsxEditorNavigateDirection = "up" | "down" | "left" | "right";
213
+ /**
214
+ * 编辑会话主题(供 React overlay 对齐 canvas)。
215
+ */
216
+ interface XlsxEditorTheme {
217
+ fontSize: number;
218
+ fontFamily: string;
219
+ verticalAlign: "top" | "middle" | "bottom";
220
+ textColor: string;
221
+ backgroundColor: string;
222
+ borderColor: string;
223
+ paddingInline: number;
224
+ paddingBlock: number;
225
+ }
226
+ /**
227
+ * 核心向宿主层请求的编辑会话。
228
+ */
229
+ interface XlsxEditorRequest {
230
+ address: XlsxCellAddress;
231
+ sheetId: string;
232
+ /** 相对 canvas 宿主的矩形。 */
233
+ hostRect: XlsxEditorRect;
234
+ /** 视口裁剪矩形(body 区域)。 */
235
+ clipRect: XlsxEditorRect;
236
+ /** 编辑浮层挂载宿主,通常为 canvasHost。 */
237
+ hostElement?: HTMLElement;
238
+ value: XlsxCellValue | undefined;
239
+ displayText: string;
240
+ formula?: string;
241
+ cellType?: XlsxCellType;
242
+ mode: "edit" | "replace";
243
+ theme: XlsxEditorTheme;
244
+ onChange: (value: XlsxCellValue | undefined, displayText?: string) => void;
245
+ onCommit: () => void;
246
+ onCancel: () => void;
247
+ onNavigate?: (direction: XlsxEditorNavigateDirection) => void;
248
+ }
249
+ /**
250
+ * 公式栏状态。
251
+ */
252
+ interface XlsxFormulaBarState {
253
+ addressLabel: string;
254
+ valueText: string;
255
+ formula?: string;
256
+ disabled: boolean;
257
+ editing: boolean;
258
+ }
259
+ /**
260
+ * 编辑中的草稿单元格。
261
+ */
262
+ interface XlsxEditingDraft {
263
+ address: XlsxCellAddress;
264
+ sheetId: string;
265
+ originalCell?: XlsxCell;
266
+ nextValue: XlsxCellValue | undefined;
267
+ nextDisplayText: string;
268
+ nextFormula?: string;
269
+ mode: "edit" | "replace";
270
+ }
271
+
272
+ /**
273
+ * 本地/协同统一的变更 patch。
274
+ */
275
+ interface XlsxPatch {
276
+ id: string;
277
+ type: "set-range" | "set-cell" | "resize-column" | "resize-row" | "set-row-config" | "set-column-config" | "set-sheet-config";
278
+ sheetId: string;
279
+ baseVersion: number;
280
+ authorId?: string;
281
+ createdAt: number;
282
+ /**
283
+ * 变更前单元格快照;key 为 r{row}c{col},值为 undefined 表示原本无单元格。
284
+ */
285
+ beforeCells: Record<string, XlsxCell | undefined>;
286
+ /**
287
+ * 变更后单元格快照。
288
+ */
289
+ afterCells: Record<string, XlsxCell | undefined>;
290
+ beforeSheetSize?: {
291
+ rowCount: number;
292
+ columnCount: number;
293
+ };
294
+ afterSheetSize?: {
295
+ rowCount: number;
296
+ columnCount: number;
297
+ };
298
+ /** set-row-config 使用的变更前行配置。 */
299
+ beforeRows?: Record<number, XlsxRowConfig | undefined>;
300
+ /** set-row-config 使用的变更后行配置。 */
301
+ afterRows?: Record<number, XlsxRowConfig | undefined>;
302
+ /** set-column-config 使用的变更前列配置。 */
303
+ beforeColumns?: Record<number, XlsxColumnConfig | undefined>;
304
+ /** set-column-config 使用的变更后列配置。 */
305
+ afterColumns?: Record<number, XlsxColumnConfig | undefined>;
306
+ /** set-sheet-config 使用的变更前 sheet 配置。 */
307
+ beforeSheetConfig?: {
308
+ filter?: XlsxSheetFilterState;
309
+ frozen?: XlsxFrozenPane;
310
+ merges?: XlsxMergedRange[];
311
+ sort?: XlsxSheetSortState;
312
+ };
313
+ /** set-sheet-config 使用的变更后 sheet 配置。 */
314
+ afterSheetConfig?: {
315
+ filter?: XlsxSheetFilterState;
316
+ frozen?: XlsxFrozenPane;
317
+ merges?: XlsxMergedRange[];
318
+ sort?: XlsxSheetSortState;
319
+ };
320
+ /** resize-column / resize-row 使用的目标索引。 */
321
+ resizeIndex?: number;
322
+ beforeSize?: number | null;
323
+ afterSize?: number | null;
324
+ }
325
+ /**
326
+ * history 栈状态。
327
+ */
328
+ interface XlsxHistoryState {
329
+ canUndo: boolean;
330
+ canRedo: boolean;
331
+ undoCount: number;
332
+ redoCount: number;
333
+ }
334
+
335
+ /**
336
+ * 协同冲突描述。
337
+ */
338
+ interface XlsxPatchConflict {
339
+ local: XlsxPatch;
340
+ remote: XlsxPatch;
341
+ keys: string[];
342
+ }
343
+ /**
344
+ * 协同 adapter:核心不绑定具体传输层。
345
+ */
346
+ interface XlsxCollaborationAdapter {
347
+ /** 发送本地已确认写入的 patches。 */
348
+ sendPatches?: (patches: XlsxPatch[]) => void;
349
+ /** 发送本地 presence(选区/光标)。 */
350
+ sendPresence?: (selection: XlsxRemoteSelection) => void;
351
+ /**
352
+ * 订阅远端 patches。
353
+ * @returns 取消订阅函数
354
+ */
355
+ onRemotePatches?: (listener: (patches: XlsxPatch[]) => void) => () => void;
356
+ /**
357
+ * 订阅远端 presence。
358
+ * @returns 取消订阅函数
359
+ */
360
+ onRemotePresence?: (listener: (selection: XlsxRemoteSelection) => void) => () => void;
361
+ /** 适配器销毁。 */
362
+ destroy?: () => void;
363
+ }
364
+ /**
365
+ * 协同配置。
366
+ */
367
+ interface XlsxCollaborationOptions {
368
+ /** 当前用户。开启协同时建议提供。 */
369
+ self?: XlsxCollaborator;
370
+ /** 传输适配器。 */
371
+ adapter?: XlsxCollaborationAdapter;
372
+ /** presence 过期时间(毫秒)。@default 30000 */
373
+ presenceTtlMs?: number;
374
+ /**
375
+ * 冲突策略。
376
+ * @default "remote" last-write-wins 偏向远端
377
+ */
378
+ onConflict?: (conflict: XlsxPatchConflict) => "remote" | "local" | XlsxPatch[];
379
+ /** 远端 patches 应用后的业务回调。 */
380
+ onRemotePatches?: (patches: XlsxPatch[]) => void;
381
+ /** presence 变化回调。 */
382
+ onPresenceChange?: (selections: Record<string, XlsxRemoteSelection>) => void;
383
+ /** 本地产生 patches 后的回调(可用于调试/旁路同步)。 */
384
+ onLocalPatches?: (patches: XlsxPatch[]) => void;
385
+ }
386
+ /**
387
+ * 协作者默认颜色板。
388
+ */
389
+ declare const DEFAULT_COLLABORATOR_COLORS: readonly ["#e11d48", "#ea580c", "#ca8a04", "#16a34a", "#0891b2", "#2563eb", "#7c3aed", "#db2777"];
390
+ /**
391
+ * 为用户分配稳定颜色。
392
+ */
393
+ declare function resolveCollaboratorColor(userId: string, preferred?: string): string;
394
+
395
+ interface XlsxSelectionState {
396
+ activeCell: XlsxCellAddress | null;
397
+ anchorCell: XlsxCellAddress | null;
398
+ ranges: XlsxCellRange[];
399
+ }
400
+ type XlsxHeaderActionType = "filter" | "fixed" | "sort";
401
+ type XlsxContextMenuTarget = {
402
+ type: "corner";
403
+ sheetId: string;
404
+ } | {
405
+ type: "row";
406
+ sheetId: string;
407
+ rowIndex: number;
408
+ range?: XlsxCellRange;
409
+ } | {
410
+ type: "column";
411
+ sheetId: string;
412
+ columnIndex: number;
413
+ range?: XlsxCellRange;
414
+ } | {
415
+ type: "column-action";
416
+ sheetId: string;
417
+ columnIndex: number;
418
+ actionType: XlsxHeaderActionType;
419
+ range?: XlsxCellRange;
420
+ } | {
421
+ type: "cell";
422
+ sheetId: string;
423
+ rowIndex: number;
424
+ columnIndex: number;
425
+ };
426
+ interface XlsxContextMenuRequest {
427
+ clientX: number;
428
+ clientY: number;
429
+ anchorRect?: {
430
+ x: number;
431
+ y: number;
432
+ width: number;
433
+ height: number;
434
+ };
435
+ target: XlsxContextMenuTarget;
436
+ }
437
+ /**
438
+ * 剪贴板相关配置。
439
+ */
440
+ interface XlsxClipboardOptions {
441
+ /**
442
+ * 粘贴超出 sheet 边界时是否自动扩展行列。
443
+ * @default false
444
+ */
445
+ expandBounds?: boolean;
446
+ }
447
+ /**
448
+ * 原生 xlsx-table 配置。
449
+ */
450
+ interface XlsxTableOptions {
451
+ workbook: XlsxWorkbook;
452
+ width?: number | string;
453
+ height?: number | string;
454
+ theme?: Partial<XlsxTableTheme>;
455
+ readonly?: boolean;
456
+ /** 默认行高。@default 28 */
457
+ rowHeight?: number;
458
+ /** 默认列宽。@default 100 */
459
+ columnWidth?: number;
460
+ /** 行头宽度。@default 48 */
461
+ rowHeaderWidth?: number;
462
+ /** 列头高度。@default 28 */
463
+ columnHeaderHeight?: number;
464
+ overscanRowCount?: number;
465
+ overscanColumnCount?: number;
466
+ /** 复制粘贴配置。 */
467
+ clipboard?: XlsxClipboardOptions;
468
+ /** 多人协同配置(可选,不绑定具体网络层)。 */
469
+ collaboration?: XlsxCollaborationOptions;
470
+ onWorkbookChange?: (workbook: XlsxWorkbook) => void;
471
+ onSelectionChange?: (state: XlsxSelectionState) => void;
472
+ /** 编辑器请求;传入 null 表示关闭。 */
473
+ onEditorRequest?: (request: XlsxEditorRequest | null) => void;
474
+ /** 公式栏状态变化。 */
475
+ onFormulaBarChange?: (state: XlsxFormulaBarState) => void;
476
+ /** 本地 patch 产生后的旁路回调。 */
477
+ onLocalPatches?: (patches: XlsxPatch[]) => void;
478
+ /** 活动 sheet 变化。 */
479
+ onActiveSheetChange?: (sheetId: string | null) => void;
480
+ /** 右键菜单请求。 */
481
+ onContextMenuRequest?: (request: XlsxContextMenuRequest | null) => void;
482
+ }
483
+
484
+ type XlsxFilterSpecialOptionValue = "__all__" | "__blank__" | "__not_blank__";
485
+ type XlsxFilterOptionValue = XlsxFilterValue | XlsxFilterSpecialOptionValue;
486
+ type XlsxFilterOptionKind = "all" | "blank" | "notBlank" | "value";
487
+ interface XlsxFilterOptionItem {
488
+ label: string;
489
+ value: XlsxFilterOptionValue;
490
+ count: number;
491
+ kind: XlsxFilterOptionKind;
492
+ }
493
+ interface XlsxFilterSelection {
494
+ values: XlsxFilterValue[];
495
+ includeBlank?: boolean;
496
+ includeNonBlank?: boolean;
497
+ }
498
+ /**
499
+ * 设置指定列的值筛选,并按当前 filter 状态重算行可见性。
500
+ */
501
+ declare function applySheetColumnValueFilter(params: {
502
+ sheet: XlsxSheet;
503
+ columnIndex: number;
504
+ values: XlsxFilterValue[];
505
+ startRowIndex?: number;
506
+ endRowIndex?: number;
507
+ }): XlsxSheet;
508
+ /**
509
+ * 按筛选候选项值设置列筛选,支持“全部/空/非空”特殊项。
510
+ */
511
+ declare function applySheetColumnOptionFilter(params: {
512
+ sheet: XlsxSheet;
513
+ columnIndex: number;
514
+ optionValues: XlsxFilterOptionValue[];
515
+ startRowIndex?: number;
516
+ endRowIndex?: number;
517
+ }): XlsxSheet;
518
+ /**
519
+ * 按条件设置列筛选。
520
+ */
521
+ declare function applySheetColumnConditionFilter(params: {
522
+ sheet: XlsxSheet;
523
+ columnIndex: number;
524
+ condition: XlsxFilterCondition;
525
+ secondCondition?: XlsxFilterCondition;
526
+ relation?: XlsxFilterConditionRelation;
527
+ startRowIndex?: number;
528
+ endRowIndex?: number;
529
+ }): XlsxSheet;
530
+ /**
531
+ * 清除指定列筛选,并重算行可见性。
532
+ */
533
+ declare function clearSheetColumnFilter(sheet: XlsxSheet, columnIndex: number): XlsxSheet;
534
+ /**
535
+ * 清除全部筛选。
536
+ */
537
+ declare function clearSheetFilters(sheet: XlsxSheet): XlsxSheet;
538
+ /**
539
+ * 按当前 sheet.filter 重新计算行筛选标记。
540
+ */
541
+ declare function reapplySheetFilters(sheet: XlsxSheet): XlsxSheet;
542
+ /**
543
+ * 采集指定列的筛选候选值。
544
+ */
545
+ declare function getSheetColumnFilterOptions(params: {
546
+ sheet: XlsxSheet;
547
+ columnIndex: number;
548
+ optionThreshold?: number;
549
+ startRowIndex?: number;
550
+ endRowIndex?: number;
551
+ }): XlsxFilterOptionItem[];
552
+ /**
553
+ * 按关键字过滤候选项;特殊项始终保留。
554
+ */
555
+ declare function searchSheetFilterOptions(params: {
556
+ options: XlsxFilterOptionItem[];
557
+ keyword?: string;
558
+ exact?: boolean;
559
+ }): XlsxFilterOptionItem[];
560
+ /**
561
+ * 将面板选中的候选项值解析为列筛选状态。
562
+ */
563
+ declare function resolveFilterSelectionFromOptionValues(optionValues: XlsxFilterOptionValue[]): XlsxFilterSelection | null;
564
+ declare function evaluateFilterCondition(value: XlsxFilterValue, condition: XlsxFilterCondition | undefined): boolean;
565
+
566
+ /**
567
+ * 按指定列对 sheet 行数据排序。
568
+ */
569
+ declare function sortSheetRowsByColumn(params: {
570
+ sheet: XlsxSheet;
571
+ columnIndex: number;
572
+ direction: XlsxSortDirection;
573
+ startRowIndex?: number;
574
+ endRowIndex?: number;
575
+ }): XlsxSheet;
576
+ /**
577
+ * 清除 sheet 排序状态,不回滚已经完成的行重排。
578
+ */
579
+ declare function clearSheetSort(sheet: XlsxSheet): XlsxSheet;
580
+
581
+ interface CreateSheetOptions {
582
+ id?: string;
583
+ name?: string;
584
+ rowCount?: number;
585
+ columnCount?: number;
586
+ }
587
+ interface DuplicateSheetOptions {
588
+ id?: string;
589
+ name?: string;
590
+ activate?: boolean;
591
+ }
592
+
593
+ interface XlsxFormulaDependencyDebugNode {
594
+ id: string;
595
+ sheetId: string;
596
+ sheetName: string;
597
+ address: XlsxCellAddress;
598
+ addressLabel: string;
599
+ formula: string;
600
+ valueText: string;
601
+ volatile: boolean;
602
+ dependencyCount: number;
603
+ dependentCount: number;
604
+ }
605
+ interface XlsxFormulaDependencyDebugEdge {
606
+ from: string;
607
+ to: string;
608
+ fromLabel: string;
609
+ toLabel: string;
610
+ kind: "cell";
611
+ }
612
+ interface XlsxFormulaDependencyDebugRangeEdge {
613
+ fromRangeLabel: string;
614
+ to: string;
615
+ toLabel: string;
616
+ sheetId: string;
617
+ sheetName: string;
618
+ range: XlsxCellRange;
619
+ kind: "range";
620
+ }
621
+ interface XlsxFormulaDependencyDebugSnapshot {
622
+ workbookVersion?: number;
623
+ formulaCount: number;
624
+ volatileCount: number;
625
+ edgeCount: number;
626
+ rangeEdgeCount: number;
627
+ nodes: XlsxFormulaDependencyDebugNode[];
628
+ edges: XlsxFormulaDependencyDebugEdge[];
629
+ rangeEdges: XlsxFormulaDependencyDebugRangeEdge[];
630
+ }
631
+
632
+ type XlsxSheetExportFormat = "xlsx" | "csv" | "txt" | "json";
633
+ interface XlsxSheetExportOptions {
634
+ fileName?: string;
635
+ includeHidden?: boolean;
636
+ }
637
+ interface XlsxSheetExportData {
638
+ rows: number[];
639
+ columns: ExportTableColumn<number>[];
640
+ }
641
+ /**
642
+ * 将工作表转换为通用表格导出数据。
643
+ */
644
+ declare function buildXlsxSheetExportData(sheet: XlsxSheet, options?: Pick<XlsxSheetExportOptions, "includeHidden">): XlsxSheetExportData;
645
+ /**
646
+ * 下载指定工作表。
647
+ */
648
+ declare function exportXlsxSheet(sheet: XlsxSheet, format: XlsxSheetExportFormat, options?: XlsxSheetExportOptions): Promise<void>;
649
+
650
+ type XlsxTableSelectionSnapshot = XlsxSelectionState;
651
+ type XlsxTableWorkbookSnapshot = XlsxWorkbook;
652
+ type XlsxTableFormulaDependencySnapshot = XlsxFormulaDependencyDebugSnapshot;
653
+ type XlsxTableFormulaBarSnapshot = XlsxFormulaBarState;
654
+ type XlsxTableHistorySnapshot = XlsxHistoryState;
655
+ type XlsxTablePresenceRecord = Record<string, XlsxRemoteSelection>;
656
+ type XlsxTableEditMode = "edit" | "replace";
657
+ type XlsxTableExportFormat = XlsxSheetExportFormat;
658
+ type XlsxTableExportOptions = XlsxSheetExportOptions;
659
+ type XlsxTableCreateSheetOptions = CreateSheetOptions & {
660
+ activate?: boolean;
661
+ };
662
+ type XlsxTableDuplicateSheetOptions = DuplicateSheetOptions;
663
+ interface XlsxTableFilterConditionParams {
664
+ columnIndex: number;
665
+ condition: XlsxFilterCondition;
666
+ secondCondition?: XlsxFilterCondition;
667
+ relation?: XlsxFilterConditionRelation;
668
+ }
669
+
670
+ /**
671
+ * XlsxTable 原生入口。
672
+ */
673
+ declare class XlsxTable {
674
+ private readonly container;
675
+ private options;
676
+ private core;
677
+ constructor(container: HTMLElement, options: XlsxTableOptions);
678
+ /**
679
+ * 挂载表格。
680
+ */
681
+ mount(): void;
682
+ /**
683
+ * 更新配置。
684
+ */
685
+ updateOptions(options: XlsxTableOptions): void;
686
+ /**
687
+ * 获取当前选区状态。
688
+ */
689
+ getSelection(): XlsxTableSelectionSnapshot;
690
+ /**
691
+ * 获取当前 workbook。
692
+ */
693
+ getWorkbook(): XlsxTableWorkbookSnapshot;
694
+ /**
695
+ * 下载当前活动工作表。
696
+ */
697
+ exportActiveSheet(format: XlsxTableExportFormat, options?: XlsxTableExportOptions): Promise<boolean>;
698
+ /**
699
+ * 获取公式依赖图调试快照。
700
+ */
701
+ getFormulaDependencyDebugSnapshot(): XlsxTableFormulaDependencySnapshot;
702
+ /**
703
+ * 获取 workbook 命名区域列表。
704
+ */
705
+ getNamedRanges(): XlsxNamedRange[];
706
+ /**
707
+ * 新增或覆盖命名区域。
708
+ */
709
+ upsertNamedRange(named: XlsxNamedRange): boolean;
710
+ /**
711
+ * 删除命名区域。
712
+ */
713
+ removeNamedRange(name: string): boolean;
714
+ /**
715
+ * 当前活动 sheet id。
716
+ */
717
+ getActiveSheetId(): string | null;
718
+ /**
719
+ * 切换活动 sheet。
720
+ */
721
+ setActiveSheet(sheetId: string): boolean;
722
+ /**
723
+ * 新增 sheet。
724
+ */
725
+ addSheet(options?: XlsxTableCreateSheetOptions): string | null;
726
+ /**
727
+ * 复制 sheet。
728
+ */
729
+ duplicateSheet(sheetId: string, options?: XlsxTableDuplicateSheetOptions): string | null;
730
+ /**
731
+ * 移动 sheet 顺序。
732
+ */
733
+ moveSheet(sheetId: string, targetIndex: number): boolean;
734
+ /**
735
+ * 重命名 sheet。
736
+ */
737
+ renameSheet(sheetId: string, name: string): boolean;
738
+ /**
739
+ * 删除 sheet。
740
+ */
741
+ removeSheet(sheetId: string): boolean;
742
+ /**
743
+ * 获取公式栏状态。
744
+ */
745
+ getFormulaBarState(): XlsxTableFormulaBarSnapshot;
746
+ /**
747
+ * 开始编辑活动格。
748
+ */
749
+ startEditing(mode?: XlsxTableEditMode, initialText?: string): boolean;
750
+ /**
751
+ * 从公式栏提交文本。
752
+ */
753
+ commitFormulaBarText(text: string): boolean;
754
+ /**
755
+ * 撤销。
756
+ */
757
+ undo(): boolean;
758
+ /**
759
+ * 重做。
760
+ */
761
+ redo(): boolean;
762
+ /**
763
+ * 获取 history 状态。
764
+ */
765
+ getHistoryState(): XlsxTableHistorySnapshot;
766
+ /**
767
+ * 当前 sheet 的远端协同选区。
768
+ */
769
+ getRemoteSelections(): XlsxTablePresenceRecord[string][];
770
+ /**
771
+ * 全部远端 presence 快照。
772
+ */
773
+ getPresenceRecord(): XlsxTablePresenceRecord;
774
+ /**
775
+ * 确认本地 pending patches(服务端 ack 后调用)。
776
+ */
777
+ acknowledgePatches(patchIds: string[]): void;
778
+ /**
779
+ * 隐藏当前 sheet 的指定行。
780
+ */
781
+ hideRows(rowIndexes: number[]): boolean;
782
+ /**
783
+ * 显示当前 sheet 的指定行。
784
+ */
785
+ showRows(rowIndexes: number[]): boolean;
786
+ /**
787
+ * 隐藏当前 sheet 的指定列。
788
+ */
789
+ hideColumns(columnIndexes: number[]): boolean;
790
+ /**
791
+ * 显示当前 sheet 的指定列。
792
+ */
793
+ showColumns(columnIndexes: number[]): boolean;
794
+ /**
795
+ * 清空当前选区单元格值。
796
+ */
797
+ clearSelectionValues(): boolean;
798
+ /**
799
+ * 合并当前主选区。
800
+ */
801
+ mergeSelectionCells(): boolean;
802
+ /**
803
+ * 取消当前主选区内的合并单元格。
804
+ */
805
+ unmergeSelectionCells(): boolean;
806
+ /**
807
+ * 设置当前选区的单元格样式。
808
+ */
809
+ setSelectionCellStyle(stylePatch: Partial<XlsxCellStyle>): boolean;
810
+ /**
811
+ * 设置当前选区边框。
812
+ */
813
+ setSelectionCellBorder(preset: XlsxCellBorderPreset, line: XlsxCellBorderLine): boolean;
814
+ /**
815
+ * 清空当前选区的单元格样式。
816
+ */
817
+ clearSelectionCellStyle(): boolean;
818
+ /**
819
+ * 清空当前选区指定样式字段。
820
+ */
821
+ clearSelectionCellStyleKeys(keys: Array<keyof XlsxCellStyle>): boolean;
822
+ /**
823
+ * 根据活动格当前样式切换当前选区样式。
824
+ */
825
+ toggleSelectionCellStyle(activeStyle: Partial<XlsxCellStyle>, inactiveStyle: Partial<XlsxCellStyle>): boolean;
826
+ /**
827
+ * 设置当前选区的单元格类型。
828
+ */
829
+ setSelectionCellType(type: XlsxCellType | undefined): boolean;
830
+ /**
831
+ * 设置当前 sheet 的冻结窗格。
832
+ */
833
+ setFrozenPane(frozen: XlsxFrozenPane | null): boolean;
834
+ /**
835
+ * 冻结到当前活动格的上方行和左侧列。
836
+ */
837
+ freezeToSelection(): boolean;
838
+ /**
839
+ * 取消当前 sheet 冻结。
840
+ */
841
+ clearFreeze(): boolean;
842
+ /**
843
+ * 向活动格插入公式模板并进入编辑。
844
+ */
845
+ insertFormulaTemplate(template: string): boolean;
846
+ /**
847
+ * 在指定位置插入行。
848
+ */
849
+ insertRows(rowIndex: number, count?: number): boolean;
850
+ /**
851
+ * 在指定位置插入列。
852
+ */
853
+ insertColumns(columnIndex: number, count?: number): boolean;
854
+ /**
855
+ * 删除指定位置开始的行。
856
+ */
857
+ deleteRows(rowIndex: number, count?: number): boolean;
858
+ /**
859
+ * 删除指定位置开始的列。
860
+ */
861
+ deleteColumns(columnIndex: number, count?: number): boolean;
862
+ /**
863
+ * 按当前 sheet 指定列排序。
864
+ */
865
+ sortByColumn(columnIndex: number, direction: XlsxSortDirection): boolean;
866
+ /**
867
+ * 清除当前 sheet 的排序状态。
868
+ */
869
+ clearSort(): boolean;
870
+ /**
871
+ * 获取当前 sheet 指定列的筛选候选项。
872
+ */
873
+ getColumnFilterOptions(columnIndex: number): XlsxFilterOptionItem[];
874
+ /**
875
+ * 按指定列设置值筛选。
876
+ */
877
+ setColumnFilterValues(columnIndex: number, values: XlsxFilterValue[]): boolean;
878
+ /**
879
+ * 激活指定列表头 action 图标。
880
+ */
881
+ setHeaderActionHint(columnIndex: number, actionType: XlsxHeaderActionType): boolean;
882
+ /**
883
+ * 按筛选候选项设置列筛选。
884
+ */
885
+ setColumnFilterOptionValues(columnIndex: number, optionValues: XlsxFilterOptionValue[]): boolean;
886
+ /**
887
+ * 按条件设置列筛选。
888
+ */
889
+ setColumnFilterCondition(params: XlsxTableFilterConditionParams): boolean;
890
+ /**
891
+ * 清除指定列筛选。
892
+ */
893
+ clearColumnFilter(columnIndex: number): boolean;
894
+ /**
895
+ * 清除当前 sheet 全部筛选。
896
+ */
897
+ clearFilters(): boolean;
898
+ /**
899
+ * 销毁实例。
900
+ */
901
+ destroy(): void;
902
+ }
903
+
904
+ type XlsxTableContextMenuRequest = XlsxContextMenuRequest;
905
+ type XlsxTableContextMenuTarget = XlsxContextMenuTarget;
906
+ type XlsxTableHeaderActionType = XlsxHeaderActionType;
907
+ type XlsxTableEditorRect = XlsxEditorRect;
908
+ type XlsxTableEditorRequest = XlsxEditorRequest;
909
+ type XlsxTableEditorTheme = XlsxEditorTheme;
910
+ type XlsxTableEditorNavigateDirection = XlsxEditorNavigateDirection;
911
+ type XlsxTableFormulaBarState = XlsxFormulaBarState;
912
+
913
+ interface XlsxFormulaValidationResult {
914
+ valid: boolean;
915
+ message?: string;
916
+ }
917
+ declare function validateXlsxFormulaInput(formula: string): XlsxFormulaValidationResult;
918
+
919
+ interface XlsxWorkbookValidationIssue {
920
+ path: string;
921
+ message: string;
922
+ }
923
+ interface XlsxWorkbookValidationResult {
924
+ valid: boolean;
925
+ issues: XlsxWorkbookValidationIssue[];
926
+ }
927
+ declare function validateXlsxWorkbook(workbook: XlsxWorkbook): XlsxWorkbookValidationResult;
928
+
929
+ interface XlsxCollapsedRowMarker {
930
+ rowIndex: number;
931
+ align: "bottom" | "top";
932
+ rangeStart: number;
933
+ rangeEnd: number;
934
+ }
935
+ interface XlsxCollapsedColumnMarker {
936
+ columnIndex: number;
937
+ align: "left" | "right";
938
+ rangeStart: number;
939
+ rangeEnd: number;
940
+ }
941
+ interface XlsxVisibilitySheetLike {
942
+ rowCount: number;
943
+ columnCount: number;
944
+ rows?: Record<number, XlsxRowConfig>;
945
+ columns?: Record<number, XlsxColumnConfig>;
946
+ }
947
+ type XlsxVisibleIndexFallback = "nearest" | "next" | "previous";
948
+ type XlsxVisibleNavigationDirection = "down" | "left" | "right" | "up";
949
+ declare function setSheetRowsHidden(sheet: XlsxSheet, rowIndexes: number[], hidden: boolean): XlsxSheet;
950
+ declare function setSheetColumnsHidden(sheet: XlsxSheet, columnIndexes: number[], hidden: boolean): XlsxSheet;
951
+ declare function restoreSheetRowsRange(sheet: XlsxSheet, rangeStart: number, rangeEnd: number): XlsxSheet;
952
+ declare function restoreSheetColumnsRange(sheet: XlsxSheet, rangeStart: number, rangeEnd: number): XlsxSheet;
953
+ /**
954
+ * 判断指定索引是否被隐藏。
955
+ */
956
+ declare function isSheetIndexHidden(configs: Record<number, {
957
+ hidden?: boolean;
958
+ filtered?: boolean;
959
+ } | undefined> | undefined, index: number): boolean;
960
+ /**
961
+ * 将索引解析到可见项;命中隐藏项时按 fallback 选择附近可见项。
962
+ */
963
+ declare function resolveVisibleIndex(params: {
964
+ count: number;
965
+ configs?: Record<number, {
966
+ hidden?: boolean;
967
+ filtered?: boolean;
968
+ } | undefined>;
969
+ index: number;
970
+ fallback?: XlsxVisibleIndexFallback;
971
+ }): number | null;
972
+ /**
973
+ * 从当前索引向指定方向查找下一个可见项。
974
+ */
975
+ declare function resolveNextVisibleIndex(params: {
976
+ count: number;
977
+ configs?: Record<number, {
978
+ hidden?: boolean;
979
+ filtered?: boolean;
980
+ } | undefined>;
981
+ fromIndex: number;
982
+ direction: -1 | 1;
983
+ }): number | null;
984
+ /**
985
+ * 将单元格地址吸附到可见行列。
986
+ */
987
+ declare function resolveVisibleAddress(params: {
988
+ sheet: XlsxVisibilitySheetLike;
989
+ address: XlsxCellAddress;
990
+ columnFallback?: XlsxVisibleIndexFallback;
991
+ rowFallback?: XlsxVisibleIndexFallback;
992
+ }): XlsxCellAddress | null;
993
+ /**
994
+ * 从当前地址向指定方向移动到下一个可见单元格。
995
+ */
996
+ declare function resolveNextVisibleAddress(params: {
997
+ sheet: XlsxVisibilitySheetLike;
998
+ address: XlsxCellAddress;
999
+ direction: XlsxVisibleNavigationDirection;
1000
+ }): XlsxCellAddress | null;
1001
+ /**
1002
+ * 解析隐藏行折叠段在行头两侧的恢复标记。
1003
+ */
1004
+ declare function resolveCollapsedRowMarkers(sheet: XlsxSheet): XlsxCollapsedRowMarker[];
1005
+ /**
1006
+ * 解析隐藏列折叠段在列头两侧的恢复标记。
1007
+ */
1008
+ declare function resolveCollapsedColumnMarkers(sheet: XlsxSheet): XlsxCollapsedColumnMarker[];
1009
+ declare function createRowVisibilityPatch(params: {
1010
+ sheetId: string;
1011
+ beforeSheet: XlsxSheet;
1012
+ rowIndexes: number[];
1013
+ hidden: boolean;
1014
+ baseVersion: number;
1015
+ authorId?: string;
1016
+ }): XlsxPatch | null;
1017
+ declare function createColumnVisibilityPatch(params: {
1018
+ sheetId: string;
1019
+ beforeSheet: XlsxSheet;
1020
+ columnIndexes: number[];
1021
+ hidden: boolean;
1022
+ baseVersion: number;
1023
+ authorId?: string;
1024
+ }): XlsxPatch | null;
1025
+
1026
+ /**
1027
+ * 从锚点与焦点生成归一化矩形选区。
1028
+ */
1029
+ declare function createRangeFromAddresses(anchor: XlsxCellAddress, focus: XlsxCellAddress): XlsxCellRange;
1030
+ interface XlsxVisibleSelectionRangeResult {
1031
+ anchor: XlsxCellAddress;
1032
+ focus: XlsxCellAddress;
1033
+ range: XlsxCellRange;
1034
+ }
1035
+ /**
1036
+ * 将选区锚点/焦点吸附到可见行列,再生成矩形选区。
1037
+ */
1038
+ declare function createVisibleRangeFromAddresses(sheet: XlsxVisibilitySheetLike, anchor: XlsxCellAddress, focus: XlsxCellAddress): XlsxVisibleSelectionRangeResult | null;
1039
+ /**
1040
+ * 将地址限制在 sheet 边界内。
1041
+ */
1042
+ declare function clampAddress(address: XlsxCellAddress, rowCount: number, columnCount: number): XlsxCellAddress;
1043
+ /**
1044
+ * 判断地址是否在矩形选区内(含边界)。
1045
+ */
1046
+ declare function isAddressInRange(address: XlsxCellAddress, range: XlsxCellRange): boolean;
1047
+ /**
1048
+ * 判断两个选区是否相同(归一化后比较)。
1049
+ */
1050
+ declare function isSameRange(a: XlsxCellRange, b: XlsxCellRange): boolean;
1051
+ /**
1052
+ * 判断两个地址是否相同。
1053
+ */
1054
+ declare function isSameAddress(a: XlsxCellAddress | null, b: XlsxCellAddress | null): boolean;
1055
+ /**
1056
+ * 选区覆盖的单元格数量。
1057
+ */
1058
+ declare function getRangeCellCount(range: XlsxCellRange): number;
1059
+ /**
1060
+ * 追加选区:若与已有选区完全相同则移除(toggle),否则追加到末尾。
1061
+ * 返回的数组中最后一个为当前主选区。
1062
+ */
1063
+ declare function appendSelectionRange(ranges: XlsxCellRange[], next: XlsxCellRange): XlsxCellRange[];
1064
+ /**
1065
+ * 取主选区(最后一个)。
1066
+ */
1067
+ declare function getPrimaryRange(ranges: XlsxCellRange[]): XlsxCellRange | null;
1068
+ /**
1069
+ * 生成整行选区。
1070
+ */
1071
+ declare function createRowRange(rowIndex: number, columnCount: number): XlsxCellRange;
1072
+ /**
1073
+ * 生成整列选区。
1074
+ */
1075
+ declare function createColumnRange(columnIndex: number, rowCount: number): XlsxCellRange;
1076
+ /**
1077
+ * 生成整张 sheet 选区。
1078
+ */
1079
+ declare function createSheetRange(rowCount: number, columnCount: number): XlsxCellRange;
1080
+ /**
1081
+ * 根据已有单元格估算 used range;无数据时回退 A1。
1082
+ */
1083
+ declare function resolveUsedRange(params: {
1084
+ cells?: Record<string, unknown>;
1085
+ rowCount: number;
1086
+ columnCount: number;
1087
+ }): XlsxCellRange;
1088
+ /**
1089
+ * 判断当前主选区是否已覆盖整张 sheet。
1090
+ */
1091
+ declare function isFullSheetRange(range: XlsxCellRange | null, rowCount: number, columnCount: number): boolean;
1092
+
1093
+ /**
1094
+ * 对比两张 sheet 的 cells,生成 set-range patch。
1095
+ */
1096
+ declare function createSheetCellsPatch(params: {
1097
+ sheetId: string;
1098
+ beforeSheet: XlsxSheet;
1099
+ afterSheet: XlsxSheet;
1100
+ baseVersion: number;
1101
+ authorId?: string;
1102
+ }): XlsxPatch | null;
1103
+ /**
1104
+ * 将 patch 正向应用到 workbook。
1105
+ */
1106
+ declare function applyPatch(workbook: XlsxWorkbook, patch: XlsxPatch, direction?: "forward" | "backward"): XlsxWorkbook;
1107
+ /**
1108
+ * 从单点写入构造 patch(便于单测)。
1109
+ */
1110
+ declare function createCellPatch(params: {
1111
+ sheetId: string;
1112
+ rowIndex: number;
1113
+ columnIndex: number;
1114
+ before?: XlsxCell;
1115
+ after?: XlsxCell;
1116
+ baseVersion: number;
1117
+ }): XlsxPatch;
1118
+ /**
1119
+ * 构造列宽 / 行高尺寸 patch。
1120
+ */
1121
+ declare function createResizePatch(params: {
1122
+ sheetId: string;
1123
+ axis: "column" | "row";
1124
+ index: number;
1125
+ beforeSize: number | null;
1126
+ afterSize: number | null;
1127
+ baseVersion: number;
1128
+ authorId?: string;
1129
+ }): XlsxPatch | null;
1130
+
1131
+ declare function setSheetRangesCellStyle(sheet: XlsxSheet, ranges: XlsxCellRange[], stylePatch: Partial<XlsxCellStyle>): XlsxSheet;
1132
+ /**
1133
+ * 按选区位置设置单元格边框。
1134
+ */
1135
+ declare function setSheetRangesCellBorder(sheet: XlsxSheet, ranges: XlsxCellRange[], preset: XlsxCellBorderPreset, line: XlsxCellBorderLine): XlsxSheet;
1136
+ declare function clearSheetRangesCellStyle(sheet: XlsxSheet, ranges: XlsxCellRange[]): XlsxSheet;
1137
+ declare function clearSheetRangesCellStyleKeys(sheet: XlsxSheet, ranges: XlsxCellRange[], keys: Array<keyof XlsxCellStyle>): XlsxSheet;
1138
+ declare function setSheetRangesCellType(sheet: XlsxSheet, ranges: XlsxCellRange[], type: XlsxCellType | undefined): XlsxSheet;
1139
+
1140
+ declare function setSheetFrozenPane(sheet: XlsxSheet, frozen: XlsxFrozenPane | null): XlsxSheet;
1141
+ declare function createSheetFrozenPanePatch(params: {
1142
+ sheetId: string;
1143
+ beforeSheet: XlsxSheet;
1144
+ frozen: XlsxFrozenPane | null;
1145
+ baseVersion: number;
1146
+ authorId?: string;
1147
+ }): XlsxPatch | null;
1148
+
1149
+ declare function insertSheetRows(sheet: XlsxSheet, rowIndex: number, count?: number): XlsxSheet;
1150
+ declare function insertSheetColumns(sheet: XlsxSheet, columnIndex: number, count?: number): XlsxSheet;
1151
+ declare function deleteSheetRows(sheet: XlsxSheet, rowIndex: number, count?: number): XlsxSheet;
1152
+ declare function deleteSheetColumns(sheet: XlsxSheet, columnIndex: number, count?: number): XlsxSheet;
1153
+
1154
+ /**
1155
+ * 查找包含指定单元格的合并区域。
1156
+ */
1157
+ declare function findMergedCellRange(sheet: Pick<XlsxSheet, "merges">, address: XlsxCellAddress): XlsxMergedRange | undefined;
1158
+ /**
1159
+ * 将选区扩展到所有相交的合并区域。
1160
+ */
1161
+ declare function expandRangeToMergedCells(sheet: Pick<XlsxSheet, "merges">, range: XlsxCellRange): XlsxCellRange;
1162
+ /**
1163
+ * 判断选区是否可以合并。
1164
+ */
1165
+ declare function canMergeSheetRange(sheet: XlsxSheet, range: XlsxCellRange): boolean;
1166
+ /**
1167
+ * 合并选区;被覆盖单元格的数据保留,取消合并后可恢复展示。
1168
+ */
1169
+ declare function mergeSheetRange(sheet: XlsxSheet, range: XlsxCellRange): XlsxSheet;
1170
+ /**
1171
+ * 取消与选区相交的合并区域。
1172
+ */
1173
+ declare function unmergeSheetRange(sheet: XlsxSheet, range: XlsxCellRange): XlsxSheet;
1174
+ /**
1175
+ * 判断选区是否包含可取消的合并区域。
1176
+ */
1177
+ declare function canUnmergeSheetRange(sheet: Pick<XlsxSheet, "merges">, range: XlsxCellRange): boolean;
1178
+
1179
+ /**
1180
+ * 撤销/重做栈。
1181
+ */
1182
+ declare class XlsxHistoryStack {
1183
+ private undoStack;
1184
+ private redoStack;
1185
+ private readonly maxSize;
1186
+ constructor(maxSize?: number);
1187
+ push(patch: XlsxPatch): void;
1188
+ popUndo(): XlsxPatch | null;
1189
+ popRedo(): XlsxPatch | null;
1190
+ clear(): void;
1191
+ getState(): XlsxHistoryState;
1192
+ }
1193
+
1194
+ /**
1195
+ * 根据填充拖拽终点计算目标选区(包含源区)。
1196
+ * 仅支持单向扩展:右/左/下/上。
1197
+ */
1198
+ declare function resolveFillTargetRange(source: XlsxCellRange, focusRowIndex: number, focusColumnIndex: number): XlsxCellRange;
1199
+
1200
+ type XlsxFillMode = "auto" | "copy" | "series";
1201
+ interface XlsxFillOptions {
1202
+ /** 是否只填充可见行列。@default false */
1203
+ visibleOnly?: boolean;
1204
+ }
1205
+ /**
1206
+ * 自动填充:优先对数字/日期做等差序列,否则回退 copy。
1207
+ *
1208
+ * 垂直扩展时按列独立识别;水平扩展时按行独立识别。
1209
+ */
1210
+ declare function applyAutoFill(params: {
1211
+ sheet: XlsxSheet;
1212
+ sourceRange: XlsxCellRange;
1213
+ targetRange: XlsxCellRange;
1214
+ options?: XlsxFillOptions;
1215
+ }): XlsxSheet;
1216
+ /**
1217
+ * copy 策略填充:将源区按矩阵循环复制到目标区。
1218
+ */
1219
+ declare function applyCopyFill(params: {
1220
+ sheet: XlsxSheet;
1221
+ sourceRange: XlsxCellRange;
1222
+ targetRange: XlsxCellRange;
1223
+ options?: XlsxFillOptions;
1224
+ }): XlsxSheet;
1225
+ /**
1226
+ * 强制序列填充;无法识别序列的通道回退 copy。
1227
+ */
1228
+ declare function applySeriesFill(params: {
1229
+ sheet: XlsxSheet;
1230
+ sourceRange: XlsxCellRange;
1231
+ targetRange: XlsxCellRange;
1232
+ options?: XlsxFillOptions;
1233
+ }): XlsxSheet;
1234
+
1235
+ interface PresenceStateOptions {
1236
+ /** presence 过期毫秒。@default 30000 */
1237
+ ttlMs?: number;
1238
+ /** 当前用户 id,不会进入远端列表。 */
1239
+ selfUserId?: string;
1240
+ }
1241
+ /**
1242
+ * 远端 presence 状态管理。
1243
+ */
1244
+ declare class XlsxPresenceState {
1245
+ private selections;
1246
+ private ttlMs;
1247
+ private selfUserId?;
1248
+ constructor(options?: PresenceStateOptions);
1249
+ setOptions(options: PresenceStateOptions): void;
1250
+ /**
1251
+ * 更新/写入一条远端 presence。
1252
+ */
1253
+ upsert(selection: XlsxRemoteSelection): boolean;
1254
+ remove(userId: string): boolean;
1255
+ clear(): void;
1256
+ /**
1257
+ * 清理过期 presence。
1258
+ * @returns 是否发生变更
1259
+ */
1260
+ prune(now?: number): boolean;
1261
+ /**
1262
+ * 当前 sheet 的有效远端选区列表。
1263
+ */
1264
+ listForSheet(sheetId: string, now?: number): XlsxRemoteSelection[];
1265
+ /**
1266
+ * 导出 map 快照。
1267
+ */
1268
+ toRecord(now?: number): Record<string, XlsxRemoteSelection>;
1269
+ }
1270
+
1271
+ /**
1272
+ * 判断两个 patch 是否触碰同一批单元格。
1273
+ */
1274
+ declare function getOverlappingCellKeys(local: XlsxPatch, remote: XlsxPatch): string[];
1275
+ /**
1276
+ * MVP 冲突处理:默认 last-write-wins 偏向 remote。
1277
+ * 返回需要应用的 patches(已是最终结果方向)。
1278
+ */
1279
+ declare function resolvePatchConflict(params: {
1280
+ local: XlsxPatch;
1281
+ remote: XlsxPatch;
1282
+ onConflict?: (conflict: XlsxPatchConflict) => "remote" | "local" | XlsxPatch[];
1283
+ }): XlsxPatch[];
1284
+ /**
1285
+ * 将远端 patches 与本地 pending patches 合并排序。
1286
+ * 策略:
1287
+ * 1. 先按 baseVersion / createdAt 排序远端
1288
+ * 2. 对每条远端,与 pending 做冲突裁剪
1289
+ * 3. 无冲突 pending 保留,最后按顺序返回“应应用的远端 + 需重放的 pending”
1290
+ */
1291
+ declare function transformRemoteAgainstPending(params: {
1292
+ remotePatches: XlsxPatch[];
1293
+ pendingLocalPatches: XlsxPatch[];
1294
+ onConflict?: (conflict: XlsxPatchConflict) => "remote" | "local" | XlsxPatch[];
1295
+ }): {
1296
+ /** 应用到 workbook 的远端 patches(可能已裁剪) */
1297
+ remoteToApply: XlsxPatch[];
1298
+ /** 远端应用后需要重放的本地 pending */
1299
+ pendingToReplay: XlsxPatch[];
1300
+ };
1301
+
1302
+ type XlsxServerConflictPolicy = "server" | "client" | "reject";
1303
+ interface XlsxServerPatchConflict {
1304
+ incoming: XlsxPatch;
1305
+ committed: XlsxPatch;
1306
+ keys: string[];
1307
+ }
1308
+ interface XlsxServerTransformOptions {
1309
+ /**
1310
+ * 旧版本 patch 与服务端已提交 patch 冲突时的策略。
1311
+ * - server:服务端已提交内容胜出,裁剪 incoming 冲突键
1312
+ * - client:incoming 胜出,保留冲突键
1313
+ * - reject:拒绝整个 incoming
1314
+ *
1315
+ * @default "server"
1316
+ */
1317
+ conflictPolicy?: XlsxServerConflictPolicy;
1318
+ /**
1319
+ * 自定义冲突处理;返回 `"server"` / `"client"` / `"reject"`。
1320
+ */
1321
+ onConflict?: (conflict: XlsxServerPatchConflict) => XlsxServerConflictPolicy;
1322
+ }
1323
+ interface XlsxServerTransformResult {
1324
+ status: "accepted" | "transformed" | "rejected" | "noop";
1325
+ patch: XlsxPatch | null;
1326
+ conflicts: XlsxServerPatchConflict[];
1327
+ droppedKeys: string[];
1328
+ }
1329
+ /**
1330
+ * 服务端权威源下的单元格级 OT 转换。
1331
+ *
1332
+ * 服务端可保存 append-only patch log。收到基于旧版本的 incoming patch 时,
1333
+ * 取 baseVersion 之后已经提交的 patches 作为 committedPatches 调用本函数。
1334
+ */
1335
+ declare function transformPatchAgainstCommitted(params: {
1336
+ incomingPatch: XlsxPatch;
1337
+ committedPatches: XlsxPatch[];
1338
+ options?: XlsxServerTransformOptions;
1339
+ }): XlsxServerTransformResult;
1340
+ /**
1341
+ * 给服务端已接受的 patch 写入权威版本信息。
1342
+ */
1343
+ declare function stampServerAcceptedPatch(params: {
1344
+ patch: XlsxPatch;
1345
+ serverVersion: number;
1346
+ createdAt?: number;
1347
+ }): XlsxPatch;
1348
+
1349
+ interface XlsxAuthoritativePatchLogEntry {
1350
+ version: number;
1351
+ patch: XlsxPatch;
1352
+ }
1353
+ interface XlsxAuthoritativeAccessContext {
1354
+ user: XlsxCollaborator;
1355
+ workbook: XlsxWorkbook;
1356
+ }
1357
+ interface XlsxAuthoritativePatchAccessContext extends XlsxAuthoritativeAccessContext {
1358
+ patch: XlsxPatch;
1359
+ }
1360
+ interface XlsxAuthoritativePresenceAccessContext extends XlsxAuthoritativeAccessContext {
1361
+ presence: XlsxRemoteSelection;
1362
+ }
1363
+ interface XlsxAuthoritativeRoomOptions {
1364
+ workbook: XlsxWorkbook;
1365
+ /**
1366
+ * 旧版本 patch 与服务端已提交 patch 冲突时的默认策略。
1367
+ * @default "server"
1368
+ */
1369
+ conflictPolicy?: XlsxServerConflictPolicy;
1370
+ /** 是否由服务端在每次接受 patch 后重算公式结果。@default true */
1371
+ recalculateFormulas?: boolean;
1372
+ /** patch 级鉴权 hook。返回 false 或字符串时拒绝。 */
1373
+ authorizePatch?: (context: XlsxAuthoritativePatchAccessContext) => boolean | string;
1374
+ /** presence 级鉴权 hook。返回 false 或字符串时拒绝。 */
1375
+ authorizePresence?: (context: XlsxAuthoritativePresenceAccessContext) => boolean | string;
1376
+ /** 自定义冲突处理。 */
1377
+ onConflict?: XlsxServerTransformOptions["onConflict"];
1378
+ /** 注入服务端时间,便于测试。 */
1379
+ now?: () => number;
1380
+ }
1381
+ interface XlsxAuthoritativeRejectedPatch {
1382
+ patch: XlsxPatch;
1383
+ reason: string;
1384
+ transform?: XlsxServerTransformResult;
1385
+ }
1386
+ interface XlsxAuthoritativePatchSubmitResult {
1387
+ workbook: XlsxWorkbook;
1388
+ acceptedPatches: XlsxPatch[];
1389
+ rejectedPatches: XlsxAuthoritativeRejectedPatch[];
1390
+ noopPatchIds: string[];
1391
+ ackPatchIds: string[];
1392
+ serverVersion: number;
1393
+ }
1394
+ interface XlsxAuthoritativePresenceSubmitResult {
1395
+ accepted: boolean;
1396
+ reason?: string;
1397
+ presence?: XlsxRemoteSelection;
1398
+ }
1399
+ /**
1400
+ * 无网络依赖的服务端权威协同房间核心。
1401
+ *
1402
+ * 业务服务端可将它接到 WebSocket / SSE / HTTP 网关上,负责鉴权、版本、
1403
+ * patch log、单元格级 OT 转换,以及公式结果权威重算。
1404
+ */
1405
+ declare class XlsxAuthoritativeCollaborationRoom {
1406
+ private workbook;
1407
+ private readonly patchLog;
1408
+ private readonly presence;
1409
+ private readonly options;
1410
+ constructor(options: XlsxAuthoritativeRoomOptions);
1411
+ /**
1412
+ * 获取服务端当前权威 workbook。
1413
+ */
1414
+ getWorkbook(): XlsxWorkbook;
1415
+ /**
1416
+ * 获取 patch log 副本。
1417
+ */
1418
+ getPatchLog(): XlsxAuthoritativePatchLogEntry[];
1419
+ /**
1420
+ * 获取 presence 快照。
1421
+ */
1422
+ getPresenceRecord(): {
1423
+ [k: string]: XlsxRemoteSelection;
1424
+ };
1425
+ /**
1426
+ * 提交客户端 patches,返回服务端接受/拒绝结果。
1427
+ */
1428
+ submitPatches(params: {
1429
+ user: XlsxCollaborator;
1430
+ patches: XlsxPatch[];
1431
+ }): XlsxAuthoritativePatchSubmitResult;
1432
+ /**
1433
+ * 提交 presence;服务端只保留每个用户最新值。
1434
+ */
1435
+ submitPresence(params: {
1436
+ user: XlsxCollaborator;
1437
+ presence: Omit<XlsxRemoteSelection, "user" | "updatedAt">;
1438
+ }): XlsxAuthoritativePresenceSubmitResult;
1439
+ private authorizePatch;
1440
+ private authorizePresence;
1441
+ }
1442
+
1443
+ /**
1444
+ * 内存 mock 协同适配器,用于双实例联调与单测。
1445
+ * 不绑定 WebSocket / HTTP。
1446
+ */
1447
+ declare class MockXlsxCollaborationAdapter implements XlsxCollaborationAdapter {
1448
+ private readonly room;
1449
+ private readonly user;
1450
+ private patchListeners;
1451
+ private presenceListeners;
1452
+ private unsubscribers;
1453
+ constructor(room: MockCollaborationRoom, user: XlsxCollaborator);
1454
+ sendPatches(patches: XlsxPatch[]): void;
1455
+ sendPresence(selection: XlsxRemoteSelection): void;
1456
+ onRemotePatches(listener: (patches: XlsxPatch[]) => void): () => void;
1457
+ onRemotePresence(listener: (selection: XlsxRemoteSelection) => void): () => void;
1458
+ destroy(): void;
1459
+ }
1460
+ /**
1461
+ * 简易房间:多个 adapter 共享。
1462
+ */
1463
+ declare class MockCollaborationRoom {
1464
+ private patchListeners;
1465
+ private presenceListeners;
1466
+ private version;
1467
+ getVersion(): number;
1468
+ broadcastPatches(fromUserId: string, patches: XlsxPatch[]): void;
1469
+ broadcastPresence(fromUserId: string, selection: XlsxRemoteSelection): void;
1470
+ subscribePatches(userId: string, listener: (patches: XlsxPatch[]) => void): () => void;
1471
+ subscribePresence(userId: string, listener: (selection: XlsxRemoteSelection) => void): () => void;
1472
+ }
1473
+
1474
+ /**
1475
+ * 协同 WebSocket 消息:patches 广播。
1476
+ */
1477
+ interface XlsxWsPatchMessage {
1478
+ type: "patches";
1479
+ roomId: string;
1480
+ fromUserId: string;
1481
+ patches: XlsxPatch[];
1482
+ serverVersion?: number;
1483
+ }
1484
+ /**
1485
+ * 协同 WebSocket 消息:presence 广播。
1486
+ */
1487
+ interface XlsxWsPresenceMessage {
1488
+ type: "presence";
1489
+ roomId: string;
1490
+ selection: XlsxRemoteSelection;
1491
+ }
1492
+ /**
1493
+ * 协同 WebSocket 消息:服务端对本地 patch 的确认。
1494
+ */
1495
+ interface XlsxWsPatchAckMessage {
1496
+ type: "patch-ack";
1497
+ patchIds: string[];
1498
+ serverVersion: number;
1499
+ roomId?: string;
1500
+ }
1501
+ /**
1502
+ * 可选 join:连接后声明房间与用户(服务端可忽略)。
1503
+ */
1504
+ interface XlsxWsJoinMessage {
1505
+ type: "join";
1506
+ roomId: string;
1507
+ userId: string;
1508
+ }
1509
+ /**
1510
+ * 客户端可发送的消息。
1511
+ */
1512
+ type XlsxWsClientMessage = XlsxWsPatchMessage | XlsxWsPresenceMessage | XlsxWsJoinMessage;
1513
+ /**
1514
+ * 客户端可接收的消息。
1515
+ */
1516
+ type XlsxWsServerMessage = XlsxWsPatchMessage | XlsxWsPresenceMessage | XlsxWsPatchAckMessage;
1517
+ /**
1518
+ * patch-ack 回调载荷。
1519
+ */
1520
+ interface XlsxPatchAckPayload {
1521
+ patchIds: string[];
1522
+ serverVersion: number;
1523
+ }
1524
+ /**
1525
+ * 将协同消息编码为 WebSocket 文本帧。
1526
+ */
1527
+ declare function encodeCollaborationMessage(message: XlsxWsClientMessage | XlsxWsServerMessage): string;
1528
+ /**
1529
+ * 解析服务端文本帧;非法或未知类型返回 null。
1530
+ */
1531
+ declare function decodeCollaborationMessage(raw: string | ArrayBuffer | Blob | unknown): XlsxWsServerMessage | null;
1532
+
1533
+ /**
1534
+ * 可注入的 WebSocket 构造器,便于单测 mock。
1535
+ */
1536
+ type XlsxWebSocketConstructor = new (url: string | URL, protocols?: string | string[]) => XlsxWebSocketLike;
1537
+ /**
1538
+ * 适配器依赖的最小 WebSocket 接口(浏览器 / Node 兼容)。
1539
+ */
1540
+ interface XlsxWebSocketLike {
1541
+ readonly readyState: number;
1542
+ onopen: ((ev: Event) => void) | null;
1543
+ onclose: ((ev: CloseEvent) => void) | null;
1544
+ onerror: ((ev: Event) => void) | null;
1545
+ onmessage: ((ev: MessageEvent) => void) | null;
1546
+ send(data: string): void;
1547
+ close(code?: number, reason?: string): void;
1548
+ }
1549
+ /**
1550
+ * WebSocket 协同适配器配置。
1551
+ */
1552
+ interface WebSocketXlsxCollaborationAdapterOptions {
1553
+ /** 房间 id,写入每条消息。 */
1554
+ roomId: string;
1555
+ /** 当前用户(用于 fromUserId / join)。 */
1556
+ user: XlsxCollaborator;
1557
+ /**
1558
+ * 完整 WebSocket URL,或返回 URL 的函数。
1559
+ * 例:`wss://example.com/xlsx?room=demo`
1560
+ */
1561
+ url: string | (() => string);
1562
+ /** 可选子协议。 */
1563
+ protocols?: string | string[];
1564
+ /** 注入 WebSocket 实现;默认使用全局 `WebSocket`。 */
1565
+ webSocketCtor?: XlsxWebSocketConstructor;
1566
+ /**
1567
+ * 断线后是否自动重连。
1568
+ * @default true
1569
+ */
1570
+ autoReconnect?: boolean;
1571
+ /**
1572
+ * 重连初始间隔(毫秒)。
1573
+ * @default 1000
1574
+ */
1575
+ reconnectDelayMs?: number;
1576
+ /**
1577
+ * 重连最大间隔(毫秒)。
1578
+ * @default 15000
1579
+ */
1580
+ maxReconnectDelayMs?: number;
1581
+ /**
1582
+ * 离线时最多缓存的出站消息条数。
1583
+ * @default 200
1584
+ */
1585
+ maxOutboundQueue?: number;
1586
+ /**
1587
+ * 连接成功后是否发送 `join` 消息。
1588
+ * @default true
1589
+ */
1590
+ sendJoinOnOpen?: boolean;
1591
+ /** 连接打开回调。 */
1592
+ onOpen?: () => void;
1593
+ /** 连接关闭回调。 */
1594
+ onClose?: (event: {
1595
+ code: number;
1596
+ reason: string;
1597
+ wasClean: boolean;
1598
+ }) => void;
1599
+ /** 传输层错误回调。 */
1600
+ onError?: (error: unknown) => void;
1601
+ /** 收到 patch-ack 时回调(业务可转调 table.acknowledgePatches)。 */
1602
+ onPatchAck?: (payload: XlsxPatchAckPayload) => void;
1603
+ /** 解析失败或未知消息时回调。 */
1604
+ onInvalidMessage?: (raw: unknown) => void;
1605
+ }
1606
+ /**
1607
+ * 基于 WebSocket 的 `XlsxCollaborationAdapter` 实现。
1608
+ *
1609
+ * - 消息格式见 `docs/collaboration-protocol.md` 与 `websocket-protocol.ts`
1610
+ * - 不依赖具体服务端;业务提供 URL 与可选鉴权 query/token
1611
+ * - 支持断线重连与出站队列
1612
+ */
1613
+ declare class WebSocketXlsxCollaborationAdapter implements XlsxCollaborationAdapter {
1614
+ private readonly options;
1615
+ private readonly patchListeners;
1616
+ private readonly presenceListeners;
1617
+ private readonly ackListeners;
1618
+ private socket;
1619
+ private outboundQueue;
1620
+ private reconnectAttempt;
1621
+ private reconnectTimer;
1622
+ private destroyed;
1623
+ private intentionalClose;
1624
+ constructor(options: WebSocketXlsxCollaborationAdapterOptions);
1625
+ /**
1626
+ * 当前 socket 是否处于 OPEN。
1627
+ */
1628
+ isConnected(): boolean;
1629
+ /**
1630
+ * 手动重连(会先关闭现有连接)。
1631
+ */
1632
+ reconnect(): void;
1633
+ sendPatches(patches: XlsxPatch[]): void;
1634
+ sendPresence(selection: XlsxRemoteSelection): void;
1635
+ onRemotePatches(listener: (patches: XlsxPatch[]) => void): () => void;
1636
+ onRemotePresence(listener: (selection: XlsxRemoteSelection) => void): () => void;
1637
+ /**
1638
+ * 订阅服务端 patch-ack。
1639
+ */
1640
+ onPatchAck(listener: (payload: XlsxPatchAckPayload) => void): () => void;
1641
+ destroy(): void;
1642
+ private connect;
1643
+ private handleIncoming;
1644
+ private dispatchDecoded;
1645
+ private enqueueOrSend;
1646
+ private flushOutboundQueue;
1647
+ private sendRaw;
1648
+ private scheduleReconnect;
1649
+ private clearReconnectTimer;
1650
+ private closeSocket;
1651
+ private resolveWebSocketCtor;
1652
+ }
1653
+
1654
+ /**
1655
+ * 将编辑输入文本解析为单元格值与类型。
1656
+ */
1657
+ declare function parseCellInputText(text: string, preferredType?: XlsxCellType): {
1658
+ value: XlsxCellValue;
1659
+ type?: XlsxCellType;
1660
+ displayValue?: string;
1661
+ formula?: string;
1662
+ };
1663
+ /**
1664
+ * 从单元格生成可编辑文本(公式优先)。
1665
+ */
1666
+ declare function resolveCellEditText(cell: XlsxCell | undefined): string;
1667
+
1668
+ /**
1669
+ * 解析单元格显示文本。
1670
+ */
1671
+ declare function resolveCellDisplayText(cell: XlsxCell | undefined): string;
1672
+
1673
+ type FormulaArrayValue = XlsxCellValue[][];
1674
+ type FormulaEvalValue = XlsxCellValue | FormulaArrayValue;
1675
+ interface FormulaSpillParentMeta {
1676
+ rowIndex: number;
1677
+ columnIndex: number;
1678
+ }
1679
+ interface FormulaSpillRangeMeta extends XlsxCellRange {
1680
+ }
1681
+ /**
1682
+ * 判断公式求值结果是否为二维数组。
1683
+ */
1684
+ declare function isFormulaArrayValue(value: FormulaEvalValue): value is FormulaArrayValue;
1685
+ /**
1686
+ * 数组结果在标量上下文中取左上角。
1687
+ */
1688
+ declare function toFormulaScalarValue(value: FormulaEvalValue): XlsxCellValue;
1689
+ /**
1690
+ * 格式化公式值为单元格展示文本。
1691
+ */
1692
+ declare function formatFormulaValue(value: FormulaEvalValue): string;
1693
+
1694
+ type FormulaErrorCode = "#DIV/0!" | "#VALUE!" | "#NAME?" | "#REF!" | "#CYCLE!" | "#SPILL!" | "#ERROR!" | "#N/A";
1695
+ interface FormulaEvalResult {
1696
+ value: FormulaEvalValue;
1697
+ error?: FormulaErrorCode;
1698
+ }
1699
+ interface EvalContext {
1700
+ workbook: XlsxWorkbook;
1701
+ /** 当前公式所在 sheet。 */
1702
+ sheet: XlsxSheet;
1703
+ stack: Set<string>;
1704
+ memo: Map<string, FormulaEvalResult>;
1705
+ }
1706
+ /**
1707
+ * 判断单元格是否包含公式。
1708
+ */
1709
+ declare function hasFormula(cell: XlsxCell | undefined): boolean;
1710
+ /**
1711
+ * 计算单元格显示文本;公式走求值,普通单元格回退 formatter。
1712
+ */
1713
+ declare function evaluateCellFormula(params: {
1714
+ sheet: XlsxSheet;
1715
+ address: XlsxCellAddress;
1716
+ cell?: XlsxCell;
1717
+ workbook?: XlsxWorkbook;
1718
+ context?: EvalContext;
1719
+ }): string;
1720
+ /**
1721
+ * 求单元格计算值(公式优先)。
1722
+ */
1723
+ declare function evaluateCellValue(params: {
1724
+ sheet: XlsxSheet;
1725
+ address: XlsxCellAddress;
1726
+ cell?: XlsxCell;
1727
+ workbook?: XlsxWorkbook;
1728
+ context?: EvalContext;
1729
+ }): FormulaEvalResult;
1730
+ /**
1731
+ * 重算单 sheet 内公式(可传入 workbook 以支持跨表引用)。
1732
+ */
1733
+ declare function recalculateSheetFormulas(sheet: XlsxSheet, workbook?: XlsxWorkbook): XlsxSheet;
1734
+ /**
1735
+ * 重算 workbook 内全部 sheet 的公式。
1736
+ */
1737
+ declare function recalculateWorkbookFormulas(workbook: XlsxWorkbook): XlsxWorkbook;
1738
+ /**
1739
+ * 解析并计算表达式(不含前导 =)。
1740
+ */
1741
+ declare function evaluateExpression(expression: string, context: EvalContext): FormulaEvalResult;
1742
+
1743
+ /**
1744
+ * 依赖图节点 id:`${sheetId}!r{row}c{col}`。
1745
+ */
1746
+ type FormulaCellId = string;
1747
+ /**
1748
+ * 增量重算种子。
1749
+ */
1750
+ interface FormulaDirtySeed {
1751
+ sheetId: string;
1752
+ rowIndex: number;
1753
+ columnIndex: number;
1754
+ }
1755
+ /**
1756
+ * 公式引用(单格或区间)。
1757
+ */
1758
+ interface FormulaReference {
1759
+ sheetId: string;
1760
+ range: XlsxCellRange;
1761
+ /** 是否为区间引用(含 A1:A1 仍标 range 时 true 仅当解析到 `:`)。 */
1762
+ isRange: boolean;
1763
+ }
1764
+ /**
1765
+ * 大区间边:不展开为逐格依赖。
1766
+ */
1767
+ interface FormulaRangeEdge {
1768
+ from: FormulaCellId;
1769
+ sheetId: string;
1770
+ range: XlsxCellRange;
1771
+ }
1772
+ /**
1773
+ * 公式依赖图。
1774
+ */
1775
+ interface FormulaDependencyGraph {
1776
+ deps: Map<FormulaCellId, Set<FormulaCellId>>;
1777
+ dependents: Map<FormulaCellId, Set<FormulaCellId>>;
1778
+ formulaNodes: Set<FormulaCellId>;
1779
+ volatileFormulaNodes: Set<FormulaCellId>;
1780
+ rangeEdges: FormulaRangeEdge[];
1781
+ }
1782
+ /**
1783
+ * 小区间展开阈值:超过则记 rangeEdge。
1784
+ */
1785
+ declare const FORMULA_RANGE_EXPAND_LIMIT = 256;
1786
+ /**
1787
+ * 构造单元格节点 id。
1788
+ */
1789
+ declare function toFormulaCellId(sheetId: string, rowIndex: number, columnIndex: number): FormulaCellId;
1790
+ /**
1791
+ * 解析节点 id。
1792
+ */
1793
+ declare function parseFormulaCellId(id: FormulaCellId): {
1794
+ sheetId: string;
1795
+ address: XlsxCellAddress;
1796
+ } | null;
1797
+ /**
1798
+ * 从公式文本抽取引用(不求值)。
1799
+ * 支持 A1 / $A$1 / Sheet1!A1 / '名'!B2 / 区间与函数参数中的引用。
1800
+ */
1801
+ declare function extractFormulaReferences(expression: string, params: {
1802
+ workbook: XlsxWorkbook;
1803
+ sheet: XlsxSheet;
1804
+ }): FormulaReference[];
1805
+ /**
1806
+ * 构建 workbook 公式依赖图。
1807
+ */
1808
+ declare function buildFormulaDependencyGraph(workbook: XlsxWorkbook): FormulaDependencyGraph;
1809
+ /**
1810
+ * 增量重算:仅重算 dirtySeeds 下游公式闭包。
1811
+ */
1812
+ declare function recalculateWorkbookFormulasIncremental(params: {
1813
+ workbook: XlsxWorkbook;
1814
+ dirtySeeds: FormulaDirtySeed[];
1815
+ graph?: FormulaDependencyGraph;
1816
+ }): {
1817
+ workbook: XlsxWorkbook;
1818
+ graph: FormulaDependencyGraph;
1819
+ recomputed: number;
1820
+ };
1821
+ /**
1822
+ * 对比两个 workbook,收集单元格级 dirty seeds;结构变化返回 "full"。
1823
+ */
1824
+ declare function collectWorkbookDirtySeeds(before: XlsxWorkbook, after: XlsxWorkbook): FormulaDirtySeed[] | "full";
1825
+ /**
1826
+ * 将 cell key 列表转为 seeds。
1827
+ */
1828
+ declare function cellKeysToSeeds(sheetId: string, keys: Iterable<string>): FormulaDirtySeed[];
1829
+ /**
1830
+ * 判断公式是否包含易失函数。
1831
+ */
1832
+ declare function hasVolatileFormula(formula: string): boolean;
1833
+ /**
1834
+ * 收集图中的易失公式 seeds。
1835
+ */
1836
+ declare function collectVolatileFormulaSeeds(graph: FormulaDependencyGraph): FormulaDirtySeed[];
1837
+
1838
+ /**
1839
+ * 构建公式依赖图调试快照,返回适合 UI 面板消费的可序列化数据。
1840
+ */
1841
+ declare function createFormulaDependencyDebugSnapshot(params: {
1842
+ workbook: XlsxWorkbook;
1843
+ graph?: FormulaDependencyGraph | null;
1844
+ }): XlsxFormulaDependencyDebugSnapshot;
1845
+
1846
+ type XlsxFormulaCompletionKind = "function" | "named-range";
1847
+ interface XlsxFormulaCompletionSuggestion {
1848
+ kind: XlsxFormulaCompletionKind;
1849
+ label: string;
1850
+ insertText: string;
1851
+ detail?: string;
1852
+ replaceStart: number;
1853
+ replaceEnd: number;
1854
+ }
1855
+ interface XlsxFormulaAutocompleteOptions {
1856
+ text: string;
1857
+ cursorIndex?: number;
1858
+ workbook?: XlsxWorkbook;
1859
+ limit?: number;
1860
+ }
1861
+ declare const XLSX_FORMULA_FUNCTIONS: readonly ["SUM", "AVERAGE", "MIN", "MAX", "COUNT", "COUNTA", "COUNTBLANK", "SUMIF", "COUNTIF", "SUMIFS", "COUNTIFS", "IF", "IFERROR", "AND", "OR", "NOT", "ABS", "INT", "ROUND", "SQRT", "POWER", "VLOOKUP", "HLOOKUP", "INDEX", "MATCH", "TEXT", "VALUE", "DATE", "YEAR", "MONTH", "DAY", "TODAY", "NOW", "CONCAT", "CONCATENATE", "LEN", "LEFT", "RIGHT", "MID", "UPPER", "LOWER", "TRIM"];
1862
+ /**
1863
+ * 生成公式自动补全候选。
1864
+ */
1865
+ declare function getFormulaAutocompleteSuggestions(options: XlsxFormulaAutocompleteOptions): XlsxFormulaCompletionSuggestion[];
1866
+ /**
1867
+ * 应用补全候选,并返回新的文本与光标位置。
1868
+ */
1869
+ declare function applyFormulaAutocompleteSuggestion(text: string, suggestion: XlsxFormulaCompletionSuggestion): {
1870
+ text: string;
1871
+ cursorIndex: number;
1872
+ };
1873
+
1874
+ /**
1875
+ * 校验命名区域名称。
1876
+ * - 字母或下划线开头
1877
+ * - 仅 [A-Za-z0-9_.]
1878
+ * - 不可为纯 A1 地址
1879
+ */
1880
+ declare function isValidNamedRangeName(name: string): boolean;
1881
+ /**
1882
+ * 列出命名区域(按 name 字典序,稳定副本)。
1883
+ */
1884
+ declare function listNamedRanges(workbook: XlsxWorkbook): XlsxNamedRange[];
1885
+ /**
1886
+ * 按名称查找(大小写不敏感)。
1887
+ */
1888
+ declare function findNamedRange(workbook: XlsxWorkbook, name: string): XlsxNamedRange | null;
1889
+ /**
1890
+ * 解析命名引用为 sheetId + range;不存在返回 null。
1891
+ */
1892
+ declare function resolveNamedRangeRef(workbook: XlsxWorkbook, name: string): {
1893
+ sheetId: string;
1894
+ range: XlsxCellRange;
1895
+ } | null;
1896
+ /**
1897
+ * 新增或覆盖同名命名区域。
1898
+ * 名称非法或 sheet 不存在时返回 null。
1899
+ */
1900
+ declare function upsertNamedRange(workbook: XlsxWorkbook, named: XlsxNamedRange): XlsxWorkbook | null;
1901
+ /**
1902
+ * 删除命名区域(大小写不敏感)。
1903
+ */
1904
+ declare function removeNamedRange(workbook: XlsxWorkbook, name: string): XlsxWorkbook;
1905
+ /**
1906
+ * 删除 sheet 时级联清理指向该 sheet 的命名。
1907
+ */
1908
+ declare function removeNamedRangesForSheet(workbook: XlsxWorkbook, sheetId: string): XlsxWorkbook;
1909
+
1910
+ /**
1911
+ * 生成 sheet id。
1912
+ */
1913
+ declare function createSheetId(): string;
1914
+ /**
1915
+ * 创建空白 sheet。
1916
+ */
1917
+ declare function createEmptySheet(options?: CreateSheetOptions): XlsxSheet;
1918
+ /**
1919
+ * 解析当前活动 sheet。
1920
+ */
1921
+ declare function resolveActiveSheet(workbook: XlsxWorkbook): XlsxSheet | null;
1922
+ /**
1923
+ * 解析活动 sheet id。
1924
+ */
1925
+ declare function resolveActiveSheetId(workbook: XlsxWorkbook): string | null;
1926
+ /**
1927
+ * 按 id 查找 sheet。
1928
+ */
1929
+ declare function findSheetById(workbook: XlsxWorkbook, sheetId: string): XlsxSheet | null;
1930
+ /**
1931
+ * 切换活动 sheet。
1932
+ */
1933
+ declare function setActiveSheet(workbook: XlsxWorkbook, sheetId: string): XlsxWorkbook | null;
1934
+ /**
1935
+ * 追加 sheet,并可选切换为活动页。
1936
+ */
1937
+ declare function addSheet(workbook: XlsxWorkbook, options?: CreateSheetOptions & {
1938
+ activate?: boolean;
1939
+ }): XlsxWorkbook;
1940
+ /**
1941
+ * 复制 sheet,并插入到原 sheet 后方。
1942
+ */
1943
+ declare function duplicateSheet(workbook: XlsxWorkbook, sheetId: string, options?: DuplicateSheetOptions): XlsxWorkbook | null;
1944
+ /**
1945
+ * 移动 sheet 顺序。
1946
+ */
1947
+ declare function moveSheet(workbook: XlsxWorkbook, sheetId: string, targetIndex: number): XlsxWorkbook | null;
1948
+ /**
1949
+ * 重命名 sheet。
1950
+ */
1951
+ declare function renameSheet(workbook: XlsxWorkbook, sheetId: string, name: string): XlsxWorkbook | null;
1952
+ /**
1953
+ * 删除 sheet(至少保留一张)。
1954
+ */
1955
+ declare function removeSheet(workbook: XlsxWorkbook, sheetId: string): XlsxWorkbook | null;
1956
+
1957
+ /**
1958
+ * 剪贴板二维文本矩阵。
1959
+ */
1960
+ type XlsxClipboardMatrix = string[][];
1961
+ /**
1962
+ * 将二维矩阵序列化为 TSV(Excel/飞书 兼容)。
1963
+ */
1964
+ declare function serializeTsv(matrix: XlsxClipboardMatrix): string;
1965
+ /**
1966
+ * 解析 TSV / 纯文本为二维矩阵。
1967
+ * 支持引号包裹字段内的 tab/换行。
1968
+ */
1969
+ declare function parseTsv(text: string): XlsxClipboardMatrix;
1970
+
1971
+ interface PasteMatrixOptions {
1972
+ /** 超出边界时是否扩展行列。@default false */
1973
+ expandBounds?: boolean;
1974
+ /** 是否只作用于可见行列。@default false */
1975
+ visibleOnly?: boolean;
1976
+ }
1977
+ interface PasteMatrixRangeResult {
1978
+ range: XlsxCellRange;
1979
+ rowCount: number;
1980
+ columnCount: number;
1981
+ }
1982
+ /**
1983
+ * 从 sheet 选区导出可复制矩阵(使用可编辑文本)。
1984
+ */
1985
+ declare function extractRangeMatrix(sheet: XlsxSheet, range: XlsxCellRange, options?: {
1986
+ visibleOnly?: boolean;
1987
+ }): XlsxClipboardMatrix;
1988
+ /**
1989
+ * 将矩阵粘贴到 sheet,以 origin 为左上角。
1990
+ * 单值矩阵可填满 targetRange。
1991
+ */
1992
+ declare function applyMatrixToSheet(params: {
1993
+ sheet: XlsxSheet;
1994
+ origin: XlsxCellAddress;
1995
+ matrix: XlsxClipboardMatrix;
1996
+ targetRange?: XlsxCellRange | null;
1997
+ options?: PasteMatrixOptions;
1998
+ }): XlsxSheet;
1999
+ /**
2000
+ * 解析矩阵粘贴实际覆盖范围;超出边界时按配置截断或扩展。
2001
+ */
2002
+ declare function resolvePasteMatrixRange(params: {
2003
+ rowCount: number;
2004
+ columnCount: number;
2005
+ origin: XlsxCellAddress;
2006
+ matrix: XlsxClipboardMatrix;
2007
+ targetRange?: XlsxCellRange | null;
2008
+ options?: PasteMatrixOptions;
2009
+ }): PasteMatrixRangeResult | null;
2010
+ /**
2011
+ * 清空选区内单元格值。
2012
+ */
2013
+ declare function clearRangeOnSheet(sheet: XlsxSheet, range: XlsxCellRange): XlsxSheet;
2014
+ /**
2015
+ * 在 workbook 上应用 sheet 替换。
2016
+ */
2017
+ declare function replaceWorkbookSheet(workbook: XlsxWorkbook, sheetId: string, nextSheet: XlsxSheet): XlsxWorkbook;
2018
+
2019
+ declare const MIN_COLUMN_WIDTH = 24;
2020
+ declare const MIN_ROW_HEIGHT = 16;
2021
+ /**
2022
+ * 限制列宽。
2023
+ */
2024
+ declare function clampColumnWidth(width: number): number;
2025
+ /**
2026
+ * 限制行高。
2027
+ */
2028
+ declare function clampRowHeight(height: number): number;
2029
+ /**
2030
+ * 写入列宽(immutable)。
2031
+ */
2032
+ declare function setSheetColumnWidth(sheet: XlsxSheet, columnIndex: number, width: number): XlsxSheet;
2033
+ /**
2034
+ * 写入行高(immutable)。
2035
+ */
2036
+ declare function setSheetRowHeight(sheet: XlsxSheet, rowIndex: number, height: number): XlsxSheet;
2037
+
2038
+ interface XlsxSizeMetrics {
2039
+ offsets: number[];
2040
+ sizes: number[];
2041
+ total: number;
2042
+ }
2043
+ interface XlsxVisibleRange {
2044
+ startIndex: number;
2045
+ endIndex: number;
2046
+ startOffset: number;
2047
+ }
2048
+ interface XlsxGridLayout {
2049
+ rowHeaderWidth: number;
2050
+ columnHeaderHeight: number;
2051
+ bodyWidth: number;
2052
+ bodyHeight: number;
2053
+ rowMetrics: XlsxSizeMetrics;
2054
+ columnMetrics: XlsxSizeMetrics;
2055
+ contentWidth: number;
2056
+ contentHeight: number;
2057
+ maxScrollLeft: number;
2058
+ maxScrollTop: number;
2059
+ /** 冻结行数(从 0 起连续)。 */
2060
+ frozenRows: number;
2061
+ /** 冻结列数(从 0 起连续)。 */
2062
+ frozenColumns: number;
2063
+ /** 冻结行总高度。 */
2064
+ frozenRowsHeight: number;
2065
+ /** 冻结列总宽度。 */
2066
+ frozenColumnsWidth: number;
2067
+ /** 可滚动区宽度(body 减去冻结列)。 */
2068
+ scrollBodyWidth: number;
2069
+ /** 可滚动区高度(body 减去冻结行)。 */
2070
+ scrollBodyHeight: number;
2071
+ }
2072
+ interface XlsxViewportLayout extends XlsxGridLayout {
2073
+ scrollLeft: number;
2074
+ scrollTop: number;
2075
+ /** 滚动区可见行(不含冻结行)。 */
2076
+ visibleRows: XlsxVisibleRange;
2077
+ /** 滚动区可见列(不含冻结列)。 */
2078
+ visibleColumns: XlsxVisibleRange;
2079
+ /** 冻结行范围;无冻结时 endIndex = -1。 */
2080
+ frozenRowRange: XlsxVisibleRange;
2081
+ /** 冻结列范围;无冻结时 endIndex = -1。 */
2082
+ frozenColumnRange: XlsxVisibleRange;
2083
+ }
2084
+ /**
2085
+ * 构建行/列尺寸前缀和。
2086
+ */
2087
+ declare function buildSizeMetrics(params: {
2088
+ count: number;
2089
+ defaultSize: number;
2090
+ customSizes?: Record<number, {
2091
+ width?: number;
2092
+ height?: number;
2093
+ hidden?: boolean;
2094
+ filtered?: boolean;
2095
+ }>;
2096
+ sizeKey: "width" | "height";
2097
+ }): XlsxSizeMetrics;
2098
+ /**
2099
+ * 根据滚动偏移查找可见起止索引。
2100
+ */
2101
+ declare function resolveVisibleRange(params: {
2102
+ metrics: XlsxSizeMetrics;
2103
+ offset: number;
2104
+ viewportSize: number;
2105
+ overscan: number;
2106
+ /** 可见索引起点下限(用于跳过冻结区)。 */
2107
+ minIndex?: number;
2108
+ }): XlsxVisibleRange;
2109
+ /**
2110
+ * 解析并钳制冻结行列数量。
2111
+ */
2112
+ declare function resolveFrozenCounts(params: {
2113
+ sheet: XlsxSheet;
2114
+ rowMetrics: XlsxSizeMetrics;
2115
+ columnMetrics: XlsxSizeMetrics;
2116
+ bodyWidth: number;
2117
+ bodyHeight: number;
2118
+ }): {
2119
+ frozenRows: number;
2120
+ frozenColumns: number;
2121
+ frozenColumnsWidth: number;
2122
+ frozenRowsHeight: number;
2123
+ };
2124
+ /**
2125
+ * 单元格在视口中的左上角坐标(含冻结)。
2126
+ */
2127
+ declare function resolveCellViewportOrigin(layout: Pick<XlsxViewportLayout, "rowHeaderWidth" | "columnHeaderHeight" | "rowMetrics" | "columnMetrics" | "scrollLeft" | "scrollTop" | "frozenRows" | "frozenColumns">, rowIndex: number, columnIndex: number): {
2128
+ x: number;
2129
+ y: number;
2130
+ };
2131
+ /**
2132
+ * 指针 body 坐标映射到内容坐标(含冻结)。
2133
+ */
2134
+ declare function mapPointerToContentOffset(layout: Pick<XlsxViewportLayout, "rowHeaderWidth" | "columnHeaderHeight" | "scrollLeft" | "scrollTop" | "frozenColumnsWidth" | "frozenRowsHeight">, localX: number, localY: number): {
2135
+ contentX: number;
2136
+ contentY: number;
2137
+ bodyX: number;
2138
+ bodyY: number;
2139
+ };
2140
+ /**
2141
+ * 计算 sheet 网格布局。
2142
+ */
2143
+ declare function createGridLayout(params: {
2144
+ sheet: XlsxSheet;
2145
+ viewportWidth: number;
2146
+ viewportHeight: number;
2147
+ defaultRowHeight: number;
2148
+ defaultColumnWidth: number;
2149
+ rowHeaderWidth: number;
2150
+ columnHeaderHeight: number;
2151
+ scrollLeft: number;
2152
+ scrollTop: number;
2153
+ overscanRowCount: number;
2154
+ overscanColumnCount: number;
2155
+ }): XlsxViewportLayout;
2156
+
2157
+ export { type CreateSheetOptions, DEFAULT_COLLABORATOR_COLORS, type DuplicateSheetOptions, FORMULA_RANGE_EXPAND_LIMIT, type FormulaArrayValue, type FormulaCellId, type FormulaDependencyGraph, type FormulaDirtySeed, type FormulaErrorCode, type FormulaEvalResult, type FormulaEvalValue, type FormulaRangeEdge, type FormulaReference, type FormulaSpillParentMeta, type FormulaSpillRangeMeta, MIN_COLUMN_WIDTH, MIN_ROW_HEIGHT, MockCollaborationRoom, MockXlsxCollaborationAdapter, type PasteMatrixOptions, type PasteMatrixRangeResult, WebSocketXlsxCollaborationAdapter, type WebSocketXlsxCollaborationAdapterOptions, XLSX_FORMULA_FUNCTIONS, type XlsxAuthoritativeAccessContext, XlsxAuthoritativeCollaborationRoom, type XlsxAuthoritativePatchAccessContext, type XlsxAuthoritativePatchLogEntry, type XlsxAuthoritativePatchSubmitResult, type XlsxAuthoritativePresenceAccessContext, type XlsxAuthoritativePresenceSubmitResult, type XlsxAuthoritativeRejectedPatch, type XlsxAuthoritativeRoomOptions, type XlsxCell, type XlsxCellAddress, type XlsxCellBorderLine, type XlsxCellBorderLineStyle, type XlsxCellBorderPreset, type XlsxCellBorders, type XlsxCellRange, type XlsxCellStyle, type XlsxCellType, type XlsxCellValue, type XlsxClipboardMatrix, type XlsxClipboardOptions, type XlsxCollaborationAdapter, type XlsxCollaborationOptions, type XlsxCollaborator, type XlsxCollapsedColumnMarker, type XlsxCollapsedRowMarker, type XlsxColumnConfig, type XlsxColumnFilterState, type XlsxContextMenuRequest, type XlsxContextMenuTarget, type XlsxEditingDraft, type XlsxEditorNavigateDirection, type XlsxEditorRect, type XlsxEditorRequest, type XlsxEditorTheme, type XlsxFillMode, type XlsxFillOptions, type XlsxFilterCondition, type XlsxFilterConditionOperator, type XlsxFilterConditionRelation, type XlsxFilterOptionItem, type XlsxFilterOptionKind, type XlsxFilterOptionValue, type XlsxFilterSelection, type XlsxFilterSpecialOptionValue, type XlsxFilterValue, type XlsxFormulaAutocompleteOptions, type XlsxFormulaBarState, type XlsxFormulaCompletionKind, type XlsxFormulaCompletionSuggestion, type XlsxFormulaDependencyDebugEdge, type XlsxFormulaDependencyDebugNode, type XlsxFormulaDependencyDebugRangeEdge, type XlsxFormulaDependencyDebugSnapshot, type XlsxFormulaValidationResult, type XlsxFrozenPane, type XlsxGridLayout, type XlsxHeaderActionType, XlsxHistoryStack, type XlsxHistoryState, type XlsxMergedRange, type XlsxNamedRange, type XlsxPatch, type XlsxPatchAckPayload, type XlsxPatchConflict, XlsxPresenceState, type XlsxRemoteSelection, type XlsxRowConfig, type XlsxSelectionState, type XlsxServerConflictPolicy, type XlsxServerPatchConflict, type XlsxServerTransformOptions, type XlsxServerTransformResult, type XlsxSheet, type XlsxSheetFilterState, type XlsxSheetSortState, type XlsxSizeMetrics, type XlsxSortDirection, XlsxTable, type XlsxTableContextMenuRequest, type XlsxTableContextMenuTarget, type XlsxTableCreateSheetOptions, type XlsxTableDuplicateSheetOptions, type XlsxTableEditMode, type XlsxTableEditorNavigateDirection, type XlsxTableEditorRect, type XlsxTableEditorRequest, type XlsxTableEditorTheme, type XlsxTableExportFormat, type XlsxTableExportOptions, type XlsxTableFilterConditionParams, type XlsxTableFormulaBarSnapshot, type XlsxTableFormulaBarState, type XlsxTableFormulaDependencySnapshot, type XlsxTableHeaderActionType, type XlsxTableHistorySnapshot, type XlsxTableOptions, type XlsxTablePresenceRecord, type XlsxTableSelectionSnapshot, type XlsxTableTheme, type XlsxTableWorkbookSnapshot, type XlsxViewportLayout, type XlsxVisibilitySheetLike, type XlsxVisibleIndexFallback, type XlsxVisibleNavigationDirection, type XlsxVisibleRange, type XlsxWebSocketConstructor, type XlsxWebSocketLike, type XlsxWorkbook, type XlsxWorkbookValidationIssue, type XlsxWorkbookValidationResult, type XlsxWsClientMessage, type XlsxWsJoinMessage, type XlsxWsPatchAckMessage, type XlsxWsPatchMessage, type XlsxWsPresenceMessage, type XlsxWsServerMessage, addSheet, addressToA1, appendSelectionRange, applyAutoFill, applyCopyFill, applyFormulaAutocompleteSuggestion, applyMatrixToSheet, applyPatch, applySeriesFill, applySheetColumnConditionFilter, applySheetColumnOptionFilter, applySheetColumnValueFilter, buildFormulaDependencyGraph, buildSizeMetrics, buildXlsxSheetExportData, canMergeSheetRange, canUnmergeSheetRange, cellKeysToSeeds, clampAddress, clampColumnWidth, clampRowHeight, clearRangeOnSheet, clearSheetColumnFilter, clearSheetFilters, clearSheetRangesCellStyle, clearSheetRangesCellStyleKeys, clearSheetSort, collectVolatileFormulaSeeds, collectWorkbookDirtySeeds, columnIndexToName, columnNameToIndex, createCellPatch, createColumnRange, createColumnVisibilityPatch, createEmptySheet, createFormulaDependencyDebugSnapshot, createGridLayout, createRangeFromAddresses, createResizePatch, createRowRange, createRowVisibilityPatch, createSheetCellsPatch, createSheetFrozenPanePatch, createSheetId, createSheetRange, createVisibleRangeFromAddresses, decodeCollaborationMessage, defaultXlsxTableTheme, deleteSheetColumns, deleteSheetRows, duplicateSheet, encodeCollaborationMessage, evaluateCellFormula, evaluateCellValue, evaluateExpression, evaluateFilterCondition, expandRangeToMergedCells, exportXlsxSheet, extractFormulaReferences, extractRangeMatrix, findMergedCellRange, findNamedRange, findSheetById, formatFormulaValue, getCellKey, getFormulaAutocompleteSuggestions, getOverlappingCellKeys, getPrimaryRange, getRangeCellCount, getSheetColumnFilterOptions, hasFormula, hasVolatileFormula, insertSheetColumns, insertSheetRows, isAddressInRange, isFormulaArrayValue, isFullSheetRange, isSameAddress, isSameRange, isSheetIndexHidden, isValidNamedRangeName, listNamedRanges, mapPointerToContentOffset, mergeSheetRange, moveSheet, normalizeRange, parseCellInputText, parseCellKey, parseFormulaCellId, parseTsv, reapplySheetFilters, recalculateSheetFormulas, recalculateWorkbookFormulas, recalculateWorkbookFormulasIncremental, removeNamedRange, removeNamedRangesForSheet, removeSheet, renameSheet, replaceWorkbookSheet, resolveActiveSheet, resolveActiveSheetId, resolveCellDisplayText, resolveCellEditText, resolveCellViewportOrigin, resolveCollaboratorColor, resolveCollapsedColumnMarkers, resolveCollapsedRowMarkers, resolveFillTargetRange, resolveFilterSelectionFromOptionValues, resolveFrozenCounts, resolveNamedRangeRef, resolveNextVisibleAddress, resolveNextVisibleIndex, resolvePasteMatrixRange, resolvePatchConflict, resolveUsedRange, resolveVisibleAddress, resolveVisibleIndex, resolveVisibleRange, resolveXlsxTableTheme, restoreSheetColumnsRange, restoreSheetRowsRange, searchSheetFilterOptions, serializeTsv, setActiveSheet, setSheetColumnWidth, setSheetColumnsHidden, setSheetFrozenPane, setSheetRangesCellBorder, setSheetRangesCellStyle, setSheetRangesCellType, setSheetRowHeight, setSheetRowsHidden, sortSheetRowsByColumn, stampServerAcceptedPatch, toFormulaCellId, toFormulaScalarValue, transformPatchAgainstCommitted, transformRemoteAgainstPending, unmergeSheetRange, upsertNamedRange, validateXlsxFormulaInput, validateXlsxWorkbook };