@univerjs/sheets 0.5.1 → 0.5.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.
Files changed (34) hide show
  1. package/lib/cjs/facade.js +1 -1
  2. package/lib/cjs/index.js +3 -3
  3. package/lib/es/facade.js +1959 -500
  4. package/lib/es/index.js +3640 -3263
  5. package/lib/types/basics/cell-position.d.ts +25 -0
  6. package/lib/types/basics/index.d.ts +1 -0
  7. package/lib/types/basics/selection.d.ts +1 -1
  8. package/lib/types/basics/split-range-text.d.ts +42 -0
  9. package/lib/types/commands/commands/__tests__/set-gridlines-command.spec.d.ts +16 -0
  10. package/lib/types/commands/commands/add-worksheet-merge.command.d.ts +1 -1
  11. package/lib/types/commands/commands/set-gridlines-color.command.d.ts +7 -0
  12. package/lib/types/commands/commands/set-worksheet-show.command.d.ts +0 -1
  13. package/lib/types/commands/commands/split-text-to-columns.command.d.ts +15 -0
  14. package/lib/types/commands/mutations/set-gridlines-color.mutation.d.ts +12 -0
  15. package/lib/types/controllers/defined-name-data.controller.d.ts +1 -0
  16. package/lib/types/facade/f-defined-name.d.ts +294 -0
  17. package/lib/types/facade/f-permission.d.ts +49 -1
  18. package/lib/types/facade/f-range.d.ts +96 -5
  19. package/lib/types/facade/f-selection.d.ts +71 -1
  20. package/lib/types/facade/f-univer.d.ts +17 -3
  21. package/lib/types/facade/f-workbook.d.ts +345 -7
  22. package/lib/types/facade/f-worksheet.d.ts +350 -11
  23. package/lib/types/index.d.ts +13 -2
  24. package/lib/types/services/__tests__/move-active-cell.spec.d.ts +16 -0
  25. package/lib/types/services/exclusive-range/exclusive-range-service.d.ts +12 -0
  26. package/lib/types/services/permission/permission-point/const.d.ts +82 -0
  27. package/lib/types/services/ref-range/util.d.ts +1 -1
  28. package/lib/types/services/selections/index.d.ts +1 -1
  29. package/lib/types/services/selections/move-active-cell-util.d.ts +10 -0
  30. package/lib/types/services/selections/selection-data-model.d.ts +5 -10
  31. package/lib/types/services/selections/selection.service.d.ts +21 -1
  32. package/lib/umd/facade.js +1 -1
  33. package/lib/umd/index.js +3 -3
  34. package/package.json +8 -8
@@ -1,11 +1,81 @@
1
- import { Workbook, Worksheet, Injector } from '@univerjs/core';
1
+ import { Direction, ISelectionCell, Nullable, Workbook, Worksheet, Injector } from '@univerjs/core';
2
2
  import { ISelectionWithStyle } from '@univerjs/sheets';
3
3
  import { FRange } from './f-range';
4
+ import { FWorksheet } from './f-worksheet';
5
+ /**
6
+ * @description Represents the active selection in the sheet.
7
+ * @example
8
+ * ```ts
9
+ * const fWorkbook = univerAPI.getActiveWorkbook()
10
+ * const fWorksheet = fWorkbook.getActiveSheet()
11
+ * const fSelection = fWorksheet.getSelection();
12
+ * const activeRange = fSelection.getActiveRange();
13
+ * console.log(activeRange);
14
+ * ```
15
+ */
4
16
  export declare class FSelection {
5
17
  private readonly _workbook;
6
18
  private readonly _worksheet;
7
19
  private readonly _selections;
8
20
  private readonly _injector;
9
21
  constructor(_workbook: Workbook, _worksheet: Worksheet, _selections: Readonly<ISelectionWithStyle[]>, _injector: Injector);
22
+ /**
23
+ * Represents the active selection in the sheet. Which means the selection contains the active cell.
24
+ * @returns {FRange | null} The active selection.
25
+ */
10
26
  getActiveRange(): FRange | null;
27
+ /**
28
+ * Represents the active selection list in the sheet.
29
+ * @returns {FRange[]} The active selection list.
30
+ */
31
+ getActiveRangeList(): FRange[];
32
+ /**
33
+ * Represents the current select cell in the sheet.
34
+ * @returns {ISelectionCell} The current select cell info.Pay attention to the type of the return value.
35
+ */
36
+ getCurrentCell(): Nullable<ISelectionCell>;
37
+ /**
38
+ * Returns the active sheet in the spreadsheet.
39
+ * @returns {FWorksheet} The active sheet in the spreadsheet.
40
+ * @example
41
+ * ```ts
42
+ * const fWorkbook = univerAPI.getActiveWorkbook();
43
+ * const fWorksheet = fWorkbook.getActiveSheet();
44
+ * const fSelection = fWorksheet.getSelection();
45
+ * const activeSheet = fSelection.getActiveSheet();
46
+ * console.log(activeSheet.equalTo(fWorksheet)); // true
47
+ * ```
48
+ */
49
+ getActiveSheet(): FWorksheet;
50
+ /**
51
+ * Update the primary cell in the selection. if the primary cell not exists in selections, add it to the selections and clear the old selections.
52
+ * @param {FRange} cell The new primary cell to update.
53
+ * @returns {FSelection} The new selection after updating the primary cell.Because the selection is immutable, the return value is a new selection.
54
+ * @example
55
+ * ```ts
56
+ * const fWorkbook = univerAPI.getActiveWorkbook();
57
+ * const fWorksheet = fWorkbook.getActiveSheet();
58
+ * const fSelection = fWorksheet.getSelection();
59
+ * const cell = fWorksheet.getCell('A1');
60
+ * const newSelection = fSelection.updatePrimaryCell(cell);
61
+ * console.log(newSelection.getActiveRange().getA1Notation()); // A1
62
+ * ```
63
+ */
64
+ updatePrimaryCell(cell: FRange): Promise<FSelection>;
65
+ /**
66
+ *Get the next primary cell in the specified direction. If the primary cell not exists in selections, return null.
67
+ * @param {Direction} direction The direction to move the primary cell.The enum value is maybe one of the following: UP(0),RIGHT(1), DOWN(2), LEFT(3).
68
+ * @returns {FRange | null} The next primary cell in the specified direction.
69
+ * @example
70
+ * ```ts
71
+ * // import { Direction } from '@univerjs/core';
72
+ * const fWorkbook = univerAPI.getActiveWorkbook();
73
+ * const fWorksheet = fWorkbook.getActiveSheet();
74
+ * // make sure the active cell is A1 and selection is A1:C3
75
+ * const fSelection = fWorksheet.getSelection();
76
+ * const nextCell = fSelection.getNextDataRange(Direction.RIGHT);
77
+ * console.log(nextCell?.getA1Notation()); // B1
78
+ * ```
79
+ */
80
+ getNextDataRange(direction: Direction): FRange | null;
11
81
  }
@@ -1,4 +1,5 @@
1
- import { IWorkbookData, FUniver } from '@univerjs/core';
1
+ import { IDisposable, IWorkbookData, FUniver } from '@univerjs/core';
2
+ import { FDefinedNameBuilder } from './f-defined-name';
2
3
  import { FPermission } from './f-permission';
3
4
  import { FWorkbook } from './f-workbook';
4
5
  export interface IFUniverSheetsMixin {
@@ -24,15 +25,28 @@ export interface IFUniverSheetsMixin {
24
25
  getUniverSheet(id: string): FWorkbook | null;
25
26
  /**
26
27
  * Get the PermissionInstance.
27
- *
28
+ * @deprecated This function is deprecated and will be removed in version 0.6.0.
29
+ * Please use the function with the same name on the `FWorkbook` instance instead.
28
30
  * @returns {FPermission} - The PermissionInstance.
29
31
  */
30
32
  getPermission(): FPermission;
33
+ /**
34
+ * Register a callback that will be triggered when a Univer Sheet is created.
35
+ */
36
+ onUniverSheetCreated(callback: (workbook: FWorkbook) => void): IDisposable;
37
+ /**
38
+ * Create a new defined name builder.
39
+ * @returns {FDefinedNameBuilder} - The defined name builder.
40
+ */
41
+ newDefinedName(): FDefinedNameBuilder;
31
42
  }
32
- export declare class FUniverSheetsMixin extends FUniver {
43
+ export declare class FUniverSheetsMixin extends FUniver implements IFUniverSheetsMixin {
33
44
  createUniverSheet(data: Partial<IWorkbookData>): FWorkbook;
34
45
  getActiveWorkbook(): FWorkbook | null;
46
+ getUniverSheet(id: string): FWorkbook | null;
35
47
  getPermission(): FPermission;
48
+ onUniverSheetCreated(callback: (workbook: FWorkbook) => void): IDisposable;
49
+ newDefinedName(): FDefinedNameBuilder;
36
50
  }
37
51
  declare module '@univerjs/core' {
38
52
  interface FUniver extends IFUniverSheetsMixin {
@@ -1,5 +1,8 @@
1
- import { CommandListener, IDisposable, IRange, IWorkbookData, Workbook, FBase, ICommandService, ILogService, Injector, IPermissionService, IResourceLoaderService, IUniverInstanceService } from '@univerjs/core';
1
+ import { CommandListener, IDisposable, IRange, IWorkbookData, LocaleType, Workbook, FBase, ICommandService, ILogService, Injector, IPermissionService, IResourceLoaderService, IUniverInstanceService, LocaleService } from '@univerjs/core';
2
+ import { ISetDefinedNameMutationParam, IDefinedNamesService } from '@univerjs/engine-formula';
2
3
  import { SheetsSelectionsService } from '@univerjs/sheets';
4
+ import { FDefinedName } from './f-defined-name';
5
+ import { FPermission } from './f-permission';
3
6
  import { FRange } from './f-range';
4
7
  import { FWorksheet } from './f-worksheet';
5
8
  export declare class FWorkbook extends FBase {
@@ -11,28 +14,80 @@ export declare class FWorkbook extends FBase {
11
14
  protected readonly _commandService: ICommandService;
12
15
  protected readonly _permissionService: IPermissionService;
13
16
  protected readonly _logService: ILogService;
17
+ protected readonly _localeService: LocaleService;
18
+ protected readonly _definedNamesService: IDefinedNamesService;
14
19
  readonly id: string;
15
- constructor(_workbook: Workbook, _injector: Injector, _resourceLoaderService: IResourceLoaderService, _selectionManagerService: SheetsSelectionsService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _permissionService: IPermissionService, _logService: ILogService);
20
+ constructor(_workbook: Workbook, _injector: Injector, _resourceLoaderService: IResourceLoaderService, _selectionManagerService: SheetsSelectionsService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _permissionService: IPermissionService, _logService: ILogService, _localeService: LocaleService, _definedNamesService: IDefinedNamesService);
21
+ /**
22
+ * Get the id of the workbook.
23
+ * @returns {string} The id of the workbook.
24
+ * @example
25
+ * ```ts
26
+ * // The code below gets the id of the workbook
27
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
28
+ * const id = activeSpreadsheet.getId();
29
+ * ```
30
+ */
16
31
  getId(): string;
32
+ /**
33
+ * Get the name of the workbook.
34
+ * @returns {string} The name of the workbook.
35
+ * @example
36
+ * ```ts
37
+ * // The code below gets the name of the workbook
38
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
39
+ * const name = activeSpreadsheet.getName();
40
+ * ```
41
+ */
17
42
  getName(): string;
43
+ /**
44
+ * Set the name of the workbook.
45
+ * @param {string} name The new name of the workbook.
46
+ * @example
47
+ * ```ts
48
+ * // The code below sets the name of the workbook
49
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
50
+ * activeSpreadsheet.setName('MyWorkbook');
51
+ * ```
52
+ */
53
+ setName(name: string): void;
18
54
  /**
19
55
  * save workbook snapshot data, including conditional formatting, data validation, and other plugin data.
56
+ * @return Workbook snapshot data
57
+ * @example
58
+ * ```ts
59
+ * // The code below saves the workbook snapshot data
60
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
61
+ * const snapshot = activeSpreadsheet.save();
62
+ * ```
20
63
  */
21
64
  save(): IWorkbookData;
22
65
  /**
23
66
  * @deprecated use 'save' instead.
24
- * @return {*} {IWorkbookData}
67
+ * @return {*} {IWorkbookData} Workbook snapshot data
25
68
  * @memberof FWorkbook
26
69
  */
27
70
  getSnapshot(): IWorkbookData;
28
71
  /**
29
72
  * Get the active sheet of the workbook.
30
73
  * @returns The active sheet of the workbook
74
+ * @example
75
+ * ```ts
76
+ * // The code below gets the active sheet of the workbook
77
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
78
+ * const activeSheet = activeSpreadsheet.getActiveSheet();
79
+ * ```
31
80
  */
32
81
  getActiveSheet(): FWorksheet;
33
82
  /**
34
83
  * Gets all the worksheets in this workbook
35
84
  * @returns An array of all the worksheets in the workbook
85
+ * @example
86
+ * ```ts
87
+ * // The code below gets all the worksheets in the workbook
88
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
89
+ * const sheets = activeSpreadsheet.getSheets();
90
+ * ```
36
91
  */
37
92
  getSheets(): FWorksheet[];
38
93
  /**
@@ -41,51 +96,150 @@ export declare class FWorkbook extends FBase {
41
96
  * @param rows How may rows would the new sheet have
42
97
  * @param column How many columns would the new sheet have
43
98
  * @returns The new created sheet
99
+ * @example
100
+ * ```ts
101
+ * // The code below creates a new sheet
102
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
103
+ * const newSheet = activeSpreadsheet.create('MyNewSheet', 10, 10);
104
+ * ```
44
105
  */
45
106
  create(name: string, rows: number, column: number): FWorksheet;
46
107
  /**
47
108
  * Get a worksheet by sheet id.
48
109
  * @param sheetId The id of the sheet to get.
49
110
  * @return The worksheet with given sheet id
111
+ * @example
112
+ * ```ts
113
+ * // The code below gets a worksheet by sheet id
114
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
115
+ * const sheet = activeSpreadsheet.getSheetBySheetId('sheetId');
116
+ * ```
50
117
  */
51
118
  getSheetBySheetId(sheetId: string): FWorksheet | null;
52
119
  /**
53
120
  * Get a worksheet by sheet name.
54
121
  * @param name The name of the sheet to get.
55
122
  * @returns The worksheet with given sheet name
123
+ * @example
124
+ * ```ts
125
+ * // The code below gets a worksheet by sheet name
126
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
127
+ * const sheet = activeSpreadsheet.getSheetByName('Sheet1');
128
+ * ```
56
129
  */
57
130
  getSheetByName(name: string): FWorksheet | null;
58
131
  /**
59
132
  * Sets the given worksheet to be the active worksheet in the workbook.
60
133
  * @param sheet The worksheet to set as the active worksheet.
61
134
  * @returns The active worksheet
135
+ * @example
136
+ * ```ts
137
+ * // The code below sets the given worksheet to be the active worksheet
138
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
139
+ * const sheet = activeSpreadsheet.getSheetByName('Sheet1');
140
+ * activeSpreadsheet.setActiveSheet(sheet);
141
+ * ```
62
142
  */
63
143
  setActiveSheet(sheet: FWorksheet): FWorksheet;
64
144
  /**
65
145
  * Inserts a new worksheet into the workbook.
66
146
  * Using a default sheet name. The new sheet becomes the active sheet
147
+ * @param sheetName - (optional) The name of the new sheet
67
148
  * @returns The new sheet
149
+ * @example
150
+ * ```ts
151
+ * // The code below inserts a new sheet into the workbook
152
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
153
+ * activeSpreadsheet.insertSheet();
154
+ *
155
+ * // The code below inserts a new sheet into the workbook, using a custom name
156
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
157
+ * activeSpreadsheet.insertSheet('MyNewSheet');
158
+ * ```
68
159
  */
69
- insertSheet(): FWorksheet;
160
+ insertSheet(sheetName?: string): FWorksheet;
70
161
  /**
71
162
  * Deletes the specified worksheet.
72
163
  * @param sheet The worksheet to delete.
164
+ * @example
165
+ * ```ts
166
+ * // The code below deletes the specified worksheet
167
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
168
+ * const sheet = activeSpreadsheet.getSheetByName('Sheet1');
169
+ * activeSpreadsheet.deleteSheet(sheet);
170
+ * ```
171
+ */
172
+ deleteSheet(sheet: FWorksheet): Promise<boolean>;
173
+ /**
174
+ * Undo the last action.
175
+ * @returns A promise that resolves to true if the undo was successful, false otherwise.
176
+ * @example
177
+ * ```ts
178
+ * // The code below undoes the last action
179
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
180
+ * activeSpreadsheet.undo();
181
+ * ```
73
182
  */
74
- deleteSheet(sheet: FWorksheet): void;
75
183
  undo(): Promise<boolean>;
184
+ /**
185
+ * Redo the last undone action.
186
+ * @returns A promise that resolves to true if the redo was successful, false otherwise.
187
+ * @example
188
+ * ```ts
189
+ * // The code below redoes the last undone action
190
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
191
+ * activeSpreadsheet.redo();
192
+ * ```
193
+ */
76
194
  redo(): Promise<boolean>;
195
+ /**
196
+ * Callback for command execution.
197
+ * @callback onBeforeCommandExecuteCallback
198
+ * @param {ICommandInfo<ISheetCommandSharedParams>} command The command that was executed.
199
+ */
77
200
  /**
78
201
  * Register a callback that will be triggered before invoking a command targeting the Univer sheet.
79
- * @param callback the callback.
202
+ * @param {onBeforeCommandExecuteCallback} callback the callback.
80
203
  * @returns A function to dispose the listening.
204
+ * @example
205
+ * ```ts
206
+ * // The code below registers a callback that will be triggered before invoking a command targeting the Univer sheet
207
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
208
+ * activeSpreadsheet.onBeforeCommandExecute((command) => {
209
+ * console.log('Command executed:', command);
210
+ * });
211
+ * ```
81
212
  */
82
213
  onBeforeCommandExecute(callback: CommandListener): IDisposable;
214
+ /**
215
+ * Callback for command execution.
216
+ * @callback onCommandExecutedCallback
217
+ * @param {ICommandInfo<ISheetCommandSharedParams>} command The command that was executed
218
+ */
83
219
  /**
84
220
  * Register a callback that will be triggered when a command is invoked targeting the Univer sheet.
85
- * @param callback the callback.
221
+ * @param {onCommandExecutedCallback} callback the callback.
86
222
  * @returns A function to dispose the listening.
223
+ * @example
224
+ * ```ts
225
+ * // The code below registers a callback that will be triggered when a command is invoked targeting the Univer sheet
226
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
227
+ * activeSpreadsheet.onCommandExecuted((command) => {
228
+ * console.log('Command executed:', command);
229
+ * });
87
230
  */
88
231
  onCommandExecuted(callback: CommandListener): IDisposable;
232
+ /**
233
+ * Callback for selection changes.
234
+ *
235
+ * @callback onSelectionChangeCallback
236
+ * @param {IRange[]} selections The new selection.
237
+ */
238
+ /**
239
+ * Register a callback that will be triggered when the selection changes.
240
+ * @param {onSelectionChangeCallback} callback The callback.
241
+ * @returns A function to dispose the listening
242
+ */
89
243
  onSelectionChange(callback: (selections: IRange[]) => void): IDisposable;
90
244
  /**
91
245
  * Used to modify the editing permissions of the workbook. When the value is false, editing is not allowed.
@@ -102,4 +256,188 @@ export declare class FWorkbook extends FBase {
102
256
  * @returns the active range
103
257
  */
104
258
  getActiveRange(): FRange | null;
259
+ /**
260
+ * Deletes the currently active sheet.
261
+ * @example
262
+ * ```ts
263
+ * // The code below deletes the currently active sheet and stores the new active
264
+ * // sheet in a variable
265
+ * const sheet = univerAPI.getActiveWorkbook().deleteActiveSheet();
266
+ * ```
267
+ */
268
+ deleteActiveSheet(): Promise<boolean>;
269
+ /**
270
+ * Duplicates the given worksheet.
271
+ * @param {FWorksheet} sheet The worksheet to duplicate.
272
+ * @returns {Promise<boolean>} true if the sheet was duplicated, false otherwise
273
+ * @example
274
+ * ```ts
275
+ * // The code below duplicates the given worksheet
276
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
277
+ * const activeSheet = activeSpreadsheet.getActiveSheet();
278
+ * activeSpreadsheet.duplicateSheet(activeSheet);
279
+ * ```
280
+ */
281
+ duplicateSheet(sheet: FWorksheet): Promise<boolean>;
282
+ /**
283
+ * Duplicates the active sheet.
284
+ * @returns {Promise<boolean>} true if the sheet was duplicated, false otherwise
285
+ * @example
286
+ * ```ts
287
+ * // The code below duplicates the active sheet
288
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
289
+ * activeSpreadsheet.duplicateActiveSheet();
290
+ * ```
291
+ */
292
+ duplicateActiveSheet(): Promise<boolean>;
293
+ /**
294
+ * Get the number of sheets in the workbook.
295
+ * @returns The number of sheets in the workbook
296
+ * @example
297
+ * ```ts
298
+ * // The code below gets the number of sheets in the workbook
299
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
300
+ * const numSheets = activeSpreadsheet.getNumSheets();
301
+ * ```
302
+ */
303
+ getNumSheets(): number;
304
+ /**
305
+ * Get the locale of the workbook.
306
+ * @returns {LocaleType} The locale of the workbook
307
+ * @example
308
+ * ```ts
309
+ * // The code below gets the locale of the workbook
310
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
311
+ * const locale = activeSpreadsheet.getLocale();
312
+ * ```
313
+ */
314
+ getLocale(): LocaleType;
315
+ /**
316
+ * Set the locale of the workbook.
317
+ * @param {LocaleType} locale The locale to set
318
+ * @example
319
+ * ```ts
320
+ * // The code below sets the locale of the workbook
321
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
322
+ * activeSpreadsheet.setLocale(LocaleType.EN_US);
323
+ * ```
324
+ */
325
+ setLocale(locale: LocaleType): void;
326
+ /**
327
+ * Get the URL of the workbook.
328
+ * @returns {string} The URL of the workbook
329
+ * @example
330
+ * ```ts
331
+ * // The code below gets the URL of the workbook
332
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
333
+ * const url = activeSpreadsheet.getUrl();
334
+ * ```
335
+ */
336
+ getUrl(): string;
337
+ /**
338
+ * Move the sheet to the specified index.
339
+ * @param {FWorksheet} sheet The sheet to move
340
+ * @param {number} index The index to move the sheet to
341
+ * @returns {Promise<boolean>} true if the sheet was moved, false otherwise
342
+ * @example
343
+ * ```ts
344
+ * // The code below moves the sheet to the specified index
345
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
346
+ * const sheet = activeSpreadsheet.getActiveSheet();
347
+ * activeSpreadsheet.moveSheet(sheet, 1);
348
+ * ```
349
+ */
350
+ moveSheet(sheet: FWorksheet, index: number): Promise<boolean>;
351
+ /**
352
+ * Move the active sheet to the specified index.
353
+ * @param {number} index The index to move the active sheet to
354
+ * @returns {Promise<boolean>} true if the sheet was moved, false otherwise
355
+ * @example
356
+ * ```ts
357
+ * // The code below moves the active sheet to the specified index
358
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
359
+ * activeSpreadsheet.moveActiveSheet(1);
360
+ * ```
361
+ */
362
+ moveActiveSheet(index: number): Promise<boolean>;
363
+ /**
364
+ * Get the PermissionInstance.
365
+ *
366
+ * @returns {FPermission} - The PermissionInstance.
367
+ */
368
+ getPermission(): FPermission;
369
+ /**
370
+ * Get the defined name by name.
371
+ * @param {string} name The name of the defined name to get
372
+ * @returns {FDefinedName | null} The defined name with the given name
373
+ * @example
374
+ * ```ts
375
+ * // The code below gets the defined name by name
376
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
377
+ * const definedName = activeSpreadsheet.getDefinedName('MyDefinedName');
378
+ * ```
379
+ */
380
+ getDefinedName(name: string): FDefinedName | null;
381
+ /**
382
+ * Get all the defined names in the workbook.
383
+ * @returns {FDefinedName[]} All the defined names in the workbook
384
+ * @example
385
+ * ```ts
386
+ * // The code below gets all the defined names in the workbook
387
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
388
+ * const definedNames = activeSpreadsheet.getDefinedNames();
389
+ * ```
390
+ */
391
+ getDefinedNames(): FDefinedName[];
392
+ /**
393
+ * Insert a defined name.
394
+ * @param {string} name The name of the defined name to insert
395
+ * @param {string} formulaOrRefString The formula(=sum(A2:b10)) or reference(A1) string of the defined name to insert
396
+ * @example
397
+ * ```ts
398
+ * // The code below inserts a defined name
399
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
400
+ * activeSpreadsheet.insertDefinedName('MyDefinedName', 'Sheet1!A1');
401
+ * ```
402
+ */
403
+ insertDefinedName(name: string, formulaOrRefString: string): void;
404
+ /**
405
+ * Delete the defined name with the given name.
406
+ * @param {string} name The name of the defined name to delete
407
+ * @returns {boolean} true if the defined name was deleted, false otherwise
408
+ * @example
409
+ * ```ts
410
+ * // The code below deletes the defined name with the given name
411
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
412
+ * const deleted = activeSpreadsheet.deleteDefinedName('MyDefinedName');
413
+ * ```
414
+ */
415
+ deleteDefinedName(name: string): boolean;
416
+ /**
417
+ * insert a defined name by builder param
418
+ * @param {ISetDefinedNameMutationParam} param The param to insert the defined name
419
+ * @example
420
+ * ```ts
421
+ * // The code below inserts a defined name by builder param
422
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
423
+ * const builder = univerAPI.newDefinedName();
424
+ * const param = builder.setName('MyDefinedName').setRef('Sheet1!A1').build();
425
+ * activeSpreadsheet.insertDefinedNameBuilder(param);
426
+ * ```
427
+ */
428
+ insertDefinedNameBuilder(param: ISetDefinedNameMutationParam): void;
429
+ /**
430
+ * Update the defined name with the given name.
431
+ * @param {ISetDefinedNameMutationParam} param The param to insert the defined name
432
+ * @example
433
+ * ```ts
434
+ * // The code below updates the defined name with the given name
435
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
436
+ * const builder = activeSpreadsheet.getDefinedName('MyDefinedName').toBuilder();
437
+ * builder.setRef('Sheet1!A2').setName('MyDefinedName1').build();
438
+ * activeSpreadsheet.updateDefinedNameBuilder(param);
439
+ *
440
+ * ```
441
+ */
442
+ updateDefinedNameBuilder(param: ISetDefinedNameMutationParam): void;
105
443
  }