@univerjs/sheets 0.5.4 → 0.5.5-nightly.202501201336
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +3 -3
- package/lib/es/facade.js +2021 -1010
- package/lib/es/index.js +2214 -1996
- package/lib/types/basics/const/command-listener-const.d.ts +149 -13
- package/lib/types/commands/commands/remove-sheet.command.d.ts +1 -1
- package/lib/types/commands/commands/split-text-to-columns.command.d.ts +1 -1
- package/lib/types/commands/operations/selection.operation.d.ts +1 -0
- package/lib/types/commands/utils/selection-command-util.d.ts +1 -1
- package/lib/types/controllers/config.schema.d.ts +4 -0
- package/lib/types/facade/f-enum.d.ts +21 -0
- package/lib/types/facade/f-event.d.ts +470 -21
- package/lib/types/facade/f-range.d.ts +363 -51
- package/lib/types/facade/f-selection.d.ts +24 -0
- package/lib/types/facade/f-univer.d.ts +30 -0
- package/lib/types/facade/f-workbook.d.ts +44 -55
- package/lib/types/facade/f-worksheet.d.ts +652 -208
- package/lib/types/facade/index.d.ts +2 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/model/range-theme-util.d.ts +3 -3
- package/lib/types/services/selections/selection-data-model.d.ts +7 -7
- package/lib/types/services/selections/selection.service.d.ts +4 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +3 -3
- package/package.json +6 -6
- package/LICENSE +0 -176
package/lib/es/facade.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Inject as u, Injector as
|
|
5
|
-
import { WorksheetProtectionRuleModel as
|
|
6
|
-
import { IDefinedNamesService as
|
|
7
|
-
var
|
|
8
|
-
for (var
|
|
9
|
-
(
|
|
10
|
-
return n &&
|
|
11
|
-
},
|
|
12
|
-
function
|
|
13
|
-
const n = t.getDefinedNameMap(
|
|
1
|
+
var Ge = Object.defineProperty;
|
|
2
|
+
var qe = (r, e, t) => e in r ? Ge(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var b = (r, e, t) => qe(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Inject as u, Injector as y, IAuthzIoService as Ne, LocaleService as Te, ICommandService as l, IPermissionService as ae, generateRandomId as Me, FBase as de, Rectangle as M, HorizontalAlign as U, VerticalAlign as P, isFormulaString as Ke, isCellV as Ye, isICellData as Je, ObjectMatrix as W, Tools as Qe, RANGE_TYPE as _, FBaseInitialable as ce, TextStyleValue as le, RichTextValue as E, BooleanNumber as g, WrapStrategy as Y, Dimension as me, ILogService as De, Direction as D, IResourceLoaderService as Xe, mergeWorksheetSnapshotWithDefault as Ze, UndoCommand as et, RedoCommand as tt, toDisposable as Ae, UniverInstanceType as p, IUniverInstanceService as J, FUniver as Be, CanceledError as nt, FEnum as rt, FEventName as We } from "@univerjs/core";
|
|
5
|
+
import { WorksheetProtectionRuleModel as Fe, RangeProtectionRuleModel as je, WorksheetProtectionPointModel as Oe, SetDefinedNameCommand as Q, SCOPE_WORKBOOK_VALUE_DEFINED_NAME as X, RemoveDefinedNameCommand as st, PermissionPointsDefinitions as it, WorkbookEditablePermission as Le, UnitObject as x, AddWorksheetProtectionMutation as ot, DeleteWorksheetProtectionMutation as ht, getAllWorksheetPermissionPoint as at, getAllWorksheetPermissionPointByPointPanel as _e, SetWorksheetPermissionPointsMutation as dt, AddRangeProtectionMutation as ct, DeleteRangeProtectionMutation as ut, SetRangeProtectionMutation as gt, WorksheetEditPermission as lt, WorksheetViewPermission as mt, SetBorderBasicCommand as _t, SetStyleCommand as I, SetRangeValuesCommand as N, SetTextWrapCommand as Z, SetVerticalTextAlignCommand as kt, SetHorizontalTextAlignCommand as St, addMergeCellsUtil as H, getAddMergeMutationRangeByType as ke, RemoveWorksheetMergeCommand as wt, SplitTextToColumnsCommand as Ct, SetWorksheetRangeThemeStyleCommand as ft, DeleteWorksheetRangeThemeStyleCommand as vt, SheetRangeThemeService as Ve, getPrimaryForRange as ee, SetSelectionsOperation as He, getNextPrimaryCell as It, SheetsSelectionsService as ze, SetWorksheetDefaultStyleMutation as bt, SetColDataCommand as Se, SetRowDataCommand as we, copyRangeStyles as A, InsertRowByRangeCommand as Ce, RemoveRowByRangeCommand as Rt, MoveRowsCommand as pt, SetRowHiddenCommand as fe, SetSpecificRowsVisibleCommand as ve, SetWorksheetRowIsAutoHeightMutation as yt, SetRowHeightCommand as Ie, SetWorksheetRowIsAutoHeightCommand as be, InsertColByRangeCommand as Re, RemoveColByRangeCommand as Et, MoveColsCommand as Ut, SetColHiddenCommand as pe, SetSpecificColsVisibleCommand as ye, SetColWidthCommand as Pt, SetFrozenCommand as z, CancelFrozenCommand as xt, ToggleGridlinesCommand as te, SetGridlinesColorCommand as ne, SetTabColorCommand as re, SetRangeValuesMutation as Ee, SetWorksheetHideCommand as se, SetWorksheetShowCommand as Nt, SetWorksheetNameCommand as ie, ClearSelectionAllCommand as Tt, ClearSelectionContentCommand as Mt, ClearSelectionFormatCommand as Dt, InsertSheetCommand as T, SetWorksheetActiveOperation as $, RemoveSheetCommand as oe, CopySheetCommand as At, SetWorksheetOrderCommand as he, RegisterWorksheetRangeThemeStyleCommand as Bt, UnregisterWorksheetRangeThemeStyleCommand as Wt, SetWorksheetActivateCommand as Ue, COMMAND_LISTENER_VALUE_CHANGE as Ft, getValueChangedEffectedRange as jt, SheetValueChangeType as Ot, SheetSkeletonChangeType as Lt } from "@univerjs/sheets";
|
|
6
|
+
import { IDefinedNamesService as $e, serializeRange as ue, FormulaDataModel as Vt, serializeRangeWithSheet as Ht, deserializeRangeWithSheet as zt } from "@univerjs/engine-formula";
|
|
7
|
+
var $t = Object.defineProperty, Gt = Object.getOwnPropertyDescriptor, qt = (r, e, t, n) => {
|
|
8
|
+
for (var s = n > 1 ? void 0 : n ? Gt(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
9
|
+
(o = r[i]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
10
|
+
return n && s && $t(e, t, s), s;
|
|
11
|
+
}, w = (r, e) => (t, n) => e(t, n, r);
|
|
12
|
+
function Kt(r, e, t) {
|
|
13
|
+
const n = t.getDefinedNameMap(r);
|
|
14
14
|
if (n == null)
|
|
15
15
|
return e.t("definedName.defaultName") + 1;
|
|
16
|
-
const
|
|
17
|
-
if (t.getValueByName(
|
|
18
|
-
return
|
|
19
|
-
let
|
|
16
|
+
const i = Array.from(Object.values(n)).length + 1, o = e.t("definedName.defaultName") + i;
|
|
17
|
+
if (t.getValueByName(r, o) == null)
|
|
18
|
+
return o;
|
|
19
|
+
let h = i + 1;
|
|
20
20
|
for (; ; ) {
|
|
21
|
-
const
|
|
22
|
-
if (t.getValueByName(
|
|
23
|
-
return
|
|
24
|
-
|
|
21
|
+
const a = e.t("definedName.defaultName") + h;
|
|
22
|
+
if (t.getValueByName(r, a) == null)
|
|
23
|
+
return a;
|
|
24
|
+
h++;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
class
|
|
27
|
+
class V {
|
|
28
28
|
constructor() {
|
|
29
|
-
|
|
29
|
+
b(this, "_definedNameParam");
|
|
30
30
|
this._definedNameParam = {
|
|
31
|
-
id:
|
|
31
|
+
id: Me(10),
|
|
32
32
|
unitId: "",
|
|
33
33
|
name: "",
|
|
34
34
|
formulaOrRefString: ""
|
|
@@ -99,12 +99,12 @@ class L {
|
|
|
99
99
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
100
100
|
* ```
|
|
101
101
|
*/
|
|
102
|
-
setRefByRange(e, t, n,
|
|
103
|
-
return this._definedNameParam.formulaOrRefString =
|
|
102
|
+
setRefByRange(e, t, n, s) {
|
|
103
|
+
return this._definedNameParam.formulaOrRefString = ue({
|
|
104
104
|
startRow: e,
|
|
105
105
|
endRow: e + (n != null ? n : 1) - 1,
|
|
106
106
|
startColumn: t,
|
|
107
|
-
endColumn: t + (
|
|
107
|
+
endColumn: t + (s != null ? s : 1) - 1
|
|
108
108
|
}), this;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
@@ -159,12 +159,12 @@ class L {
|
|
|
159
159
|
return this._definedNameParam = e, this;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
let
|
|
163
|
-
constructor(
|
|
164
|
-
super(), this._definedNameParam =
|
|
162
|
+
let F = class extends de {
|
|
163
|
+
constructor(r, e, t, n, s, i, o, h, a, d) {
|
|
164
|
+
super(), this._definedNameParam = r, this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = s, this._rangeProtectionRuleModel = i, this._worksheetProtectionPointRuleModel = o, this._authzIoService = h, this._localeService = a, this._definedNamesService = d;
|
|
165
165
|
}
|
|
166
166
|
_apply() {
|
|
167
|
-
this._definedNameParam.name === "" && (this._definedNameParam.name =
|
|
167
|
+
this._definedNameParam.name === "" && (this._definedNameParam.name = Kt(this._definedNameParam.unitId, this._localeService, this._definedNamesService)), this._commandService.syncExecuteCommand(Q.id, this._definedNameParam);
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* Gets the name of the defined name.
|
|
@@ -189,8 +189,8 @@ let j = class extends te {
|
|
|
189
189
|
* definedName.setName('NewDefinedName');
|
|
190
190
|
* ```
|
|
191
191
|
*/
|
|
192
|
-
setName(
|
|
193
|
-
this._definedNameParam.name =
|
|
192
|
+
setName(r) {
|
|
193
|
+
this._definedNameParam.name = r, this._apply();
|
|
194
194
|
}
|
|
195
195
|
/**
|
|
196
196
|
* Sets the formula of the defined name.
|
|
@@ -202,8 +202,8 @@ let j = class extends te {
|
|
|
202
202
|
* definedName.setFormula('SUM(Sheet1!$A$1)');
|
|
203
203
|
* ```
|
|
204
204
|
*/
|
|
205
|
-
setFormula(
|
|
206
|
-
this._definedNameParam.formulaOrRefString = `=${
|
|
205
|
+
setFormula(r) {
|
|
206
|
+
this._definedNameParam.formulaOrRefString = `=${r}`, this._apply();
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
209
|
* Sets the reference of the defined name.
|
|
@@ -215,8 +215,8 @@ let j = class extends te {
|
|
|
215
215
|
* definedName.setRef('Sheet1!$A$1');
|
|
216
216
|
* ```
|
|
217
217
|
*/
|
|
218
|
-
setRef(
|
|
219
|
-
this._definedNameParam.formulaOrRefString =
|
|
218
|
+
setRef(r) {
|
|
219
|
+
this._definedNameParam.formulaOrRefString = r, this._apply();
|
|
220
220
|
}
|
|
221
221
|
/**
|
|
222
222
|
* Gets the reference of the defined name.
|
|
@@ -244,10 +244,10 @@ let j = class extends te {
|
|
|
244
244
|
* definedName.setRefByRange(1, 3, 2, 5);
|
|
245
245
|
* ```
|
|
246
246
|
*/
|
|
247
|
-
setRefByRange(
|
|
248
|
-
this._definedNameParam.formulaOrRefString =
|
|
249
|
-
startRow:
|
|
250
|
-
endRow:
|
|
247
|
+
setRefByRange(r, e, t, n) {
|
|
248
|
+
this._definedNameParam.formulaOrRefString = ue({
|
|
249
|
+
startRow: r,
|
|
250
|
+
endRow: r + (t != null ? t : 1) - 1,
|
|
251
251
|
startColumn: e,
|
|
252
252
|
endColumn: e + (n != null ? n : 1) - 1
|
|
253
253
|
}), this._apply();
|
|
@@ -275,8 +275,8 @@ let j = class extends te {
|
|
|
275
275
|
* definedName.setComment('This is a comment');
|
|
276
276
|
* ```
|
|
277
277
|
*/
|
|
278
|
-
setComment(
|
|
279
|
-
this._definedNameParam.comment =
|
|
278
|
+
setComment(r) {
|
|
279
|
+
this._definedNameParam.comment = r, this._apply();
|
|
280
280
|
}
|
|
281
281
|
/**
|
|
282
282
|
* Sets the scope of the defined name to the worksheet.
|
|
@@ -289,8 +289,8 @@ let j = class extends te {
|
|
|
289
289
|
* definedName.setScopeToWorksheet(worksheet);
|
|
290
290
|
* ```
|
|
291
291
|
*/
|
|
292
|
-
setScopeToWorksheet(
|
|
293
|
-
this._definedNameParam.localSheetId =
|
|
292
|
+
setScopeToWorksheet(r) {
|
|
293
|
+
this._definedNameParam.localSheetId = r.getSheetId(), this._apply();
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
* Sets the scope of the defined name to the workbook.
|
|
@@ -314,8 +314,8 @@ let j = class extends te {
|
|
|
314
314
|
* definedName.setHidden(true);
|
|
315
315
|
* ```
|
|
316
316
|
*/
|
|
317
|
-
setHidden(
|
|
318
|
-
this._definedNameParam.hidden =
|
|
317
|
+
setHidden(r) {
|
|
318
|
+
this._definedNameParam.hidden = r, this._apply();
|
|
319
319
|
}
|
|
320
320
|
/**
|
|
321
321
|
* Deletes the defined name.
|
|
@@ -327,7 +327,7 @@ let j = class extends te {
|
|
|
327
327
|
* ```
|
|
328
328
|
*/
|
|
329
329
|
delete() {
|
|
330
|
-
this._commandService.syncExecuteCommand(
|
|
330
|
+
this._commandService.syncExecuteCommand(st.id, this._definedNameParam);
|
|
331
331
|
}
|
|
332
332
|
/**
|
|
333
333
|
* Gets the local sheet id of the defined name.
|
|
@@ -368,33 +368,33 @@ let j = class extends te {
|
|
|
368
368
|
* ```
|
|
369
369
|
*/
|
|
370
370
|
toBuilder() {
|
|
371
|
-
const
|
|
372
|
-
return
|
|
371
|
+
const r = this._injector.createInstance(V);
|
|
372
|
+
return r.load(this._definedNameParam), r;
|
|
373
373
|
}
|
|
374
374
|
};
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
],
|
|
386
|
-
var
|
|
387
|
-
for (var
|
|
388
|
-
(
|
|
389
|
-
return n &&
|
|
390
|
-
},
|
|
391
|
-
let
|
|
392
|
-
constructor(e, t, n,
|
|
375
|
+
F = qt([
|
|
376
|
+
w(1, u(y)),
|
|
377
|
+
w(2, l),
|
|
378
|
+
w(3, ae),
|
|
379
|
+
w(4, u(Fe)),
|
|
380
|
+
w(5, u(je)),
|
|
381
|
+
w(6, u(Oe)),
|
|
382
|
+
w(7, u(Ne)),
|
|
383
|
+
w(8, u(Te)),
|
|
384
|
+
w(9, $e)
|
|
385
|
+
], F);
|
|
386
|
+
var Yt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, Qt = (r, e, t, n) => {
|
|
387
|
+
for (var s = n > 1 ? void 0 : n ? Jt(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
388
|
+
(o = r[i]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
389
|
+
return n && s && Yt(e, t, s), s;
|
|
390
|
+
}, R = (r, e) => (t, n) => e(t, n, r);
|
|
391
|
+
let j = class extends de {
|
|
392
|
+
constructor(e, t, n, s, i, o, h) {
|
|
393
393
|
super();
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel =
|
|
394
|
+
b(this, "permissionPointsDefinition", it);
|
|
395
|
+
b(this, "rangeRuleChangedAfterAuth$");
|
|
396
|
+
b(this, "sheetRuleChangedAfterAuth$");
|
|
397
|
+
this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = s, this._rangeProtectionRuleModel = i, this._worksheetProtectionPointRuleModel = o, this._authzIoService = h, this.rangeRuleChangedAfterAuth$ = this._rangeProtectionRuleModel.ruleRefresh$, this.sheetRuleChangedAfterAuth$ = this._worksheetProtectionRuleModel.ruleRefresh$;
|
|
398
398
|
}
|
|
399
399
|
/**
|
|
400
400
|
* Configures a specific permission point for a workbook.
|
|
@@ -406,8 +406,8 @@ let O = class extends te {
|
|
|
406
406
|
* @param {boolean} value - The boolean value to determine whether the permission point is enabled or disabled.
|
|
407
407
|
*/
|
|
408
408
|
setWorkbookPermissionPoint(e, t, n) {
|
|
409
|
-
const
|
|
410
|
-
this._permissionService.getPermissionPoint(
|
|
409
|
+
const s = new t(e);
|
|
410
|
+
this._permissionService.getPermissionPoint(s.id) || this._permissionService.addPermissionPoint(s), this._permissionService.updatePermissionPoint(s.id, n);
|
|
411
411
|
}
|
|
412
412
|
/**
|
|
413
413
|
* This function is used to set whether the workbook can be edited
|
|
@@ -415,7 +415,7 @@ let O = class extends te {
|
|
|
415
415
|
* @param {boolean} value - A value that controls whether the workbook can be edited
|
|
416
416
|
*/
|
|
417
417
|
setWorkbookEditPermission(e, t) {
|
|
418
|
-
this.setWorkbookPermissionPoint(e,
|
|
418
|
+
this.setWorkbookPermissionPoint(e, Le, t);
|
|
419
419
|
}
|
|
420
420
|
/**
|
|
421
421
|
* This function is used to add a base permission for a worksheet.
|
|
@@ -426,8 +426,8 @@ let O = class extends te {
|
|
|
426
426
|
async addWorksheetBasePermission(e, t) {
|
|
427
427
|
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length > 0)
|
|
428
428
|
throw new Error("sheet protection cannot intersect with range protection");
|
|
429
|
-
const
|
|
430
|
-
objectType:
|
|
429
|
+
const s = await this._authzIoService.create({
|
|
430
|
+
objectType: x.Worksheet,
|
|
431
431
|
worksheetObject: {
|
|
432
432
|
collaborators: [],
|
|
433
433
|
unitID: e,
|
|
@@ -436,17 +436,17 @@ let O = class extends te {
|
|
|
436
436
|
scope: void 0
|
|
437
437
|
}
|
|
438
438
|
});
|
|
439
|
-
if (this._commandService.syncExecuteCommand(
|
|
439
|
+
if (this._commandService.syncExecuteCommand(ot.id, {
|
|
440
440
|
unitId: e,
|
|
441
441
|
subUnitId: t,
|
|
442
442
|
rule: {
|
|
443
|
-
permissionId:
|
|
444
|
-
unitType:
|
|
443
|
+
permissionId: s,
|
|
444
|
+
unitType: x.Worksheet,
|
|
445
445
|
unitId: e,
|
|
446
446
|
subUnitId: t
|
|
447
447
|
}
|
|
448
448
|
}))
|
|
449
|
-
return
|
|
449
|
+
return s;
|
|
450
450
|
}
|
|
451
451
|
/**
|
|
452
452
|
* Delete the entire table protection set for the worksheet and reset the point permissions of the worksheet to true
|
|
@@ -454,12 +454,12 @@ let O = class extends te {
|
|
|
454
454
|
* @param {string} subUnitId - The unique identifier of the worksheet for which the permission is being set.
|
|
455
455
|
*/
|
|
456
456
|
removeWorksheetPermission(e, t) {
|
|
457
|
-
this._commandService.syncExecuteCommand(
|
|
457
|
+
this._commandService.syncExecuteCommand(ht.id, {
|
|
458
458
|
unitId: e,
|
|
459
459
|
subUnitId: t
|
|
460
|
-
}), [...
|
|
461
|
-
const
|
|
462
|
-
this._permissionService.updatePermissionPoint(
|
|
460
|
+
}), [...at(), ..._e()].forEach((n) => {
|
|
461
|
+
const s = new n(e, t);
|
|
462
|
+
this._permissionService.updatePermissionPoint(s.id, !0);
|
|
463
463
|
}), this._worksheetProtectionPointRuleModel.deleteRule(e, t);
|
|
464
464
|
}
|
|
465
465
|
/**
|
|
@@ -472,21 +472,21 @@ let O = class extends te {
|
|
|
472
472
|
* @param {boolean} value - The new permission value to be set for the worksheet.
|
|
473
473
|
* @returns {Promise<string | undefined>} - Returns the `permissionId` if the permission point is successfully set or created. If no permission is set, it resolves to `undefined`.
|
|
474
474
|
*/
|
|
475
|
-
async setWorksheetPermissionPoint(e, t, n,
|
|
476
|
-
const
|
|
477
|
-
let
|
|
478
|
-
if (n ===
|
|
479
|
-
if (
|
|
480
|
-
|
|
475
|
+
async setWorksheetPermissionPoint(e, t, n, s) {
|
|
476
|
+
const i = this._worksheetProtectionRuleModel.getRule(e, t);
|
|
477
|
+
let o;
|
|
478
|
+
if (n === lt || n === mt)
|
|
479
|
+
if (i)
|
|
480
|
+
o = i.permissionId;
|
|
481
481
|
else {
|
|
482
482
|
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length > 0)
|
|
483
483
|
throw new Error("sheet protection cannot intersect with range protection");
|
|
484
|
-
|
|
484
|
+
o = await this.addWorksheetBasePermission(e, t);
|
|
485
485
|
}
|
|
486
486
|
else {
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
objectType:
|
|
487
|
+
const c = this._worksheetProtectionPointRuleModel.getRule(e, t);
|
|
488
|
+
c ? o = c.permissionId : (o = await this._authzIoService.create({
|
|
489
|
+
objectType: x.Worksheet,
|
|
490
490
|
worksheetObject: {
|
|
491
491
|
collaborators: [],
|
|
492
492
|
unitID: e,
|
|
@@ -494,10 +494,10 @@ let O = class extends te {
|
|
|
494
494
|
name: "",
|
|
495
495
|
scope: void 0
|
|
496
496
|
}
|
|
497
|
-
}), this._commandService.
|
|
497
|
+
}), this._commandService.syncExecuteCommand(dt.id, { unitId: e, subUnitId: t, permissionId: o }));
|
|
498
498
|
}
|
|
499
|
-
const
|
|
500
|
-
return this._permissionService.getPermissionPoint(
|
|
499
|
+
const a = new n(e, t);
|
|
500
|
+
return this._permissionService.getPermissionPoint(a.id) || this._permissionService.addPermissionPoint(a), this._permissionService.updatePermissionPoint(a.id, s), o;
|
|
501
501
|
}
|
|
502
502
|
/**
|
|
503
503
|
* Adds a range protection to the worksheet.
|
|
@@ -507,34 +507,34 @@ let O = class extends te {
|
|
|
507
507
|
* @returns {Promise<{ permissionId: string, ruleId: string } | undefined>} - Returns an object containing the `permissionId` and `ruleId` if the range protection is successfully added. If the operation fails or no result is returned, it resolves to `undefined`. permissionId is used to stitch permission point ID,ruleId is used to store permission rules
|
|
508
508
|
*/
|
|
509
509
|
async addRangeBaseProtection(e, t, n) {
|
|
510
|
-
const
|
|
511
|
-
objectType:
|
|
510
|
+
const s = await this._authzIoService.create({
|
|
511
|
+
objectType: x.SelectRange,
|
|
512
512
|
selectRangeObject: {
|
|
513
513
|
collaborators: [],
|
|
514
514
|
unitID: e,
|
|
515
515
|
name: "",
|
|
516
516
|
scope: void 0
|
|
517
517
|
}
|
|
518
|
-
}),
|
|
518
|
+
}), i = `ruleId_${Me(6)}`;
|
|
519
519
|
if (this._worksheetProtectionRuleModel.getRule(e, t))
|
|
520
520
|
throw new Error("sheet protection cannot intersect with range protection");
|
|
521
|
-
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((
|
|
521
|
+
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((c) => c.ranges.some((v) => n.some((k) => M.intersects(k, v)))))
|
|
522
522
|
throw new Error("range protection cannot intersect");
|
|
523
|
-
if (this._commandService.syncExecuteCommand(
|
|
523
|
+
if (this._commandService.syncExecuteCommand(ct.id, {
|
|
524
524
|
unitId: e,
|
|
525
525
|
subUnitId: t,
|
|
526
526
|
rules: [{
|
|
527
|
-
permissionId:
|
|
528
|
-
unitType:
|
|
527
|
+
permissionId: s,
|
|
528
|
+
unitType: x.SelectRange,
|
|
529
529
|
unitId: e,
|
|
530
530
|
subUnitId: t,
|
|
531
531
|
ranges: n,
|
|
532
|
-
id:
|
|
532
|
+
id: i
|
|
533
533
|
}]
|
|
534
534
|
}))
|
|
535
535
|
return {
|
|
536
|
-
permissionId:
|
|
537
|
-
ruleId:
|
|
536
|
+
permissionId: s,
|
|
537
|
+
ruleId: i
|
|
538
538
|
};
|
|
539
539
|
}
|
|
540
540
|
/**
|
|
@@ -544,13 +544,13 @@ let O = class extends te {
|
|
|
544
544
|
* @param {string[]} ruleIds - The rule IDs of the range protection to be removed.
|
|
545
545
|
*/
|
|
546
546
|
removeRangeProtection(e, t, n) {
|
|
547
|
-
this._commandService.syncExecuteCommand(
|
|
547
|
+
this._commandService.syncExecuteCommand(ut.id, {
|
|
548
548
|
unitId: e,
|
|
549
549
|
subUnitId: t,
|
|
550
550
|
ruleIds: n
|
|
551
|
-
}) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [...
|
|
552
|
-
const
|
|
553
|
-
this._permissionService.updatePermissionPoint(
|
|
551
|
+
}) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [..._e()].forEach((o) => {
|
|
552
|
+
const h = new o(e, t);
|
|
553
|
+
this._permissionService.updatePermissionPoint(h.id, h.value);
|
|
554
554
|
}));
|
|
555
555
|
}
|
|
556
556
|
/**
|
|
@@ -562,9 +562,9 @@ let O = class extends te {
|
|
|
562
562
|
* See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
|
|
563
563
|
* @param {boolean} value - The new permission value to be set for the range (e.g., true for allowing access, false for restricting access).
|
|
564
564
|
*/
|
|
565
|
-
setRangeProtectionPermissionPoint(e, t, n,
|
|
566
|
-
const
|
|
567
|
-
this._permissionService.getPermissionPoint(
|
|
565
|
+
setRangeProtectionPermissionPoint(e, t, n, s, i) {
|
|
566
|
+
const o = new s(e, t, n);
|
|
567
|
+
this._permissionService.getPermissionPoint(o.id) || this._permissionService.addPermissionPoint(o), this._permissionService.updatePermissionPoint(o.id, i);
|
|
568
568
|
}
|
|
569
569
|
/**
|
|
570
570
|
* Sets the ranges for range protection in a worksheet.
|
|
@@ -577,228 +577,328 @@ let O = class extends te {
|
|
|
577
577
|
* @param {string} ruleId - The ruleId of the range protection rule that is being updated.
|
|
578
578
|
* @param {IRange[]} ranges - The array of new ranges to be set for the range protection rule.
|
|
579
579
|
*/
|
|
580
|
-
setRangeProtectionRanges(e, t, n,
|
|
581
|
-
const
|
|
582
|
-
if (
|
|
583
|
-
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).filter((
|
|
580
|
+
setRangeProtectionRanges(e, t, n, s) {
|
|
581
|
+
const i = this._rangeProtectionRuleModel.getRule(e, t, n);
|
|
582
|
+
if (i) {
|
|
583
|
+
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).filter((a) => a.id !== n).some((a) => a.ranges.some((d) => s.some((c) => M.intersects(c, d)))))
|
|
584
584
|
throw new Error("range protection cannot intersect");
|
|
585
|
-
this._commandService.syncExecuteCommand(
|
|
585
|
+
this._commandService.syncExecuteCommand(gt.id, {
|
|
586
586
|
unitId: e,
|
|
587
587
|
subUnitId: t,
|
|
588
588
|
ruleId: n,
|
|
589
589
|
rule: {
|
|
590
|
-
...
|
|
591
|
-
ranges:
|
|
590
|
+
...i,
|
|
591
|
+
ranges: s
|
|
592
592
|
}
|
|
593
593
|
});
|
|
594
594
|
}
|
|
595
595
|
}
|
|
596
596
|
};
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
],
|
|
606
|
-
function
|
|
607
|
-
switch (
|
|
597
|
+
j = Qt([
|
|
598
|
+
R(0, u(y)),
|
|
599
|
+
R(1, l),
|
|
600
|
+
R(2, ae),
|
|
601
|
+
R(3, u(Fe)),
|
|
602
|
+
R(4, u(je)),
|
|
603
|
+
R(5, u(Oe)),
|
|
604
|
+
R(6, u(Ne))
|
|
605
|
+
], j);
|
|
606
|
+
function Xt(r) {
|
|
607
|
+
switch (r) {
|
|
608
608
|
case "left":
|
|
609
|
-
return
|
|
609
|
+
return U.LEFT;
|
|
610
610
|
case "center":
|
|
611
|
-
return
|
|
611
|
+
return U.CENTER;
|
|
612
612
|
case "normal":
|
|
613
|
-
return
|
|
613
|
+
return U.RIGHT;
|
|
614
614
|
default:
|
|
615
|
-
throw new Error(`Invalid horizontal alignment: ${
|
|
615
|
+
throw new Error(`Invalid horizontal alignment: ${r}`);
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
function
|
|
619
|
-
switch (
|
|
620
|
-
case
|
|
618
|
+
function Zt(r) {
|
|
619
|
+
switch (r) {
|
|
620
|
+
case U.LEFT:
|
|
621
621
|
return "left";
|
|
622
|
-
case
|
|
622
|
+
case U.CENTER:
|
|
623
623
|
return "center";
|
|
624
|
-
case
|
|
624
|
+
case U.RIGHT:
|
|
625
625
|
return "normal";
|
|
626
626
|
default:
|
|
627
|
-
throw new Error(`Invalid horizontal alignment: ${
|
|
627
|
+
throw new Error(`Invalid horizontal alignment: ${r}`);
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
|
-
function
|
|
631
|
-
switch (
|
|
630
|
+
function en(r) {
|
|
631
|
+
switch (r) {
|
|
632
632
|
case "top":
|
|
633
|
-
return
|
|
633
|
+
return P.TOP;
|
|
634
634
|
case "middle":
|
|
635
|
-
return
|
|
635
|
+
return P.MIDDLE;
|
|
636
636
|
case "bottom":
|
|
637
|
-
return
|
|
637
|
+
return P.BOTTOM;
|
|
638
638
|
default:
|
|
639
|
-
throw new Error(`Invalid vertical alignment: ${
|
|
639
|
+
throw new Error(`Invalid vertical alignment: ${r}`);
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
|
-
function
|
|
643
|
-
switch (
|
|
644
|
-
case
|
|
642
|
+
function tn(r) {
|
|
643
|
+
switch (r) {
|
|
644
|
+
case P.TOP:
|
|
645
645
|
return "top";
|
|
646
|
-
case
|
|
646
|
+
case P.MIDDLE:
|
|
647
647
|
return "middle";
|
|
648
|
-
case
|
|
648
|
+
case P.BOTTOM:
|
|
649
649
|
return "bottom";
|
|
650
650
|
default:
|
|
651
|
-
throw new Error(`Invalid vertical alignment: ${
|
|
651
|
+
throw new Error(`Invalid vertical alignment: ${r}`);
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
|
-
function
|
|
655
|
-
return
|
|
656
|
-
f:
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
} : (
|
|
654
|
+
function O(r) {
|
|
655
|
+
return Ke(r) ? {
|
|
656
|
+
f: r,
|
|
657
|
+
v: null,
|
|
658
|
+
p: null
|
|
659
|
+
} : Ye(r) ? {
|
|
660
|
+
v: r,
|
|
661
|
+
p: null,
|
|
662
|
+
f: null
|
|
663
|
+
} : (Je(r), r);
|
|
660
664
|
}
|
|
661
|
-
function
|
|
662
|
-
const t = new
|
|
663
|
-
if (
|
|
664
|
-
for (let
|
|
665
|
-
for (let
|
|
666
|
-
t.setValue(
|
|
665
|
+
function Pe(r, e) {
|
|
666
|
+
const t = new W(), { startRow: n, startColumn: s, endRow: i, endColumn: o } = e;
|
|
667
|
+
if (Qe.isArray(r))
|
|
668
|
+
for (let h = 0; h <= i - n; h++)
|
|
669
|
+
for (let a = 0; a <= o - s; a++)
|
|
670
|
+
t.setValue(h + n, a + s, O(r[h][a]));
|
|
667
671
|
else
|
|
668
|
-
new
|
|
669
|
-
t.setValue(
|
|
672
|
+
new W(r).forValue((a, d, c) => {
|
|
673
|
+
t.setValue(a, d, O(c));
|
|
670
674
|
});
|
|
671
675
|
return t.getMatrix();
|
|
672
676
|
}
|
|
673
|
-
function
|
|
677
|
+
function G(r, e) {
|
|
674
678
|
return {
|
|
675
|
-
startRow:
|
|
676
|
-
endRow:
|
|
679
|
+
startRow: r.startRow,
|
|
680
|
+
endRow: r.endRow,
|
|
677
681
|
startColumn: 0,
|
|
678
682
|
endColumn: e.getColumnCount() - 1,
|
|
679
683
|
rangeType: _.ROW
|
|
680
684
|
};
|
|
681
685
|
}
|
|
682
|
-
function
|
|
686
|
+
function q(r, e) {
|
|
683
687
|
return {
|
|
684
688
|
startRow: 0,
|
|
685
689
|
endRow: e.getRowCount() - 1,
|
|
686
|
-
startColumn:
|
|
687
|
-
endColumn:
|
|
690
|
+
startColumn: r.startColumn,
|
|
691
|
+
endColumn: r.endColumn,
|
|
688
692
|
rangeType: _.COLUMN
|
|
689
693
|
};
|
|
690
694
|
}
|
|
691
|
-
var
|
|
692
|
-
for (var
|
|
693
|
-
(
|
|
694
|
-
return n &&
|
|
695
|
-
},
|
|
696
|
-
let
|
|
697
|
-
constructor(
|
|
698
|
-
super(n), this._workbook =
|
|
695
|
+
var nn = Object.defineProperty, rn = Object.getOwnPropertyDescriptor, sn = (r, e, t, n) => {
|
|
696
|
+
for (var s = n > 1 ? void 0 : n ? rn(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
697
|
+
(o = r[i]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
698
|
+
return n && s && nn(e, t, s), s;
|
|
699
|
+
}, K = (r, e) => (t, n) => e(t, n, r);
|
|
700
|
+
let S = class extends ce {
|
|
701
|
+
constructor(r, e, t, n, s, i) {
|
|
702
|
+
super(n), this._workbook = r, this._worksheet = e, this._range = t, this._injector = n, this._commandService = s, this._formulaDataModel = i;
|
|
699
703
|
}
|
|
700
704
|
/**
|
|
701
705
|
* Get the unit ID of the current workbook
|
|
702
|
-
* @returns The unit ID of the workbook
|
|
706
|
+
* @returns {string} The unit ID of the workbook
|
|
707
|
+
* @example
|
|
708
|
+
* ```ts
|
|
709
|
+
* univerAPI.getActiveWorkbook()
|
|
710
|
+
* .getActiveSheet()
|
|
711
|
+
* .getActiveRange()
|
|
712
|
+
* .getUnitId()
|
|
713
|
+
* ```
|
|
703
714
|
*/
|
|
704
715
|
getUnitId() {
|
|
705
716
|
return this._workbook.getUnitId();
|
|
706
717
|
}
|
|
707
718
|
/**
|
|
708
719
|
* Gets the name of the worksheet
|
|
709
|
-
* @returns The name of the worksheet
|
|
720
|
+
* @returns {string} The name of the worksheet
|
|
721
|
+
* @example
|
|
722
|
+
* ```ts
|
|
723
|
+
* univerAPI.getActiveWorkbook()
|
|
724
|
+
* .getActiveSheet()
|
|
725
|
+
* .getActiveRange()
|
|
726
|
+
* .getSheetName()
|
|
727
|
+
* ```
|
|
710
728
|
*/
|
|
711
729
|
getSheetName() {
|
|
712
730
|
return this._worksheet.getName();
|
|
713
731
|
}
|
|
714
732
|
/**
|
|
715
733
|
* Gets the ID of the worksheet
|
|
716
|
-
* @returns The ID of the worksheet
|
|
734
|
+
* @returns {string} The ID of the worksheet
|
|
735
|
+
* @example
|
|
736
|
+
* ```ts
|
|
737
|
+
* univerAPI.getActiveWorkbook()
|
|
738
|
+
* .getActiveSheet()
|
|
739
|
+
* .getActiveRange()
|
|
740
|
+
* .getSheetId()
|
|
741
|
+
* ```
|
|
717
742
|
*/
|
|
718
743
|
getSheetId() {
|
|
719
744
|
return this._worksheet.getSheetId();
|
|
720
745
|
}
|
|
721
746
|
/**
|
|
722
747
|
* Gets the area where the statement is applied
|
|
723
|
-
* @returns The area where the statement is applied
|
|
748
|
+
* @returns {IRange} The area where the statement is applied
|
|
749
|
+
* @example
|
|
750
|
+
* ```ts
|
|
751
|
+
* univerAPI.getActiveWorkbook()
|
|
752
|
+
* .getActiveSheet()
|
|
753
|
+
* .getActiveRange()
|
|
754
|
+
* .getRange()
|
|
755
|
+
* ```
|
|
724
756
|
*/
|
|
725
757
|
getRange() {
|
|
726
758
|
return this._range;
|
|
727
759
|
}
|
|
728
760
|
/**
|
|
729
761
|
* Gets the starting row number of the applied area
|
|
730
|
-
* @returns The starting row number of the area
|
|
762
|
+
* @returns {number} The starting row number of the area
|
|
763
|
+
* @example
|
|
764
|
+
* ```ts
|
|
765
|
+
* univerAPI.getActiveWorkbook()
|
|
766
|
+
* .getActiveSheet()
|
|
767
|
+
* .getActiveRange()
|
|
768
|
+
* .getRow()
|
|
769
|
+
* ```
|
|
731
770
|
*/
|
|
732
771
|
getRow() {
|
|
733
772
|
return this._range.startRow;
|
|
734
773
|
}
|
|
735
774
|
/**
|
|
736
775
|
* Gets the starting column number of the applied area
|
|
737
|
-
* @returns The starting column number of the area
|
|
776
|
+
* @returns {number} The starting column number of the area
|
|
777
|
+
* @example
|
|
778
|
+
* ```ts
|
|
779
|
+
* univerAPI.getActiveWorkbook()
|
|
780
|
+
* .getActiveSheet()
|
|
781
|
+
* .getActiveRange()
|
|
782
|
+
* .getColumn()
|
|
783
|
+
* ```
|
|
738
784
|
*/
|
|
739
785
|
getColumn() {
|
|
740
786
|
return this._range.startColumn;
|
|
741
787
|
}
|
|
742
788
|
/**
|
|
743
789
|
* Gets the width of the applied area
|
|
744
|
-
* @returns The width of the area
|
|
790
|
+
* @returns {number} The width of the area
|
|
791
|
+
* @example
|
|
792
|
+
* ```ts
|
|
793
|
+
* univerAPI.getActiveWorkbook()
|
|
794
|
+
* .getActiveSheet()
|
|
795
|
+
* .getActiveRange()
|
|
796
|
+
* .getWidth()
|
|
797
|
+
* ```
|
|
745
798
|
*/
|
|
746
799
|
getWidth() {
|
|
747
800
|
return this._range.endColumn - this._range.startColumn + 1;
|
|
748
801
|
}
|
|
749
802
|
/**
|
|
750
803
|
* Gets the height of the applied area
|
|
751
|
-
* @returns The height of the area
|
|
804
|
+
* @returns {number} The height of the area
|
|
805
|
+
* @example
|
|
806
|
+
* ```ts
|
|
807
|
+
* univerAPI.getActiveWorkbook()
|
|
808
|
+
* .getActiveSheet()
|
|
809
|
+
* .getActiveRange()
|
|
810
|
+
* .getHeight()
|
|
811
|
+
* ```
|
|
752
812
|
*/
|
|
753
813
|
getHeight() {
|
|
754
814
|
return this._range.endRow - this._range.startRow + 1;
|
|
755
815
|
}
|
|
756
816
|
/**
|
|
757
817
|
* Return range whether this range is merged
|
|
758
|
-
* @returns if true is merged
|
|
818
|
+
* @returns {boolean} if true is merged
|
|
819
|
+
* @example
|
|
820
|
+
* ```ts
|
|
821
|
+
* univerAPI.getActiveWorkbook()
|
|
822
|
+
* .getActiveSheet()
|
|
823
|
+
* .getActiveRange()
|
|
824
|
+
* .isMerged()
|
|
825
|
+
* ```
|
|
759
826
|
*/
|
|
760
827
|
isMerged() {
|
|
761
|
-
const { startColumn:
|
|
762
|
-
return this._worksheet.getMergedCellRange(e,
|
|
828
|
+
const { startColumn: r, startRow: e, endColumn: t, endRow: n } = this._range;
|
|
829
|
+
return this._worksheet.getMergedCellRange(e, r, n, t).some((i) => M.equals(i, this._range));
|
|
763
830
|
}
|
|
764
831
|
/**
|
|
765
832
|
* Return first cell style data in this range
|
|
766
833
|
* @returns {IStyleData | null} The cell style data
|
|
834
|
+
* @example
|
|
835
|
+
* ```ts
|
|
836
|
+
* univerAPI.getActiveWorkbook()
|
|
837
|
+
* .getActiveSheet()
|
|
838
|
+
* .getActiveRange()
|
|
839
|
+
* .getCellStyleData()
|
|
840
|
+
* ```
|
|
767
841
|
*/
|
|
768
842
|
getCellStyleData() {
|
|
769
843
|
var t;
|
|
770
|
-
const
|
|
771
|
-
return
|
|
844
|
+
const r = this.getCellData(), e = this._workbook.getStyles();
|
|
845
|
+
return r && e && (t = e.getStyleByCell(r)) != null ? t : null;
|
|
772
846
|
}
|
|
773
847
|
/**
|
|
774
|
-
*
|
|
775
|
-
* @returns {
|
|
848
|
+
* Return first cell style in this range
|
|
849
|
+
* @returns {TextStyleValue | null} The cell style
|
|
850
|
+
* @example
|
|
851
|
+
* ```ts
|
|
852
|
+
* univerAPI.getActiveWorkbook()
|
|
853
|
+
* .getActiveSheet()
|
|
854
|
+
* .getActiveRange()
|
|
855
|
+
* .getCellStyle()
|
|
856
|
+
* ```
|
|
776
857
|
*/
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
return
|
|
858
|
+
getCellStyle() {
|
|
859
|
+
const r = this.getCellStyleData();
|
|
860
|
+
return r ? le.create(r) : null;
|
|
780
861
|
}
|
|
781
862
|
/**
|
|
782
|
-
* Returns the
|
|
783
|
-
*
|
|
784
|
-
* @
|
|
863
|
+
* Returns the cell styles for the cells in the range.
|
|
864
|
+
* @returns {Array<Array<TextStyleValue | null>>} A two-dimensional array of cell styles.
|
|
865
|
+
* @example
|
|
866
|
+
* ```ts
|
|
867
|
+
* univerAPI.getActiveWorkbook()
|
|
868
|
+
* .getActiveSheet()
|
|
869
|
+
* .getActiveRange()
|
|
870
|
+
* .getCellStyles()
|
|
871
|
+
* ```
|
|
785
872
|
*/
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
const
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
873
|
+
getCellStyles() {
|
|
874
|
+
const r = this.getCellDatas(), e = this._workbook.getStyles();
|
|
875
|
+
return r.map((t) => t.map((n) => {
|
|
876
|
+
if (!n) return null;
|
|
877
|
+
const s = e.getStyleByCell(n);
|
|
878
|
+
return s ? le.create(s) : null;
|
|
879
|
+
}));
|
|
880
|
+
}
|
|
881
|
+
getValue(r) {
|
|
882
|
+
var e, t;
|
|
883
|
+
return r ? this.getValueAndRichTextValue() : (t = (e = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) == null ? void 0 : e.v) != null ? t : null;
|
|
884
|
+
}
|
|
885
|
+
getValues(r) {
|
|
886
|
+
var o, h;
|
|
887
|
+
r && this.getValueAndRichTextValues();
|
|
888
|
+
const { startRow: e, endRow: t, startColumn: n, endColumn: s } = this._range, i = [];
|
|
889
|
+
for (let a = e; a <= t; a++) {
|
|
890
|
+
const d = [];
|
|
891
|
+
for (let c = n; c <= s; c++)
|
|
892
|
+
d.push((h = (o = this._worksheet.getCell(a, c)) == null ? void 0 : o.v) != null ? h : null);
|
|
893
|
+
i.push(d);
|
|
794
894
|
}
|
|
795
|
-
return
|
|
895
|
+
return i;
|
|
796
896
|
}
|
|
797
897
|
/**
|
|
798
898
|
* Return first cell model data in this range
|
|
799
899
|
* @returns {ICellData | null} The cell model data
|
|
800
900
|
* @example
|
|
801
|
-
* ```
|
|
901
|
+
* ```ts
|
|
802
902
|
* univerAPI.getActiveWorkbook()
|
|
803
903
|
* .getActiveSheet()
|
|
804
904
|
* .getActiveRange()
|
|
@@ -806,14 +906,14 @@ let w = class extends ne {
|
|
|
806
906
|
* ```
|
|
807
907
|
*/
|
|
808
908
|
getCellData() {
|
|
809
|
-
var
|
|
810
|
-
return (
|
|
909
|
+
var r;
|
|
910
|
+
return (r = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) != null ? r : null;
|
|
811
911
|
}
|
|
812
912
|
/**
|
|
813
|
-
*
|
|
913
|
+
* Alias for getCellDataGrid.
|
|
814
914
|
* @returns {Nullable<ICellData>[][]} A two-dimensional array of cell data.
|
|
815
915
|
* @example
|
|
816
|
-
* ```
|
|
916
|
+
* ```ts
|
|
817
917
|
* univerAPI.getActiveWorkbook()
|
|
818
918
|
* .getActiveSheet()
|
|
819
919
|
* .getActiveRange()
|
|
@@ -821,26 +921,36 @@ let w = class extends ne {
|
|
|
821
921
|
* ```
|
|
822
922
|
*/
|
|
823
923
|
getCellDatas() {
|
|
824
|
-
|
|
825
|
-
for (let o = s; o <= e; o++) {
|
|
826
|
-
const i = [];
|
|
827
|
-
for (let a = t; a <= n; a++)
|
|
828
|
-
i.push(this._worksheet.getCellRaw(o, a));
|
|
829
|
-
r.push(i);
|
|
830
|
-
}
|
|
831
|
-
return r;
|
|
924
|
+
return this.getCellDataGrid();
|
|
832
925
|
}
|
|
833
926
|
/**
|
|
834
|
-
*
|
|
927
|
+
* Returns the cell data for the cells in the range.
|
|
928
|
+
* @returns {Nullable<ICellData>[][]} A two-dimensional array of cell data.
|
|
929
|
+
* @example
|
|
930
|
+
* ```ts
|
|
931
|
+
* univerAPI.getActiveWorkbook()
|
|
932
|
+
* .getActiveSheet()
|
|
933
|
+
* .getActiveRange()
|
|
934
|
+
* .getCellDataGrid()
|
|
935
|
+
* ```
|
|
835
936
|
*/
|
|
836
937
|
getCellDataGrid() {
|
|
837
|
-
|
|
938
|
+
const { startRow: r, endRow: e, startColumn: t, endColumn: n } = this._range, s = [];
|
|
939
|
+
for (let i = r; i <= e; i++) {
|
|
940
|
+
const o = [];
|
|
941
|
+
for (let h = t; h <= n; h++)
|
|
942
|
+
o.push(this._worksheet.getCellRaw(i, h));
|
|
943
|
+
s.push(o);
|
|
944
|
+
}
|
|
945
|
+
return s;
|
|
838
946
|
}
|
|
839
947
|
/**
|
|
840
948
|
* Returns the rich text value for the cell at the start of this range.
|
|
841
949
|
* @returns {Nullable<RichTextValue>} The rich text value
|
|
950
|
+
* @internal
|
|
951
|
+
* @beta
|
|
842
952
|
* @example
|
|
843
|
-
* ```
|
|
953
|
+
* ```ts
|
|
844
954
|
* univerAPI.getActiveWorkbook()
|
|
845
955
|
* .getActiveSheet()
|
|
846
956
|
* .getActiveRange()
|
|
@@ -848,14 +958,16 @@ let w = class extends ne {
|
|
|
848
958
|
* ```
|
|
849
959
|
*/
|
|
850
960
|
getRichTextValue() {
|
|
851
|
-
const
|
|
852
|
-
return
|
|
961
|
+
const r = this.getCellData();
|
|
962
|
+
return r != null && r.p ? new E(r.p) : null;
|
|
853
963
|
}
|
|
854
964
|
/**
|
|
855
965
|
* Returns the rich text value for the cells in the range.
|
|
856
966
|
* @returns {Nullable<RichTextValue>[][]} A two-dimensional array of RichTextValue objects.
|
|
967
|
+
* @internal
|
|
968
|
+
* @beta
|
|
857
969
|
* @example
|
|
858
|
-
* ```
|
|
970
|
+
* ```ts
|
|
859
971
|
* univerAPI.getActiveWorkbook()
|
|
860
972
|
* .getActiveSheet()
|
|
861
973
|
* .getActiveRange()
|
|
@@ -863,13 +975,15 @@ let w = class extends ne {
|
|
|
863
975
|
* ```
|
|
864
976
|
*/
|
|
865
977
|
getRichTextValues() {
|
|
866
|
-
return this.getCellDataGrid().map((e) => e.map((t) => t != null && t.p ? new
|
|
978
|
+
return this.getCellDataGrid().map((e) => e.map((t) => t != null && t.p ? new E(t.p) : null));
|
|
867
979
|
}
|
|
868
980
|
/**
|
|
869
981
|
* Returns the value and rich text value for the cell at the start of this range.
|
|
870
982
|
* @returns {Nullable<CellValue | RichTextValue>} The value and rich text value
|
|
983
|
+
* @internal
|
|
984
|
+
* @beta
|
|
871
985
|
* @example
|
|
872
|
-
* ```
|
|
986
|
+
* ```ts
|
|
873
987
|
* univerAPI.getActiveWorkbook()
|
|
874
988
|
* .getActiveSheet()
|
|
875
989
|
* .getActiveRange()
|
|
@@ -877,14 +991,14 @@ let w = class extends ne {
|
|
|
877
991
|
* ```
|
|
878
992
|
*/
|
|
879
993
|
getValueAndRichTextValue() {
|
|
880
|
-
const
|
|
881
|
-
return
|
|
994
|
+
const r = this.getCellData();
|
|
995
|
+
return r != null && r.p ? new E(r.p) : r == null ? void 0 : r.v;
|
|
882
996
|
}
|
|
883
997
|
/**
|
|
884
998
|
* Returns the value and rich text value for the cells in the range.
|
|
885
999
|
* @returns {Nullable<CellValue | RichTextValue>[][]} A two-dimensional array of value and rich text value
|
|
886
1000
|
* @example
|
|
887
|
-
* ```
|
|
1001
|
+
* ```ts
|
|
888
1002
|
* univerAPI.getActiveWorkbook()
|
|
889
1003
|
* .getActiveSheet()
|
|
890
1004
|
* .getActiveRange()
|
|
@@ -892,7 +1006,7 @@ let w = class extends ne {
|
|
|
892
1006
|
* ```
|
|
893
1007
|
*/
|
|
894
1008
|
getValueAndRichTextValues() {
|
|
895
|
-
return this.getCellDatas().map((e) => e.map((t) => t != null && t.p ? new
|
|
1009
|
+
return this.getCellDatas().map((e) => e.map((t) => t != null && t.p ? new E(t.p) : t == null ? void 0 : t.v));
|
|
896
1010
|
}
|
|
897
1011
|
/**
|
|
898
1012
|
* Returns the formulas (A1 notation) for the cells in the range. Entries in the 2D array are empty strings for cells with no formula.
|
|
@@ -906,28 +1020,72 @@ let w = class extends ne {
|
|
|
906
1020
|
* ```
|
|
907
1021
|
*/
|
|
908
1022
|
getFormulas() {
|
|
909
|
-
const
|
|
910
|
-
for (let
|
|
911
|
-
const
|
|
912
|
-
for (let
|
|
913
|
-
const
|
|
914
|
-
|
|
1023
|
+
const r = [], { startRow: e, endRow: t, startColumn: n, endColumn: s } = this._range, i = this._worksheet.getSheetId(), o = this._workbook.getUnitId();
|
|
1024
|
+
for (let h = e; h <= t; h++) {
|
|
1025
|
+
const a = [];
|
|
1026
|
+
for (let d = n; d <= s; d++) {
|
|
1027
|
+
const c = this._formulaDataModel.getFormulaStringByCell(h, d, i, o);
|
|
1028
|
+
a.push(c || "");
|
|
915
1029
|
}
|
|
916
|
-
|
|
1030
|
+
r.push(a);
|
|
917
1031
|
}
|
|
918
|
-
return
|
|
1032
|
+
return r;
|
|
919
1033
|
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Returns true if the cell wrap is enabled
|
|
1036
|
+
* @returns {boolean} True if the cell wrap is enabled
|
|
1037
|
+
* @example
|
|
1038
|
+
* ```ts
|
|
1039
|
+
* univerAPI.getActiveWorkbook()
|
|
1040
|
+
* .getActiveSheet()
|
|
1041
|
+
* .getActiveRange()
|
|
1042
|
+
* .getWrap()
|
|
1043
|
+
* ```
|
|
1044
|
+
*/
|
|
920
1045
|
getWrap() {
|
|
921
|
-
return this._worksheet.getRange(this._range).getWrap() ===
|
|
1046
|
+
return this._worksheet.getRange(this._range).getWrap() === g.TRUE;
|
|
922
1047
|
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Returns the text wrapping strategy for the top left cell of the range.
|
|
1050
|
+
* @returns {WrapStrategy} The text wrapping strategy
|
|
1051
|
+
* @example
|
|
1052
|
+
* ```ts
|
|
1053
|
+
* univerAPI.getActiveWorkbook()
|
|
1054
|
+
* .getActiveSheet()
|
|
1055
|
+
* .getActiveRange()
|
|
1056
|
+
* .getWrapStrategy()
|
|
1057
|
+
* ```
|
|
1058
|
+
*/
|
|
923
1059
|
getWrapStrategy() {
|
|
924
1060
|
return this._worksheet.getRange(this._range).getWrapStrategy();
|
|
925
1061
|
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Returns the horizontal alignment for the top left cell of the range.
|
|
1064
|
+
* @returns {string} The horizontal alignment
|
|
1065
|
+
* @example
|
|
1066
|
+
* ```ts
|
|
1067
|
+
* univerAPI.getActiveWorkbook()
|
|
1068
|
+
* .getActiveSheet()
|
|
1069
|
+
* .getActiveRange()
|
|
1070
|
+
* .getHorizontalAlignment()
|
|
1071
|
+
* ```
|
|
1072
|
+
*/
|
|
926
1073
|
getHorizontalAlignment() {
|
|
927
|
-
return
|
|
1074
|
+
return Zt(this._worksheet.getRange(this._range).getHorizontalAlignment());
|
|
928
1075
|
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Returns the vertical alignment for the top left cell of the range.
|
|
1078
|
+
* @returns {string} The vertical alignment
|
|
1079
|
+
* @example
|
|
1080
|
+
* ```ts
|
|
1081
|
+
* univerAPI.getActiveWorkbook()
|
|
1082
|
+
* .getActiveSheet()
|
|
1083
|
+
* .getActiveRange()
|
|
1084
|
+
* .getVerticalAlignment()
|
|
1085
|
+
* ```
|
|
1086
|
+
*/
|
|
929
1087
|
getVerticalAlignment() {
|
|
930
|
-
return
|
|
1088
|
+
return tn(this._worksheet.getRange(this._range).getVerticalAlignment());
|
|
931
1089
|
}
|
|
932
1090
|
/**
|
|
933
1091
|
* Set custom meta data for first cell in current range.
|
|
@@ -940,9 +1098,9 @@ let w = class extends ne {
|
|
|
940
1098
|
* .setCustomMetaData({ key: 'value' });
|
|
941
1099
|
* ```
|
|
942
1100
|
*/
|
|
943
|
-
setCustomMetaData(
|
|
1101
|
+
setCustomMetaData(r) {
|
|
944
1102
|
return this.setValue({
|
|
945
|
-
custom:
|
|
1103
|
+
custom: r
|
|
946
1104
|
});
|
|
947
1105
|
}
|
|
948
1106
|
/**
|
|
@@ -956,8 +1114,8 @@ let w = class extends ne {
|
|
|
956
1114
|
* .setCustomMetaDatas([[{ key: 'value' }]]);
|
|
957
1115
|
* ```
|
|
958
1116
|
*/
|
|
959
|
-
setCustomMetaDatas(
|
|
960
|
-
return this.setValues(
|
|
1117
|
+
setCustomMetaDatas(r) {
|
|
1118
|
+
return this.setValues(r.map((e) => e.map((t) => ({ custom: t }))));
|
|
961
1119
|
}
|
|
962
1120
|
/**
|
|
963
1121
|
* Returns the custom meta data for the cell at the start of this range.
|
|
@@ -972,8 +1130,8 @@ let w = class extends ne {
|
|
|
972
1130
|
*/
|
|
973
1131
|
getCustomMetaData() {
|
|
974
1132
|
var e;
|
|
975
|
-
const
|
|
976
|
-
return (e =
|
|
1133
|
+
const r = this.getCellData();
|
|
1134
|
+
return (e = r == null ? void 0 : r.custom) != null ? e : null;
|
|
977
1135
|
}
|
|
978
1136
|
/**
|
|
979
1137
|
* Returns the custom meta data for the cells in the range.
|
|
@@ -992,51 +1150,85 @@ let w = class extends ne {
|
|
|
992
1150
|
return (n = t == null ? void 0 : t.custom) != null ? n : null;
|
|
993
1151
|
}));
|
|
994
1152
|
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Sets basic border properties for the current range.
|
|
1155
|
+
* @param {BorderType} type The type of border to apply
|
|
1156
|
+
* @param {BorderStyleTypes} style The border style
|
|
1157
|
+
* @param {string} [color] Optional border color in CSS notation
|
|
1158
|
+
* @returns {FRange} This range, for chaining
|
|
1159
|
+
* @example
|
|
1160
|
+
* ```ts
|
|
1161
|
+
* univerAPI.getActiveWorkbook()
|
|
1162
|
+
* .getActiveSheet()
|
|
1163
|
+
* .getActiveRange()
|
|
1164
|
+
* .setBorder(BorderType.ALL, BorderStyleType.THIN, '#ff0000');
|
|
1165
|
+
* ```
|
|
1166
|
+
*/
|
|
1167
|
+
setBorder(r, e, t) {
|
|
1168
|
+
return this._commandService.syncExecuteCommand(_t.id, {
|
|
1169
|
+
unitId: this._workbook.getUnitId(),
|
|
1170
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
1171
|
+
value: {
|
|
1172
|
+
type: r,
|
|
1173
|
+
style: e,
|
|
1174
|
+
color: t
|
|
1175
|
+
}
|
|
1176
|
+
}), this;
|
|
1177
|
+
}
|
|
995
1178
|
// #region editing
|
|
996
1179
|
/**
|
|
997
1180
|
* Set background color for current range.
|
|
998
|
-
* @param
|
|
1181
|
+
* @param {string} color The background color
|
|
1182
|
+
* @returns {FRange} This range, for chaining
|
|
999
1183
|
* @example
|
|
1000
|
-
* ```
|
|
1184
|
+
* ```ts
|
|
1001
1185
|
* univerAPI.getActiveWorkbook()
|
|
1002
1186
|
* .getActiveSheet()
|
|
1003
1187
|
* .getActiveRange()
|
|
1004
1188
|
* .setBackgroundColor('red')
|
|
1005
1189
|
* ```
|
|
1006
1190
|
*/
|
|
1007
|
-
setBackgroundColor(
|
|
1008
|
-
return this._commandService.syncExecuteCommand(
|
|
1191
|
+
setBackgroundColor(r) {
|
|
1192
|
+
return this._commandService.syncExecuteCommand(I.id, {
|
|
1009
1193
|
unitId: this._workbook.getUnitId(),
|
|
1010
1194
|
subUnitId: this._worksheet.getSheetId(),
|
|
1011
1195
|
range: this._range,
|
|
1012
1196
|
style: {
|
|
1013
1197
|
type: "bg",
|
|
1014
1198
|
value: {
|
|
1015
|
-
rgb:
|
|
1199
|
+
rgb: r
|
|
1016
1200
|
}
|
|
1017
1201
|
}
|
|
1018
1202
|
}), this;
|
|
1019
1203
|
}
|
|
1020
1204
|
/**
|
|
1021
1205
|
* Set background color for current range.
|
|
1206
|
+
* @param {string} color The background color
|
|
1207
|
+
* @returns {FRange} This range, for chaining
|
|
1022
1208
|
* @example
|
|
1023
1209
|
* ```typescript
|
|
1024
1210
|
* univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackground('red')
|
|
1025
1211
|
* ```
|
|
1026
|
-
* @param color {string}
|
|
1027
1212
|
*/
|
|
1028
|
-
setBackground(
|
|
1029
|
-
return this.setBackgroundColor(
|
|
1213
|
+
setBackground(r) {
|
|
1214
|
+
return this.setBackgroundColor(r), this;
|
|
1030
1215
|
}
|
|
1031
1216
|
/**
|
|
1032
1217
|
* Set new value for current cell, first cell in this range.
|
|
1033
1218
|
* @param {CellValue | ICellData} value The value can be a number, string, boolean, or standard cell format. If it begins with `=`, it is interpreted as a formula. The value is tiled to all cells in the range.
|
|
1219
|
+
* @returns {FRange} This range, for chaining
|
|
1220
|
+
* ```ts
|
|
1221
|
+
* univerAPI.getActiveWorkbook()
|
|
1222
|
+
* .getActiveSheet()
|
|
1223
|
+
* .getActiveRange()
|
|
1224
|
+
* .setValue(1);
|
|
1225
|
+
* ```
|
|
1034
1226
|
*/
|
|
1035
|
-
setValue(
|
|
1036
|
-
const e =
|
|
1227
|
+
setValue(r) {
|
|
1228
|
+
const e = O(r);
|
|
1037
1229
|
if (!e)
|
|
1038
1230
|
throw new Error("Invalid value");
|
|
1039
|
-
return this._commandService.syncExecuteCommand(
|
|
1231
|
+
return this._commandService.syncExecuteCommand(N.id, {
|
|
1040
1232
|
unitId: this._workbook.getUnitId(),
|
|
1041
1233
|
subUnitId: this._worksheet.getSheetId(),
|
|
1042
1234
|
range: this._range,
|
|
@@ -1046,6 +1238,7 @@ let w = class extends ne {
|
|
|
1046
1238
|
/**
|
|
1047
1239
|
* Set new value for current cell, first cell in this range.
|
|
1048
1240
|
* @param {CellValue | ICellData} value The value can be a number, string, boolean, or standard cell format. If it begins with `=`, it is interpreted as a formula. The value is tiled to all cells in the range.
|
|
1241
|
+
* @returns {FRange} This range, for chaining
|
|
1049
1242
|
* ```ts
|
|
1050
1243
|
* univerAPI.getActiveWorkbook()
|
|
1051
1244
|
* .getActiveSheet()
|
|
@@ -1053,11 +1246,11 @@ let w = class extends ne {
|
|
|
1053
1246
|
* .setValueForCell(1);
|
|
1054
1247
|
* ```
|
|
1055
1248
|
*/
|
|
1056
|
-
setValueForCell(
|
|
1057
|
-
const e =
|
|
1249
|
+
setValueForCell(r) {
|
|
1250
|
+
const e = O(r);
|
|
1058
1251
|
if (!e)
|
|
1059
1252
|
throw new Error("Invalid value");
|
|
1060
|
-
return this._commandService.syncExecuteCommand(
|
|
1253
|
+
return this._commandService.syncExecuteCommand(N.id, {
|
|
1061
1254
|
unitId: this._workbook.getUnitId(),
|
|
1062
1255
|
subUnitId: this._worksheet.getSheetId(),
|
|
1063
1256
|
range: {
|
|
@@ -1081,8 +1274,8 @@ let w = class extends ne {
|
|
|
1081
1274
|
* .setRichTextValueForCell(new RichTextValue().insertText('Hello'));
|
|
1082
1275
|
* ```
|
|
1083
1276
|
*/
|
|
1084
|
-
setRichTextValueForCell(
|
|
1085
|
-
const e =
|
|
1277
|
+
setRichTextValueForCell(r) {
|
|
1278
|
+
const e = r instanceof E ? r.getData() : r, t = {
|
|
1086
1279
|
unitId: this._workbook.getUnitId(),
|
|
1087
1280
|
subUnitId: this._worksheet.getSheetId(),
|
|
1088
1281
|
range: {
|
|
@@ -1093,7 +1286,7 @@ let w = class extends ne {
|
|
|
1093
1286
|
},
|
|
1094
1287
|
value: { p: e }
|
|
1095
1288
|
};
|
|
1096
|
-
return this._commandService.syncExecuteCommand(
|
|
1289
|
+
return this._commandService.syncExecuteCommand(N.id, t), this;
|
|
1097
1290
|
}
|
|
1098
1291
|
/**
|
|
1099
1292
|
* Set the rich text value for the cells in the range.
|
|
@@ -1108,71 +1301,111 @@ let w = class extends ne {
|
|
|
1108
1301
|
* .setRichTextValues([[new RichTextValue().insertText('Hello')]]);
|
|
1109
1302
|
* ```
|
|
1110
1303
|
*/
|
|
1111
|
-
setRichTextValues(
|
|
1112
|
-
const e =
|
|
1304
|
+
setRichTextValues(r) {
|
|
1305
|
+
const e = r.map((s) => s.map((i) => i && { p: i instanceof E ? i.getData() : i })), t = Pe(e, this._range), n = {
|
|
1113
1306
|
unitId: this._workbook.getUnitId(),
|
|
1114
1307
|
subUnitId: this._worksheet.getSheetId(),
|
|
1115
1308
|
range: this._range,
|
|
1116
1309
|
value: t
|
|
1117
1310
|
};
|
|
1118
|
-
return this._commandService.syncExecuteCommand(
|
|
1311
|
+
return this._commandService.syncExecuteCommand(N.id, n), this;
|
|
1119
1312
|
}
|
|
1120
1313
|
/**
|
|
1121
1314
|
* Set the cell wrap of the given range.
|
|
1122
1315
|
* Cells with wrap enabled (the default) resize to display their full content. Cells with wrap disabled display as much as possible in the cell without resizing or running to multiple lines.
|
|
1123
|
-
* @param isWrapEnabled
|
|
1316
|
+
* @param {boolean} isWrapEnabled Whether to enable wrap
|
|
1317
|
+
* @returns {FRange} this range, for chaining
|
|
1318
|
+
* @example
|
|
1319
|
+
* ```ts
|
|
1320
|
+
* univerAPI.getActiveWorkbook()
|
|
1321
|
+
* .getActiveSheet()
|
|
1322
|
+
* .getActiveRange()
|
|
1323
|
+
* .setWrap(true);
|
|
1324
|
+
* ```
|
|
1124
1325
|
*/
|
|
1125
|
-
setWrap(
|
|
1126
|
-
return this._commandService.syncExecuteCommand(
|
|
1326
|
+
setWrap(r) {
|
|
1327
|
+
return this._commandService.syncExecuteCommand(Z.id, {
|
|
1127
1328
|
unitId: this._workbook.getUnitId(),
|
|
1128
1329
|
subUnitId: this._worksheet.getSheetId(),
|
|
1129
1330
|
range: this._range,
|
|
1130
|
-
value:
|
|
1331
|
+
value: r ? Y.WRAP : Y.UNSPECIFIED
|
|
1131
1332
|
}), this;
|
|
1132
1333
|
}
|
|
1133
1334
|
/**
|
|
1134
1335
|
* Sets the text wrapping strategy for the cells in the range.
|
|
1135
|
-
* @param strategy
|
|
1336
|
+
* @param {WrapStrategy} strategy The text wrapping strategy
|
|
1337
|
+
* @returns {FRange} this range, for chaining
|
|
1338
|
+
* @example
|
|
1339
|
+
* ```ts
|
|
1340
|
+
* univerAPI.getActiveWorkbook()
|
|
1341
|
+
* .getActiveSheet()
|
|
1342
|
+
* .getActiveRange()
|
|
1343
|
+
* .setWrapStrategy(WrapStrategy.WRAP);
|
|
1344
|
+
* ```
|
|
1136
1345
|
*/
|
|
1137
|
-
setWrapStrategy(
|
|
1138
|
-
return this._commandService.syncExecuteCommand(
|
|
1346
|
+
setWrapStrategy(r) {
|
|
1347
|
+
return this._commandService.syncExecuteCommand(Z.id, {
|
|
1139
1348
|
unitId: this._workbook.getUnitId(),
|
|
1140
1349
|
subUnitId: this._worksheet.getSheetId(),
|
|
1141
1350
|
range: this._range,
|
|
1142
|
-
value:
|
|
1351
|
+
value: r
|
|
1143
1352
|
}), this;
|
|
1144
1353
|
}
|
|
1145
1354
|
/**
|
|
1146
1355
|
* Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
|
|
1147
|
-
* @param alignment
|
|
1356
|
+
* @param {"top" | "middle" | "bottom"} alignment The vertical alignment
|
|
1357
|
+
* @returns {FRange} this range, for chaining
|
|
1358
|
+
* @example
|
|
1359
|
+
* ```ts
|
|
1360
|
+
* univerAPI.getActiveWorkbook()
|
|
1361
|
+
* .getActiveSheet()
|
|
1362
|
+
* .getActiveRange()
|
|
1363
|
+
* .setVerticalAlignment('top');
|
|
1364
|
+
* ```
|
|
1148
1365
|
*/
|
|
1149
|
-
setVerticalAlignment(
|
|
1150
|
-
return this._commandService.syncExecuteCommand(
|
|
1366
|
+
setVerticalAlignment(r) {
|
|
1367
|
+
return this._commandService.syncExecuteCommand(kt.id, {
|
|
1151
1368
|
unitId: this._workbook.getUnitId(),
|
|
1152
1369
|
subUnitId: this._worksheet.getSheetId(),
|
|
1153
1370
|
range: this._range,
|
|
1154
|
-
value:
|
|
1371
|
+
value: en(r)
|
|
1155
1372
|
}), this;
|
|
1156
1373
|
}
|
|
1157
1374
|
/**
|
|
1158
1375
|
* Set the horizontal (left to right) alignment for the given range (left/center/right).
|
|
1159
|
-
* @param alignment
|
|
1376
|
+
* @param {"left" | "center" | "normal"} alignment The horizontal alignment
|
|
1377
|
+
* @returns {FRange} this range, for chaining
|
|
1378
|
+
* @example
|
|
1379
|
+
* ```ts
|
|
1380
|
+
* univerAPI.getActiveWorkbook()
|
|
1381
|
+
* .getActiveSheet()
|
|
1382
|
+
* .getActiveRange()
|
|
1383
|
+
* .setHorizontalAlignment('left');
|
|
1384
|
+
* ```
|
|
1160
1385
|
*/
|
|
1161
|
-
setHorizontalAlignment(
|
|
1162
|
-
return this._commandService.syncExecuteCommand(
|
|
1386
|
+
setHorizontalAlignment(r) {
|
|
1387
|
+
return this._commandService.syncExecuteCommand(St.id, {
|
|
1163
1388
|
unitId: this._workbook.getUnitId(),
|
|
1164
1389
|
subUnitId: this._worksheet.getSheetId(),
|
|
1165
1390
|
range: this._range,
|
|
1166
|
-
value:
|
|
1391
|
+
value: Xt(r)
|
|
1167
1392
|
}), this;
|
|
1168
1393
|
}
|
|
1169
1394
|
/**
|
|
1170
1395
|
* Sets a different value for each cell in the range. The value can be a two-dimensional array or a standard range matrix (must match the dimensions of this range), consisting of numbers, strings, Boolean values or Composed of standard cell formats. If a value begins with `=`, it is interpreted as a formula.
|
|
1171
|
-
* @param value
|
|
1396
|
+
* @param {CellValue[][] | IObjectMatrixPrimitiveType<CellValue> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>} value The value can be a two-dimensional array or a standard range matrix (must match the dimensions of this range), consisting of numbers, strings, Boolean values or Composed of standard cell formats.
|
|
1397
|
+
* @returns {FRange} This range, for chaining
|
|
1398
|
+
* @example
|
|
1399
|
+
* ```ts
|
|
1400
|
+
* univerAPI.getActiveWorkbook()
|
|
1401
|
+
* .getActiveSheet()
|
|
1402
|
+
* .getActiveRange()
|
|
1403
|
+
* .setValues([[1, 2], [3, 4]]);
|
|
1404
|
+
* ```
|
|
1172
1405
|
*/
|
|
1173
|
-
setValues(
|
|
1174
|
-
const e =
|
|
1175
|
-
return this._commandService.syncExecuteCommand(
|
|
1406
|
+
setValues(r) {
|
|
1407
|
+
const e = Pe(r, this._range);
|
|
1408
|
+
return this._commandService.syncExecuteCommand(N.id, {
|
|
1176
1409
|
unitId: this._workbook.getUnitId(),
|
|
1177
1410
|
subUnitId: this._worksheet.getSheetId(),
|
|
1178
1411
|
range: this._range,
|
|
@@ -1181,15 +1414,23 @@ let w = class extends ne {
|
|
|
1181
1414
|
}
|
|
1182
1415
|
/**
|
|
1183
1416
|
* Sets the font weight for the given range (normal/bold),
|
|
1184
|
-
* @param fontWeight The font weight, either 'normal' or 'bold'; a null value resets the font weight.
|
|
1417
|
+
* @param {FontWeight|null} fontWeight The font weight, either 'normal' or 'bold'; a null value resets the font weight.
|
|
1418
|
+
* @returns {FRange} This range, for chaining
|
|
1419
|
+
* @example
|
|
1420
|
+
* ```ts
|
|
1421
|
+
* univerAPI.getActiveWorkbook()
|
|
1422
|
+
* .getActiveSheet()
|
|
1423
|
+
* .getActiveRange()
|
|
1424
|
+
* .setFontWeight('bold');
|
|
1425
|
+
* ```
|
|
1185
1426
|
*/
|
|
1186
|
-
setFontWeight(
|
|
1427
|
+
setFontWeight(r) {
|
|
1187
1428
|
let e;
|
|
1188
|
-
if (
|
|
1189
|
-
e =
|
|
1190
|
-
else if (
|
|
1191
|
-
e =
|
|
1192
|
-
else if (
|
|
1429
|
+
if (r === "bold")
|
|
1430
|
+
e = g.TRUE;
|
|
1431
|
+
else if (r === "normal")
|
|
1432
|
+
e = g.FALSE;
|
|
1433
|
+
else if (r === null)
|
|
1193
1434
|
e = null;
|
|
1194
1435
|
else
|
|
1195
1436
|
throw new Error("Invalid fontWeight");
|
|
@@ -1202,19 +1443,27 @@ let w = class extends ne {
|
|
|
1202
1443
|
range: this._range,
|
|
1203
1444
|
style: t
|
|
1204
1445
|
};
|
|
1205
|
-
return this._commandService.
|
|
1446
|
+
return this._commandService.syncExecuteCommand(I.id, n), this;
|
|
1206
1447
|
}
|
|
1207
1448
|
/**
|
|
1208
1449
|
* Sets the font style for the given range ('italic' or 'normal').
|
|
1209
|
-
* @param fontStyle The font style, either 'italic' or 'normal'; a null value resets the font style.
|
|
1450
|
+
* @param {FontStyle|null} fontStyle The font style, either 'italic' or 'normal'; a null value resets the font style.
|
|
1451
|
+
* @returns {FRange} This range, for chaining
|
|
1452
|
+
* @example
|
|
1453
|
+
* ```ts
|
|
1454
|
+
* univerAPI.getActiveWorkbook()
|
|
1455
|
+
* .getActiveSheet()
|
|
1456
|
+
* .getActiveRange()
|
|
1457
|
+
* .setFontStyle('italic');
|
|
1458
|
+
* ```
|
|
1210
1459
|
*/
|
|
1211
|
-
setFontStyle(
|
|
1460
|
+
setFontStyle(r) {
|
|
1212
1461
|
let e;
|
|
1213
|
-
if (
|
|
1214
|
-
e =
|
|
1215
|
-
else if (
|
|
1216
|
-
e =
|
|
1217
|
-
else if (
|
|
1462
|
+
if (r === "italic")
|
|
1463
|
+
e = g.TRUE;
|
|
1464
|
+
else if (r === "normal")
|
|
1465
|
+
e = g.FALSE;
|
|
1466
|
+
else if (r === null)
|
|
1218
1467
|
e = null;
|
|
1219
1468
|
else
|
|
1220
1469
|
throw new Error("Invalid fontStyle");
|
|
@@ -1227,28 +1476,36 @@ let w = class extends ne {
|
|
|
1227
1476
|
range: this._range,
|
|
1228
1477
|
style: t
|
|
1229
1478
|
};
|
|
1230
|
-
return this._commandService.
|
|
1479
|
+
return this._commandService.syncExecuteCommand(I.id, n), this;
|
|
1231
1480
|
}
|
|
1232
1481
|
/**
|
|
1233
1482
|
* Sets the font line style of the given range ('underline', 'line-through', or 'none').
|
|
1234
|
-
* @param fontLine The font line style, either 'underline', 'line-through', or 'none'; a null value resets the font line style.
|
|
1483
|
+
* @param {FontLine|null} fontLine The font line style, either 'underline', 'line-through', or 'none'; a null value resets the font line style.
|
|
1484
|
+
* @returns {FRange} This range, for chaining
|
|
1485
|
+
* @example
|
|
1486
|
+
* ```ts
|
|
1487
|
+
* univerAPI.getActiveWorkbook()
|
|
1488
|
+
* .getActiveSheet()
|
|
1489
|
+
* .getActiveRange()
|
|
1490
|
+
* .setFontLine('underline');
|
|
1491
|
+
* ```
|
|
1235
1492
|
*/
|
|
1236
|
-
setFontLine(
|
|
1237
|
-
if (
|
|
1493
|
+
setFontLine(r) {
|
|
1494
|
+
if (r === "underline")
|
|
1238
1495
|
this._setFontUnderline({
|
|
1239
|
-
s:
|
|
1496
|
+
s: g.TRUE
|
|
1240
1497
|
});
|
|
1241
|
-
else if (
|
|
1498
|
+
else if (r === "line-through")
|
|
1242
1499
|
this._setFontStrikethrough({
|
|
1243
|
-
s:
|
|
1500
|
+
s: g.TRUE
|
|
1244
1501
|
});
|
|
1245
|
-
else if (
|
|
1502
|
+
else if (r === "none")
|
|
1246
1503
|
this._setFontUnderline({
|
|
1247
|
-
s:
|
|
1504
|
+
s: g.FALSE
|
|
1248
1505
|
}), this._setFontStrikethrough({
|
|
1249
|
-
s:
|
|
1506
|
+
s: g.FALSE
|
|
1250
1507
|
});
|
|
1251
|
-
else if (
|
|
1508
|
+
else if (r === null)
|
|
1252
1509
|
this._setFontUnderline(null), this._setFontStrikethrough(null);
|
|
1253
1510
|
else
|
|
1254
1511
|
throw new Error("Invalid fontLine");
|
|
@@ -1256,90 +1513,123 @@ let w = class extends ne {
|
|
|
1256
1513
|
}
|
|
1257
1514
|
/**
|
|
1258
1515
|
* Sets the font underline style of the given ITextDecoration
|
|
1259
|
-
* @param value
|
|
1516
|
+
* @param {ITextDecoration|null} value The font underline style of the given ITextDecoration; a null value resets the font underline style
|
|
1517
|
+
* @returns {void}
|
|
1518
|
+
* @example
|
|
1519
|
+
* ```ts
|
|
1520
|
+
* univerAPI.getActiveWorkbook()
|
|
1521
|
+
* .getActiveSheet()
|
|
1522
|
+
* .getActiveRange()
|
|
1523
|
+
* .setFontLine('underline');
|
|
1524
|
+
* ```
|
|
1260
1525
|
*/
|
|
1261
|
-
_setFontUnderline(
|
|
1526
|
+
_setFontUnderline(r) {
|
|
1262
1527
|
const e = {
|
|
1263
1528
|
type: "ul",
|
|
1264
|
-
value:
|
|
1529
|
+
value: r
|
|
1265
1530
|
}, t = {
|
|
1266
1531
|
unitId: this._workbook.getUnitId(),
|
|
1267
1532
|
subUnitId: this._worksheet.getSheetId(),
|
|
1268
1533
|
range: this._range,
|
|
1269
1534
|
style: e
|
|
1270
1535
|
};
|
|
1271
|
-
this._commandService.
|
|
1536
|
+
this._commandService.syncExecuteCommand(I.id, t);
|
|
1272
1537
|
}
|
|
1273
1538
|
/**
|
|
1274
1539
|
* Sets the font strikethrough style of the given ITextDecoration
|
|
1275
|
-
* @param value
|
|
1540
|
+
* @param {ITextDecoration|null} value The font strikethrough style of the given ITextDecoration; a null value resets the font strikethrough style
|
|
1541
|
+
* @returns {void}
|
|
1276
1542
|
*/
|
|
1277
|
-
_setFontStrikethrough(
|
|
1543
|
+
_setFontStrikethrough(r) {
|
|
1278
1544
|
const e = {
|
|
1279
1545
|
type: "st",
|
|
1280
|
-
value:
|
|
1546
|
+
value: r
|
|
1281
1547
|
}, t = {
|
|
1282
1548
|
unitId: this._workbook.getUnitId(),
|
|
1283
1549
|
subUnitId: this._worksheet.getSheetId(),
|
|
1284
1550
|
range: this._range,
|
|
1285
1551
|
style: e
|
|
1286
1552
|
};
|
|
1287
|
-
this._commandService.
|
|
1553
|
+
this._commandService.syncExecuteCommand(I.id, t);
|
|
1288
1554
|
}
|
|
1289
1555
|
/**
|
|
1290
1556
|
* Sets the font family, such as "Arial" or "Helvetica".
|
|
1291
|
-
* @param fontFamily The font family to set; a null value resets the font family.
|
|
1557
|
+
* @param {string|null} fontFamily The font family to set; a null value resets the font family.
|
|
1558
|
+
* @returns {FRange} This range, for chaining
|
|
1559
|
+
* @example
|
|
1560
|
+
* ```ts
|
|
1561
|
+
* univerAPI.getActiveWorkbook()
|
|
1562
|
+
* .getActiveSheet()
|
|
1563
|
+
* .getActiveRange()
|
|
1564
|
+
* .setFontFamily('Arial');
|
|
1565
|
+
* ```
|
|
1292
1566
|
*/
|
|
1293
|
-
setFontFamily(
|
|
1567
|
+
setFontFamily(r) {
|
|
1294
1568
|
const e = {
|
|
1295
1569
|
type: "ff",
|
|
1296
|
-
value:
|
|
1570
|
+
value: r
|
|
1297
1571
|
}, t = {
|
|
1298
1572
|
unitId: this._workbook.getUnitId(),
|
|
1299
1573
|
subUnitId: this._worksheet.getSheetId(),
|
|
1300
1574
|
range: this._range,
|
|
1301
1575
|
style: e
|
|
1302
1576
|
};
|
|
1303
|
-
return this._commandService.
|
|
1577
|
+
return this._commandService.syncExecuteCommand(I.id, t), this;
|
|
1304
1578
|
}
|
|
1305
1579
|
/**
|
|
1306
1580
|
* Sets the font size, with the size being the point size to use.
|
|
1307
|
-
* @param size A font size in point size. A null value resets the font size.
|
|
1581
|
+
* @param {number|null} size A font size in point size. A null value resets the font size.
|
|
1582
|
+
* @returns {FRange} This range, for chaining
|
|
1583
|
+
* @example
|
|
1584
|
+
* ```ts
|
|
1585
|
+
* univerAPI.getActiveWorkbook()
|
|
1586
|
+
* .getActiveSheet()
|
|
1587
|
+
* .getActiveRange()
|
|
1588
|
+
* .setFontSize(12);
|
|
1589
|
+
* ```
|
|
1308
1590
|
*/
|
|
1309
|
-
setFontSize(
|
|
1591
|
+
setFontSize(r) {
|
|
1310
1592
|
const e = {
|
|
1311
1593
|
type: "fs",
|
|
1312
|
-
value:
|
|
1594
|
+
value: r
|
|
1313
1595
|
}, t = {
|
|
1314
1596
|
unitId: this._workbook.getUnitId(),
|
|
1315
1597
|
subUnitId: this._worksheet.getSheetId(),
|
|
1316
1598
|
range: this._range,
|
|
1317
1599
|
style: e
|
|
1318
1600
|
};
|
|
1319
|
-
return this._commandService.
|
|
1601
|
+
return this._commandService.syncExecuteCommand(I.id, t), this;
|
|
1320
1602
|
}
|
|
1321
1603
|
/**
|
|
1322
1604
|
* Sets the font color in CSS notation (such as '#ffffff' or 'white').
|
|
1323
|
-
* @param color The font color in CSS notation (such as '#ffffff' or 'white'); a null value resets the color.
|
|
1605
|
+
* @param {string|null} color The font color in CSS notation (such as '#ffffff' or 'white'); a null value resets the color.
|
|
1606
|
+
* @returns {FRange} This range, for chaining
|
|
1607
|
+
* @example
|
|
1608
|
+
* ```ts
|
|
1609
|
+
* univerAPI.getActiveWorkbook()
|
|
1610
|
+
* .getActiveSheet()
|
|
1611
|
+
* .getActiveRange()
|
|
1612
|
+
* .setFontColor('#ff0000');
|
|
1613
|
+
* ```
|
|
1324
1614
|
*/
|
|
1325
|
-
setFontColor(
|
|
1615
|
+
setFontColor(r) {
|
|
1326
1616
|
const t = {
|
|
1327
1617
|
type: "cl",
|
|
1328
|
-
value:
|
|
1618
|
+
value: r === null ? null : { rgb: r }
|
|
1329
1619
|
}, n = {
|
|
1330
1620
|
unitId: this._workbook.getUnitId(),
|
|
1331
1621
|
subUnitId: this._worksheet.getSheetId(),
|
|
1332
1622
|
range: this._range,
|
|
1333
1623
|
style: t
|
|
1334
1624
|
};
|
|
1335
|
-
return this._commandService.
|
|
1625
|
+
return this._commandService.syncExecuteCommand(I.id, n), this;
|
|
1336
1626
|
}
|
|
1337
1627
|
// #endregion editing
|
|
1338
1628
|
//#region Merge cell
|
|
1339
1629
|
/**
|
|
1340
1630
|
* Merge cells in a range into one merged cell
|
|
1341
|
-
* @param [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1342
|
-
* @returns This range, for chaining
|
|
1631
|
+
* @param {boolean} [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1632
|
+
* @returns {FRange} This range, for chaining
|
|
1343
1633
|
* @example
|
|
1344
1634
|
* ```ts
|
|
1345
1635
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
@@ -1350,14 +1640,14 @@ let w = class extends ne {
|
|
|
1350
1640
|
* console.log('debugger', isMerged);
|
|
1351
1641
|
* ```
|
|
1352
1642
|
*/
|
|
1353
|
-
merge(
|
|
1643
|
+
merge(r = !0) {
|
|
1354
1644
|
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId();
|
|
1355
|
-
return
|
|
1645
|
+
return H(this._injector, e, t, [this._range], r), this;
|
|
1356
1646
|
}
|
|
1357
1647
|
/**
|
|
1358
1648
|
* Merges cells in a range horizontally.
|
|
1359
|
-
* @param [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1360
|
-
* @returns This range, for chaining
|
|
1649
|
+
* @param {boolean} [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1650
|
+
* @returns {FRange} This range, for chaining
|
|
1361
1651
|
* @example
|
|
1362
1652
|
* ```ts
|
|
1363
1653
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
@@ -1368,14 +1658,14 @@ let w = class extends ne {
|
|
|
1368
1658
|
* console.log(allMerge.length); // There will be two merged cells.
|
|
1369
1659
|
* ```
|
|
1370
1660
|
*/
|
|
1371
|
-
mergeAcross(
|
|
1372
|
-
const e =
|
|
1373
|
-
return
|
|
1661
|
+
mergeAcross(r = !0) {
|
|
1662
|
+
const e = ke([this._range], me.ROWS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
1663
|
+
return H(this._injector, t, n, e, r), this;
|
|
1374
1664
|
}
|
|
1375
1665
|
/**
|
|
1376
1666
|
* Merges cells in a range vertically.
|
|
1377
|
-
* @param [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1378
|
-
* @returns This range, for chaining
|
|
1667
|
+
* @param {boolean} [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1668
|
+
* @returns {FRange} This range, for chaining
|
|
1379
1669
|
* @example
|
|
1380
1670
|
* ```ts
|
|
1381
1671
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
@@ -1386,9 +1676,9 @@ let w = class extends ne {
|
|
|
1386
1676
|
* console.log(allMerge.length); // There will be two merged cells.
|
|
1387
1677
|
* ```
|
|
1388
1678
|
*/
|
|
1389
|
-
mergeVertically(
|
|
1390
|
-
const e =
|
|
1391
|
-
return
|
|
1679
|
+
mergeVertically(r = !0) {
|
|
1680
|
+
const e = ke([this._range], me.COLUMNS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
1681
|
+
return H(this._injector, t, n, e, r), this;
|
|
1392
1682
|
}
|
|
1393
1683
|
/**
|
|
1394
1684
|
* Returns true if cells in the current range overlap a merged cell.
|
|
@@ -1405,12 +1695,12 @@ let w = class extends ne {
|
|
|
1405
1695
|
* ```
|
|
1406
1696
|
*/
|
|
1407
1697
|
isPartOfMerge() {
|
|
1408
|
-
const { startRow:
|
|
1409
|
-
return this._worksheet.getMergedCellRange(
|
|
1698
|
+
const { startRow: r, startColumn: e, endRow: t, endColumn: n } = this._range;
|
|
1699
|
+
return this._worksheet.getMergedCellRange(r, e, t, n).length > 0;
|
|
1410
1700
|
}
|
|
1411
1701
|
/**
|
|
1412
1702
|
* Break all horizontally- or vertically-merged cells contained within the range list into individual cells again.
|
|
1413
|
-
* @returns This range, for chaining
|
|
1703
|
+
* @returns {FRange} This range, for chaining
|
|
1414
1704
|
* @example
|
|
1415
1705
|
* ```ts
|
|
1416
1706
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
@@ -1426,12 +1716,12 @@ let w = class extends ne {
|
|
|
1426
1716
|
* ```
|
|
1427
1717
|
*/
|
|
1428
1718
|
breakApart() {
|
|
1429
|
-
return this._commandService.
|
|
1719
|
+
return this._commandService.syncExecuteCommand(wt.id, { ranges: [this._range] }), this;
|
|
1430
1720
|
}
|
|
1431
1721
|
//#endregion
|
|
1432
1722
|
/**
|
|
1433
1723
|
* Iterate cells in this range. Merged cells will be respected.
|
|
1434
|
-
* @param callback the callback function to be called for each cell in the range
|
|
1724
|
+
* @param {Function} callback the callback function to be called for each cell in the range
|
|
1435
1725
|
* @param {number} callback.row the row number of the cell
|
|
1436
1726
|
* @param {number} callback.col the column number of the cell
|
|
1437
1727
|
* @param {ICellData} callback.cell the cell data
|
|
@@ -1444,15 +1734,15 @@ let w = class extends ne {
|
|
|
1444
1734
|
* });
|
|
1445
1735
|
* ```
|
|
1446
1736
|
*/
|
|
1447
|
-
forEach(
|
|
1448
|
-
const { startColumn: e, startRow: t, endColumn: n, endRow:
|
|
1449
|
-
this._worksheet.getMatrixWithMergedCells(t, e,
|
|
1450
|
-
|
|
1737
|
+
forEach(r) {
|
|
1738
|
+
const { startColumn: e, startRow: t, endColumn: n, endRow: s } = this._range;
|
|
1739
|
+
this._worksheet.getMatrixWithMergedCells(t, e, s, n).forValue((i, o, h) => {
|
|
1740
|
+
r(i, o, h);
|
|
1451
1741
|
});
|
|
1452
1742
|
}
|
|
1453
1743
|
/**
|
|
1454
1744
|
* Returns a string description of the range, in A1 notation.
|
|
1455
|
-
* @param withSheet
|
|
1745
|
+
* @param {boolean} [withSheet] - If true, the sheet name is included in the A1 notation.
|
|
1456
1746
|
* @returns {string} The A1 notation of the range.
|
|
1457
1747
|
* ```ts
|
|
1458
1748
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1461,8 +1751,8 @@ let w = class extends ne {
|
|
|
1461
1751
|
* console.log(fRange.getA1Notation()); // A1:B2
|
|
1462
1752
|
* ```
|
|
1463
1753
|
*/
|
|
1464
|
-
getA1Notation(
|
|
1465
|
-
return
|
|
1754
|
+
getA1Notation(r) {
|
|
1755
|
+
return r ? Ht(this._worksheet.getName(), this._range) : ue(this._range);
|
|
1466
1756
|
}
|
|
1467
1757
|
/**
|
|
1468
1758
|
* Sets the specified range as the active range, with the top left cell in the range as the current cell.
|
|
@@ -1476,7 +1766,7 @@ let w = class extends ne {
|
|
|
1476
1766
|
* ```
|
|
1477
1767
|
*/
|
|
1478
1768
|
activate() {
|
|
1479
|
-
return this._injector.createInstance(
|
|
1769
|
+
return this._injector.createInstance(f, this._workbook).setActiveRange(this), this;
|
|
1480
1770
|
}
|
|
1481
1771
|
/**
|
|
1482
1772
|
* Sets the specified cell as the current cell.
|
|
@@ -1486,8 +1776,8 @@ let w = class extends ne {
|
|
|
1486
1776
|
* @description If the range is not a single cell, an error will be thrown.
|
|
1487
1777
|
*/
|
|
1488
1778
|
activateAsCurrentCell() {
|
|
1489
|
-
const
|
|
1490
|
-
if (
|
|
1779
|
+
const r = this._worksheet.getMergedCell(this._range.startRow, this._range.startColumn);
|
|
1780
|
+
if (r && M.equals(r, this._range) || !r && this._range.startRow === this._range.endRow && this._range.startColumn === this._range.endColumn)
|
|
1491
1781
|
return this.activate();
|
|
1492
1782
|
throw new Error("The range is not a single cell");
|
|
1493
1783
|
}
|
|
@@ -1523,14 +1813,14 @@ let w = class extends ne {
|
|
|
1523
1813
|
* // 1 | 2 | 3
|
|
1524
1814
|
* // 4 | 5 | 6
|
|
1525
1815
|
*/
|
|
1526
|
-
splitTextToColumns(
|
|
1527
|
-
this._commandService.
|
|
1816
|
+
splitTextToColumns(r, e, t) {
|
|
1817
|
+
this._commandService.syncExecuteCommand(Ct.id, {
|
|
1528
1818
|
unitId: this._workbook.getUnitId(),
|
|
1529
1819
|
subUnitId: this._worksheet.getSheetId(),
|
|
1530
1820
|
range: this._range,
|
|
1531
1821
|
delimiter: e,
|
|
1532
1822
|
customDelimiter: t,
|
|
1533
|
-
treatMultipleDelimitersAsOne:
|
|
1823
|
+
treatMultipleDelimitersAsOne: r
|
|
1534
1824
|
});
|
|
1535
1825
|
}
|
|
1536
1826
|
/**
|
|
@@ -1544,16 +1834,16 @@ let w = class extends ne {
|
|
|
1544
1834
|
* fRange.useThemeStyle('default');
|
|
1545
1835
|
* ```
|
|
1546
1836
|
*/
|
|
1547
|
-
useThemeStyle(
|
|
1548
|
-
if (
|
|
1837
|
+
useThemeStyle(r) {
|
|
1838
|
+
if (r == null) {
|
|
1549
1839
|
const e = this.getUsedThemeStyle();
|
|
1550
1840
|
e && this.removeThemeStyle(e);
|
|
1551
1841
|
} else
|
|
1552
|
-
this._commandService.
|
|
1842
|
+
this._commandService.syncExecuteCommand(ft.id, {
|
|
1553
1843
|
unitId: this._workbook.getUnitId(),
|
|
1554
1844
|
subUnitId: this._worksheet.getSheetId(),
|
|
1555
1845
|
range: this._range,
|
|
1556
|
-
themeName:
|
|
1846
|
+
themeName: r
|
|
1557
1847
|
});
|
|
1558
1848
|
}
|
|
1559
1849
|
/**
|
|
@@ -1567,12 +1857,12 @@ let w = class extends ne {
|
|
|
1567
1857
|
* fRange.removeThemeStyle('default');
|
|
1568
1858
|
* ```
|
|
1569
1859
|
*/
|
|
1570
|
-
removeThemeStyle(
|
|
1571
|
-
this._commandService.
|
|
1860
|
+
removeThemeStyle(r) {
|
|
1861
|
+
this._commandService.syncExecuteCommand(vt.id, {
|
|
1572
1862
|
unitId: this._workbook.getUnitId(),
|
|
1573
1863
|
subUnitId: this._worksheet.getSheetId(),
|
|
1574
1864
|
range: this._range,
|
|
1575
|
-
themeName:
|
|
1865
|
+
themeName: r
|
|
1576
1866
|
});
|
|
1577
1867
|
}
|
|
1578
1868
|
/**
|
|
@@ -1589,49 +1879,73 @@ let w = class extends ne {
|
|
|
1589
1879
|
* ```
|
|
1590
1880
|
*/
|
|
1591
1881
|
getUsedThemeStyle() {
|
|
1592
|
-
return this._injector.get(
|
|
1882
|
+
return this._injector.get(Ve).getAppliedRangeThemeStyle({
|
|
1593
1883
|
unitId: this._workbook.getUnitId(),
|
|
1594
1884
|
subUnitId: this._worksheet.getSheetId(),
|
|
1595
1885
|
range: this._range
|
|
1596
1886
|
});
|
|
1597
1887
|
}
|
|
1598
1888
|
};
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
],
|
|
1604
|
-
var
|
|
1605
|
-
for (var
|
|
1606
|
-
(
|
|
1607
|
-
return n &&
|
|
1608
|
-
},
|
|
1609
|
-
let
|
|
1610
|
-
constructor(
|
|
1611
|
-
this._workbook =
|
|
1889
|
+
S = sn([
|
|
1890
|
+
K(3, u(y)),
|
|
1891
|
+
K(4, l),
|
|
1892
|
+
K(5, u(Vt))
|
|
1893
|
+
], S);
|
|
1894
|
+
var on = Object.defineProperty, hn = Object.getOwnPropertyDescriptor, an = (r, e, t, n) => {
|
|
1895
|
+
for (var s = n > 1 ? void 0 : n ? hn(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
1896
|
+
(o = r[i]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
1897
|
+
return n && s && on(e, t, s), s;
|
|
1898
|
+
}, dn = (r, e) => (t, n) => e(t, n, r);
|
|
1899
|
+
let L = class {
|
|
1900
|
+
constructor(r, e, t, n) {
|
|
1901
|
+
this._workbook = r, this._worksheet = e, this._selections = t, this._injector = n;
|
|
1612
1902
|
}
|
|
1613
1903
|
/**
|
|
1614
1904
|
* Represents the active selection in the sheet. Which means the selection contains the active cell.
|
|
1615
1905
|
* @returns {FRange | null} The active selection.
|
|
1906
|
+
* @example
|
|
1907
|
+
* ```ts
|
|
1908
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1909
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1910
|
+
* const fSelection = fWorksheet.getSelection();
|
|
1911
|
+
* const activeRange = fSelection.getActiveRange();
|
|
1912
|
+
* console.log(activeRange);
|
|
1913
|
+
* ```
|
|
1616
1914
|
*/
|
|
1617
1915
|
getActiveRange() {
|
|
1618
|
-
const
|
|
1619
|
-
return
|
|
1916
|
+
const r = this._selections.find((e) => !!e.primary);
|
|
1917
|
+
return r ? this._injector.createInstance(S, this._workbook, this._worksheet, r.range) : null;
|
|
1620
1918
|
}
|
|
1621
1919
|
/**
|
|
1622
1920
|
* Represents the active selection list in the sheet.
|
|
1623
1921
|
* @returns {FRange[]} The active selection list.
|
|
1922
|
+
* @example
|
|
1923
|
+
* ```ts
|
|
1924
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1925
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1926
|
+
* const fSelection = fWorksheet.getSelection();
|
|
1927
|
+
* const activeRangeList = fSelection.getActiveRangeList();
|
|
1928
|
+
* console.log(activeRangeList);
|
|
1929
|
+
* ```
|
|
1624
1930
|
*/
|
|
1625
1931
|
getActiveRangeList() {
|
|
1626
|
-
return this._selections.map((
|
|
1932
|
+
return this._selections.map((r) => this._injector.createInstance(S, this._workbook, this._worksheet, r.range));
|
|
1627
1933
|
}
|
|
1628
1934
|
/**
|
|
1629
1935
|
* Represents the current select cell in the sheet.
|
|
1630
1936
|
* @returns {ISelectionCell} The current select cell info.Pay attention to the type of the return value.
|
|
1937
|
+
* @example
|
|
1938
|
+
* ```ts
|
|
1939
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1940
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1941
|
+
* const fSelection = fWorksheet.getSelection();
|
|
1942
|
+
* const currentCell = fSelection.getCurrentCell();
|
|
1943
|
+
* console.log(currentCell);
|
|
1944
|
+
* ```
|
|
1631
1945
|
*/
|
|
1632
1946
|
getCurrentCell() {
|
|
1633
|
-
const
|
|
1634
|
-
return
|
|
1947
|
+
const r = this._selections.find((e) => !!e.primary);
|
|
1948
|
+
return r ? r.primary : null;
|
|
1635
1949
|
}
|
|
1636
1950
|
/**
|
|
1637
1951
|
* Returns the active sheet in the spreadsheet.
|
|
@@ -1646,8 +1960,8 @@ let B = class {
|
|
|
1646
1960
|
* ```
|
|
1647
1961
|
*/
|
|
1648
1962
|
getActiveSheet() {
|
|
1649
|
-
const
|
|
1650
|
-
return this._injector.createInstance(
|
|
1963
|
+
const r = this._injector.createInstance(f, this._workbook);
|
|
1964
|
+
return this._injector.createInstance(m, r, this._workbook, this._worksheet);
|
|
1651
1965
|
}
|
|
1652
1966
|
/**
|
|
1653
1967
|
* 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.
|
|
@@ -1663,31 +1977,31 @@ let B = class {
|
|
|
1663
1977
|
* console.log(newSelection.getActiveRange().getA1Notation()); // A1
|
|
1664
1978
|
* ```
|
|
1665
1979
|
*/
|
|
1666
|
-
updatePrimaryCell(
|
|
1980
|
+
updatePrimaryCell(r) {
|
|
1667
1981
|
const e = this._injector.get(l);
|
|
1668
1982
|
let t = [], n = !1;
|
|
1669
|
-
for (const { range:
|
|
1670
|
-
|
|
1671
|
-
range:
|
|
1672
|
-
primary:
|
|
1673
|
-
style:
|
|
1983
|
+
for (const { range: i, style: o } of this._selections)
|
|
1984
|
+
M.contains(i, r.getRange()) ? (t.push({
|
|
1985
|
+
range: i,
|
|
1986
|
+
primary: ee(r.getRange(), this._worksheet),
|
|
1987
|
+
style: o
|
|
1674
1988
|
}), n = !0) : t.push({
|
|
1675
|
-
range:
|
|
1989
|
+
range: i,
|
|
1676
1990
|
primary: null,
|
|
1677
|
-
style:
|
|
1991
|
+
style: o
|
|
1678
1992
|
});
|
|
1679
1993
|
n || (t = [
|
|
1680
1994
|
{
|
|
1681
|
-
range:
|
|
1682
|
-
primary:
|
|
1995
|
+
range: r.getRange(),
|
|
1996
|
+
primary: ee(r.getRange(), this._worksheet)
|
|
1683
1997
|
}
|
|
1684
1998
|
]);
|
|
1685
|
-
const
|
|
1999
|
+
const s = {
|
|
1686
2000
|
unitId: this._workbook.getUnitId(),
|
|
1687
2001
|
subUnitId: this._worksheet.getSheetId(),
|
|
1688
2002
|
selections: t
|
|
1689
2003
|
};
|
|
1690
|
-
return e.syncExecuteCommand(
|
|
2004
|
+
return e.syncExecuteCommand(He.id, s), new L(this._workbook, this._worksheet, t, this._injector);
|
|
1691
2005
|
}
|
|
1692
2006
|
/**
|
|
1693
2007
|
*Get the next primary cell in the specified direction. If the primary cell not exists in selections, return null.
|
|
@@ -1704,79 +2018,77 @@ let B = class {
|
|
|
1704
2018
|
* console.log(nextCell?.getA1Notation()); // B1
|
|
1705
2019
|
* ```
|
|
1706
2020
|
*/
|
|
1707
|
-
getNextDataRange(
|
|
2021
|
+
getNextDataRange(r) {
|
|
1708
2022
|
if (!this._selections.find((n) => !!n.primary))
|
|
1709
2023
|
return null;
|
|
1710
|
-
const t =
|
|
1711
|
-
return t ? this._injector.createInstance(
|
|
2024
|
+
const t = It(this._selections.concat(), r, this._worksheet);
|
|
2025
|
+
return t ? this._injector.createInstance(S, this._workbook, this._worksheet, t) : null;
|
|
1712
2026
|
}
|
|
1713
2027
|
};
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
],
|
|
1717
|
-
var
|
|
1718
|
-
for (var
|
|
1719
|
-
(
|
|
1720
|
-
return n &&
|
|
1721
|
-
},
|
|
1722
|
-
let
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
2028
|
+
L = an([
|
|
2029
|
+
dn(3, u(y))
|
|
2030
|
+
], L);
|
|
2031
|
+
var cn = Object.defineProperty, un = Object.getOwnPropertyDescriptor, gn = (r, e, t, n) => {
|
|
2032
|
+
for (var s = n > 1 ? void 0 : n ? un(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
2033
|
+
(o = r[i]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
2034
|
+
return n && s && cn(e, t, s), s;
|
|
2035
|
+
}, B = (r, e) => (t, n) => e(t, n, r);
|
|
2036
|
+
let m = class extends ce {
|
|
2037
|
+
/**
|
|
2038
|
+
* Creates a new worksheet facade instance
|
|
2039
|
+
* @param {FWorkbook} _fWorkbook - The facade workbook instance
|
|
2040
|
+
* @param {Workbook} _workbook - The workbook instance
|
|
2041
|
+
* @param {Worksheet} _worksheet - The worksheet instance
|
|
2042
|
+
* @param {Injector} _injector - The injector instance
|
|
2043
|
+
* @param {SheetsSelectionsService} _selectionManagerService - The selection manager service
|
|
2044
|
+
* @param {ILogService} _logService - The log service
|
|
2045
|
+
* @param {ICommandService} _commandService - The command service
|
|
2046
|
+
*/
|
|
2047
|
+
constructor(e, t, n, s, i, o, h) {
|
|
2048
|
+
super(s);
|
|
1726
2049
|
/**
|
|
1727
2050
|
* Sets the active selection region for this sheet.
|
|
1728
|
-
* @param range The range to set as the active selection
|
|
2051
|
+
* @param range - The range to set as the active selection
|
|
2052
|
+
* @returns This sheet, for chaining
|
|
2053
|
+
* @example
|
|
2054
|
+
* ```ts
|
|
2055
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2056
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2057
|
+
* fWorkSheet.setActiveRange(fWorkSheet.getRange('A1'));
|
|
2058
|
+
* ```
|
|
1729
2059
|
*/
|
|
1730
|
-
|
|
1731
|
-
this._fWorkbook = e, this._workbook = t, this._worksheet = n, this._injector =
|
|
1732
|
-
}
|
|
1733
|
-
getSheet() {
|
|
1734
|
-
return this._worksheet;
|
|
1735
|
-
}
|
|
1736
|
-
_ensureEventRegistry(e) {
|
|
1737
|
-
return this._eventRegistry.has(e) || this._eventRegistry.set(e, new ye()), this._eventRegistry.get(e);
|
|
2060
|
+
b(this, "setActiveSelection", this.setActiveRange);
|
|
2061
|
+
this._fWorkbook = e, this._workbook = t, this._worksheet = n, this._injector = s, this._selectionManagerService = i, this._logService = o, this._commandService = h;
|
|
1738
2062
|
}
|
|
1739
2063
|
/**
|
|
1740
|
-
*
|
|
1741
|
-
* @
|
|
1742
|
-
* @param callback callback when event triggered
|
|
1743
|
-
* @returns {Disposable} The Disposable instance, for remove the listener
|
|
2064
|
+
* Returns the worksheet
|
|
2065
|
+
* @returns {Worksheet} The worksheet instance.
|
|
1744
2066
|
* @example
|
|
1745
|
-
* ```
|
|
1746
|
-
* univerAPI.
|
|
1747
|
-
* console.log('unit created', params);
|
|
1748
|
-
* });
|
|
2067
|
+
* ```typescript
|
|
2068
|
+
* const sheet = univerAPI.getActiveWorkbook().getActiveSheet().getSheet();
|
|
1749
2069
|
* ```
|
|
1750
2070
|
*/
|
|
1751
|
-
|
|
1752
|
-
return this.
|
|
2071
|
+
getSheet() {
|
|
2072
|
+
return this._worksheet;
|
|
1753
2073
|
}
|
|
1754
2074
|
/**
|
|
1755
|
-
*
|
|
1756
|
-
* @
|
|
1757
|
-
* @param params {any} params of event
|
|
1758
|
-
* @returns {boolean} should cancel
|
|
2075
|
+
* Returns the injector
|
|
2076
|
+
* @returns {Injector} The injector
|
|
1759
2077
|
* @example
|
|
1760
|
-
* ```
|
|
1761
|
-
*
|
|
2078
|
+
* ```typescript
|
|
2079
|
+
* const injector = univerAPI.getActiveWorkbook().getActiveSheet().getInject();
|
|
1762
2080
|
* ```
|
|
1763
2081
|
*/
|
|
1764
|
-
fireEvent(e, t) {
|
|
1765
|
-
var n;
|
|
1766
|
-
return (n = this._eventRegistry.get(e)) == null || n.getData().forEach((r) => {
|
|
1767
|
-
r(t);
|
|
1768
|
-
}), t.cancel;
|
|
1769
|
-
}
|
|
1770
|
-
/**
|
|
1771
|
-
* Returns the injector
|
|
1772
|
-
* @returns The injector
|
|
1773
|
-
*/
|
|
1774
2082
|
getInject() {
|
|
1775
2083
|
return this._injector;
|
|
1776
2084
|
}
|
|
1777
2085
|
/**
|
|
1778
2086
|
* Returns the workbook
|
|
1779
2087
|
* @returns {Workbook} The workbook instance.
|
|
2088
|
+
* @example
|
|
2089
|
+
* ```typescript
|
|
2090
|
+
* const workbook = univerAPI.getActiveWorkbook().getWorkbook();
|
|
2091
|
+
* ```
|
|
1780
2092
|
*/
|
|
1781
2093
|
getWorkbook() {
|
|
1782
2094
|
return this._workbook;
|
|
@@ -1784,6 +2096,11 @@ let g = class extends ne {
|
|
|
1784
2096
|
/**
|
|
1785
2097
|
* Returns the worksheet id.
|
|
1786
2098
|
* @returns {string} The id of the worksheet.
|
|
2099
|
+
* @example
|
|
2100
|
+
* ```typescript
|
|
2101
|
+
* const sheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
2102
|
+
* const id = sheet.getSheetId();
|
|
2103
|
+
* ```
|
|
1787
2104
|
*/
|
|
1788
2105
|
getSheetId() {
|
|
1789
2106
|
return this._worksheet.getSheetId();
|
|
@@ -1791,6 +2108,11 @@ let g = class extends ne {
|
|
|
1791
2108
|
/**
|
|
1792
2109
|
* Returns the worksheet name.
|
|
1793
2110
|
* @returns {string} The name of the worksheet.
|
|
2111
|
+
* @example
|
|
2112
|
+
* ```typescript
|
|
2113
|
+
* const sheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
2114
|
+
* const name = sheet.getSheetName();
|
|
2115
|
+
* ```
|
|
1794
2116
|
*/
|
|
1795
2117
|
getSheetName() {
|
|
1796
2118
|
return this._worksheet.getName();
|
|
@@ -1798,46 +2120,78 @@ let g = class extends ne {
|
|
|
1798
2120
|
/**
|
|
1799
2121
|
* Represents the selection ranges info of the worksheet.
|
|
1800
2122
|
* @returns {FSelection} return the current selections of the worksheet or null if there is no selection.
|
|
2123
|
+
* @example
|
|
2124
|
+
* ```typescript
|
|
2125
|
+
* const sheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
2126
|
+
* const selections = sheet.getSelection();
|
|
2127
|
+
* ```
|
|
1801
2128
|
*/
|
|
1802
2129
|
getSelection() {
|
|
1803
2130
|
const e = this._selectionManagerService.getCurrentSelections();
|
|
1804
|
-
return e ? this._injector.createInstance(
|
|
2131
|
+
return e ? this._injector.createInstance(L, this._workbook, this._worksheet, e) : null;
|
|
1805
2132
|
}
|
|
1806
2133
|
// #region rows
|
|
1807
2134
|
// #region default style
|
|
1808
2135
|
/**
|
|
1809
2136
|
* Get the default style of the worksheet
|
|
1810
2137
|
* @returns {IStyleData} Default style of the worksheet.
|
|
2138
|
+
* @example
|
|
2139
|
+
* ```typescript
|
|
2140
|
+
* const sheet = workbook.getActiveSheet();
|
|
2141
|
+
* const defaultStyle = sheet.getDefaultStyle();
|
|
2142
|
+
* ```
|
|
1811
2143
|
*/
|
|
1812
2144
|
getDefaultStyle() {
|
|
1813
2145
|
return this._worksheet.getDefaultCellStyle();
|
|
1814
2146
|
}
|
|
1815
2147
|
/**
|
|
1816
2148
|
* Get the default style of the worksheet row
|
|
1817
|
-
* @param {number} index The row index
|
|
1818
|
-
* @param {boolean} [keepRaw] If true, return the raw style data maybe the style name or style data, otherwise return the data from row manager
|
|
1819
|
-
* @returns {Nullable<IStyleData> | string} The default style of the worksheet row name or style data
|
|
2149
|
+
* @param {number} index - The row index
|
|
2150
|
+
* @param {boolean} [keepRaw] - If true, return the raw style data maybe the style name or style data, otherwise return the data from row manager
|
|
2151
|
+
* @returns {(Nullable<IStyleData> | string)} The default style of the worksheet row name or style data
|
|
2152
|
+
* @example
|
|
2153
|
+
* ```typescript
|
|
2154
|
+
* const sheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
2155
|
+
* // Get default style for row 0 (1)
|
|
2156
|
+
* const rowStyle = sheet.getRowDefaultStyle(0);
|
|
2157
|
+
* // Get raw style data for row 0
|
|
2158
|
+
* const rawRowStyle = sheet.getRowDefaultStyle(0, true);
|
|
2159
|
+
* ```
|
|
1820
2160
|
*/
|
|
1821
2161
|
getRowDefaultStyle(e, t = !1) {
|
|
1822
2162
|
return this._worksheet.getRowStyle(e, t);
|
|
1823
2163
|
}
|
|
1824
2164
|
/**
|
|
1825
2165
|
* Get the default style of the worksheet column
|
|
1826
|
-
* @param {number} index The column index
|
|
1827
|
-
* @param {boolean} [keepRaw] If true, return the raw style data maybe the style name or style data, otherwise return the data from col manager
|
|
1828
|
-
* @returns {Nullable<IStyleData> | string} The default style of the worksheet column name or style data
|
|
2166
|
+
* @param {number} index - The column index
|
|
2167
|
+
* @param {boolean} [keepRaw] - If true, return the raw style data maybe the style name or style data, otherwise return the data from col manager
|
|
2168
|
+
* @returns {(Nullable<IStyleData> | string)} The default style of the worksheet column name or style data
|
|
2169
|
+
* @example
|
|
2170
|
+
* ```typescript
|
|
2171
|
+
* const sheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
2172
|
+
* // Get default style for column 0 (A)
|
|
2173
|
+
* const colStyle = sheet.getColumnDefaultStyle(0);
|
|
2174
|
+
* // Get raw style data for column 0
|
|
2175
|
+
* const rawColStyle = sheet.getColumnDefaultStyle(0, true);
|
|
2176
|
+
* ```
|
|
1829
2177
|
*/
|
|
1830
2178
|
getColumnDefaultStyle(e, t = !1) {
|
|
1831
2179
|
return this._worksheet.getColumnStyle(e, t);
|
|
1832
2180
|
}
|
|
1833
2181
|
/**
|
|
1834
2182
|
* Set the default style of the worksheet
|
|
1835
|
-
* @param {
|
|
1836
|
-
* @returns {FWorksheet} This
|
|
2183
|
+
* @param {string} style - The style to set
|
|
2184
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2185
|
+
* @example
|
|
2186
|
+
* ```typescript
|
|
2187
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2188
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
2189
|
+
* fWorksheet.setDefaultStyle('default');
|
|
2190
|
+
* ```
|
|
1837
2191
|
*/
|
|
1838
2192
|
setDefaultStyle(e) {
|
|
1839
2193
|
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
1840
|
-
return this._commandService.syncExecuteCommand(
|
|
2194
|
+
return this._commandService.syncExecuteCommand(bt.id, {
|
|
1841
2195
|
unitId: t,
|
|
1842
2196
|
subUnitId: n,
|
|
1843
2197
|
defaultStyle: e
|
|
@@ -1845,74 +2199,94 @@ let g = class extends ne {
|
|
|
1845
2199
|
}
|
|
1846
2200
|
/**
|
|
1847
2201
|
* Set the default style of the worksheet row
|
|
1848
|
-
* @param {number} index The row index
|
|
1849
|
-
* @param {string | Nullable<IStyleData>} style The style name or style data
|
|
2202
|
+
* @param {number} index - The row index
|
|
2203
|
+
* @param {string | Nullable<IStyleData>} style - The style name or style data
|
|
1850
2204
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2205
|
+
* @example
|
|
2206
|
+
* ```ts
|
|
2207
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2208
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
2209
|
+
* fWorksheet.setRowDefaultStyle(0, 'default');
|
|
2210
|
+
* ```
|
|
1851
2211
|
*/
|
|
1852
2212
|
setColumnDefaultStyle(e, t) {
|
|
1853
|
-
const n = this._workbook.getUnitId(),
|
|
2213
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = {
|
|
1854
2214
|
unitId: n,
|
|
1855
|
-
subUnitId:
|
|
2215
|
+
subUnitId: s,
|
|
1856
2216
|
columnData: {
|
|
1857
2217
|
[e]: {
|
|
1858
2218
|
s: t
|
|
1859
2219
|
}
|
|
1860
2220
|
}
|
|
1861
2221
|
};
|
|
1862
|
-
return this._commandService.syncExecuteCommand(
|
|
2222
|
+
return this._commandService.syncExecuteCommand(Se.id, i), this;
|
|
1863
2223
|
}
|
|
1864
2224
|
/**
|
|
1865
2225
|
* Set the default style of the worksheet column
|
|
1866
|
-
* @param {number} index The column index
|
|
1867
|
-
* @param {string | Nullable<IStyleData>} style The style name or style data
|
|
2226
|
+
* @param {number} index - The column index
|
|
2227
|
+
* @param {string | Nullable<IStyleData>} style - The style name or style data
|
|
1868
2228
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2229
|
+
* @example
|
|
2230
|
+
* ```ts
|
|
2231
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2232
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
2233
|
+
* fWorksheet.setColumnDefaultStyle(0, 'default');
|
|
2234
|
+
* ```
|
|
1869
2235
|
*/
|
|
1870
2236
|
setRowDefaultStyle(e, t) {
|
|
1871
|
-
const n = this._workbook.getUnitId(),
|
|
2237
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = {
|
|
1872
2238
|
unitId: n,
|
|
1873
|
-
subUnitId:
|
|
2239
|
+
subUnitId: s,
|
|
1874
2240
|
rowData: {
|
|
1875
2241
|
[e]: {
|
|
1876
2242
|
s: t
|
|
1877
2243
|
}
|
|
1878
2244
|
}
|
|
1879
2245
|
};
|
|
1880
|
-
return this._commandService.syncExecuteCommand(
|
|
1881
|
-
}
|
|
1882
|
-
getRange(e, t, n,
|
|
1883
|
-
let
|
|
1884
|
-
if (typeof e == "
|
|
1885
|
-
|
|
1886
|
-
|
|
2246
|
+
return this._commandService.syncExecuteCommand(we.id, i), this;
|
|
2247
|
+
}
|
|
2248
|
+
getRange(e, t, n, s) {
|
|
2249
|
+
let i, o;
|
|
2250
|
+
if (typeof e == "object")
|
|
2251
|
+
i = e, o = this._worksheet;
|
|
2252
|
+
else if (typeof e == "string") {
|
|
2253
|
+
const { range: h, sheetName: a } = zt(e), d = a ? this._workbook.getSheetBySheetName(a) : this._worksheet;
|
|
2254
|
+
if (!d)
|
|
1887
2255
|
throw new Error("Range not found");
|
|
1888
|
-
|
|
1889
|
-
...
|
|
2256
|
+
o = d, i = {
|
|
2257
|
+
...h,
|
|
1890
2258
|
unitId: this._workbook.getUnitId(),
|
|
1891
|
-
sheetId:
|
|
2259
|
+
sheetId: o.getSheetId(),
|
|
1892
2260
|
// Use the current range instead of the future actual range to match Apps Script behavior.
|
|
1893
2261
|
// Users can create the latest range in real time when needed.
|
|
1894
2262
|
rangeType: _.NORMAL,
|
|
1895
|
-
startRow:
|
|
1896
|
-
endRow:
|
|
1897
|
-
startColumn:
|
|
1898
|
-
endColumn:
|
|
2263
|
+
startRow: h.rangeType === _.COLUMN ? 0 : h.startRow,
|
|
2264
|
+
endRow: h.rangeType === _.COLUMN ? o.getMaxRows() - 1 : h.endRow,
|
|
2265
|
+
startColumn: h.rangeType === _.ROW ? 0 : h.startColumn,
|
|
2266
|
+
endColumn: h.rangeType === _.ROW ? o.getMaxColumns() - 1 : h.endColumn
|
|
1899
2267
|
};
|
|
1900
2268
|
} else if (typeof e == "number" && t !== void 0)
|
|
1901
|
-
|
|
2269
|
+
o = this._worksheet, i = {
|
|
1902
2270
|
startRow: e,
|
|
1903
2271
|
endRow: e + (n != null ? n : 1) - 1,
|
|
1904
2272
|
startColumn: t,
|
|
1905
|
-
endColumn: t + (
|
|
2273
|
+
endColumn: t + (s != null ? s : 1) - 1,
|
|
1906
2274
|
unitId: this._workbook.getUnitId(),
|
|
1907
2275
|
sheetId: this._worksheet.getSheetId()
|
|
1908
2276
|
};
|
|
1909
2277
|
else
|
|
1910
2278
|
throw new Error("Invalid range specification");
|
|
1911
|
-
return this._injector.createInstance(
|
|
2279
|
+
return this._injector.createInstance(S, this._workbook, o, i);
|
|
1912
2280
|
}
|
|
1913
2281
|
/**
|
|
1914
2282
|
* Returns the current number of columns in the sheet, regardless of content.
|
|
1915
2283
|
* @returns {number} The maximum columns count of the sheet
|
|
2284
|
+
* @example
|
|
2285
|
+
* ```typescript
|
|
2286
|
+
* const sheet = workbook.getActiveSheet();
|
|
2287
|
+
* const totalColumns = sheet.getMaxColumns();
|
|
2288
|
+
* console.log(`Sheet has ${totalColumns} columns`);
|
|
2289
|
+
* ```
|
|
1916
2290
|
*/
|
|
1917
2291
|
getMaxColumns() {
|
|
1918
2292
|
return this._worksheet.getMaxColumns();
|
|
@@ -1920,90 +2294,152 @@ let g = class extends ne {
|
|
|
1920
2294
|
/**
|
|
1921
2295
|
* Returns the current number of rows in the sheet, regardless of content.
|
|
1922
2296
|
* @returns {number}The maximum rows count of the sheet
|
|
2297
|
+
* @example
|
|
2298
|
+
* ```typescript
|
|
2299
|
+
* const sheet = workbook.getActiveSheet();
|
|
2300
|
+
* const totalRows = sheet.getMaxRows();
|
|
2301
|
+
* console.log(`Sheet has ${totalRows} rows`);
|
|
2302
|
+
* ```
|
|
1923
2303
|
*/
|
|
1924
2304
|
getMaxRows() {
|
|
1925
2305
|
return this._worksheet.getMaxRows();
|
|
1926
2306
|
}
|
|
1927
2307
|
/**
|
|
1928
2308
|
* Inserts a row after the given row position.
|
|
1929
|
-
* @param {number} afterPosition The row after which the new row should be added, starting at 0 for the first row.
|
|
2309
|
+
* @param {number} afterPosition - The row after which the new row should be added, starting at 0 for the first row.
|
|
1930
2310
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2311
|
+
* @example
|
|
2312
|
+
* ```typescript
|
|
2313
|
+
* const sheet = workbook.getActiveSheet();
|
|
2314
|
+
* // Insert 3 rows at row index 2 (before the third row)
|
|
2315
|
+
* sheet.insertRowAfter(2);
|
|
2316
|
+
* // Insert 1 row at row index 0 (before the first row)
|
|
2317
|
+
* sheet.insertRowAfter(0);
|
|
2318
|
+
* ```
|
|
1931
2319
|
*/
|
|
1932
2320
|
insertRowAfter(e) {
|
|
1933
2321
|
return this.insertRowsAfter(e, 1);
|
|
1934
2322
|
}
|
|
1935
2323
|
/**
|
|
1936
2324
|
* Inserts a row before the given row position.
|
|
1937
|
-
* @param {number} beforePosition The row before which the new row should be added, starting at 0 for the first row.
|
|
2325
|
+
* @param {number} beforePosition - The row before which the new row should be added, starting at 0 for the first row.
|
|
1938
2326
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2327
|
+
* @example
|
|
2328
|
+
* ```typescript
|
|
2329
|
+
* const sheet = workbook.getActiveSheet();
|
|
2330
|
+
* // Insert 3 rows at row index 2 (before the third row)
|
|
2331
|
+
* sheet.insertRowBefore(2);
|
|
2332
|
+
* // Insert 1 row at row index 0 (before the first row)
|
|
2333
|
+
* sheet.insertRowBefore(0);
|
|
2334
|
+
* ```
|
|
1939
2335
|
*/
|
|
1940
2336
|
insertRowBefore(e) {
|
|
1941
2337
|
return this.insertRowsBefore(e, 1);
|
|
1942
2338
|
}
|
|
1943
2339
|
/**
|
|
1944
2340
|
* Inserts one or more consecutive blank rows in a sheet starting at the specified location.
|
|
1945
|
-
* @param rowIndex The index indicating where to insert a row, starting at 0 for the first row.
|
|
1946
|
-
* @param numRows The number of rows to insert.
|
|
1947
|
-
* @returns This sheet, for chaining.
|
|
2341
|
+
* @param {number} rowIndex - The index indicating where to insert a row, starting at 0 for the first row.
|
|
2342
|
+
* @param {number} numRows - The number of rows to insert.
|
|
2343
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
2344
|
+
* @example
|
|
2345
|
+
* ```typescript
|
|
2346
|
+
* const sheet = workbook.getActiveSheet();
|
|
2347
|
+
* // Insert 3 rows at row index 2 (before the third row)
|
|
2348
|
+
* sheet.insertRows(2, 3);
|
|
2349
|
+
* // Insert 1 row at row index 0 (before the first row)
|
|
2350
|
+
* sheet.insertRows(0);
|
|
2351
|
+
* ```
|
|
1948
2352
|
*/
|
|
1949
2353
|
insertRows(e, t = 1) {
|
|
1950
2354
|
return this.insertRowsBefore(e, t);
|
|
1951
2355
|
}
|
|
1952
2356
|
/**
|
|
1953
2357
|
* Inserts a number of rows after the given row position.
|
|
1954
|
-
* @param afterPosition The row after which the new rows should be added, starting at 0 for the first row.
|
|
1955
|
-
* @param howMany The number of rows to insert.
|
|
1956
|
-
* @returns This sheet, for chaining.
|
|
2358
|
+
* @param {number} afterPosition - The row after which the new rows should be added, starting at 0 for the first row.
|
|
2359
|
+
* @param {number} howMany - The number of rows to insert.
|
|
2360
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
2361
|
+
* @example
|
|
2362
|
+
* ```typescript
|
|
2363
|
+
* const sheet = workbook.getActiveSheet();
|
|
2364
|
+
* // Insert 3 rows at row index 2 (before the third row)
|
|
2365
|
+
* sheet.insertRowsAfter(2, 3);
|
|
2366
|
+
* // Insert 1 row at row index 0 (before the first row)
|
|
2367
|
+
* sheet.insertRowsAfter(0);
|
|
2368
|
+
* ```
|
|
1957
2369
|
*/
|
|
1958
2370
|
insertRowsAfter(e, t) {
|
|
1959
|
-
const n = this._workbook.getUnitId(),
|
|
1960
|
-
return this._commandService.syncExecuteCommand(
|
|
2371
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = D.DOWN, o = e + 1, h = e + t, a = 0, d = this._worksheet.getColumnCount() - 1, c = A(this._worksheet, o, h, a, d, !0, e);
|
|
2372
|
+
return this._commandService.syncExecuteCommand(Ce.id, {
|
|
1961
2373
|
unitId: n,
|
|
1962
|
-
subUnitId:
|
|
1963
|
-
direction:
|
|
2374
|
+
subUnitId: s,
|
|
2375
|
+
direction: i,
|
|
1964
2376
|
range: {
|
|
1965
|
-
startRow:
|
|
1966
|
-
endRow:
|
|
1967
|
-
startColumn:
|
|
1968
|
-
endColumn:
|
|
2377
|
+
startRow: o,
|
|
2378
|
+
endRow: h,
|
|
2379
|
+
startColumn: a,
|
|
2380
|
+
endColumn: d
|
|
1969
2381
|
},
|
|
1970
|
-
cellValue:
|
|
2382
|
+
cellValue: c
|
|
1971
2383
|
}), this;
|
|
1972
2384
|
}
|
|
1973
2385
|
/**
|
|
1974
2386
|
* Inserts a number of rows before the given row position.
|
|
1975
|
-
* @param beforePosition The row before which the new rows should be added, starting at 0 for the first row.
|
|
1976
|
-
* @param howMany The number of rows to insert.
|
|
1977
|
-
* @returns This sheet, for chaining.
|
|
2387
|
+
* @param {number} beforePosition - The row before which the new rows should be added, starting at 0 for the first row.
|
|
2388
|
+
* @param {number} howMany - The number of rows to insert.
|
|
2389
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
2390
|
+
* @example
|
|
2391
|
+
* ```typescript
|
|
2392
|
+
* const sheet = workbook.getActiveSheet();
|
|
2393
|
+
* // Insert 3 rows at row index 2 (before the third row)
|
|
2394
|
+
* sheet.insertRowsBefore(2, 3);
|
|
2395
|
+
* // Insert 1 row at row index 0 (before the first row)
|
|
2396
|
+
* sheet.insertRowsBefore(0);
|
|
2397
|
+
* ```
|
|
1978
2398
|
*/
|
|
1979
2399
|
insertRowsBefore(e, t) {
|
|
1980
|
-
const n = this._workbook.getUnitId(),
|
|
1981
|
-
return this._commandService.syncExecuteCommand(
|
|
2400
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = D.UP, o = e, h = e + t - 1, a = 0, d = this._worksheet.getColumnCount() - 1, c = A(this._worksheet, o, h, a, d, !0, e - 1);
|
|
2401
|
+
return this._commandService.syncExecuteCommand(Ce.id, {
|
|
1982
2402
|
unitId: n,
|
|
1983
|
-
subUnitId:
|
|
1984
|
-
direction:
|
|
2403
|
+
subUnitId: s,
|
|
2404
|
+
direction: i,
|
|
1985
2405
|
range: {
|
|
1986
|
-
startRow:
|
|
1987
|
-
endRow:
|
|
1988
|
-
startColumn:
|
|
1989
|
-
endColumn:
|
|
2406
|
+
startRow: o,
|
|
2407
|
+
endRow: h,
|
|
2408
|
+
startColumn: a,
|
|
2409
|
+
endColumn: d
|
|
1990
2410
|
},
|
|
1991
|
-
cellValue:
|
|
2411
|
+
cellValue: c
|
|
1992
2412
|
}), this;
|
|
1993
2413
|
}
|
|
1994
2414
|
/**
|
|
1995
2415
|
* Deletes the row at the given row position.
|
|
1996
|
-
* @param rowPosition The position of the row, starting at 0 for the first row.
|
|
1997
|
-
* @returns This sheet, for chaining.
|
|
2416
|
+
* @param {number} rowPosition - The position of the row, starting at 0 for the first row.
|
|
2417
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
2418
|
+
* @example
|
|
2419
|
+
* ```typescript
|
|
2420
|
+
* const sheet = workbook.getActiveSheet();
|
|
2421
|
+
* // Delete 3 rows at row index 2 (rows 3-5)
|
|
2422
|
+
* sheet.deleteRow(2);
|
|
2423
|
+
* // Delete 1 row at row index 0 (first row)
|
|
2424
|
+
* sheet.deleteRow(0);
|
|
2425
|
+
* ```
|
|
1998
2426
|
*/
|
|
1999
2427
|
deleteRow(e) {
|
|
2000
2428
|
return this.deleteRows(e, 1);
|
|
2001
2429
|
}
|
|
2002
2430
|
/**
|
|
2003
2431
|
* Deletes a number of rows starting at the given row position.
|
|
2004
|
-
* @param rowPosition The position of the first row to delete, starting at 0 for the first row.
|
|
2005
|
-
* @param howMany The number of rows to delete.
|
|
2006
|
-
* @returns This sheet, for chaining.
|
|
2432
|
+
* @param {number} rowPosition - The position of the first row to delete, starting at 0 for the first row.
|
|
2433
|
+
* @param {number} howMany - The number of rows to delete.
|
|
2434
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
2435
|
+
* @example
|
|
2436
|
+
* ```typescript
|
|
2437
|
+
* const sheet = workbook.getActiveSheet();
|
|
2438
|
+
* // Delete 3 rows at row index 2 (rows 3-5)
|
|
2439
|
+
* sheet.deleteRows(2, 3);
|
|
2440
|
+
* // Delete 1 row at row index 0 (first row)
|
|
2441
|
+
* sheet.deleteRows(0);
|
|
2442
|
+
* ```
|
|
2007
2443
|
*/
|
|
2008
2444
|
deleteRows(e, t) {
|
|
2009
2445
|
const n = {
|
|
@@ -2012,7 +2448,7 @@ let g = class extends ne {
|
|
|
2012
2448
|
startColumn: 0,
|
|
2013
2449
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2014
2450
|
};
|
|
2015
|
-
return this._commandService.syncExecuteCommand(
|
|
2451
|
+
return this._commandService.syncExecuteCommand(Rt.id, {
|
|
2016
2452
|
range: n,
|
|
2017
2453
|
unitId: this._workbook.getUnitId(),
|
|
2018
2454
|
subUnitId: this._worksheet.getSheetId()
|
|
@@ -2020,140 +2456,258 @@ let g = class extends ne {
|
|
|
2020
2456
|
}
|
|
2021
2457
|
/**
|
|
2022
2458
|
* Moves the rows selected by the given range to the position indicated by the destinationIndex. The rowSpec itself does not have to exactly represent an entire row or group of rows to move—it selects all rows that the range spans.
|
|
2023
|
-
* @param rowSpec A range spanning the rows that should be moved.
|
|
2024
|
-
* @param destinationIndex The index that the rows should be moved to. Note that this index is based on the coordinates before the rows are moved. Existing data is shifted down to make room for the moved rows while the source rows are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method.
|
|
2025
|
-
* @returns This sheet, for chaining.
|
|
2459
|
+
* @param {FRange} rowSpec - A range spanning the rows that should be moved.
|
|
2460
|
+
* @param {number} destinationIndex - The index that the rows should be moved to. Note that this index is based on the coordinates before the rows are moved. Existing data is shifted down to make room for the moved rows while the source rows are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method.
|
|
2461
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
2462
|
+
* @example
|
|
2463
|
+
* ```typescript
|
|
2464
|
+
* const sheet = workbook.getActiveSheet();
|
|
2465
|
+
* // Move 3 rows at row index 2 (rows 3-5) to row index 0
|
|
2466
|
+
* sheet.moveRows(rowSpec, 0);
|
|
2467
|
+
* // Move 1 row at row index 0 (first row) to row index 2
|
|
2468
|
+
* sheet.moveRows(rowSpec, 2);
|
|
2469
|
+
* ```
|
|
2026
2470
|
*/
|
|
2027
2471
|
moveRows(e, t) {
|
|
2028
|
-
const n = this._workbook.getUnitId(),
|
|
2472
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = G(e.getRange(), this._worksheet), o = i, h = {
|
|
2029
2473
|
startRow: t,
|
|
2030
2474
|
endRow: t,
|
|
2031
|
-
startColumn:
|
|
2032
|
-
endColumn:
|
|
2475
|
+
startColumn: i.startColumn,
|
|
2476
|
+
endColumn: i.endColumn
|
|
2033
2477
|
};
|
|
2034
|
-
return this._commandService.syncExecuteCommand(
|
|
2478
|
+
return this._commandService.syncExecuteCommand(pt.id, {
|
|
2035
2479
|
unitId: n,
|
|
2036
|
-
subUnitId:
|
|
2037
|
-
range:
|
|
2038
|
-
fromRange:
|
|
2039
|
-
toRange:
|
|
2480
|
+
subUnitId: s,
|
|
2481
|
+
range: i,
|
|
2482
|
+
fromRange: o,
|
|
2483
|
+
toRange: h
|
|
2040
2484
|
}), this;
|
|
2041
2485
|
}
|
|
2042
2486
|
/**
|
|
2043
2487
|
* Hides the rows in the given range.
|
|
2044
|
-
* @param row The row range to hide.
|
|
2045
|
-
* @returns This sheet, for chaining.
|
|
2488
|
+
* @param {FRange} row - The row range to hide.
|
|
2489
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
2490
|
+
* @example
|
|
2491
|
+
* ```typescript
|
|
2492
|
+
* const sheet = workbook.getActiveSheet();
|
|
2493
|
+
* // Hide 3 rows starting from row index 1 (rows 2-4)
|
|
2494
|
+
* sheet.hideRow(1);
|
|
2495
|
+
* // Hide single row at index 0 (first row)
|
|
2496
|
+
* sheet.hideRow(0);
|
|
2497
|
+
* ```
|
|
2046
2498
|
*/
|
|
2047
2499
|
hideRow(e) {
|
|
2048
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2049
|
-
return this._commandService.syncExecuteCommand(
|
|
2500
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = G(e.getRange(), this._worksheet);
|
|
2501
|
+
return this._commandService.syncExecuteCommand(fe.id, {
|
|
2050
2502
|
unitId: t,
|
|
2051
2503
|
subUnitId: n,
|
|
2052
|
-
ranges: [
|
|
2504
|
+
ranges: [s]
|
|
2053
2505
|
}), this;
|
|
2054
2506
|
}
|
|
2055
2507
|
/**
|
|
2056
|
-
* Hides one or more consecutive rows starting at the given index. Use 0-index for this method
|
|
2057
|
-
* @param {number} rowIndex The starting index of the rows to hide
|
|
2058
|
-
* @param {number}
|
|
2508
|
+
* Hides one or more consecutive rows starting at the given index. Use 0-index for this method
|
|
2509
|
+
* @param {number} rowIndex - The starting index of the rows to hide
|
|
2510
|
+
* @param {number} numRow - The number of rows to hide
|
|
2059
2511
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2512
|
+
* @example
|
|
2513
|
+
* ```typescript
|
|
2514
|
+
* const sheet = workbook.getActiveSheet();
|
|
2515
|
+
* // Hide 3 rows starting from row index 1 (rows 2-4)
|
|
2516
|
+
* sheet.hideRows(1, 3);
|
|
2517
|
+
* // Hide single row at index 0 (first row)
|
|
2518
|
+
* sheet.hideRows(0);
|
|
2519
|
+
* ```
|
|
2060
2520
|
*/
|
|
2061
2521
|
hideRows(e, t = 1) {
|
|
2062
|
-
const n = this._workbook.getUnitId(),
|
|
2522
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = {
|
|
2063
2523
|
startRow: e,
|
|
2064
2524
|
endRow: e + t - 1,
|
|
2065
2525
|
startColumn: 0,
|
|
2066
2526
|
endColumn: this._worksheet.getColumnCount() - 1,
|
|
2067
2527
|
rangeType: _.ROW
|
|
2068
2528
|
};
|
|
2069
|
-
return this._commandService.syncExecuteCommand(
|
|
2529
|
+
return this._commandService.syncExecuteCommand(fe.id, {
|
|
2070
2530
|
unitId: n,
|
|
2071
|
-
subUnitId:
|
|
2072
|
-
ranges: [
|
|
2531
|
+
subUnitId: s,
|
|
2532
|
+
ranges: [i]
|
|
2073
2533
|
}), this;
|
|
2074
2534
|
}
|
|
2075
2535
|
/**
|
|
2076
2536
|
* Make the row in the given range visible.
|
|
2077
|
-
* @param {FRange} row The range to unhide, if hidden.
|
|
2537
|
+
* @param {FRange} row - The range to unhide, if hidden.
|
|
2078
2538
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2539
|
+
* @example
|
|
2540
|
+
* ```typescript
|
|
2541
|
+
* const sheet = workbook.getActiveSheet();
|
|
2542
|
+
* // Unhide 3 rows starting from row index 1 (rows 2-4)
|
|
2543
|
+
* sheet.unhideRow(1);
|
|
2544
|
+
* // Unhide single row at index 0 (first row)
|
|
2545
|
+
* sheet.unhideRow(0);
|
|
2546
|
+
* ```
|
|
2079
2547
|
*/
|
|
2080
2548
|
unhideRow(e) {
|
|
2081
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2082
|
-
return this._commandService.syncExecuteCommand(
|
|
2549
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = G(e.getRange(), this._worksheet);
|
|
2550
|
+
return this._commandService.syncExecuteCommand(ve.id, {
|
|
2083
2551
|
unitId: t,
|
|
2084
2552
|
subUnitId: n,
|
|
2085
|
-
ranges: [
|
|
2553
|
+
ranges: [s]
|
|
2086
2554
|
}), this;
|
|
2087
2555
|
}
|
|
2088
2556
|
/**
|
|
2089
2557
|
* Scrolling sheet to make specific rows visible.
|
|
2090
|
-
* @param {number} rowIndex The starting index of the rows
|
|
2091
|
-
* @param {number}
|
|
2092
|
-
* @returns {FWorksheet} This
|
|
2558
|
+
* @param {number} rowIndex - The starting index of the rows
|
|
2559
|
+
* @param {number} numRow - The number of rows
|
|
2560
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2561
|
+
* @example
|
|
2562
|
+
* ```typescript
|
|
2563
|
+
* const sheet = workbook.getActiveSheet();
|
|
2564
|
+
* // Show 3 rows starting from row index 1 (rows 2-4)
|
|
2565
|
+
* sheet.showRows(1);
|
|
2566
|
+
* // Show single row at index 0 (first row)
|
|
2567
|
+
* sheet.showRows(0);
|
|
2568
|
+
* ```
|
|
2093
2569
|
*/
|
|
2094
2570
|
showRows(e, t = 1) {
|
|
2095
|
-
const n = this._workbook.getUnitId(),
|
|
2571
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = {
|
|
2096
2572
|
startRow: e,
|
|
2097
2573
|
endRow: e + t - 1,
|
|
2098
2574
|
startColumn: 0,
|
|
2099
2575
|
endColumn: this._worksheet.getColumnCount() - 1,
|
|
2100
2576
|
rangeType: _.ROW
|
|
2101
2577
|
};
|
|
2102
|
-
return this._commandService.syncExecuteCommand(
|
|
2578
|
+
return this._commandService.syncExecuteCommand(ve.id, {
|
|
2103
2579
|
unitId: n,
|
|
2104
|
-
subUnitId:
|
|
2105
|
-
ranges: [
|
|
2580
|
+
subUnitId: s,
|
|
2581
|
+
ranges: [i]
|
|
2106
2582
|
}), this;
|
|
2107
2583
|
}
|
|
2108
2584
|
/**
|
|
2109
2585
|
* Sets the row height of the given row in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).
|
|
2110
|
-
* @param {number} rowPosition The row position to change.
|
|
2111
|
-
* @param {number} height The height in pixels to set it to.
|
|
2112
|
-
* @returns {FWorksheet} This
|
|
2586
|
+
* @param {number} rowPosition - The row position to change.
|
|
2587
|
+
* @param {number} height - The height in pixels to set it to.
|
|
2588
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2589
|
+
* @example
|
|
2590
|
+
* ```typescript
|
|
2591
|
+
* const sheet = workbook.getActiveSheet();
|
|
2592
|
+
* // Set the height of the second row to 30 pixels
|
|
2593
|
+
* sheet.setRowHeight(1, 30);
|
|
2594
|
+
* // Set the height of the first row to 20 pixels
|
|
2595
|
+
* sheet.setRowHeight(0, 20);
|
|
2596
|
+
* ```
|
|
2113
2597
|
*/
|
|
2114
2598
|
setRowHeight(e, t) {
|
|
2115
2599
|
return this.setRowHeights(e, 1, t);
|
|
2116
2600
|
}
|
|
2601
|
+
/**
|
|
2602
|
+
* Make certain row wrap and auto height.
|
|
2603
|
+
* @param rowPosition
|
|
2604
|
+
* @param auto
|
|
2605
|
+
* @returns {FWorksheet} this
|
|
2606
|
+
* @example
|
|
2607
|
+
* ```ts
|
|
2608
|
+
const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2609
|
+
const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2610
|
+
fWorkSheet.autoFitRow(24);
|
|
2611
|
+
* ```
|
|
2612
|
+
*/
|
|
2613
|
+
autoFitRow(e, t = g.TRUE) {
|
|
2614
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = [{
|
|
2615
|
+
startRow: e,
|
|
2616
|
+
endRow: e,
|
|
2617
|
+
startColumn: 0,
|
|
2618
|
+
endColumn: this._worksheet.getColumnCount() - 1
|
|
2619
|
+
}];
|
|
2620
|
+
return this._commandService.syncExecuteCommand(Z.id, {
|
|
2621
|
+
unitId: this._workbook.getUnitId(),
|
|
2622
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
2623
|
+
range: i[0],
|
|
2624
|
+
value: Y.WRAP
|
|
2625
|
+
}), this._commandService.syncExecuteCommand(
|
|
2626
|
+
yt.id,
|
|
2627
|
+
{
|
|
2628
|
+
unitId: n,
|
|
2629
|
+
subUnitId: s,
|
|
2630
|
+
ranges: i,
|
|
2631
|
+
autoHeightInfo: t
|
|
2632
|
+
}
|
|
2633
|
+
), this;
|
|
2634
|
+
}
|
|
2117
2635
|
/**
|
|
2118
2636
|
* Sets the height of the given rows in pixels.
|
|
2119
2637
|
* By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).
|
|
2120
|
-
* @param {number} startRow The starting row position to change
|
|
2121
|
-
* @param {number} numRows The number of rows to change
|
|
2122
|
-
* @param {number} height The height in pixels to set it to
|
|
2123
|
-
* @returns {FWorksheet} This
|
|
2638
|
+
* @param {number} startRow - The starting row position to change
|
|
2639
|
+
* @param {number} numRows - The number of rows to change
|
|
2640
|
+
* @param {number} height - The height in pixels to set it to
|
|
2641
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2642
|
+
* @example
|
|
2643
|
+
* ```typescript
|
|
2644
|
+
* const sheet = workbook.getActiveSheet();
|
|
2645
|
+
* sheet.setRowHeights(1, 10, 30);
|
|
2646
|
+
* ```
|
|
2647
|
+
*/
|
|
2648
|
+
setRowHeights(e, t, n) {
|
|
2649
|
+
var d;
|
|
2650
|
+
const s = this._workbook.getUnitId(), i = this._worksheet.getSheetId(), o = this._worksheet.getRowManager(), h = [], a = [];
|
|
2651
|
+
for (let c = e; c < e + t; c++) {
|
|
2652
|
+
const v = ((d = o.getRow(c)) == null ? void 0 : d.ah) || this._worksheet.getConfig().defaultRowHeight, k = {
|
|
2653
|
+
startRow: c,
|
|
2654
|
+
endRow: c,
|
|
2655
|
+
startColumn: 0,
|
|
2656
|
+
endColumn: this._worksheet.getColumnCount() - 1
|
|
2657
|
+
};
|
|
2658
|
+
n <= v ? h.push(k) : a.push(k);
|
|
2659
|
+
}
|
|
2660
|
+
return a.length > 0 && this._commandService.syncExecuteCommand(Ie.id, {
|
|
2661
|
+
unitId: s,
|
|
2662
|
+
subUnitId: i,
|
|
2663
|
+
ranges: a,
|
|
2664
|
+
value: n
|
|
2665
|
+
}), h.length > 0 && this._commandService.syncExecuteCommand(be.id, {
|
|
2666
|
+
unitId: s,
|
|
2667
|
+
subUnitId: i,
|
|
2668
|
+
ranges: h
|
|
2669
|
+
}), this;
|
|
2670
|
+
}
|
|
2671
|
+
/**
|
|
2672
|
+
* Sets the height of the given rows to auto.
|
|
2673
|
+
* @param {number} startRow - The starting row position to change
|
|
2674
|
+
* @param {number} numRows - The number of rows to change
|
|
2675
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2676
|
+
* @example
|
|
2677
|
+
* ```typescript
|
|
2678
|
+
* const sheet = workbook.getActiveSheet();
|
|
2679
|
+
* sheet.setRowAutoHeight(1, 10);
|
|
2680
|
+
* ```
|
|
2124
2681
|
*/
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
startRow: d,
|
|
2131
|
-
endRow: d,
|
|
2682
|
+
setRowAutoHeight(e, t) {
|
|
2683
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = [
|
|
2684
|
+
{
|
|
2685
|
+
startRow: e,
|
|
2686
|
+
endRow: e + t - 1,
|
|
2132
2687
|
startColumn: 0,
|
|
2133
2688
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2134
|
-
}
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
ranges: h,
|
|
2141
|
-
value: n
|
|
2142
|
-
}), a.length > 0 && this._commandService.syncExecuteCommand(_t.id, {
|
|
2143
|
-
unitId: r,
|
|
2144
|
-
subUnitId: o,
|
|
2145
|
-
ranges: a
|
|
2689
|
+
}
|
|
2690
|
+
];
|
|
2691
|
+
return this._commandService.syncExecuteCommand(be.id, {
|
|
2692
|
+
unitId: n,
|
|
2693
|
+
subUnitId: s,
|
|
2694
|
+
ranges: i
|
|
2146
2695
|
}), this;
|
|
2147
2696
|
}
|
|
2148
2697
|
/**
|
|
2149
2698
|
* Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. When you use setRowHeightsForced, rows are forced to the specified height even if the cell contents are taller than the row height.
|
|
2150
|
-
* @param {number} startRow The starting row position to change
|
|
2151
|
-
* @param {number} numRows The number of rows to change
|
|
2152
|
-
* @param {number} height The height in pixels to set it to
|
|
2153
|
-
* @returns {FWorksheet} This
|
|
2699
|
+
* @param {number} startRow - The starting row position to change
|
|
2700
|
+
* @param {number} numRows - The number of rows to change
|
|
2701
|
+
* @param {number} height - The height in pixels to set it to
|
|
2702
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2703
|
+
* @example
|
|
2704
|
+
* ```typescript
|
|
2705
|
+
* const sheet = workbook.getActiveSheet();
|
|
2706
|
+
* sheet.setRowHeightsForced(1, 10, 30);
|
|
2707
|
+
* ```
|
|
2154
2708
|
*/
|
|
2155
2709
|
setRowHeightsForced(e, t, n) {
|
|
2156
|
-
const
|
|
2710
|
+
const s = this._workbook.getUnitId(), i = this._worksheet.getSheetId(), o = [
|
|
2157
2711
|
{
|
|
2158
2712
|
startRow: e,
|
|
2159
2713
|
endRow: e + t - 1,
|
|
@@ -2161,113 +2715,175 @@ let g = class extends ne {
|
|
|
2161
2715
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2162
2716
|
}
|
|
2163
2717
|
];
|
|
2164
|
-
return this._commandService.syncExecuteCommand(
|
|
2165
|
-
unitId:
|
|
2166
|
-
subUnitId:
|
|
2167
|
-
ranges:
|
|
2718
|
+
return this._commandService.syncExecuteCommand(Ie.id, {
|
|
2719
|
+
unitId: s,
|
|
2720
|
+
subUnitId: i,
|
|
2721
|
+
ranges: o,
|
|
2168
2722
|
value: n
|
|
2169
2723
|
}), this;
|
|
2170
2724
|
}
|
|
2171
2725
|
// #endregion
|
|
2172
2726
|
/**
|
|
2173
2727
|
* Set custom properties for given rows.
|
|
2174
|
-
* @param custom The custom properties to set
|
|
2175
|
-
* @returns This
|
|
2728
|
+
* @param {IObjectArrayPrimitiveType<CustomData>} custom - The custom properties to set
|
|
2729
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2730
|
+
* @example
|
|
2731
|
+
* ```typescript
|
|
2732
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2733
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2734
|
+
* fWorkSheet.setRowCustom({ key: 'value' });
|
|
2735
|
+
* ```
|
|
2176
2736
|
*/
|
|
2177
2737
|
setRowCustom(e) {
|
|
2178
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2179
|
-
for (const [
|
|
2180
|
-
|
|
2181
|
-
custom:
|
|
2738
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = {};
|
|
2739
|
+
for (const [o, h] of Object.entries(e))
|
|
2740
|
+
s[Number(o)] = {
|
|
2741
|
+
custom: h
|
|
2182
2742
|
};
|
|
2183
|
-
const
|
|
2743
|
+
const i = {
|
|
2184
2744
|
unitId: t,
|
|
2185
2745
|
subUnitId: n,
|
|
2186
|
-
rowData:
|
|
2746
|
+
rowData: s
|
|
2187
2747
|
};
|
|
2188
|
-
return this._commandService.syncExecuteCommand(
|
|
2748
|
+
return this._commandService.syncExecuteCommand(we.id, i), this;
|
|
2189
2749
|
}
|
|
2190
2750
|
// #region Column
|
|
2191
2751
|
/**
|
|
2192
2752
|
* Inserts a column after the given column position.
|
|
2193
|
-
* @param afterPosition The column after which the new column should be added, starting at 0 for the first column
|
|
2194
|
-
* @returns This
|
|
2753
|
+
* @param {number} afterPosition - The column after which the new column should be added, starting at 0 for the first column
|
|
2754
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2755
|
+
* @example
|
|
2756
|
+
* ```typescript
|
|
2757
|
+
* const sheet = workbook.getActiveSheet();
|
|
2758
|
+
* // Insert 3 columns at column index 2 (before column C)
|
|
2759
|
+
* sheet.insertColumnAfter(2);
|
|
2760
|
+
* // Insert 1 column at column index 0 (before column A)
|
|
2761
|
+
* sheet.insertColumnAfter(0);
|
|
2762
|
+
* ```
|
|
2195
2763
|
*/
|
|
2196
2764
|
insertColumnAfter(e) {
|
|
2197
2765
|
return this.insertColumnsAfter(e, 1);
|
|
2198
2766
|
}
|
|
2199
2767
|
/**
|
|
2200
2768
|
* Inserts a column before the given column position.
|
|
2201
|
-
* @param beforePosition The column before which the new column should be added, starting at 0 for the first column
|
|
2202
|
-
* @returns This
|
|
2769
|
+
* @param {number} beforePosition - The column before which the new column should be added, starting at 0 for the first column
|
|
2770
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2771
|
+
* @example
|
|
2772
|
+
* ```typescript
|
|
2773
|
+
* const sheet = workbook.getActiveSheet();
|
|
2774
|
+
* // Insert 3 columns at column index 2 (before column C)
|
|
2775
|
+
* sheet.insertColumnBefore(2);
|
|
2776
|
+
* // Insert 1 column at column index 0 (before column A)
|
|
2777
|
+
* sheet.insertColumnBefore(0);
|
|
2778
|
+
* ```
|
|
2203
2779
|
*/
|
|
2204
2780
|
insertColumnBefore(e) {
|
|
2205
2781
|
return this.insertColumnsBefore(e, 1);
|
|
2206
2782
|
}
|
|
2207
2783
|
/**
|
|
2208
2784
|
* Inserts one or more consecutive blank columns in a sheet starting at the specified location.
|
|
2209
|
-
* @param columnIndex The index indicating where to insert a column, starting at 0 for the first column
|
|
2210
|
-
* @param numColumns The number of columns to insert
|
|
2211
|
-
* @returns This sheet, for chaining
|
|
2785
|
+
* @param {number} columnIndex - The index indicating where to insert a column, starting at 0 for the first column
|
|
2786
|
+
* @param {number} numColumns - The number of columns to insert
|
|
2787
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
2788
|
+
* @example
|
|
2789
|
+
* ```typescript
|
|
2790
|
+
* const sheet = workbook.getActiveSheet();
|
|
2791
|
+
* // Insert 3 columns at column index 2 (before column C)
|
|
2792
|
+
* sheet.insertColumns(2, 3);
|
|
2793
|
+
* // Insert 1 column at column index 0 (before column A)
|
|
2794
|
+
* sheet.insertColumns(0);
|
|
2795
|
+
* ```
|
|
2212
2796
|
*/
|
|
2213
2797
|
insertColumns(e, t = 1) {
|
|
2214
2798
|
return this.insertColumnsBefore(e, t);
|
|
2215
2799
|
}
|
|
2216
2800
|
/**
|
|
2217
2801
|
* Inserts a given number of columns after the given column position.
|
|
2218
|
-
* @param afterPosition The column after which the new
|
|
2219
|
-
* @param howMany The number of columns to insert
|
|
2220
|
-
* @returns This sheet, for chaining
|
|
2802
|
+
* @param {number} afterPosition - The column after which the new columns should be added, starting at 0 for the first column
|
|
2803
|
+
* @param {number} howMany - The number of columns to insert
|
|
2804
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
2805
|
+
* @example
|
|
2806
|
+
* ```typescript
|
|
2807
|
+
* const sheet = workbook.getActiveSheet();
|
|
2808
|
+
* // Insert 3 columns at column index 2 (before column C)
|
|
2809
|
+
* sheet.insertColumnsAfter(2, 3);
|
|
2810
|
+
* // Insert 1 column at column index 0 (before column A)
|
|
2811
|
+
* sheet.insertColumnsAfter(0, 1);
|
|
2812
|
+
* ```
|
|
2221
2813
|
*/
|
|
2222
2814
|
insertColumnsAfter(e, t) {
|
|
2223
|
-
const n = this._workbook.getUnitId(),
|
|
2224
|
-
return this._commandService.syncExecuteCommand(
|
|
2815
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = D.RIGHT, o = 0, h = this._worksheet.getRowCount() - 1, a = e + 1, d = e + t, c = A(this._worksheet, o, h, a, d, !1, e);
|
|
2816
|
+
return this._commandService.syncExecuteCommand(Re.id, {
|
|
2225
2817
|
unitId: n,
|
|
2226
|
-
subUnitId:
|
|
2227
|
-
direction:
|
|
2818
|
+
subUnitId: s,
|
|
2819
|
+
direction: i,
|
|
2228
2820
|
range: {
|
|
2229
|
-
startRow:
|
|
2230
|
-
endRow:
|
|
2231
|
-
startColumn:
|
|
2232
|
-
endColumn:
|
|
2821
|
+
startRow: o,
|
|
2822
|
+
endRow: h,
|
|
2823
|
+
startColumn: a,
|
|
2824
|
+
endColumn: d
|
|
2233
2825
|
},
|
|
2234
|
-
cellValue:
|
|
2826
|
+
cellValue: c
|
|
2235
2827
|
}), this;
|
|
2236
2828
|
}
|
|
2237
2829
|
/**
|
|
2238
2830
|
* Inserts a number of columns before the given column position.
|
|
2239
|
-
* @param beforePosition The column before which the new
|
|
2240
|
-
* @param howMany The number of columns to insert
|
|
2241
|
-
* @returns This sheet, for chaining
|
|
2831
|
+
* @param {number} beforePosition - The column before which the new columns should be added, starting at 0 for the first column
|
|
2832
|
+
* @param {number} howMany - The number of columns to insert
|
|
2833
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
2834
|
+
* @example
|
|
2835
|
+
* ```typescript
|
|
2836
|
+
* const sheet = workbook.getActiveSheet();
|
|
2837
|
+
* // Insert 3 columns at column index 2 (before column C)
|
|
2838
|
+
* sheet.insertColumnsBefore(2, 3);
|
|
2839
|
+
* // Insert 1 column at column index 0 (before column A)
|
|
2840
|
+
* sheet.insertColumnsBefore(0, 1);
|
|
2841
|
+
* ```
|
|
2242
2842
|
*/
|
|
2243
2843
|
insertColumnsBefore(e, t) {
|
|
2244
|
-
const n = this._workbook.getUnitId(),
|
|
2245
|
-
return this._commandService.syncExecuteCommand(
|
|
2844
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = D.LEFT, o = 0, h = this._worksheet.getRowCount() - 1, a = e, d = e + t - 1, c = A(this._worksheet, o, h, a, d, !1, e - 1);
|
|
2845
|
+
return this._commandService.syncExecuteCommand(Re.id, {
|
|
2246
2846
|
unitId: n,
|
|
2247
|
-
subUnitId:
|
|
2248
|
-
direction:
|
|
2847
|
+
subUnitId: s,
|
|
2848
|
+
direction: i,
|
|
2249
2849
|
range: {
|
|
2250
|
-
startRow:
|
|
2251
|
-
endRow:
|
|
2252
|
-
startColumn:
|
|
2253
|
-
endColumn:
|
|
2850
|
+
startRow: o,
|
|
2851
|
+
endRow: h,
|
|
2852
|
+
startColumn: a,
|
|
2853
|
+
endColumn: d
|
|
2254
2854
|
},
|
|
2255
|
-
cellValue:
|
|
2855
|
+
cellValue: c
|
|
2256
2856
|
}), this;
|
|
2257
2857
|
}
|
|
2258
2858
|
/**
|
|
2259
2859
|
* Deletes the column at the given column position.
|
|
2260
|
-
* @param columnPosition The position of the column, starting at 0 for the first column
|
|
2261
|
-
* @returns This sheet, for chaining
|
|
2860
|
+
* @param {number} columnPosition - The position of the column, starting at 0 for the first column
|
|
2861
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
2862
|
+
* @example
|
|
2863
|
+
* ```typescript
|
|
2864
|
+
* const sheet = workbook.getActiveSheet();
|
|
2865
|
+
* // Delete column C
|
|
2866
|
+
* sheet.deleteColumn(2);
|
|
2867
|
+
* // Delete column A
|
|
2868
|
+
* sheet.deleteColumn(0);
|
|
2869
|
+
* ```
|
|
2262
2870
|
*/
|
|
2263
2871
|
deleteColumn(e) {
|
|
2264
2872
|
return this.deleteColumns(e, 1);
|
|
2265
2873
|
}
|
|
2266
2874
|
/**
|
|
2267
2875
|
* Deletes a number of columns starting at the given column position.
|
|
2268
|
-
* @param columnPosition The position of the first column to delete, starting at 0 for the first column
|
|
2269
|
-
* @param howMany The number of columns to delete
|
|
2270
|
-
* @returns This sheet, for chaining
|
|
2876
|
+
* @param {number} columnPosition - The position of the first column to delete, starting at 0 for the first column
|
|
2877
|
+
* @param {number} howMany - The number of columns to delete
|
|
2878
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
2879
|
+
* @example
|
|
2880
|
+
* ```typescript
|
|
2881
|
+
* const sheet = workbook.getActiveSheet();
|
|
2882
|
+
* // Delete 3 columns at column index 2 (columns C, D, E)
|
|
2883
|
+
* sheet.deleteColumns(2, 3);
|
|
2884
|
+
* // Delete 1 column at column index 0 (column A)
|
|
2885
|
+
* sheet.deleteColumns(0, 1);
|
|
2886
|
+
* ```
|
|
2271
2887
|
*/
|
|
2272
2888
|
deleteColumns(e, t) {
|
|
2273
2889
|
const n = {
|
|
@@ -2276,7 +2892,7 @@ let g = class extends ne {
|
|
|
2276
2892
|
startColumn: e,
|
|
2277
2893
|
endColumn: e + t - 1
|
|
2278
2894
|
};
|
|
2279
|
-
return this._commandService.syncExecuteCommand(
|
|
2895
|
+
return this._commandService.syncExecuteCommand(Et.id, {
|
|
2280
2896
|
range: n,
|
|
2281
2897
|
unitId: this._workbook.getUnitId(),
|
|
2282
2898
|
subUnitId: this._worksheet.getSheetId()
|
|
@@ -2284,109 +2900,161 @@ let g = class extends ne {
|
|
|
2284
2900
|
}
|
|
2285
2901
|
/**
|
|
2286
2902
|
* Moves the columns selected by the given range to the position indicated by the destinationIndex. The columnSpec itself does not have to exactly represent an entire column or group of columns to move—it selects all columns that the range spans.
|
|
2287
|
-
* @param columnSpec A range spanning the columns that should be moved
|
|
2288
|
-
* @param destinationIndex The index that the columns should be moved to. Note that this index is based on the coordinates before the columns are moved. Existing data is shifted right to make room for the moved columns while the source columns are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method
|
|
2289
|
-
* @returns This sheet, for chaining
|
|
2903
|
+
* @param {FRange} columnSpec - A range spanning the columns that should be moved
|
|
2904
|
+
* @param {number} destinationIndex - The index that the columns should be moved to. Note that this index is based on the coordinates before the columns are moved. Existing data is shifted right to make room for the moved columns while the source columns are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method
|
|
2905
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
2906
|
+
* @example
|
|
2907
|
+
* ```typescript
|
|
2908
|
+
* const sheet = workbook.getActiveSheet();
|
|
2909
|
+
* // Move columns C, D, E to column index 2 (columns B, C, D)
|
|
2910
|
+
* sheet.moveColumns({ startColumn: 2, endColumn: 4 }, 1);
|
|
2911
|
+
* // Move column A to column index 0 (column A)
|
|
2912
|
+
* sheet.moveColumns({ startColumn: 0, endColumn: 0 }, 0);
|
|
2913
|
+
* ```
|
|
2290
2914
|
*/
|
|
2291
2915
|
moveColumns(e, t) {
|
|
2292
|
-
const n = this._workbook.getUnitId(),
|
|
2916
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = q(e.getRange(), this._worksheet), o = i, h = {
|
|
2293
2917
|
startRow: 0,
|
|
2294
2918
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2295
2919
|
startColumn: t,
|
|
2296
2920
|
endColumn: t
|
|
2297
2921
|
};
|
|
2298
|
-
return this._commandService.syncExecuteCommand(
|
|
2922
|
+
return this._commandService.syncExecuteCommand(Ut.id, {
|
|
2299
2923
|
unitId: n,
|
|
2300
|
-
subUnitId:
|
|
2301
|
-
range:
|
|
2302
|
-
fromRange:
|
|
2303
|
-
toRange:
|
|
2924
|
+
subUnitId: s,
|
|
2925
|
+
range: i,
|
|
2926
|
+
fromRange: o,
|
|
2927
|
+
toRange: h
|
|
2304
2928
|
}), this;
|
|
2305
2929
|
}
|
|
2306
2930
|
/**
|
|
2307
2931
|
* Hides the column or columns in the given range.
|
|
2308
|
-
* @param column The column range to hide
|
|
2309
|
-
* @returns This sheet, for chaining
|
|
2932
|
+
* @param {FRange} column - The column range to hide
|
|
2933
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
2934
|
+
* @example
|
|
2935
|
+
* ```typescript
|
|
2936
|
+
* const sheet = workbook.getActiveSheet();
|
|
2937
|
+
* // Hide columns C, D, E
|
|
2938
|
+
* sheet.hideColumn({ startColumn: 2, endColumn: 4 });
|
|
2939
|
+
* // Hide column A
|
|
2940
|
+
* sheet.hideColumn({ startColumn: 0, endColumn: 0 });
|
|
2941
|
+
* ```
|
|
2310
2942
|
*/
|
|
2311
2943
|
hideColumn(e) {
|
|
2312
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2313
|
-
return this._commandService.syncExecuteCommand(
|
|
2944
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = q(e.getRange(), this._worksheet);
|
|
2945
|
+
return this._commandService.syncExecuteCommand(pe.id, {
|
|
2314
2946
|
unitId: t,
|
|
2315
2947
|
subUnitId: n,
|
|
2316
|
-
ranges: [
|
|
2948
|
+
ranges: [s]
|
|
2317
2949
|
}), this;
|
|
2318
2950
|
}
|
|
2319
2951
|
/**
|
|
2320
|
-
* Hides one or more consecutive columns starting at the given index. Use 0-index for this method
|
|
2321
|
-
* @param columnIndex The starting index of the columns to hide
|
|
2322
|
-
* @param
|
|
2323
|
-
* @returns This sheet, for chaining
|
|
2952
|
+
* Hides one or more consecutive columns starting at the given index. Use 0-index for this method
|
|
2953
|
+
* @param {number} columnIndex - The starting index of the columns to hide
|
|
2954
|
+
* @param {number} numColumn - The number of columns to hide
|
|
2955
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
2956
|
+
* @example
|
|
2957
|
+
* ```typescript
|
|
2958
|
+
* const sheet = workbook.getActiveSheet();
|
|
2959
|
+
* // Hide columns C, D, E
|
|
2960
|
+
* sheet.hideColumns(2, 3);
|
|
2961
|
+
* // Hide column A
|
|
2962
|
+
* sheet.hideColumns(0, 1);
|
|
2963
|
+
* ```
|
|
2324
2964
|
*/
|
|
2325
2965
|
hideColumns(e, t = 1) {
|
|
2326
|
-
const n = this._workbook.getUnitId(),
|
|
2966
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = {
|
|
2327
2967
|
startRow: 0,
|
|
2328
2968
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2329
2969
|
startColumn: e,
|
|
2330
2970
|
endColumn: e + t - 1,
|
|
2331
2971
|
rangeType: _.COLUMN
|
|
2332
2972
|
};
|
|
2333
|
-
return this._commandService.syncExecuteCommand(
|
|
2973
|
+
return this._commandService.syncExecuteCommand(pe.id, {
|
|
2334
2974
|
unitId: n,
|
|
2335
|
-
subUnitId:
|
|
2336
|
-
ranges: [
|
|
2975
|
+
subUnitId: s,
|
|
2976
|
+
ranges: [i]
|
|
2337
2977
|
}), this;
|
|
2338
2978
|
}
|
|
2339
2979
|
/**
|
|
2340
2980
|
* Show the column in the given range.
|
|
2341
|
-
* @param column The range to unhide, if hidden
|
|
2342
|
-
* @returns This sheet, for chaining
|
|
2981
|
+
* @param {FRange} column - The range to unhide, if hidden
|
|
2982
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
2983
|
+
* @example
|
|
2984
|
+
* ```typescript
|
|
2985
|
+
* const sheet = workbook.getActiveSheet();
|
|
2986
|
+
* // Unhide columns C, D, E
|
|
2987
|
+
* sheet.unhideColumn({ startColumn: 2, endColumn: 4 });
|
|
2988
|
+
* // Unhide column A
|
|
2989
|
+
* sheet.unhideColumn({ startColumn: 0, endColumn: 0 });
|
|
2990
|
+
* ```
|
|
2343
2991
|
*/
|
|
2344
2992
|
unhideColumn(e) {
|
|
2345
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2346
|
-
return this._commandService.syncExecuteCommand(
|
|
2993
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = q(e.getRange(), this._worksheet);
|
|
2994
|
+
return this._commandService.syncExecuteCommand(ye.id, {
|
|
2347
2995
|
unitId: t,
|
|
2348
2996
|
subUnitId: n,
|
|
2349
|
-
ranges: [
|
|
2997
|
+
ranges: [s]
|
|
2350
2998
|
}), this;
|
|
2351
2999
|
}
|
|
2352
3000
|
/**
|
|
2353
|
-
* Show one or more consecutive columns starting at the given index. Use 0-index for this method
|
|
2354
|
-
* @param columnIndex The starting index of the columns to unhide
|
|
2355
|
-
* @param
|
|
2356
|
-
* @returns This sheet, for chaining
|
|
3001
|
+
* Show one or more consecutive columns starting at the given index. Use 0-index for this method
|
|
3002
|
+
* @param {number} columnIndex - The starting index of the columns to unhide
|
|
3003
|
+
* @param {number} numColumn - The number of columns to unhide
|
|
3004
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
3005
|
+
* @example
|
|
3006
|
+
* ```typescript
|
|
3007
|
+
* const sheet = workbook.getActiveSheet();
|
|
3008
|
+
* // Unhide columns C, D, E
|
|
3009
|
+
* sheet.unhideColumns(2, 3);
|
|
3010
|
+
* // Unhide column A
|
|
3011
|
+
* sheet.unhideColumns(0, 1);
|
|
3012
|
+
* ```
|
|
2357
3013
|
*/
|
|
2358
3014
|
showColumns(e, t = 1) {
|
|
2359
|
-
const n = this._workbook.getUnitId(),
|
|
3015
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), i = {
|
|
2360
3016
|
startRow: 0,
|
|
2361
3017
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2362
3018
|
startColumn: e,
|
|
2363
3019
|
endColumn: e + t - 1,
|
|
2364
3020
|
rangeType: _.COLUMN
|
|
2365
3021
|
};
|
|
2366
|
-
return this._commandService.syncExecuteCommand(
|
|
3022
|
+
return this._commandService.syncExecuteCommand(ye.id, {
|
|
2367
3023
|
unitId: n,
|
|
2368
|
-
subUnitId:
|
|
2369
|
-
ranges: [
|
|
3024
|
+
subUnitId: s,
|
|
3025
|
+
ranges: [i]
|
|
2370
3026
|
}), this;
|
|
2371
3027
|
}
|
|
2372
3028
|
/**
|
|
2373
3029
|
* Sets the width of the given column in pixels.
|
|
2374
|
-
* @param columnPosition The position of the given column to set
|
|
2375
|
-
* @param width The width in pixels to set it to
|
|
2376
|
-
* @returns This sheet, for chaining
|
|
3030
|
+
* @param {number} columnPosition - The position of the given column to set
|
|
3031
|
+
* @param {number} width - The width in pixels to set it to
|
|
3032
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
3033
|
+
* @example
|
|
3034
|
+
* ```typescript
|
|
3035
|
+
* const sheet = workbook.getActiveSheet();
|
|
3036
|
+
* // Set width of column B to 100 pixels
|
|
3037
|
+
* sheet.setColumnWidth(1, 100);
|
|
3038
|
+
* ```
|
|
2377
3039
|
*/
|
|
2378
3040
|
setColumnWidth(e, t) {
|
|
2379
3041
|
return this.setColumnWidths(e, 1, t);
|
|
2380
3042
|
}
|
|
2381
3043
|
/**
|
|
2382
3044
|
* Sets the width of the given columns in pixels.
|
|
2383
|
-
* @param startColumn The starting column position to change
|
|
2384
|
-
* @param
|
|
2385
|
-
* @param width The width in pixels to set it to
|
|
2386
|
-
* @returns This sheet, for chaining
|
|
3045
|
+
* @param {number} startColumn - The starting column position to change
|
|
3046
|
+
* @param {number} numColumn - The number of columns to change
|
|
3047
|
+
* @param {number} width - The width in pixels to set it to
|
|
3048
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
3049
|
+
* @example
|
|
3050
|
+
* ```typescript
|
|
3051
|
+
* const sheet = workbook.getActiveSheet();
|
|
3052
|
+
* // Set width of columns B-D (index 1-3) to 100 pixels
|
|
3053
|
+
* sheet.setColumnWidths(1, 3, 100);
|
|
3054
|
+
* ```
|
|
2387
3055
|
*/
|
|
2388
3056
|
setColumnWidths(e, t, n) {
|
|
2389
|
-
const
|
|
3057
|
+
const s = this._workbook.getUnitId(), i = this._worksheet.getSheetId(), o = [
|
|
2390
3058
|
{
|
|
2391
3059
|
startColumn: e,
|
|
2392
3060
|
endColumn: e + t - 1,
|
|
@@ -2394,63 +3062,103 @@ let g = class extends ne {
|
|
|
2394
3062
|
endRow: this._worksheet.getRowCount() - 1
|
|
2395
3063
|
}
|
|
2396
3064
|
];
|
|
2397
|
-
return this._commandService.syncExecuteCommand(
|
|
2398
|
-
unitId:
|
|
2399
|
-
subUnitId:
|
|
2400
|
-
ranges:
|
|
3065
|
+
return this._commandService.syncExecuteCommand(Pt.id, {
|
|
3066
|
+
unitId: s,
|
|
3067
|
+
subUnitId: i,
|
|
3068
|
+
ranges: o,
|
|
2401
3069
|
value: n
|
|
2402
3070
|
}), this;
|
|
2403
3071
|
}
|
|
2404
3072
|
// #endregion
|
|
2405
3073
|
/**
|
|
2406
3074
|
* Set custom properties for given columns.
|
|
2407
|
-
* @param custom The custom properties to set
|
|
2408
|
-
* @returns This
|
|
3075
|
+
* @param {IObjectArrayPrimitiveType<CustomData>} custom - The custom properties to set
|
|
3076
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
3077
|
+
* @example
|
|
3078
|
+
* ```ts
|
|
3079
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3080
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3081
|
+
* fWorkSheet.setColumnCustom({ 0: { key: 'value' } });
|
|
3082
|
+
* ```
|
|
2409
3083
|
*/
|
|
2410
3084
|
setColumnCustom(e) {
|
|
2411
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2412
|
-
for (const [
|
|
2413
|
-
|
|
2414
|
-
custom:
|
|
3085
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = {};
|
|
3086
|
+
for (const [o, h] of Object.entries(e))
|
|
3087
|
+
s[Number(o)] = {
|
|
3088
|
+
custom: h
|
|
2415
3089
|
};
|
|
2416
|
-
const
|
|
3090
|
+
const i = {
|
|
2417
3091
|
unitId: t,
|
|
2418
3092
|
subUnitId: n,
|
|
2419
|
-
columnData:
|
|
3093
|
+
columnData: s
|
|
2420
3094
|
};
|
|
2421
|
-
return this._commandService.syncExecuteCommand(
|
|
3095
|
+
return this._commandService.syncExecuteCommand(Se.id, i), this;
|
|
2422
3096
|
}
|
|
2423
3097
|
// #region merge cells
|
|
2424
3098
|
/**
|
|
2425
3099
|
* Get all merged cells in the current sheet
|
|
2426
|
-
* @returns all merged cells
|
|
3100
|
+
* @returns {FRange[]} all merged cells
|
|
3101
|
+
* @example
|
|
3102
|
+
* ```typescript
|
|
3103
|
+
* const sheet = workbook.getActiveSheet();
|
|
3104
|
+
* // Get all merged ranges in the sheet
|
|
3105
|
+
* const mergedRanges = sheet.getMergedRanges();
|
|
3106
|
+
* // Process each merged range
|
|
3107
|
+
* mergedRanges.forEach(range => {
|
|
3108
|
+
* console.log(range.getA1Notation());
|
|
3109
|
+
* });
|
|
3110
|
+
* ```
|
|
2427
3111
|
*/
|
|
2428
3112
|
getMergedRanges() {
|
|
2429
|
-
return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(
|
|
3113
|
+
return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(S, this._workbook, this._worksheet, t));
|
|
2430
3114
|
}
|
|
2431
3115
|
/**
|
|
2432
3116
|
* Get the merged cell data of the specified row and column.
|
|
2433
|
-
* @param {number} row The row index
|
|
2434
|
-
* @param {number} column The column index
|
|
2435
|
-
* @returns {FRange|undefined} The merged cell data, or undefined if the cell is not merged
|
|
3117
|
+
* @param {number} row - The row index
|
|
3118
|
+
* @param {number} column - The column index
|
|
3119
|
+
* @returns {FRange|undefined} The merged cell data, or undefined if the cell is not merged
|
|
3120
|
+
* @example
|
|
3121
|
+
* ```ts
|
|
3122
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3123
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3124
|
+
* const merge = fWorkSheet.getCellMergeData(0, 0);
|
|
3125
|
+
* if (merge) {
|
|
3126
|
+
* console.log('Merged range:', merge.getA1Notation());
|
|
3127
|
+
* }
|
|
3128
|
+
* ```
|
|
2436
3129
|
*/
|
|
2437
3130
|
getCellMergeData(e, t) {
|
|
2438
|
-
const
|
|
2439
|
-
if (
|
|
2440
|
-
return this._injector.createInstance(
|
|
3131
|
+
const s = this._worksheet.getMergedCell(e, t);
|
|
3132
|
+
if (s)
|
|
3133
|
+
return this._injector.createInstance(S, this._workbook, this._worksheet, s);
|
|
2441
3134
|
}
|
|
2442
3135
|
// #endregion
|
|
2443
3136
|
/**
|
|
2444
3137
|
* Returns the selected range in the active sheet, or null if there is no active range.
|
|
2445
|
-
* @returns the active range
|
|
3138
|
+
* @returns {FRange | null} the active range
|
|
3139
|
+
* @example
|
|
3140
|
+
* ```typescript
|
|
3141
|
+
* const sheet = workbook.getActiveSheet();
|
|
3142
|
+
* // Get the currently active range
|
|
3143
|
+
* const activeRange = sheet.getActiveRange();
|
|
3144
|
+
* if (activeRange) {
|
|
3145
|
+
* console.log('Active range:', activeRange.getA1Notation());
|
|
3146
|
+
* }
|
|
3147
|
+
* ```
|
|
2446
3148
|
*/
|
|
2447
3149
|
getActiveRange() {
|
|
2448
3150
|
return this._fWorkbook.getActiveRange();
|
|
2449
3151
|
}
|
|
2450
3152
|
/**
|
|
2451
3153
|
* Sets the active selection region for this sheet.
|
|
2452
|
-
* @param {FRange} range The range to set as the active selection
|
|
2453
|
-
* @returns {FWorksheet} This sheet, for chaining
|
|
3154
|
+
* @param {FRange} range - The range to set as the active selection
|
|
3155
|
+
* @returns {FWorksheet} This sheet, for chaining
|
|
3156
|
+
* @example
|
|
3157
|
+
* ```ts
|
|
3158
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3159
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3160
|
+
* fWorkSheet.setActiveRange(fWorkSheet.getRange('A1'));
|
|
3161
|
+
* ```
|
|
2454
3162
|
*/
|
|
2455
3163
|
setActiveRange(e) {
|
|
2456
3164
|
const { unitId: t, sheetId: n } = e.getRange();
|
|
@@ -2460,13 +3168,24 @@ let g = class extends ne {
|
|
|
2460
3168
|
}
|
|
2461
3169
|
/**
|
|
2462
3170
|
* Sets the frozen state of the current sheet.
|
|
2463
|
-
* @param freeze - the scrolling viewport start range and count of freezed rows and columns.
|
|
3171
|
+
* @param {IFreeze} freeze - the scrolling viewport start range and count of freezed rows and columns.
|
|
2464
3172
|
* that means if you want to freeze the first 3 rows and 2 columns, you should set freeze as { startRow: 3, startColumn: 2, xSplit: 2, ySplit: 3 }
|
|
2465
3173
|
* @deprecated use `setFrozenRows` and `setFrozenColumns` instead.
|
|
2466
|
-
* @returns
|
|
3174
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
3175
|
+
* @example
|
|
3176
|
+
* ```typescript
|
|
3177
|
+
* const sheet = workbook.getActiveSheet();
|
|
3178
|
+
* // Freeze first 3 rows and 2 columns
|
|
3179
|
+
* sheet.setFreeze({
|
|
3180
|
+
* startRow: 3,
|
|
3181
|
+
* startColumn: 2,
|
|
3182
|
+
* xSplit: 2,
|
|
3183
|
+
* ySplit: 3
|
|
3184
|
+
* });
|
|
3185
|
+
* ```
|
|
2467
3186
|
*/
|
|
2468
3187
|
setFreeze(e) {
|
|
2469
|
-
return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(
|
|
3188
|
+
return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(z.id, {
|
|
2470
3189
|
...e,
|
|
2471
3190
|
unitId: this._workbook.getUnitId(),
|
|
2472
3191
|
subUnitId: this.getSheetId()
|
|
@@ -2474,18 +3193,30 @@ let g = class extends ne {
|
|
|
2474
3193
|
}
|
|
2475
3194
|
/**
|
|
2476
3195
|
* Cancels the frozen state of the current sheet.
|
|
2477
|
-
* @returns
|
|
3196
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
3197
|
+
* @example
|
|
3198
|
+
* ```typescript
|
|
3199
|
+
* const sheet = workbook.getActiveSheet();
|
|
3200
|
+
* // Cancel freeze
|
|
3201
|
+
* sheet.cancelFreeze();
|
|
3202
|
+
* ```
|
|
2478
3203
|
*/
|
|
2479
3204
|
cancelFreeze() {
|
|
2480
|
-
return this._commandService.syncExecuteCommand(
|
|
3205
|
+
return this._commandService.syncExecuteCommand(xt.id, {
|
|
2481
3206
|
unitId: this._workbook.getUnitId(),
|
|
2482
3207
|
subUnitId: this.getSheetId()
|
|
2483
3208
|
}), this;
|
|
2484
3209
|
}
|
|
2485
3210
|
/**
|
|
2486
3211
|
* Get the freeze state of the current sheet.
|
|
2487
|
-
* @returns The freeze state of the current sheet
|
|
2488
|
-
* @
|
|
3212
|
+
* @returns {IFreeze} The freeze state of the current sheet
|
|
3213
|
+
* @example
|
|
3214
|
+
* ```typescript
|
|
3215
|
+
* const sheet = workbook.getActiveSheet();
|
|
3216
|
+
* // Get the freeze state of the current sheet
|
|
3217
|
+
* const freeze = sheet.getFreeze();
|
|
3218
|
+
* console.log(freeze);
|
|
3219
|
+
* ```
|
|
2489
3220
|
*/
|
|
2490
3221
|
getFreeze() {
|
|
2491
3222
|
return this._worksheet.getFreeze();
|
|
@@ -2500,10 +3231,10 @@ let g = class extends ne {
|
|
|
2500
3231
|
xSplit: n
|
|
2501
3232
|
});
|
|
2502
3233
|
} else if (arguments.length === 2) {
|
|
2503
|
-
let [n = 0,
|
|
2504
|
-
n >
|
|
2505
|
-
startColumn:
|
|
2506
|
-
xSplit:
|
|
3234
|
+
let [n = 0, s = 0] = e;
|
|
3235
|
+
n > s && ([n, s] = [s, n]), this._commandService.syncExecuteCommand(z.id, {
|
|
3236
|
+
startColumn: s + 1,
|
|
3237
|
+
xSplit: s - n + 1,
|
|
2507
3238
|
startRow: t.startRow,
|
|
2508
3239
|
ySplit: t.ySplit,
|
|
2509
3240
|
unitId: this._workbook.getUnitId(),
|
|
@@ -2522,10 +3253,10 @@ let g = class extends ne {
|
|
|
2522
3253
|
ySplit: n
|
|
2523
3254
|
});
|
|
2524
3255
|
} else if (arguments.length === 2) {
|
|
2525
|
-
let [n = 0,
|
|
2526
|
-
n >
|
|
2527
|
-
startRow:
|
|
2528
|
-
ySplit:
|
|
3256
|
+
let [n = 0, s = 0] = e;
|
|
3257
|
+
n > s && ([n, s] = [s, n]), this._commandService.syncExecuteCommand(z.id, {
|
|
3258
|
+
startRow: s + 1,
|
|
3259
|
+
ySplit: s - n + 1,
|
|
2529
3260
|
startColumn: t.startColumn,
|
|
2530
3261
|
xSplit: t.xSplit,
|
|
2531
3262
|
unitId: this._workbook.getUnitId(),
|
|
@@ -2536,7 +3267,15 @@ let g = class extends ne {
|
|
|
2536
3267
|
}
|
|
2537
3268
|
/**
|
|
2538
3269
|
* Get the number of frozen columns.
|
|
2539
|
-
* @returns The number of frozen columns, returns 0 if no columns are frozen.
|
|
3270
|
+
* @returns {number} The number of frozen columns, returns 0 if no columns are frozen.
|
|
3271
|
+
* @example
|
|
3272
|
+
* ```typescript
|
|
3273
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3274
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3275
|
+
* // Get the number of frozen columns
|
|
3276
|
+
* const frozenColumns = fWorkSheet.getFrozenColumns();
|
|
3277
|
+
* console.log(frozenColumns);
|
|
3278
|
+
* ```
|
|
2540
3279
|
*/
|
|
2541
3280
|
getFrozenColumns() {
|
|
2542
3281
|
const e = this.getFreeze();
|
|
@@ -2544,7 +3283,15 @@ let g = class extends ne {
|
|
|
2544
3283
|
}
|
|
2545
3284
|
/**
|
|
2546
3285
|
* Get the number of frozen rows.
|
|
2547
|
-
* @returns The number of frozen rows. returns 0 if no rows are frozen.
|
|
3286
|
+
* @returns {number} The number of frozen rows. returns 0 if no rows are frozen.
|
|
3287
|
+
* @example
|
|
3288
|
+
* ```typescript
|
|
3289
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3290
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3291
|
+
* // Get the number of frozen rows
|
|
3292
|
+
* const frozenRows = fWorkSheet.getFrozenRows();
|
|
3293
|
+
* console.log(frozenRows);
|
|
3294
|
+
* ```
|
|
2548
3295
|
*/
|
|
2549
3296
|
getFrozenRows() {
|
|
2550
3297
|
const e = this.getFreeze();
|
|
@@ -2553,6 +3300,14 @@ let g = class extends ne {
|
|
|
2553
3300
|
/**
|
|
2554
3301
|
* Get freezed rows.
|
|
2555
3302
|
* @returns {IRowRange} The range of the frozen rows.
|
|
3303
|
+
* @example
|
|
3304
|
+
* ```ts
|
|
3305
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3306
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3307
|
+
* // Get the range of the frozen rows
|
|
3308
|
+
* const frozenRows = fWorkSheet.getFrozenRowRange();
|
|
3309
|
+
* console.log(frozenRows);
|
|
3310
|
+
* ```
|
|
2556
3311
|
*/
|
|
2557
3312
|
getFrozenRowRange() {
|
|
2558
3313
|
const e = this._worksheet.getFreeze();
|
|
@@ -2564,6 +3319,14 @@ let g = class extends ne {
|
|
|
2564
3319
|
/**
|
|
2565
3320
|
* Get freezed columns
|
|
2566
3321
|
* @returns {IColumnRange} The range of the frozen columns.
|
|
3322
|
+
* @example
|
|
3323
|
+
* ```ts
|
|
3324
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3325
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3326
|
+
* // Get the range of the frozen columns
|
|
3327
|
+
* const frozenColumns = fWorkSheet.getFrozenColumnRange();
|
|
3328
|
+
* console.log(frozenColumns);
|
|
3329
|
+
* ```
|
|
2567
3330
|
*/
|
|
2568
3331
|
getFrozenColumnRange() {
|
|
2569
3332
|
const e = this._worksheet.getFreeze();
|
|
@@ -2586,11 +3349,11 @@ let g = class extends ne {
|
|
|
2586
3349
|
* ```
|
|
2587
3350
|
*/
|
|
2588
3351
|
hasHiddenGridLines() {
|
|
2589
|
-
return this._worksheet.getConfig().showGridlines ===
|
|
3352
|
+
return this._worksheet.getConfig().showGridlines === g.FALSE;
|
|
2590
3353
|
}
|
|
2591
3354
|
/**
|
|
2592
3355
|
* Hides or reveals the sheet gridlines.
|
|
2593
|
-
* @param {boolean} hidden If `true`, hide gridlines in this sheet; otherwise show the gridlines.
|
|
3356
|
+
* @param {boolean} hidden - If `true`, hide gridlines in this sheet; otherwise show the gridlines.
|
|
2594
3357
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2595
3358
|
* @example
|
|
2596
3359
|
* ``` ts
|
|
@@ -2601,15 +3364,15 @@ let g = class extends ne {
|
|
|
2601
3364
|
* ```
|
|
2602
3365
|
*/
|
|
2603
3366
|
setHiddenGridlines(e) {
|
|
2604
|
-
return this._commandService.
|
|
3367
|
+
return this._commandService.syncExecuteCommand(te.id, {
|
|
2605
3368
|
unitId: this._workbook.getUnitId(),
|
|
2606
3369
|
subUnitId: this._worksheet.getSheetId(),
|
|
2607
|
-
showGridlines: e ?
|
|
3370
|
+
showGridlines: e ? g.FALSE : g.TRUE
|
|
2608
3371
|
}), this;
|
|
2609
3372
|
}
|
|
2610
3373
|
/**
|
|
2611
3374
|
* Set the color of the gridlines in the sheet.
|
|
2612
|
-
* @param {string|undefined} color The color to set for the gridlines.Undefined or null to reset to the default color.
|
|
3375
|
+
* @param {string|undefined} color - The color to set for the gridlines.Undefined or null to reset to the default color.
|
|
2613
3376
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2614
3377
|
* @example
|
|
2615
3378
|
* ```ts
|
|
@@ -2620,7 +3383,7 @@ let g = class extends ne {
|
|
|
2620
3383
|
* ```
|
|
2621
3384
|
*/
|
|
2622
3385
|
setGridLinesColor(e) {
|
|
2623
|
-
return this._commandService.syncExecuteCommand(
|
|
3386
|
+
return this._commandService.syncExecuteCommand(ne.id, {
|
|
2624
3387
|
unitId: this._workbook.getUnitId(),
|
|
2625
3388
|
subUnitId: this._worksheet.getSheetId(),
|
|
2626
3389
|
color: e
|
|
@@ -2629,13 +3392,20 @@ let g = class extends ne {
|
|
|
2629
3392
|
/**
|
|
2630
3393
|
* Get the color of the gridlines in the sheet.
|
|
2631
3394
|
* @returns {string | undefined} The color of the gridlines in the sheet or undefined. The default color is 'rgb(214, 216, 219)'.
|
|
3395
|
+
* @example
|
|
3396
|
+
* ```ts
|
|
3397
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3398
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3399
|
+
* // get the gridlines color of the sheet
|
|
3400
|
+
* console.log(fWorkSheet.getGridLinesColor());
|
|
3401
|
+
* ```
|
|
2632
3402
|
*/
|
|
2633
3403
|
getGridLinesColor() {
|
|
2634
3404
|
return this._worksheet.getGridlinesColor();
|
|
2635
3405
|
}
|
|
2636
3406
|
/**
|
|
2637
3407
|
* Sets the sheet tab color.
|
|
2638
|
-
* @param {string|null|undefined} color A color code in CSS notation (like '#ffffff' or 'white'), or null to reset the tab color.
|
|
3408
|
+
* @param {string|null|undefined} color - A color code in CSS notation (like '#ffffff' or 'white'), or null to reset the tab color.
|
|
2639
3409
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2640
3410
|
* @example
|
|
2641
3411
|
* ```ts
|
|
@@ -2646,7 +3416,7 @@ let g = class extends ne {
|
|
|
2646
3416
|
* ```
|
|
2647
3417
|
*/
|
|
2648
3418
|
setTabColor(e) {
|
|
2649
|
-
return this._commandService.
|
|
3419
|
+
return this._commandService.syncExecuteCommand(re.id, {
|
|
2650
3420
|
unitId: this._workbook.getUnitId(),
|
|
2651
3421
|
subUnitId: this._worksheet.getSheetId(),
|
|
2652
3422
|
color: e
|
|
@@ -2667,51 +3437,27 @@ let g = class extends ne {
|
|
|
2667
3437
|
getTabColor() {
|
|
2668
3438
|
return this._worksheet.getTabColor();
|
|
2669
3439
|
}
|
|
3440
|
+
// eslint-disable-next-line
|
|
2670
3441
|
/**
|
|
2671
|
-
*
|
|
2672
|
-
* @param callback - The callback function to be executed when the cell data changes.
|
|
2673
|
-
* @returns - A disposable object to unsubscribe from the event.
|
|
2674
|
-
* @example
|
|
2675
|
-
* ```ts
|
|
2676
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2677
|
-
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2678
|
-
* // subscribe to the cell data change event
|
|
2679
|
-
* const disposable = fWorkSheet.onCellDataChange((cellValue) => {
|
|
2680
|
-
* console.log(cellValue.toArray());
|
|
2681
|
-
* });
|
|
2682
|
-
* // unsubscribe from the event
|
|
2683
|
-
* disposable.dispose();
|
|
2684
|
-
* ```
|
|
3442
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.SheetValueChanged, callback)` instead
|
|
2685
3443
|
*/
|
|
2686
3444
|
onCellDataChange(e) {
|
|
2687
3445
|
return this._injector.get(l).onCommandExecuted((n) => {
|
|
2688
|
-
if (n.id ===
|
|
2689
|
-
const
|
|
2690
|
-
|
|
3446
|
+
if (n.id === Ee.id) {
|
|
3447
|
+
const s = n.params;
|
|
3448
|
+
s.unitId === this._workbook.getUnitId() && s.subUnitId === this._worksheet.getSheetId() && s.cellValue && e(new W(s.cellValue));
|
|
2691
3449
|
}
|
|
2692
3450
|
});
|
|
2693
3451
|
}
|
|
3452
|
+
// eslint-disable-next-line
|
|
2694
3453
|
/**
|
|
2695
|
-
*
|
|
2696
|
-
* @param callback - The callback function to be executed before the cell data changes.
|
|
2697
|
-
* @returns - A disposable object to unsubscribe from the event.
|
|
2698
|
-
* @example
|
|
2699
|
-
* ```ts
|
|
2700
|
-
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2701
|
-
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2702
|
-
* // subscribe to the cell data change event
|
|
2703
|
-
* const disposable = fWorkSheet.onBeforeCellDataChange((cellValue) => {
|
|
2704
|
-
* console.log(cellValue.toArray());
|
|
2705
|
-
* });
|
|
2706
|
-
* // unsubscribe from the event
|
|
2707
|
-
* disposable.dispose();
|
|
2708
|
-
* ```
|
|
3454
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.SheetValueChanged, callback)` instead
|
|
2709
3455
|
*/
|
|
2710
3456
|
onBeforeCellDataChange(e) {
|
|
2711
3457
|
return this._injector.get(l).beforeCommandExecuted((n) => {
|
|
2712
|
-
if (n.id ===
|
|
2713
|
-
const
|
|
2714
|
-
|
|
3458
|
+
if (n.id === Ee.id) {
|
|
3459
|
+
const s = n.params;
|
|
3460
|
+
s.unitId === this._workbook.getUnitId() && s.subUnitId === this._worksheet.getSheetId() && s.cellValue && e(new W(s.cellValue));
|
|
2715
3461
|
}
|
|
2716
3462
|
});
|
|
2717
3463
|
}
|
|
@@ -2728,9 +3474,9 @@ let g = class extends ne {
|
|
|
2728
3474
|
*/
|
|
2729
3475
|
hideSheet() {
|
|
2730
3476
|
const e = this._injector.get(l);
|
|
2731
|
-
if (this._workbook.getSheets().filter((
|
|
3477
|
+
if (this._workbook.getSheets().filter((i) => i.isSheetHidden() !== g.TRUE).length <= 1)
|
|
2732
3478
|
throw new Error("Cannot hide the only visible sheet");
|
|
2733
|
-
return e.syncExecuteCommand(
|
|
3479
|
+
return e.syncExecuteCommand(se.id, {
|
|
2734
3480
|
unitId: this._workbook.getUnitId(),
|
|
2735
3481
|
subUnitId: this._worksheet.getSheetId()
|
|
2736
3482
|
}), this;
|
|
@@ -2747,7 +3493,7 @@ let g = class extends ne {
|
|
|
2747
3493
|
* ```
|
|
2748
3494
|
*/
|
|
2749
3495
|
showSheet() {
|
|
2750
|
-
return this._injector.get(l).syncExecuteCommand(
|
|
3496
|
+
return this._injector.get(l).syncExecuteCommand(Nt.id, {
|
|
2751
3497
|
unitId: this._workbook.getUnitId(),
|
|
2752
3498
|
subUnitId: this._worksheet.getSheetId()
|
|
2753
3499
|
}), this;
|
|
@@ -2757,11 +3503,11 @@ let g = class extends ne {
|
|
|
2757
3503
|
* @returns {boolean} True if the sheet is hidden; otherwise, false.
|
|
2758
3504
|
*/
|
|
2759
3505
|
isSheetHidden() {
|
|
2760
|
-
return this._worksheet.isSheetHidden() ===
|
|
3506
|
+
return this._worksheet.isSheetHidden() === g.TRUE;
|
|
2761
3507
|
}
|
|
2762
3508
|
/**
|
|
2763
3509
|
* Sets the sheet name.
|
|
2764
|
-
* @param {string} name The new name for the sheet.
|
|
3510
|
+
* @param {string} name - The new name for the sheet.
|
|
2765
3511
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2766
3512
|
* @example
|
|
2767
3513
|
* ```ts
|
|
@@ -2772,7 +3518,7 @@ let g = class extends ne {
|
|
|
2772
3518
|
* ```
|
|
2773
3519
|
*/
|
|
2774
3520
|
setName(e) {
|
|
2775
|
-
return this._commandService.syncExecuteCommand(
|
|
3521
|
+
return this._commandService.syncExecuteCommand(ie.id, {
|
|
2776
3522
|
unitId: this._workbook.getUnitId(),
|
|
2777
3523
|
subUnitId: this._worksheet.getSheetId(),
|
|
2778
3524
|
name: e
|
|
@@ -2780,7 +3526,7 @@ let g = class extends ne {
|
|
|
2780
3526
|
}
|
|
2781
3527
|
/**
|
|
2782
3528
|
* Activates this sheet. Does not alter the sheet itself, only the parent's notion of the active sheet.
|
|
2783
|
-
* @returns Current sheet, for chaining.
|
|
3529
|
+
* @returns {FWorksheet} Current sheet, for chaining.
|
|
2784
3530
|
*/
|
|
2785
3531
|
activate() {
|
|
2786
3532
|
return this._fWorkbook.setActiveSheet(this), this;
|
|
@@ -2802,9 +3548,9 @@ let g = class extends ne {
|
|
|
2802
3548
|
}
|
|
2803
3549
|
/**
|
|
2804
3550
|
* Clears the sheet of content and formatting information.Or Optionally clears only the contents or only the formatting.
|
|
2805
|
-
* @param {IFacadeClearOptions} [options] Options for clearing the sheet. If not provided, the contents and formatting are cleared both.
|
|
2806
|
-
* @param {boolean} [options.contentsOnly] If true, the contents of the sheet are cleared. If false, the contents and formatting are cleared. Default is false.
|
|
2807
|
-
* @param {boolean} [options.formatOnly] If true, the formatting of the sheet is cleared. If false, the contents and formatting are cleared. Default is false.
|
|
3551
|
+
* @param {IFacadeClearOptions} [options] - Options for clearing the sheet. If not provided, the contents and formatting are cleared both.
|
|
3552
|
+
* @param {boolean} [options.contentsOnly] - If true, the contents of the sheet are cleared. If false, the contents and formatting are cleared. Default is false.
|
|
3553
|
+
* @param {boolean} [options.formatOnly] - If true, the formatting of the sheet is cleared. If false, the contents and formatting are cleared. Default is false.
|
|
2808
3554
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2809
3555
|
* @example
|
|
2810
3556
|
* ```ts
|
|
@@ -2818,16 +3564,16 @@ let g = class extends ne {
|
|
|
2818
3564
|
*/
|
|
2819
3565
|
clear(e) {
|
|
2820
3566
|
e && e.contentsOnly && !e.formatOnly && this.clearContents(), e && e.formatOnly && !e.contentsOnly && this.clearFormats();
|
|
2821
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
3567
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = this._injector.get(l), i = {
|
|
2822
3568
|
startRow: 0,
|
|
2823
3569
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2824
3570
|
startColumn: 0,
|
|
2825
3571
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2826
3572
|
};
|
|
2827
|
-
return
|
|
3573
|
+
return s.syncExecuteCommand(Tt.id, {
|
|
2828
3574
|
unitId: t,
|
|
2829
3575
|
subUnitId: n,
|
|
2830
|
-
ranges: [
|
|
3576
|
+
ranges: [i],
|
|
2831
3577
|
options: e
|
|
2832
3578
|
}), this;
|
|
2833
3579
|
}
|
|
@@ -2835,7 +3581,7 @@ let g = class extends ne {
|
|
|
2835
3581
|
* Clears the sheet of contents, while preserving formatting information.
|
|
2836
3582
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2837
3583
|
* @example
|
|
2838
|
-
* ```
|
|
3584
|
+
* ```typescript
|
|
2839
3585
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2840
3586
|
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2841
3587
|
* // clear the sheet of content only
|
|
@@ -2843,23 +3589,23 @@ let g = class extends ne {
|
|
|
2843
3589
|
* ```
|
|
2844
3590
|
*/
|
|
2845
3591
|
clearContents() {
|
|
2846
|
-
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l),
|
|
3592
|
+
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), s = {
|
|
2847
3593
|
startRow: 0,
|
|
2848
3594
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2849
3595
|
startColumn: 0,
|
|
2850
3596
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2851
3597
|
};
|
|
2852
|
-
return n.syncExecuteCommand(
|
|
3598
|
+
return n.syncExecuteCommand(Mt.id, {
|
|
2853
3599
|
unitId: e,
|
|
2854
3600
|
subUnitId: t,
|
|
2855
|
-
ranges: [
|
|
3601
|
+
ranges: [s]
|
|
2856
3602
|
}), this;
|
|
2857
3603
|
}
|
|
2858
3604
|
/**
|
|
2859
3605
|
* Clears the sheet of formatting, while preserving contents.
|
|
2860
3606
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2861
3607
|
* @example
|
|
2862
|
-
* ```
|
|
3608
|
+
* ```typescript
|
|
2863
3609
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2864
3610
|
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2865
3611
|
* // clear the sheet of formatting only
|
|
@@ -2867,16 +3613,16 @@ let g = class extends ne {
|
|
|
2867
3613
|
* ```
|
|
2868
3614
|
*/
|
|
2869
3615
|
clearFormats() {
|
|
2870
|
-
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l),
|
|
3616
|
+
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), s = {
|
|
2871
3617
|
startRow: 0,
|
|
2872
3618
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2873
3619
|
startColumn: 0,
|
|
2874
3620
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2875
3621
|
};
|
|
2876
|
-
return n.syncExecuteCommand(
|
|
3622
|
+
return n.syncExecuteCommand(Dt.id, {
|
|
2877
3623
|
unitId: e,
|
|
2878
3624
|
subUnitId: t,
|
|
2879
|
-
ranges: [
|
|
3625
|
+
ranges: [s]
|
|
2880
3626
|
}), this;
|
|
2881
3627
|
}
|
|
2882
3628
|
/**
|
|
@@ -2957,7 +3703,7 @@ let g = class extends ne {
|
|
|
2957
3703
|
}
|
|
2958
3704
|
/**
|
|
2959
3705
|
* Judge whether provided FWorksheet is equal to current.
|
|
2960
|
-
* @param {FWorksheet} other the FWorksheet to compare with.
|
|
3706
|
+
* @param {FWorksheet} other - the FWorksheet to compare with.
|
|
2961
3707
|
* @returns {boolean} true if the FWorksheet is equal to the current FWorksheet, false otherwise.
|
|
2962
3708
|
* @example
|
|
2963
3709
|
* ```ts
|
|
@@ -2968,12 +3714,12 @@ let g = class extends ne {
|
|
|
2968
3714
|
* ```
|
|
2969
3715
|
*/
|
|
2970
3716
|
equalTo(e) {
|
|
2971
|
-
return e instanceof
|
|
3717
|
+
return e instanceof m ? this._worksheet.getSheetId() === e.getSheetId() && this._workbook.getUnitId() === e.getWorkbook().getUnitId() : !1;
|
|
2972
3718
|
}
|
|
2973
3719
|
/*
|
|
2974
3720
|
* Insert a defined name for worksheet.
|
|
2975
|
-
* @param {string} name The name of the defined name to insert
|
|
2976
|
-
* @param {string} formulaOrRefString The formula(=sum(A2:b10)) or reference(A1) string of the defined name to insert
|
|
3721
|
+
* @param {string} name - The name of the defined name to insert
|
|
3722
|
+
* @param {string} formulaOrRefString - The formula(=sum(A2:b10)) or reference(A1) string of the defined name to insert
|
|
2977
3723
|
* @example
|
|
2978
3724
|
* ```ts
|
|
2979
3725
|
* // The code below inserts a defined name
|
|
@@ -2983,8 +3729,8 @@ let g = class extends ne {
|
|
|
2983
3729
|
* ```
|
|
2984
3730
|
*/
|
|
2985
3731
|
insertDefinedName(e, t) {
|
|
2986
|
-
const
|
|
2987
|
-
|
|
3732
|
+
const s = this._injector.createInstance(V).setName(e).setRef(t).build();
|
|
3733
|
+
s.localSheetId = this.getSheetId(), this._fWorkbook.insertDefinedNameBuilder(s);
|
|
2988
3734
|
}
|
|
2989
3735
|
/**
|
|
2990
3736
|
* Get all the defined names in the worksheet.
|
|
@@ -3002,7 +3748,8 @@ let g = class extends ne {
|
|
|
3002
3748
|
}
|
|
3003
3749
|
/**
|
|
3004
3750
|
* Set custom metadata of worksheet
|
|
3005
|
-
* @param {CustomData | undefined} custom custom metadata
|
|
3751
|
+
* @param {CustomData | undefined} custom - custom metadata
|
|
3752
|
+
* @returns {FWorksheet}
|
|
3006
3753
|
* @example
|
|
3007
3754
|
* ```ts
|
|
3008
3755
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -3015,8 +3762,9 @@ let g = class extends ne {
|
|
|
3015
3762
|
}
|
|
3016
3763
|
/**
|
|
3017
3764
|
* Set custom metadata of row
|
|
3018
|
-
* @param {number} index row index
|
|
3019
|
-
* @param {CustomData | undefined} custom custom metadata
|
|
3765
|
+
* @param {number} index - row index
|
|
3766
|
+
* @param {CustomData | undefined} custom - custom metadata
|
|
3767
|
+
* @returns {FWorksheet} Current worksheet, for chaining.
|
|
3020
3768
|
* @example
|
|
3021
3769
|
* ```ts
|
|
3022
3770
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -3029,8 +3777,9 @@ let g = class extends ne {
|
|
|
3029
3777
|
}
|
|
3030
3778
|
/**
|
|
3031
3779
|
* Set custom metadata of column
|
|
3032
|
-
* @param {number} index column index
|
|
3033
|
-
* @param {CustomData | undefined} custom custom metadata
|
|
3780
|
+
* @param {number} index - column index
|
|
3781
|
+
* @param {CustomData | undefined} custom - custom metadata
|
|
3782
|
+
* @returns {FWorksheet} Current worksheet, for chaining.
|
|
3034
3783
|
* @example
|
|
3035
3784
|
* ```ts
|
|
3036
3785
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -3043,7 +3792,7 @@ let g = class extends ne {
|
|
|
3043
3792
|
}
|
|
3044
3793
|
/**
|
|
3045
3794
|
* Get custom metadata of row
|
|
3046
|
-
* @param {number} index row index
|
|
3795
|
+
* @param {number} index - row index
|
|
3047
3796
|
* @returns {CustomData | undefined} custom metadata
|
|
3048
3797
|
* @example
|
|
3049
3798
|
* ```ts
|
|
@@ -3057,7 +3806,7 @@ let g = class extends ne {
|
|
|
3057
3806
|
}
|
|
3058
3807
|
/**
|
|
3059
3808
|
* Get custom metadata of column
|
|
3060
|
-
* @param {number} index column index
|
|
3809
|
+
* @param {number} index - column index
|
|
3061
3810
|
* @returns {CustomData | undefined} custom metadata
|
|
3062
3811
|
* @example
|
|
3063
3812
|
* ```ts
|
|
@@ -3085,74 +3834,38 @@ let g = class extends ne {
|
|
|
3085
3834
|
* ```
|
|
3086
3835
|
*/
|
|
3087
3836
|
getMergeData() {
|
|
3088
|
-
return this._worksheet.getMergeData().map((e) => this._injector.createInstance(
|
|
3837
|
+
return this._worksheet.getMergeData().map((e) => this._injector.createInstance(S, this._workbook, this._worksheet, e));
|
|
3089
3838
|
}
|
|
3090
3839
|
};
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
],
|
|
3097
|
-
var
|
|
3098
|
-
for (var
|
|
3099
|
-
(
|
|
3100
|
-
return n &&
|
|
3101
|
-
}, C = (
|
|
3102
|
-
let
|
|
3103
|
-
constructor(e, t, n,
|
|
3840
|
+
m = gn([
|
|
3841
|
+
B(3, u(y)),
|
|
3842
|
+
B(4, u(ze)),
|
|
3843
|
+
B(5, u(De)),
|
|
3844
|
+
B(6, l)
|
|
3845
|
+
], m);
|
|
3846
|
+
var ln = Object.defineProperty, mn = Object.getOwnPropertyDescriptor, _n = (r, e, t, n) => {
|
|
3847
|
+
for (var s = n > 1 ? void 0 : n ? mn(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
3848
|
+
(o = r[i]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
3849
|
+
return n && s && ln(e, t, s), s;
|
|
3850
|
+
}, C = (r, e) => (t, n) => e(t, n, r);
|
|
3851
|
+
let f = class extends ce {
|
|
3852
|
+
constructor(e, t, n, s, i, o, h, a, d, c) {
|
|
3104
3853
|
super(t);
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
this._workbook = e, this._injector = t, this._resourceLoaderService = n, this._selectionManagerService = r, this._univerInstanceService = o, this._commandService = i, this._permissionService = a, this._logService = h, this._localeService = c, this._definedNamesService = d, this.id = this._workbook.getUnitId();
|
|
3108
|
-
}
|
|
3109
|
-
getWorkbook() {
|
|
3110
|
-
return this._workbook;
|
|
3111
|
-
}
|
|
3112
|
-
_ensureEventRegistry(e) {
|
|
3113
|
-
return this._eventRegistry.has(e) || this._eventRegistry.set(e, new ye()), this._eventRegistry.get(e);
|
|
3854
|
+
b(this, "id");
|
|
3855
|
+
this._workbook = e, this._injector = t, this._resourceLoaderService = n, this._selectionManagerService = s, this._univerInstanceService = i, this._commandService = o, this._permissionService = h, this._logService = a, this._localeService = d, this._definedNamesService = c, this.id = this._workbook.getUnitId();
|
|
3114
3856
|
}
|
|
3115
3857
|
/**
|
|
3116
|
-
*
|
|
3117
|
-
* @
|
|
3118
|
-
* @param callback callback when event triggered
|
|
3119
|
-
* @returns {Disposable} The Disposable instance, for remove the listener
|
|
3858
|
+
* Get the Workbook instance.
|
|
3859
|
+
* @returns {Workbook} The Workbook instance.
|
|
3120
3860
|
* @example
|
|
3121
3861
|
* ```ts
|
|
3122
|
-
*
|
|
3123
|
-
*
|
|
3124
|
-
*
|
|
3125
|
-
* ```
|
|
3126
|
-
*/
|
|
3127
|
-
addEvent(e, t) {
|
|
3128
|
-
return this._ensureEventRegistry(e).add(t), this.addUIEvent(e, t), F(() => this._ensureEventRegistry(e).delete(t));
|
|
3129
|
-
}
|
|
3130
|
-
/**
|
|
3131
|
-
* Fire an event, used in internal only.
|
|
3132
|
-
* @param event {string} key of event
|
|
3133
|
-
* @param params {any} params of event
|
|
3134
|
-
* @returns {boolean} should cancel
|
|
3135
|
-
* @example
|
|
3136
|
-
* ```ts
|
|
3137
|
-
* this.fireEvent(univerAPI.event.UnitCreated, params);
|
|
3862
|
+
* // The code below gets the Workbook instance
|
|
3863
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
3864
|
+
* const workbook = activeSpreadsheet.getWorkbook();
|
|
3138
3865
|
* ```
|
|
3139
3866
|
*/
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
return (n = this._eventRegistry.get(e)) == null || n.getData().forEach((r) => {
|
|
3143
|
-
r(t);
|
|
3144
|
-
}), t.cancel;
|
|
3145
|
-
}
|
|
3146
|
-
addUIEvent(e, t) {
|
|
3147
|
-
}
|
|
3148
|
-
get Enum() {
|
|
3149
|
-
return ze.get();
|
|
3150
|
-
}
|
|
3151
|
-
/**
|
|
3152
|
-
* @returns {FEventName} The event name.
|
|
3153
|
-
*/
|
|
3154
|
-
get Event() {
|
|
3155
|
-
return se.get();
|
|
3867
|
+
getWorkbook() {
|
|
3868
|
+
return this._workbook;
|
|
3156
3869
|
}
|
|
3157
3870
|
/**
|
|
3158
3871
|
* Get the id of the workbook.
|
|
@@ -3183,6 +3896,7 @@ let I = class extends ne {
|
|
|
3183
3896
|
/**
|
|
3184
3897
|
* Set the name of the workbook.
|
|
3185
3898
|
* @param {string} name The new name of the workbook.
|
|
3899
|
+
* @returns {void}
|
|
3186
3900
|
* @example
|
|
3187
3901
|
* ```ts
|
|
3188
3902
|
* // The code below sets the name of the workbook
|
|
@@ -3208,8 +3922,14 @@ let I = class extends ne {
|
|
|
3208
3922
|
}
|
|
3209
3923
|
/**
|
|
3210
3924
|
* @deprecated use 'save' instead.
|
|
3211
|
-
* @returns {
|
|
3925
|
+
* @returns {IWorkbookData} Workbook snapshot data
|
|
3212
3926
|
* @memberof FWorkbook
|
|
3927
|
+
* @example
|
|
3928
|
+
* ```ts
|
|
3929
|
+
* // The code below saves the workbook snapshot data
|
|
3930
|
+
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
3931
|
+
* const snapshot = activeSpreadsheet.getSnapshot();
|
|
3932
|
+
* ```
|
|
3213
3933
|
*/
|
|
3214
3934
|
getSnapshot() {
|
|
3215
3935
|
return this._logService.warn("use 'save' instead of 'getSnapshot'"), this.save();
|
|
@@ -3226,7 +3946,7 @@ let I = class extends ne {
|
|
|
3226
3946
|
*/
|
|
3227
3947
|
getActiveSheet() {
|
|
3228
3948
|
const e = this._workbook.getActiveSheet();
|
|
3229
|
-
return this._injector.createInstance(
|
|
3949
|
+
return this._injector.createInstance(m, this, this._workbook, e);
|
|
3230
3950
|
}
|
|
3231
3951
|
/**
|
|
3232
3952
|
* Gets all the worksheets in this workbook
|
|
@@ -3239,14 +3959,14 @@ let I = class extends ne {
|
|
|
3239
3959
|
* ```
|
|
3240
3960
|
*/
|
|
3241
3961
|
getSheets() {
|
|
3242
|
-
return this._workbook.getSheets().map((e) => this._injector.createInstance(
|
|
3962
|
+
return this._workbook.getSheets().map((e) => this._injector.createInstance(m, this, this._workbook, e));
|
|
3243
3963
|
}
|
|
3244
3964
|
/**
|
|
3245
3965
|
* Create a new worksheet and returns a handle to it.
|
|
3246
|
-
* @param name Name of the new sheet
|
|
3247
|
-
* @param rows How
|
|
3248
|
-
* @param column How many columns would the new sheet have
|
|
3249
|
-
* @returns The new created sheet
|
|
3966
|
+
* @param {string} name Name of the new sheet
|
|
3967
|
+
* @param {number} rows How many rows would the new sheet have
|
|
3968
|
+
* @param {number} column How many columns would the new sheet have
|
|
3969
|
+
* @returns {FWorksheet} The new created sheet
|
|
3250
3970
|
* @example
|
|
3251
3971
|
* ```ts
|
|
3252
3972
|
* // The code below creates a new sheet
|
|
@@ -3255,24 +3975,24 @@ let I = class extends ne {
|
|
|
3255
3975
|
* ```
|
|
3256
3976
|
*/
|
|
3257
3977
|
create(e, t, n) {
|
|
3258
|
-
const
|
|
3259
|
-
|
|
3978
|
+
const s = Ze({});
|
|
3979
|
+
s.rowCount = t, s.columnCount = n, s.name = e, s.id = e.toLowerCase().replace(/ /g, "-"), this._commandService.syncExecuteCommand(T.id, {
|
|
3260
3980
|
unitId: this.id,
|
|
3261
3981
|
index: this._workbook.getSheets().length,
|
|
3262
|
-
sheet:
|
|
3263
|
-
}), this._commandService.syncExecuteCommand(
|
|
3982
|
+
sheet: s
|
|
3983
|
+
}), this._commandService.syncExecuteCommand($.id, {
|
|
3264
3984
|
unitId: this.id,
|
|
3265
3985
|
subUnitId: this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId()
|
|
3266
3986
|
});
|
|
3267
|
-
const
|
|
3268
|
-
if (!
|
|
3987
|
+
const i = this._workbook.getActiveSheet();
|
|
3988
|
+
if (!i)
|
|
3269
3989
|
throw new Error("No active sheet found");
|
|
3270
|
-
return this._injector.createInstance(
|
|
3990
|
+
return this._injector.createInstance(m, this, this._workbook, i);
|
|
3271
3991
|
}
|
|
3272
3992
|
/**
|
|
3273
3993
|
* Get a worksheet by sheet id.
|
|
3274
|
-
* @param sheetId The id of the sheet to get.
|
|
3275
|
-
* @returns The worksheet with given sheet id
|
|
3994
|
+
* @param {string} sheetId The id of the sheet to get.
|
|
3995
|
+
* @returns {FWorksheet | null} The worksheet with given sheet id
|
|
3276
3996
|
* @example
|
|
3277
3997
|
* ```ts
|
|
3278
3998
|
* // The code below gets a worksheet by sheet id
|
|
@@ -3282,12 +4002,12 @@ let I = class extends ne {
|
|
|
3282
4002
|
*/
|
|
3283
4003
|
getSheetBySheetId(e) {
|
|
3284
4004
|
const t = this._workbook.getSheetBySheetId(e);
|
|
3285
|
-
return t ? this._injector.createInstance(
|
|
4005
|
+
return t ? this._injector.createInstance(m, this, this._workbook, t) : null;
|
|
3286
4006
|
}
|
|
3287
4007
|
/**
|
|
3288
4008
|
* Get a worksheet by sheet name.
|
|
3289
|
-
* @param name The name of the sheet to get.
|
|
3290
|
-
* @returns The worksheet with given sheet name
|
|
4009
|
+
* @param {string} name The name of the sheet to get.
|
|
4010
|
+
* @returns {FWorksheet | null} The worksheet with given sheet name
|
|
3291
4011
|
* @example
|
|
3292
4012
|
* ```ts
|
|
3293
4013
|
* // The code below gets a worksheet by sheet name
|
|
@@ -3297,12 +4017,12 @@ let I = class extends ne {
|
|
|
3297
4017
|
*/
|
|
3298
4018
|
getSheetByName(e) {
|
|
3299
4019
|
const t = this._workbook.getSheetBySheetName(e);
|
|
3300
|
-
return t ? this._injector.createInstance(
|
|
4020
|
+
return t ? this._injector.createInstance(m, this, this._workbook, t) : null;
|
|
3301
4021
|
}
|
|
3302
4022
|
/**
|
|
3303
4023
|
* Sets the given worksheet to be the active worksheet in the workbook.
|
|
3304
|
-
* @param sheet The worksheet to set as the active worksheet.
|
|
3305
|
-
* @returns The active worksheet
|
|
4024
|
+
* @param {FWorksheet | string} sheet The worksheet to set as the active worksheet.
|
|
4025
|
+
* @returns {FWorksheet} The active worksheet
|
|
3306
4026
|
* @example
|
|
3307
4027
|
* ```ts
|
|
3308
4028
|
* // The code below sets the given worksheet to be the active worksheet
|
|
@@ -3312,16 +4032,16 @@ let I = class extends ne {
|
|
|
3312
4032
|
* ```
|
|
3313
4033
|
*/
|
|
3314
4034
|
setActiveSheet(e) {
|
|
3315
|
-
return this._commandService.syncExecuteCommand(
|
|
4035
|
+
return this._commandService.syncExecuteCommand($.id, {
|
|
3316
4036
|
unitId: this.id,
|
|
3317
|
-
subUnitId: e.getSheetId()
|
|
3318
|
-
}), e;
|
|
4037
|
+
subUnitId: typeof e == "string" ? e : e.getSheetId()
|
|
4038
|
+
}), typeof e == "string" ? this.getSheetBySheetId(e) : e;
|
|
3319
4039
|
}
|
|
3320
4040
|
/**
|
|
3321
4041
|
* Inserts a new worksheet into the workbook.
|
|
3322
4042
|
* Using a default sheet name. The new sheet becomes the active sheet
|
|
3323
|
-
* @param sheetName
|
|
3324
|
-
* @returns The new sheet
|
|
4043
|
+
* @param {string} [sheetName] The name of the new sheet
|
|
4044
|
+
* @returns {FWorksheet} The new sheet
|
|
3325
4045
|
* @example
|
|
3326
4046
|
* ```ts
|
|
3327
4047
|
* // The code below inserts a new sheet into the workbook
|
|
@@ -3334,20 +4054,20 @@ let I = class extends ne {
|
|
|
3334
4054
|
* ```
|
|
3335
4055
|
*/
|
|
3336
4056
|
insertSheet(e) {
|
|
3337
|
-
e != null ? this._commandService.syncExecuteCommand(
|
|
4057
|
+
e != null ? this._commandService.syncExecuteCommand(T.id, { sheet: { name: e } }) : this._commandService.syncExecuteCommand(T.id);
|
|
3338
4058
|
const t = this.id, n = this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId();
|
|
3339
|
-
this._commandService.syncExecuteCommand(
|
|
4059
|
+
this._commandService.syncExecuteCommand($.id, {
|
|
3340
4060
|
unitId: t,
|
|
3341
4061
|
subUnitId: n
|
|
3342
4062
|
});
|
|
3343
|
-
const
|
|
3344
|
-
if (!
|
|
4063
|
+
const s = this._workbook.getActiveSheet();
|
|
4064
|
+
if (!s)
|
|
3345
4065
|
throw new Error("No active sheet found");
|
|
3346
|
-
return this._injector.createInstance(
|
|
4066
|
+
return this._injector.createInstance(m, this, this._workbook, s);
|
|
3347
4067
|
}
|
|
3348
4068
|
/**
|
|
3349
4069
|
* Deletes the specified worksheet.
|
|
3350
|
-
* @param sheet The worksheet to delete.
|
|
4070
|
+
* @param {FWorksheet | string} sheet The worksheet to delete.
|
|
3351
4071
|
* @returns {boolean} True if the worksheet was deleted, false otherwise.
|
|
3352
4072
|
* @example
|
|
3353
4073
|
* ```ts
|
|
@@ -3358,8 +4078,8 @@ let I = class extends ne {
|
|
|
3358
4078
|
* ```
|
|
3359
4079
|
*/
|
|
3360
4080
|
deleteSheet(e) {
|
|
3361
|
-
const t = this.id, n = e.getSheetId();
|
|
3362
|
-
return this._commandService.syncExecuteCommand(
|
|
4081
|
+
const t = this.id, n = typeof e == "string" ? e : e.getSheetId();
|
|
4082
|
+
return this._commandService.syncExecuteCommand(oe.id, {
|
|
3363
4083
|
unitId: t,
|
|
3364
4084
|
subUnitId: n
|
|
3365
4085
|
});
|
|
@@ -3376,11 +4096,11 @@ let I = class extends ne {
|
|
|
3376
4096
|
* ```
|
|
3377
4097
|
*/
|
|
3378
4098
|
undo() {
|
|
3379
|
-
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(
|
|
4099
|
+
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(et.id), this;
|
|
3380
4100
|
}
|
|
3381
4101
|
/**
|
|
3382
4102
|
* Redo the last undone action.
|
|
3383
|
-
* @returns A promise that resolves to true if the redo was successful, false otherwise.
|
|
4103
|
+
* @returns {FWorkbook} A promise that resolves to true if the redo was successful, false otherwise.
|
|
3384
4104
|
* @example
|
|
3385
4105
|
* ```ts
|
|
3386
4106
|
* // The code below redoes the last undone action
|
|
@@ -3389,7 +4109,7 @@ let I = class extends ne {
|
|
|
3389
4109
|
* ```
|
|
3390
4110
|
*/
|
|
3391
4111
|
redo() {
|
|
3392
|
-
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(
|
|
4112
|
+
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(tt.id), this;
|
|
3393
4113
|
}
|
|
3394
4114
|
/**
|
|
3395
4115
|
* Callback for command execution.
|
|
@@ -3399,7 +4119,7 @@ let I = class extends ne {
|
|
|
3399
4119
|
/**
|
|
3400
4120
|
* Register a callback that will be triggered before invoking a command targeting the Univer sheet.
|
|
3401
4121
|
* @param {onBeforeCommandExecuteCallback} callback the callback.
|
|
3402
|
-
* @returns A function to dispose the listening.
|
|
4122
|
+
* @returns {IDisposable} A function to dispose the listening.
|
|
3403
4123
|
* @example
|
|
3404
4124
|
* ```ts
|
|
3405
4125
|
* // The code below registers a callback that will be triggered before invoking a command targeting the Univer sheet
|
|
@@ -3423,7 +4143,7 @@ let I = class extends ne {
|
|
|
3423
4143
|
/**
|
|
3424
4144
|
* Register a callback that will be triggered when a command is invoked targeting the Univer sheet.
|
|
3425
4145
|
* @param {onCommandExecutedCallback} callback the callback.
|
|
3426
|
-
* @returns A function to dispose the listening.
|
|
4146
|
+
* @returns {IDisposable} A function to dispose the listening.
|
|
3427
4147
|
* @example
|
|
3428
4148
|
* ```ts
|
|
3429
4149
|
* // The code below registers a callback that will be triggered when a command is invoked targeting the Univer sheet
|
|
@@ -3431,6 +4151,7 @@ let I = class extends ne {
|
|
|
3431
4151
|
* activeSpreadsheet.onCommandExecuted((command) => {
|
|
3432
4152
|
* console.log('Command executed:', command);
|
|
3433
4153
|
* });
|
|
4154
|
+
* ```
|
|
3434
4155
|
*/
|
|
3435
4156
|
onCommandExecuted(e) {
|
|
3436
4157
|
return this._commandService.onCommandExecuted((t) => {
|
|
@@ -3446,12 +4167,12 @@ let I = class extends ne {
|
|
|
3446
4167
|
/**
|
|
3447
4168
|
* Register a callback that will be triggered when the selection changes.
|
|
3448
4169
|
* @param {onSelectionChangeCallback} callback The callback.
|
|
3449
|
-
* @returns A function to dispose the listening
|
|
4170
|
+
* @returns {IDisposable} A function to dispose the listening
|
|
3450
4171
|
*/
|
|
3451
4172
|
onSelectionChange(e) {
|
|
3452
|
-
return
|
|
4173
|
+
return Ae(
|
|
3453
4174
|
this._selectionManagerService.selectionMoveEnd$.subscribe((t) => {
|
|
3454
|
-
this._univerInstanceService.getCurrentUnitForType(
|
|
4175
|
+
this._univerInstanceService.getCurrentUnitForType(p.UNIVER_SHEET).getUnitId() === this.id && (t != null && t.length ? e(t.map((n) => n.range)) : e([]));
|
|
3455
4176
|
})
|
|
3456
4177
|
);
|
|
3457
4178
|
}
|
|
@@ -3461,34 +4182,34 @@ let I = class extends ne {
|
|
|
3461
4182
|
* @returns {FWorkbook} FWorkbook instance
|
|
3462
4183
|
*/
|
|
3463
4184
|
setEditable(e) {
|
|
3464
|
-
const t = new
|
|
4185
|
+
const t = new Le(this._workbook.getUnitId());
|
|
3465
4186
|
return this._permissionService.getPermissionPoint(t.id) || this._permissionService.addPermissionPoint(t), this._permissionService.updatePermissionPoint(t.id, e), this;
|
|
3466
4187
|
}
|
|
3467
4188
|
/**
|
|
3468
4189
|
* Sets the selection region for active sheet.
|
|
3469
|
-
* @param range The range to set as the active selection.
|
|
4190
|
+
* @param {FRange} range The range to set as the active selection.
|
|
3470
4191
|
* @returns {FWorkbook} FWorkbook instance
|
|
3471
4192
|
*/
|
|
3472
4193
|
setActiveRange(e) {
|
|
3473
|
-
const t = this.getActiveSheet(), n = e.getRange().sheetId || t.getSheetId(),
|
|
3474
|
-
if (!
|
|
4194
|
+
const t = this.getActiveSheet(), n = e.getRange().sheetId || t.getSheetId(), s = n ? this._workbook.getSheetBySheetId(n) : this._workbook.getActiveSheet(!0);
|
|
4195
|
+
if (!s)
|
|
3475
4196
|
throw new Error("No active sheet found");
|
|
3476
|
-
|
|
3477
|
-
const
|
|
4197
|
+
s.getSheetId() !== t.getSheetId() && this.setActiveSheet(this._injector.createInstance(m, this, this._workbook, s));
|
|
4198
|
+
const i = {
|
|
3478
4199
|
unitId: this.getId(),
|
|
3479
4200
|
subUnitId: n,
|
|
3480
|
-
selections: [e].map((
|
|
4201
|
+
selections: [e].map((o) => ({ range: o.getRange(), primary: ee(o.getRange(), s), style: null }))
|
|
3481
4202
|
};
|
|
3482
|
-
return this._commandService.syncExecuteCommand(
|
|
4203
|
+
return this._commandService.syncExecuteCommand(He.id, i), this;
|
|
3483
4204
|
}
|
|
3484
4205
|
/**
|
|
3485
4206
|
* Returns the selected range in the active sheet, or null if there is no active range.
|
|
3486
|
-
* @returns
|
|
4207
|
+
* @returns {FRange | null} The active range
|
|
3487
4208
|
*/
|
|
3488
4209
|
// could sheet have no active range ?
|
|
3489
4210
|
getActiveRange() {
|
|
3490
|
-
const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((
|
|
3491
|
-
return n ? this._injector.createInstance(
|
|
4211
|
+
const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((s) => !!s.primary);
|
|
4212
|
+
return n ? this._injector.createInstance(S, this._workbook, e, n.range) : null;
|
|
3492
4213
|
}
|
|
3493
4214
|
/**
|
|
3494
4215
|
* Deletes the currently active sheet.
|
|
@@ -3517,17 +4238,16 @@ let I = class extends ne {
|
|
|
3517
4238
|
* ```
|
|
3518
4239
|
*/
|
|
3519
4240
|
duplicateSheet(e) {
|
|
3520
|
-
return this._commandService.syncExecuteCommand(
|
|
4241
|
+
return this._commandService.syncExecuteCommand(At.id, {
|
|
3521
4242
|
unitId: e.getWorkbook().getUnitId(),
|
|
3522
4243
|
subUnitId: e.getSheetId()
|
|
3523
|
-
}), this._injector.createInstance(
|
|
4244
|
+
}), this._injector.createInstance(m, this, this._workbook, this._workbook.getActiveSheet());
|
|
3524
4245
|
}
|
|
3525
4246
|
/**
|
|
3526
4247
|
* Duplicates the active sheet.
|
|
3527
4248
|
* @returns {FWorksheet} The duplicated worksheet
|
|
3528
4249
|
* @example
|
|
3529
4250
|
* ```ts
|
|
3530
|
-
* // The code below duplicates the active sheet
|
|
3531
4251
|
* const activeSpreadsheet = univerAPI.getActiveWorkbook();
|
|
3532
4252
|
* activeSpreadsheet.duplicateActiveSheet();
|
|
3533
4253
|
* ```
|
|
@@ -3538,7 +4258,7 @@ let I = class extends ne {
|
|
|
3538
4258
|
}
|
|
3539
4259
|
/**
|
|
3540
4260
|
* Get the number of sheets in the workbook.
|
|
3541
|
-
* @returns The number of sheets in the workbook
|
|
4261
|
+
* @returns {number} The number of sheets in the workbook
|
|
3542
4262
|
* @example
|
|
3543
4263
|
* ```ts
|
|
3544
4264
|
* // The code below gets the number of sheets in the workbook
|
|
@@ -3611,7 +4331,7 @@ let I = class extends ne {
|
|
|
3611
4331
|
*/
|
|
3612
4332
|
moveSheet(e, t) {
|
|
3613
4333
|
let n = t;
|
|
3614
|
-
return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.syncExecuteCommand(
|
|
4334
|
+
return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.syncExecuteCommand(he.id, {
|
|
3615
4335
|
unitId: e.getWorkbook().getUnitId(),
|
|
3616
4336
|
order: n,
|
|
3617
4337
|
subUnitId: e.getSheetId()
|
|
@@ -3637,7 +4357,7 @@ let I = class extends ne {
|
|
|
3637
4357
|
* @returns {FPermission} - The PermissionInstance.
|
|
3638
4358
|
*/
|
|
3639
4359
|
getPermission() {
|
|
3640
|
-
return this._injector.createInstance(
|
|
4360
|
+
return this._injector.createInstance(j);
|
|
3641
4361
|
}
|
|
3642
4362
|
/**
|
|
3643
4363
|
* Get the defined name by name.
|
|
@@ -3652,7 +4372,7 @@ let I = class extends ne {
|
|
|
3652
4372
|
*/
|
|
3653
4373
|
getDefinedName(e) {
|
|
3654
4374
|
const t = this._definedNamesService.getValueByName(this.id, e);
|
|
3655
|
-
return t ? this._injector.createInstance(
|
|
4375
|
+
return t ? this._injector.createInstance(F, { ...t, unitId: this.id }) : null;
|
|
3656
4376
|
}
|
|
3657
4377
|
/**
|
|
3658
4378
|
* Get all the defined names in the workbook.
|
|
@@ -3666,7 +4386,7 @@ let I = class extends ne {
|
|
|
3666
4386
|
*/
|
|
3667
4387
|
getDefinedNames() {
|
|
3668
4388
|
const e = this._definedNamesService.getDefinedNameMap(this.id);
|
|
3669
|
-
return e ? Object.values(e).map((t) => this._injector.createInstance(
|
|
4389
|
+
return e ? Object.values(e).map((t) => this._injector.createInstance(F, { ...t, unitId: this.id })) : [];
|
|
3670
4390
|
}
|
|
3671
4391
|
/**
|
|
3672
4392
|
* Insert a defined name.
|
|
@@ -3681,8 +4401,8 @@ let I = class extends ne {
|
|
|
3681
4401
|
* ```
|
|
3682
4402
|
*/
|
|
3683
4403
|
insertDefinedName(e, t) {
|
|
3684
|
-
const
|
|
3685
|
-
return
|
|
4404
|
+
const s = this._injector.createInstance(V).setName(e).setRef(t).build();
|
|
4405
|
+
return s.localSheetId = X, this.insertDefinedNameBuilder(s), this;
|
|
3686
4406
|
}
|
|
3687
4407
|
/**
|
|
3688
4408
|
* Delete the defined name with the given name.
|
|
@@ -3702,6 +4422,7 @@ let I = class extends ne {
|
|
|
3702
4422
|
/**
|
|
3703
4423
|
* Insert a defined name by builder param.
|
|
3704
4424
|
* @param {ISetDefinedNameMutationParam} param The param to insert the defined name
|
|
4425
|
+
* @returns {void}
|
|
3705
4426
|
* @example
|
|
3706
4427
|
* ```ts
|
|
3707
4428
|
* // The code below inserts a defined name by builder param
|
|
@@ -3717,6 +4438,7 @@ let I = class extends ne {
|
|
|
3717
4438
|
/**
|
|
3718
4439
|
* Update the defined name with the given name.
|
|
3719
4440
|
* @param {ISetDefinedNameMutationParam} param The param to insert the defined name
|
|
4441
|
+
* @returns {void}
|
|
3720
4442
|
* @example
|
|
3721
4443
|
* ```ts
|
|
3722
4444
|
* // The code below updates the defined name with the given name
|
|
@@ -3741,11 +4463,12 @@ let I = class extends ne {
|
|
|
3741
4463
|
* ```
|
|
3742
4464
|
*/
|
|
3743
4465
|
getRegisteredRangeThemes() {
|
|
3744
|
-
return this._injector.get(
|
|
4466
|
+
return this._injector.get(Ve).getRegisteredRangeThemes();
|
|
3745
4467
|
}
|
|
3746
4468
|
/**
|
|
3747
4469
|
* Register a custom range theme style.
|
|
3748
|
-
* @param rangeThemeStyle
|
|
4470
|
+
* @param {RangeThemeStyle} rangeThemeStyle The range theme style to register
|
|
4471
|
+
* @returns {void}
|
|
3749
4472
|
* @example
|
|
3750
4473
|
* ```ts
|
|
3751
4474
|
* // import {RangeThemeStyle} from '@univerjs/sheets';
|
|
@@ -3760,14 +4483,15 @@ let I = class extends ne {
|
|
|
3760
4483
|
* ```
|
|
3761
4484
|
*/
|
|
3762
4485
|
registerRangeTheme(e) {
|
|
3763
|
-
this._commandService.syncExecuteCommand(
|
|
4486
|
+
this._commandService.syncExecuteCommand(Bt.id, {
|
|
3764
4487
|
unitId: this.getId(),
|
|
3765
4488
|
rangeThemeStyle: e
|
|
3766
4489
|
});
|
|
3767
4490
|
}
|
|
3768
4491
|
/**
|
|
3769
4492
|
* Unregister a custom range theme style.
|
|
3770
|
-
* @param themeName
|
|
4493
|
+
* @param {string} themeName The name of the theme to unregister
|
|
4494
|
+
* @returns {void}
|
|
3771
4495
|
* @example
|
|
3772
4496
|
* ```ts
|
|
3773
4497
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -3775,7 +4499,7 @@ let I = class extends ne {
|
|
|
3775
4499
|
* ```
|
|
3776
4500
|
*/
|
|
3777
4501
|
unregisterRangeTheme(e) {
|
|
3778
|
-
this._commandService.syncExecuteCommand(
|
|
4502
|
+
this._commandService.syncExecuteCommand(Wt.id, {
|
|
3779
4503
|
unitId: this.getId(),
|
|
3780
4504
|
themeName: e
|
|
3781
4505
|
});
|
|
@@ -3806,42 +4530,42 @@ let I = class extends ne {
|
|
|
3806
4530
|
return this._workbook.getCustomMetadata();
|
|
3807
4531
|
}
|
|
3808
4532
|
};
|
|
3809
|
-
|
|
3810
|
-
C(1, u(
|
|
3811
|
-
C(2, u(
|
|
3812
|
-
C(3, u(
|
|
4533
|
+
f = _n([
|
|
4534
|
+
C(1, u(y)),
|
|
4535
|
+
C(2, u(Xe)),
|
|
4536
|
+
C(3, u(ze)),
|
|
3813
4537
|
C(4, J),
|
|
3814
4538
|
C(5, l),
|
|
3815
|
-
C(6,
|
|
3816
|
-
C(7,
|
|
3817
|
-
C(8, u(
|
|
3818
|
-
C(9,
|
|
3819
|
-
],
|
|
3820
|
-
class
|
|
4539
|
+
C(6, ae),
|
|
4540
|
+
C(7, De),
|
|
4541
|
+
C(8, u(Te)),
|
|
4542
|
+
C(9, $e)
|
|
4543
|
+
], f);
|
|
4544
|
+
class kn extends Be {
|
|
3821
4545
|
getCommandSheetTarget(e) {
|
|
3822
|
-
var
|
|
4546
|
+
var i;
|
|
3823
4547
|
const t = e.params;
|
|
3824
4548
|
if (!t) return;
|
|
3825
|
-
const n = t.unitId ? this.getUniverSheet(t.unitId) : (
|
|
4549
|
+
const n = t.unitId ? this.getUniverSheet(t.unitId) : (i = this.getActiveWorkbook) == null ? void 0 : i.call(this);
|
|
3826
4550
|
if (!n)
|
|
3827
4551
|
return;
|
|
3828
|
-
const
|
|
3829
|
-
if (
|
|
3830
|
-
return { workbook: n, worksheet:
|
|
4552
|
+
const s = n.getSheetBySheetId(t.subUnitId || t.sheetId) || n.getActiveSheet();
|
|
4553
|
+
if (s)
|
|
4554
|
+
return { workbook: n, worksheet: s };
|
|
3831
4555
|
}
|
|
3832
4556
|
getSheetTarget(e, t) {
|
|
3833
4557
|
const n = this.getUniverSheet(e);
|
|
3834
4558
|
if (!n)
|
|
3835
4559
|
return;
|
|
3836
|
-
const
|
|
3837
|
-
if (
|
|
3838
|
-
return { workbook: n, worksheet:
|
|
4560
|
+
const s = n.getSheetBySheetId(t);
|
|
4561
|
+
if (s)
|
|
4562
|
+
return { workbook: n, worksheet: s };
|
|
3839
4563
|
}
|
|
3840
4564
|
_initWorkbookEvent(e) {
|
|
3841
4565
|
const t = e.get(J);
|
|
3842
4566
|
this.disposeWithMe(
|
|
3843
4567
|
t.unitDisposed$.subscribe((n) => {
|
|
3844
|
-
this._eventRegistry.get(this.Event.WorkbookDisposed) && n.type ===
|
|
4568
|
+
this._eventRegistry.get(this.Event.WorkbookDisposed) && n.type === p.UNIVER_SHEET && this.fireEvent(
|
|
3845
4569
|
this.Event.WorkbookDisposed,
|
|
3846
4570
|
{
|
|
3847
4571
|
unitId: n.getUnitId(),
|
|
@@ -3852,59 +4576,142 @@ class hn extends Ue {
|
|
|
3852
4576
|
})
|
|
3853
4577
|
), this.disposeWithMe(
|
|
3854
4578
|
t.unitAdded$.subscribe((n) => {
|
|
3855
|
-
if (this._eventRegistry.get(this.Event.WorkbookCreated) && n.type ===
|
|
3856
|
-
const
|
|
4579
|
+
if (this._eventRegistry.get(this.Event.WorkbookCreated) && n.type === p.UNIVER_SHEET) {
|
|
4580
|
+
const s = n, i = e.createInstance(f, s);
|
|
3857
4581
|
this.fireEvent(
|
|
3858
4582
|
this.Event.WorkbookCreated,
|
|
3859
4583
|
{
|
|
3860
4584
|
unitId: n.getUnitId(),
|
|
3861
4585
|
type: n.type,
|
|
3862
|
-
workbook:
|
|
3863
|
-
unit:
|
|
4586
|
+
workbook: i,
|
|
4587
|
+
unit: i
|
|
3864
4588
|
}
|
|
3865
4589
|
);
|
|
3866
4590
|
}
|
|
3867
4591
|
})
|
|
3868
4592
|
);
|
|
3869
4593
|
}
|
|
4594
|
+
// eslint-disable-next-line max-lines-per-function
|
|
3870
4595
|
_initialize(e) {
|
|
3871
4596
|
const t = e.get(l);
|
|
3872
4597
|
this.disposeWithMe(
|
|
4598
|
+
// eslint-disable-next-line max-lines-per-function, complexity
|
|
3873
4599
|
t.beforeCommandExecuted((n) => {
|
|
3874
|
-
var
|
|
4600
|
+
var s, i, o, h;
|
|
3875
4601
|
switch (n.id) {
|
|
3876
|
-
case
|
|
3877
|
-
const
|
|
3878
|
-
if (!
|
|
4602
|
+
case T.id: {
|
|
4603
|
+
const a = n.params, { unitId: d, index: c, sheet: v } = a || {}, k = d ? this.getUniverSheet(d) : (s = this.getActiveWorkbook) == null ? void 0 : s.call(this);
|
|
4604
|
+
if (!k)
|
|
3879
4605
|
return;
|
|
3880
|
-
const
|
|
3881
|
-
workbook:
|
|
3882
|
-
index:
|
|
3883
|
-
sheet:
|
|
4606
|
+
const ge = {
|
|
4607
|
+
workbook: k,
|
|
4608
|
+
index: c,
|
|
4609
|
+
sheet: v
|
|
3884
4610
|
};
|
|
3885
4611
|
if (this.fireEvent(
|
|
3886
4612
|
this.Event.BeforeSheetCreate,
|
|
3887
|
-
|
|
3888
|
-
),
|
|
3889
|
-
throw new
|
|
4613
|
+
ge
|
|
4614
|
+
), ge.cancel)
|
|
4615
|
+
throw new nt();
|
|
4616
|
+
break;
|
|
4617
|
+
}
|
|
4618
|
+
case Ue.id: {
|
|
4619
|
+
if (!this._eventListend(this.Event.BeforeActiveSheetChange)) return;
|
|
4620
|
+
const { subUnitId: a, unitId: d } = n.params, c = d ? this.getUniverSheet(d) : (i = this.getActiveWorkbook) == null ? void 0 : i.call(this);
|
|
4621
|
+
if (!c || !a) return;
|
|
4622
|
+
const v = c.getSheetBySheetId(a), k = c.getActiveSheet();
|
|
4623
|
+
if (!v || !k) return;
|
|
4624
|
+
this._fireBeforeActiveSheetChange(c, v, k);
|
|
4625
|
+
break;
|
|
4626
|
+
}
|
|
4627
|
+
case oe.id: {
|
|
4628
|
+
if (!this._eventListend(this.Event.BeforeSheetDelete)) return;
|
|
4629
|
+
const a = this.getCommandSheetTarget(n);
|
|
4630
|
+
if (!a) return;
|
|
4631
|
+
const { workbook: d, worksheet: c } = a;
|
|
4632
|
+
this._fireBeforeSheetDelete(d, c);
|
|
4633
|
+
break;
|
|
4634
|
+
}
|
|
4635
|
+
case he.id: {
|
|
4636
|
+
if (!this._eventListend(this.Event.BeforeSheetMove)) return;
|
|
4637
|
+
const { fromOrder: a, toOrder: d } = n.params, c = this.getCommandSheetTarget(n);
|
|
4638
|
+
if (!c) return;
|
|
4639
|
+
this._fireBeforeSheetMove(c.workbook, c.worksheet, d, a);
|
|
4640
|
+
break;
|
|
4641
|
+
}
|
|
4642
|
+
case ie.id: {
|
|
4643
|
+
if (!this._eventListend(this.Event.BeforeSheetNameChange)) return;
|
|
4644
|
+
const { name: a } = n.params, d = this.getCommandSheetTarget(n);
|
|
4645
|
+
if (!d) return;
|
|
4646
|
+
this._fireBeforeSheetNameChange(d.workbook, d.worksheet, a, d.worksheet.getSheetName());
|
|
4647
|
+
break;
|
|
4648
|
+
}
|
|
4649
|
+
case re.id: {
|
|
4650
|
+
if (!this._eventListend(this.Event.BeforeSheetTabColorChange)) return;
|
|
4651
|
+
const { color: a } = n.params, d = this.getCommandSheetTarget(n);
|
|
4652
|
+
if (!d) return;
|
|
4653
|
+
this._fireBeforeSheetTabColorChange(d.workbook, d.worksheet, a, d.worksheet.getTabColor());
|
|
4654
|
+
break;
|
|
4655
|
+
}
|
|
4656
|
+
case se.id: {
|
|
4657
|
+
if (!this._eventListend(this.Event.BeforeSheetHideChange)) return;
|
|
4658
|
+
const { hidden: a } = n.params, d = this.getCommandSheetTarget(n);
|
|
4659
|
+
if (!d) return;
|
|
4660
|
+
this._fireBeforeSheetHideChange(d.workbook, d.worksheet, !!a);
|
|
4661
|
+
break;
|
|
4662
|
+
}
|
|
4663
|
+
case ne.id: {
|
|
4664
|
+
if (!this._eventListend(this.Event.BeforeGridlineColorChange)) return;
|
|
4665
|
+
const a = this.getCommandSheetTarget(n);
|
|
4666
|
+
if (!a) return;
|
|
4667
|
+
this.fireEvent(this.Event.BeforeGridlineColorChange, {
|
|
4668
|
+
...a,
|
|
4669
|
+
color: (o = n.params) == null ? void 0 : o.color
|
|
4670
|
+
});
|
|
4671
|
+
break;
|
|
4672
|
+
}
|
|
4673
|
+
case te.id: {
|
|
4674
|
+
if (!this._eventListend(this.Event.BeforeGridlineEnableChange)) return;
|
|
4675
|
+
const a = this.getCommandSheetTarget(n);
|
|
4676
|
+
if (!a) return;
|
|
4677
|
+
this.fireEvent(this.Event.BeforeGridlineEnableChange, {
|
|
4678
|
+
...a,
|
|
4679
|
+
enabled: !!((h = n.params) != null && h.showGridlines)
|
|
4680
|
+
});
|
|
3890
4681
|
break;
|
|
3891
4682
|
}
|
|
3892
4683
|
}
|
|
3893
4684
|
})
|
|
3894
4685
|
), this.disposeWithMe(
|
|
4686
|
+
// eslint-disable-next-line max-lines-per-function, complexity
|
|
3895
4687
|
t.onCommandExecuted((n) => {
|
|
3896
|
-
var
|
|
4688
|
+
var s, i;
|
|
4689
|
+
if (Ft.indexOf(n.id) > -1) {
|
|
4690
|
+
if (!this._eventListend(this.Event.SheetValueChanged) || !this.getActiveSheet()) return;
|
|
4691
|
+
const h = jt(n).map(
|
|
4692
|
+
(a) => {
|
|
4693
|
+
var d, c;
|
|
4694
|
+
return (c = (d = this.getWorkbook(a.unitId)) == null ? void 0 : d.getSheetBySheetId(a.subUnitId)) == null ? void 0 : c.getRange(a.range);
|
|
4695
|
+
}
|
|
4696
|
+
).filter(Boolean);
|
|
4697
|
+
if (!h.length) return;
|
|
4698
|
+
this.fireEvent(this.Event.SheetValueChanged, {
|
|
4699
|
+
payload: n,
|
|
4700
|
+
effectedRanges: h
|
|
4701
|
+
});
|
|
4702
|
+
return;
|
|
4703
|
+
}
|
|
3897
4704
|
switch (n.id) {
|
|
3898
|
-
case
|
|
3899
|
-
const o = n.params, { unitId:
|
|
4705
|
+
case T.id: {
|
|
4706
|
+
const o = n.params, { unitId: h } = o || {}, a = h ? this.getUniverSheet(h) : (s = this.getActiveWorkbook) == null ? void 0 : s.call(this);
|
|
3900
4707
|
if (!a)
|
|
3901
4708
|
return;
|
|
3902
|
-
const
|
|
3903
|
-
if (!
|
|
4709
|
+
const d = a.getActiveSheet();
|
|
4710
|
+
if (!d)
|
|
3904
4711
|
return;
|
|
3905
4712
|
const c = {
|
|
3906
4713
|
workbook: a,
|
|
3907
|
-
worksheet:
|
|
4714
|
+
worksheet: d
|
|
3908
4715
|
};
|
|
3909
4716
|
this.fireEvent(
|
|
3910
4717
|
this.Event.SheetCreated,
|
|
@@ -3912,47 +4719,202 @@ class hn extends Ue {
|
|
|
3912
4719
|
);
|
|
3913
4720
|
break;
|
|
3914
4721
|
}
|
|
4722
|
+
case Ue.id: {
|
|
4723
|
+
if (!this._eventListend(this.Event.ActiveSheetChanged)) return;
|
|
4724
|
+
const o = this.getActiveSheet();
|
|
4725
|
+
if (!o) return;
|
|
4726
|
+
const { workbook: h, worksheet: a } = o;
|
|
4727
|
+
this._fireActiveSheetChanged(h, a);
|
|
4728
|
+
break;
|
|
4729
|
+
}
|
|
4730
|
+
case oe.id: {
|
|
4731
|
+
if (!this._eventListend(this.Event.SheetDeleted)) return;
|
|
4732
|
+
const { subUnitId: o, unitId: h } = n.params, a = h ? this.getUniverSheet(h) : (i = this.getActiveWorkbook) == null ? void 0 : i.call(this);
|
|
4733
|
+
if (!a || !o) return;
|
|
4734
|
+
this._fireSheetDeleted(a, o);
|
|
4735
|
+
break;
|
|
4736
|
+
}
|
|
4737
|
+
case he.id: {
|
|
4738
|
+
if (!this._eventListend(this.Event.SheetMoved)) return;
|
|
4739
|
+
const { toOrder: o } = n.params, h = this.getCommandSheetTarget(n);
|
|
4740
|
+
if (!h) return;
|
|
4741
|
+
this._fireSheetMoved(h.workbook, h.worksheet, o);
|
|
4742
|
+
break;
|
|
4743
|
+
}
|
|
4744
|
+
case ie.id: {
|
|
4745
|
+
if (!this._eventListend(this.Event.SheetNameChanged)) return;
|
|
4746
|
+
const { name: o } = n.params, h = this.getCommandSheetTarget(n);
|
|
4747
|
+
if (!h) return;
|
|
4748
|
+
this._fireSheetNameChanged(h.workbook, h.worksheet, o);
|
|
4749
|
+
break;
|
|
4750
|
+
}
|
|
4751
|
+
case re.id: {
|
|
4752
|
+
if (!this._eventListend(this.Event.SheetTabColorChanged)) return;
|
|
4753
|
+
const { color: o } = n.params, h = this.getCommandSheetTarget(n);
|
|
4754
|
+
if (!h) return;
|
|
4755
|
+
this._fireSheetTabColorChanged(h.workbook, h.worksheet, o);
|
|
4756
|
+
break;
|
|
4757
|
+
}
|
|
4758
|
+
case se.id: {
|
|
4759
|
+
if (!this._eventListend(this.Event.SheetHideChanged)) return;
|
|
4760
|
+
const { hidden: o } = n.params, h = this.getCommandSheetTarget(n);
|
|
4761
|
+
if (!h) return;
|
|
4762
|
+
this._fireSheetHideChanged(h.workbook, h.worksheet, !!o);
|
|
4763
|
+
break;
|
|
4764
|
+
}
|
|
4765
|
+
case ne.id:
|
|
4766
|
+
case te.id: {
|
|
4767
|
+
if (!this._eventListend(this.Event.GridlineChanged)) return;
|
|
4768
|
+
const o = this.getCommandSheetTarget(n);
|
|
4769
|
+
if (!o) return;
|
|
4770
|
+
this.fireEvent(this.Event.GridlineChanged, {
|
|
4771
|
+
...o,
|
|
4772
|
+
enabled: !o.worksheet.hasHiddenGridLines(),
|
|
4773
|
+
color: o.worksheet.getGridLinesColor()
|
|
4774
|
+
});
|
|
4775
|
+
break;
|
|
4776
|
+
}
|
|
3915
4777
|
}
|
|
3916
4778
|
})
|
|
3917
4779
|
), this._initWorkbookEvent(e);
|
|
3918
4780
|
}
|
|
3919
4781
|
createUniverSheet(e) {
|
|
3920
|
-
const n = this._injector.get(J).createUnit(
|
|
3921
|
-
return this._injector.createInstance(
|
|
4782
|
+
const n = this._injector.get(J).createUnit(p.UNIVER_SHEET, e);
|
|
4783
|
+
return this._injector.createInstance(f, n);
|
|
3922
4784
|
}
|
|
3923
4785
|
createWorkbook(e) {
|
|
3924
4786
|
return this.createUniverSheet(e);
|
|
3925
4787
|
}
|
|
3926
4788
|
getActiveWorkbook() {
|
|
3927
|
-
const e = this._univerInstanceService.getCurrentUnitForType(
|
|
3928
|
-
return e ? this._injector.createInstance(
|
|
4789
|
+
const e = this._univerInstanceService.getCurrentUnitForType(p.UNIVER_SHEET);
|
|
4790
|
+
return e ? this._injector.createInstance(f, e) : null;
|
|
3929
4791
|
}
|
|
3930
4792
|
getActiveUniverSheet() {
|
|
3931
4793
|
return this.getActiveWorkbook();
|
|
3932
4794
|
}
|
|
3933
4795
|
getUniverSheet(e) {
|
|
3934
|
-
const t = this._univerInstanceService.getUnit(e,
|
|
3935
|
-
return t ? this._injector.createInstance(
|
|
4796
|
+
const t = this._univerInstanceService.getUnit(e, p.UNIVER_SHEET);
|
|
4797
|
+
return t ? this._injector.createInstance(f, t) : null;
|
|
3936
4798
|
}
|
|
3937
4799
|
getWorkbook(e) {
|
|
3938
4800
|
return this.getUniverSheet(e);
|
|
3939
4801
|
}
|
|
3940
4802
|
getPermission() {
|
|
3941
|
-
return this._injector.createInstance(
|
|
4803
|
+
return this._injector.createInstance(j);
|
|
3942
4804
|
}
|
|
3943
4805
|
onUniverSheetCreated(e) {
|
|
3944
|
-
const t = this._univerInstanceService.getTypeOfUnitAdded$(
|
|
3945
|
-
const
|
|
3946
|
-
e(
|
|
4806
|
+
const t = this._univerInstanceService.getTypeOfUnitAdded$(p.UNIVER_SHEET).subscribe((n) => {
|
|
4807
|
+
const s = this._injector.createInstance(f, n);
|
|
4808
|
+
e(s);
|
|
3947
4809
|
});
|
|
3948
|
-
return
|
|
4810
|
+
return Ae(t);
|
|
3949
4811
|
}
|
|
3950
4812
|
newDefinedName() {
|
|
3951
|
-
return this._injector.createInstance(
|
|
4813
|
+
return this._injector.createInstance(V);
|
|
4814
|
+
}
|
|
4815
|
+
getActiveSheet() {
|
|
4816
|
+
const e = this.getActiveWorkbook();
|
|
4817
|
+
if (!e)
|
|
4818
|
+
return null;
|
|
4819
|
+
const t = e.getActiveSheet();
|
|
4820
|
+
return t ? { workbook: e, worksheet: t } : null;
|
|
4821
|
+
}
|
|
4822
|
+
_fireBeforeActiveSheetChange(e, t, n) {
|
|
4823
|
+
this.fireEvent(this.Event.BeforeActiveSheetChange, {
|
|
4824
|
+
workbook: e,
|
|
4825
|
+
activeSheet: t,
|
|
4826
|
+
oldActiveSheet: n
|
|
4827
|
+
});
|
|
4828
|
+
}
|
|
4829
|
+
_fireActiveSheetChanged(e, t) {
|
|
4830
|
+
this.fireEvent(this.Event.ActiveSheetChanged, {
|
|
4831
|
+
workbook: e,
|
|
4832
|
+
activeSheet: t
|
|
4833
|
+
});
|
|
4834
|
+
}
|
|
4835
|
+
_fireBeforeSheetDelete(e, t) {
|
|
4836
|
+
this.fireEvent(this.Event.BeforeSheetDelete, {
|
|
4837
|
+
workbook: e,
|
|
4838
|
+
worksheet: t
|
|
4839
|
+
});
|
|
4840
|
+
}
|
|
4841
|
+
_fireSheetDeleted(e, t) {
|
|
4842
|
+
this.fireEvent(this.Event.SheetDeleted, {
|
|
4843
|
+
workbook: e,
|
|
4844
|
+
sheetId: t
|
|
4845
|
+
});
|
|
4846
|
+
}
|
|
4847
|
+
_fireBeforeSheetMove(e, t, n, s) {
|
|
4848
|
+
this.fireEvent(this.Event.BeforeSheetMove, {
|
|
4849
|
+
workbook: e,
|
|
4850
|
+
worksheet: t,
|
|
4851
|
+
newIndex: n,
|
|
4852
|
+
oldIndex: s
|
|
4853
|
+
});
|
|
4854
|
+
}
|
|
4855
|
+
_fireSheetMoved(e, t, n) {
|
|
4856
|
+
this.fireEvent(this.Event.SheetMoved, {
|
|
4857
|
+
workbook: e,
|
|
4858
|
+
worksheet: t,
|
|
4859
|
+
newIndex: n
|
|
4860
|
+
});
|
|
4861
|
+
}
|
|
4862
|
+
_fireBeforeSheetNameChange(e, t, n, s) {
|
|
4863
|
+
this.fireEvent(this.Event.BeforeSheetNameChange, {
|
|
4864
|
+
workbook: e,
|
|
4865
|
+
worksheet: t,
|
|
4866
|
+
newName: n,
|
|
4867
|
+
oldName: s
|
|
4868
|
+
});
|
|
4869
|
+
}
|
|
4870
|
+
_fireSheetNameChanged(e, t, n) {
|
|
4871
|
+
this.fireEvent(this.Event.SheetNameChanged, {
|
|
4872
|
+
workbook: e,
|
|
4873
|
+
worksheet: t,
|
|
4874
|
+
newName: n
|
|
4875
|
+
});
|
|
4876
|
+
}
|
|
4877
|
+
_fireBeforeSheetTabColorChange(e, t, n, s) {
|
|
4878
|
+
this.fireEvent(this.Event.BeforeSheetTabColorChange, {
|
|
4879
|
+
workbook: e,
|
|
4880
|
+
worksheet: t,
|
|
4881
|
+
newColor: n,
|
|
4882
|
+
oldColor: s
|
|
4883
|
+
});
|
|
4884
|
+
}
|
|
4885
|
+
_fireSheetTabColorChanged(e, t, n) {
|
|
4886
|
+
this.fireEvent(this.Event.SheetTabColorChanged, {
|
|
4887
|
+
workbook: e,
|
|
4888
|
+
worksheet: t,
|
|
4889
|
+
newColor: n
|
|
4890
|
+
});
|
|
4891
|
+
}
|
|
4892
|
+
_fireBeforeSheetHideChange(e, t, n) {
|
|
4893
|
+
this.fireEvent(this.Event.BeforeSheetHideChange, {
|
|
4894
|
+
workbook: e,
|
|
4895
|
+
worksheet: t,
|
|
4896
|
+
hidden: n
|
|
4897
|
+
});
|
|
4898
|
+
}
|
|
4899
|
+
_fireSheetHideChanged(e, t, n) {
|
|
4900
|
+
this.fireEvent(this.Event.SheetHideChanged, {
|
|
4901
|
+
workbook: e,
|
|
4902
|
+
worksheet: t,
|
|
4903
|
+
hidden: n
|
|
4904
|
+
});
|
|
4905
|
+
}
|
|
4906
|
+
}
|
|
4907
|
+
Be.extend(kn);
|
|
4908
|
+
class Sn {
|
|
4909
|
+
get SheetValueChangeType() {
|
|
4910
|
+
return Ot;
|
|
4911
|
+
}
|
|
4912
|
+
get SheetSkeletonChangeType() {
|
|
4913
|
+
return Lt;
|
|
3952
4914
|
}
|
|
3953
4915
|
}
|
|
3954
|
-
|
|
3955
|
-
class
|
|
4916
|
+
rt.extend(Sn);
|
|
4917
|
+
class wn extends We {
|
|
3956
4918
|
get SheetCreated() {
|
|
3957
4919
|
return "SheetCreated";
|
|
3958
4920
|
}
|
|
@@ -3965,27 +4927,76 @@ class cn extends se {
|
|
|
3965
4927
|
get WorkbookDisposed() {
|
|
3966
4928
|
return "WorkbookDisposed";
|
|
3967
4929
|
}
|
|
4930
|
+
get GridlineChanged() {
|
|
4931
|
+
return "GridlineChanged";
|
|
4932
|
+
}
|
|
4933
|
+
get BeforeGridlineEnableChange() {
|
|
4934
|
+
return "BeforeGridlineEnableChange";
|
|
4935
|
+
}
|
|
4936
|
+
get BeforeGridlineColorChange() {
|
|
4937
|
+
return "BeforeGridlineColorChange";
|
|
4938
|
+
}
|
|
4939
|
+
get BeforeActiveSheetChange() {
|
|
4940
|
+
return "BeforeActiveSheetChange";
|
|
4941
|
+
}
|
|
4942
|
+
get ActiveSheetChanged() {
|
|
4943
|
+
return "ActiveSheetChanged";
|
|
4944
|
+
}
|
|
4945
|
+
get SheetDeleted() {
|
|
4946
|
+
return "SheetDeleted";
|
|
4947
|
+
}
|
|
4948
|
+
get BeforeSheetDelete() {
|
|
4949
|
+
return "BeforeSheetDelete";
|
|
4950
|
+
}
|
|
4951
|
+
get SheetMoved() {
|
|
4952
|
+
return "SheetMoved";
|
|
4953
|
+
}
|
|
4954
|
+
get BeforeSheetMove() {
|
|
4955
|
+
return "BeforeSheetMove";
|
|
4956
|
+
}
|
|
4957
|
+
get SheetNameChanged() {
|
|
4958
|
+
return "SheetNameChanged";
|
|
4959
|
+
}
|
|
4960
|
+
get BeforeSheetNameChange() {
|
|
4961
|
+
return "BeforeSheetNameChange";
|
|
4962
|
+
}
|
|
4963
|
+
get SheetTabColorChanged() {
|
|
4964
|
+
return "SheetTabColorChanged";
|
|
4965
|
+
}
|
|
4966
|
+
get BeforeSheetTabColorChange() {
|
|
4967
|
+
return "BeforeSheetTabColorChange";
|
|
4968
|
+
}
|
|
4969
|
+
get SheetHideChanged() {
|
|
4970
|
+
return "SheetHideChanged";
|
|
4971
|
+
}
|
|
4972
|
+
get BeforeSheetHideChange() {
|
|
4973
|
+
return "BeforeSheetHideChange";
|
|
4974
|
+
}
|
|
4975
|
+
get SheetValueChanged() {
|
|
4976
|
+
return "SheetValueChanged";
|
|
4977
|
+
}
|
|
3968
4978
|
}
|
|
3969
|
-
|
|
3970
|
-
var
|
|
3971
|
-
for (var
|
|
3972
|
-
(
|
|
3973
|
-
return n &&
|
|
3974
|
-
},
|
|
3975
|
-
let
|
|
3976
|
-
constructor(
|
|
3977
|
-
super(), this._injector =
|
|
4979
|
+
We.extend(wn);
|
|
4980
|
+
var Cn = Object.defineProperty, fn = Object.getOwnPropertyDescriptor, vn = (r, e, t, n) => {
|
|
4981
|
+
for (var s = n > 1 ? void 0 : n ? fn(e, t) : e, i = r.length - 1, o; i >= 0; i--)
|
|
4982
|
+
(o = r[i]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
4983
|
+
return n && s && Cn(e, t, s), s;
|
|
4984
|
+
}, In = (r, e) => (t, n) => e(t, n, r);
|
|
4985
|
+
let xe = class extends de {
|
|
4986
|
+
constructor(r) {
|
|
4987
|
+
super(), this._injector = r;
|
|
3978
4988
|
}
|
|
3979
4989
|
};
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
],
|
|
4990
|
+
xe = vn([
|
|
4991
|
+
In(0, u(y))
|
|
4992
|
+
], xe);
|
|
3983
4993
|
export {
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
4994
|
+
j as FPermission,
|
|
4995
|
+
S as FRange,
|
|
4996
|
+
L as FSelection,
|
|
4997
|
+
wn as FSheetEventName,
|
|
4998
|
+
xe as FSheetHooks,
|
|
4999
|
+
Sn as FSheetsEnum,
|
|
5000
|
+
f as FWorkbook,
|
|
5001
|
+
m as FWorksheet
|
|
3991
5002
|
};
|