@univerjs/sheets 0.6.1 → 0.6.2-nightly.202503031606
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 +1504 -706
- package/lib/es/index.js +3410 -3178
- package/lib/types/basics/interfaces/selection-config.d.ts +4 -0
- package/lib/types/basics/utils.d.ts +4 -1
- package/lib/types/commands/commands/append-row.command.d.ts +17 -0
- package/lib/types/commands/commands/insert-row-col.command.d.ts +10 -0
- package/lib/types/commands/commands/set-style.command.d.ts +1 -1
- package/lib/types/commands/commands/utils/selection-utils.d.ts +2 -2
- package/lib/types/commands/operations/selection.operation.d.ts +10 -1
- package/lib/types/facade/f-range.d.ts +547 -15
- package/lib/types/facade/f-workbook.d.ts +10 -0
- package/lib/types/facade/f-worksheet.d.ts +84 -7
- package/lib/types/facade/utils.d.ts +36 -27
- package/lib/types/index.d.ts +4 -3
- package/lib/types/services/ref-range/util.d.ts +11 -2
- 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 +9 -9
- package/LICENSE +0 -176
package/lib/es/facade.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Inject as u, Injector as
|
|
5
|
-
import { FBase as
|
|
6
|
-
import { WorksheetProtectionRuleModel as
|
|
7
|
-
import { IDefinedNamesService as
|
|
8
|
-
var
|
|
9
|
-
for (var
|
|
10
|
-
(i =
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
function
|
|
14
|
-
const n = t.getDefinedNameMap(
|
|
1
|
+
var Ze = Object.defineProperty;
|
|
2
|
+
var et = (r, e, t) => e in r ? Ze(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var E = (r, e, t) => et(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Inject as u, Injector as x, ICommandService as l, IPermissionService as ue, IAuthzIoService as Be, LocaleService as Ve, generateRandomId as Fe, Rectangle as N, RANGE_TYPE as w, isFormulaString as tt, isCellV as nt, isICellData as rt, HorizontalAlign as T, VerticalAlign as A, ObjectMatrix as V, Tools as st, TextStyleValue as we, RichTextValue as P, BooleanNumber as g, WrapStrategy as G, DEFAULT_STYLES as ke, Dimension as M, isNullCell as D, ILogService as He, Direction as j, IResourceLoaderService as ot, IUniverInstanceService as re, mergeWorksheetSnapshotWithDefault as it, UndoCommand as at, RedoCommand as ht, toDisposable as Oe, UniverInstanceType as U, CanceledError as v } from "@univerjs/core";
|
|
5
|
+
import { FBase as ge, FBaseInitialable as le, FUniver as je, FEnum as dt, FEventName as ct } from "@univerjs/core/facade";
|
|
6
|
+
import { WorksheetProtectionRuleModel as Le, RangeProtectionRuleModel as ze, WorksheetProtectionPointModel as Ge, SetDefinedNameCommand as se, SCOPE_WORKBOOK_VALUE_DEFINED_NAME as oe, RemoveDefinedNameCommand as ut, PermissionPointsDefinitions as gt, WorkbookEditablePermission as $e, UnitObject as W, AddWorksheetProtectionMutation as lt, DeleteWorksheetProtectionMutation as mt, getAllWorksheetPermissionPoint as _t, getAllWorksheetPermissionPointByPointPanel as Se, SetWorksheetPermissionPointsMutation as wt, AddRangeProtectionMutation as kt, DeleteRangeProtectionMutation as St, SetRangeProtectionMutation as Ct, WorksheetEditPermission as ft, WorksheetViewPermission as vt, SetBorderBasicCommand as It, SetStyleCommand as b, SetTextRotationCommand as Rt, SetRangeValuesCommand as B, SetTextWrapCommand as ie, SetVerticalTextAlignCommand as bt, SetHorizontalTextAlignCommand as pt, addMergeCellsUtil as Q, getAddMergeMutationRangeByType as Ce, RemoveWorksheetMergeCommand as Et, getPrimaryForRange as $, SetSelectionsOperation as me, SplitTextToColumnsCommand as yt, SetWorksheetRangeThemeStyleCommand as Ut, DeleteWorksheetRangeThemeStyleCommand as xt, SheetRangeThemeService as qe, ClearSelectionAllCommand as Ke, ClearSelectionContentCommand as Ye, ClearSelectionFormatCommand as Je, InsertRangeMoveDownCommand as Pt, InsertRangeMoveRightCommand as Mt, DeleteRangeMoveUpCommand as Nt, DeleteRangeMoveLeftCommand as Tt, getNextPrimaryCell as At, SheetsSelectionsService as Qe, SetWorksheetDefaultStyleMutation as Dt, SetColDataCommand as fe, SetRowDataCommand as ve, copyRangeStyles as L, InsertRowByRangeCommand as Ie, RemoveRowByRangeCommand as Wt, MoveRowsCommand as Bt, SetRowHiddenCommand as Re, SetSpecificRowsVisibleCommand as be, SetWorksheetRowIsAutoHeightMutation as Vt, SetRowHeightCommand as pe, SetWorksheetRowIsAutoHeightCommand as X, InsertColByRangeCommand as Ee, RemoveColByRangeCommand as Ft, MoveColsCommand as Ht, SetColHiddenCommand as ye, SetSpecificColsVisibleCommand as Ue, SetColWidthCommand as Ot, SetFrozenCommand as Z, CancelFrozenCommand as jt, ToggleGridlinesCommand as ae, SetGridlinesColorCommand as he, SetTabColorCommand as Lt, SetRangeValuesMutation as xe, SetWorksheetHideCommand as zt, SetWorksheetShowCommand as Gt, SetWorksheetNameCommand as de, AppendRowCommand as $t, InsertSheetCommand as F, SetWorksheetActiveOperation as H, RemoveSheetCommand as ce, CopySheetCommand as qt, SetWorksheetOrderCommand as Kt, RegisterWorksheetRangeThemeStyleCommand as Yt, UnregisterWorksheetRangeThemeStyleCommand as Jt, RangeThemeStyle as Qt, SetWorksheetOrderMutation as Pe, SetTabColorMutation as Me, SetWorksheetHideMutation as Ne, COMMAND_LISTENER_VALUE_CHANGE as Xt, getValueChangedEffectedRange as Zt, SheetValueChangeType as en, SheetSkeletonChangeType as tn, SplitDelimiterEnum as nn } from "@univerjs/sheets";
|
|
7
|
+
import { IDefinedNamesService as Xe, serializeRange as _e, FormulaDataModel as rn, serializeRangeWithSheet as sn, deserializeRangeWithSheet as on } from "@univerjs/engine-formula";
|
|
8
|
+
var an = Object.getOwnPropertyDescriptor, hn = (r, e, t, n) => {
|
|
9
|
+
for (var s = n > 1 ? void 0 : n ? an(e, t) : e, o = r.length - 1, i; o >= 0; o--)
|
|
10
|
+
(i = r[o]) && (s = i(s) || s);
|
|
11
|
+
return s;
|
|
12
|
+
}, I = (r, e) => (t, n) => e(t, n, r);
|
|
13
|
+
function dn(r, e, t) {
|
|
14
|
+
const n = t.getDefinedNameMap(r);
|
|
15
15
|
if (n == null)
|
|
16
16
|
return e.t("definedName.defaultName") + 1;
|
|
17
17
|
const o = Array.from(Object.values(n)).length + 1, i = e.t("definedName.defaultName") + o;
|
|
18
|
-
if (t.getValueByName(
|
|
18
|
+
if (t.getValueByName(r, i) == null)
|
|
19
19
|
return i;
|
|
20
20
|
let a = o + 1;
|
|
21
21
|
for (; ; ) {
|
|
22
22
|
const h = e.t("definedName.defaultName") + a;
|
|
23
|
-
if (t.getValueByName(
|
|
23
|
+
if (t.getValueByName(r, h) == null)
|
|
24
24
|
return h;
|
|
25
25
|
a++;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
class
|
|
28
|
+
class J {
|
|
29
29
|
constructor() {
|
|
30
|
-
|
|
30
|
+
E(this, "_definedNameParam");
|
|
31
31
|
this._definedNameParam = {
|
|
32
|
-
id:
|
|
32
|
+
id: Fe(10),
|
|
33
33
|
unitId: "",
|
|
34
34
|
name: "",
|
|
35
35
|
formulaOrRefString: ""
|
|
@@ -100,12 +100,12 @@ class L {
|
|
|
100
100
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
101
101
|
* ```
|
|
102
102
|
*/
|
|
103
|
-
setRefByRange(e, t, n,
|
|
104
|
-
return this._definedNameParam.formulaOrRefString =
|
|
103
|
+
setRefByRange(e, t, n, s) {
|
|
104
|
+
return this._definedNameParam.formulaOrRefString = _e({
|
|
105
105
|
startRow: e,
|
|
106
106
|
endRow: e + (n != null ? n : 1) - 1,
|
|
107
107
|
startColumn: t,
|
|
108
|
-
endColumn: t + (
|
|
108
|
+
endColumn: t + (s != null ? s : 1) - 1
|
|
109
109
|
}), this;
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
@@ -180,12 +180,12 @@ class L {
|
|
|
180
180
|
return this._definedNameParam = e, this;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
let
|
|
184
|
-
constructor(
|
|
185
|
-
super(), this._definedNameParam =
|
|
183
|
+
let q = class extends ge {
|
|
184
|
+
constructor(r, e, t, n, s, o, i, a, h, d) {
|
|
185
|
+
super(), this._definedNameParam = r, this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = s, this._rangeProtectionRuleModel = o, this._worksheetProtectionPointRuleModel = i, this._authzIoService = a, this._localeService = h, this._definedNamesService = d;
|
|
186
186
|
}
|
|
187
187
|
_apply() {
|
|
188
|
-
this._definedNameParam.name === "" && (this._definedNameParam.name =
|
|
188
|
+
this._definedNameParam.name === "" && (this._definedNameParam.name = dn(this._definedNameParam.unitId, this._localeService, this._definedNamesService)), this._commandService.syncExecuteCommand(se.id, this._definedNameParam);
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
191
|
* Gets the name of the defined name.
|
|
@@ -210,8 +210,8 @@ let H = class extends ae {
|
|
|
210
210
|
* definedName?.setName('NewDefinedName');
|
|
211
211
|
* ```
|
|
212
212
|
*/
|
|
213
|
-
setName(
|
|
214
|
-
this._definedNameParam.name =
|
|
213
|
+
setName(r) {
|
|
214
|
+
this._definedNameParam.name = r, this._apply();
|
|
215
215
|
}
|
|
216
216
|
/**
|
|
217
217
|
* Sets the formula of the defined name.
|
|
@@ -223,8 +223,8 @@ let H = class extends ae {
|
|
|
223
223
|
* definedName?.setFormula('SUM(Sheet1!$A$1)');
|
|
224
224
|
* ```
|
|
225
225
|
*/
|
|
226
|
-
setFormula(
|
|
227
|
-
this._definedNameParam.formulaOrRefString = `=${
|
|
226
|
+
setFormula(r) {
|
|
227
|
+
this._definedNameParam.formulaOrRefString = `=${r}`, this._apply();
|
|
228
228
|
}
|
|
229
229
|
/**
|
|
230
230
|
* Sets the reference of the defined name.
|
|
@@ -236,8 +236,8 @@ let H = class extends ae {
|
|
|
236
236
|
* definedName?.setRef('Sheet1!$A$1');
|
|
237
237
|
* ```
|
|
238
238
|
*/
|
|
239
|
-
setRef(
|
|
240
|
-
this._definedNameParam.formulaOrRefString =
|
|
239
|
+
setRef(r) {
|
|
240
|
+
this._definedNameParam.formulaOrRefString = r, this._apply();
|
|
241
241
|
}
|
|
242
242
|
/**
|
|
243
243
|
* Gets the formula or reference string of the defined name.
|
|
@@ -265,10 +265,10 @@ let H = class extends ae {
|
|
|
265
265
|
* definedName?.setRefByRange(1, 3, 2, 5);
|
|
266
266
|
* ```
|
|
267
267
|
*/
|
|
268
|
-
setRefByRange(
|
|
269
|
-
this._definedNameParam.formulaOrRefString =
|
|
270
|
-
startRow:
|
|
271
|
-
endRow:
|
|
268
|
+
setRefByRange(r, e, t, n) {
|
|
269
|
+
this._definedNameParam.formulaOrRefString = _e({
|
|
270
|
+
startRow: r,
|
|
271
|
+
endRow: r + (t != null ? t : 1) - 1,
|
|
272
272
|
startColumn: e,
|
|
273
273
|
endColumn: e + (n != null ? n : 1) - 1
|
|
274
274
|
}), this._apply();
|
|
@@ -296,8 +296,8 @@ let H = class extends ae {
|
|
|
296
296
|
* definedName?.setComment('This is a comment');
|
|
297
297
|
* ```
|
|
298
298
|
*/
|
|
299
|
-
setComment(
|
|
300
|
-
this._definedNameParam.comment =
|
|
299
|
+
setComment(r) {
|
|
300
|
+
this._definedNameParam.comment = r, this._apply();
|
|
301
301
|
}
|
|
302
302
|
/**
|
|
303
303
|
* Sets the scope of the defined name to the worksheet.
|
|
@@ -310,8 +310,8 @@ let H = class extends ae {
|
|
|
310
310
|
* definedName?.setScopeToWorksheet(worksheet);
|
|
311
311
|
* ```
|
|
312
312
|
*/
|
|
313
|
-
setScopeToWorksheet(
|
|
314
|
-
this._definedNameParam.localSheetId =
|
|
313
|
+
setScopeToWorksheet(r) {
|
|
314
|
+
this._definedNameParam.localSheetId = r.getSheetId(), this._apply();
|
|
315
315
|
}
|
|
316
316
|
/**
|
|
317
317
|
* Sets the scope of the defined name to the workbook.
|
|
@@ -323,7 +323,7 @@ let H = class extends ae {
|
|
|
323
323
|
* ```
|
|
324
324
|
*/
|
|
325
325
|
setScopeToWorkbook() {
|
|
326
|
-
this._definedNameParam.localSheetId =
|
|
326
|
+
this._definedNameParam.localSheetId = oe, this._apply();
|
|
327
327
|
}
|
|
328
328
|
/**
|
|
329
329
|
* Sets the hidden status of the defined name.
|
|
@@ -335,8 +335,8 @@ let H = class extends ae {
|
|
|
335
335
|
* definedName?.setHidden(true);
|
|
336
336
|
* ```
|
|
337
337
|
*/
|
|
338
|
-
setHidden(
|
|
339
|
-
this._definedNameParam.hidden =
|
|
338
|
+
setHidden(r) {
|
|
339
|
+
this._definedNameParam.hidden = r, this._apply();
|
|
340
340
|
}
|
|
341
341
|
/**
|
|
342
342
|
* Deletes the defined name.
|
|
@@ -348,7 +348,7 @@ let H = class extends ae {
|
|
|
348
348
|
* ```
|
|
349
349
|
*/
|
|
350
350
|
delete() {
|
|
351
|
-
this._commandService.syncExecuteCommand(
|
|
351
|
+
this._commandService.syncExecuteCommand(ut.id, this._definedNameParam);
|
|
352
352
|
}
|
|
353
353
|
/**
|
|
354
354
|
* Gets the local sheet id of the defined name.
|
|
@@ -374,7 +374,7 @@ let H = class extends ae {
|
|
|
374
374
|
* ```
|
|
375
375
|
*/
|
|
376
376
|
isWorkbookScope() {
|
|
377
|
-
return this._definedNameParam.localSheetId ===
|
|
377
|
+
return this._definedNameParam.localSheetId === oe;
|
|
378
378
|
}
|
|
379
379
|
/**
|
|
380
380
|
* Converts the defined name to a defined name builder.
|
|
@@ -393,42 +393,42 @@ let H = class extends ae {
|
|
|
393
393
|
* ```
|
|
394
394
|
*/
|
|
395
395
|
toBuilder() {
|
|
396
|
-
const
|
|
397
|
-
return
|
|
396
|
+
const r = this._injector.createInstance(J);
|
|
397
|
+
return r.load(this._definedNameParam), r;
|
|
398
398
|
}
|
|
399
399
|
};
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
],
|
|
411
|
-
var
|
|
412
|
-
for (var
|
|
413
|
-
(i =
|
|
414
|
-
return
|
|
415
|
-
},
|
|
416
|
-
let
|
|
417
|
-
constructor(e, t, n,
|
|
400
|
+
q = hn([
|
|
401
|
+
I(1, u(x)),
|
|
402
|
+
I(2, l),
|
|
403
|
+
I(3, ue),
|
|
404
|
+
I(4, u(Le)),
|
|
405
|
+
I(5, u(ze)),
|
|
406
|
+
I(6, u(Ge)),
|
|
407
|
+
I(7, u(Be)),
|
|
408
|
+
I(8, u(Ve)),
|
|
409
|
+
I(9, Xe)
|
|
410
|
+
], q);
|
|
411
|
+
var cn = Object.getOwnPropertyDescriptor, un = (r, e, t, n) => {
|
|
412
|
+
for (var s = n > 1 ? void 0 : n ? cn(e, t) : e, o = r.length - 1, i; o >= 0; o--)
|
|
413
|
+
(i = r[o]) && (s = i(s) || s);
|
|
414
|
+
return s;
|
|
415
|
+
}, y = (r, e) => (t, n) => e(t, n, r);
|
|
416
|
+
let K = class extends ge {
|
|
417
|
+
constructor(e, t, n, s, o, i, a) {
|
|
418
418
|
super();
|
|
419
419
|
/**
|
|
420
420
|
* Permission point definition, can read the point constructor want to modify from here
|
|
421
421
|
*/
|
|
422
|
-
|
|
422
|
+
E(this, "permissionPointsDefinition", gt);
|
|
423
423
|
/**
|
|
424
424
|
* An observable object used to monitor permission change events within a range, thereby triggering corresponding subsequent processing.
|
|
425
425
|
*/
|
|
426
|
-
|
|
426
|
+
E(this, "rangeRuleChangedAfterAuth$");
|
|
427
427
|
/**
|
|
428
428
|
* An observable object used to monitor permission change events within a worksheet, thereby triggering corresponding subsequent processing.
|
|
429
429
|
*/
|
|
430
|
-
|
|
431
|
-
this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel =
|
|
430
|
+
E(this, "sheetRuleChangedAfterAuth$");
|
|
431
|
+
this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = s, this._rangeProtectionRuleModel = o, this._worksheetProtectionPointRuleModel = i, this._authzIoService = a, this.rangeRuleChangedAfterAuth$ = this._rangeProtectionRuleModel.ruleRefresh$, this.sheetRuleChangedAfterAuth$ = this._worksheetProtectionRuleModel.ruleRefresh$;
|
|
432
432
|
}
|
|
433
433
|
/**
|
|
434
434
|
* Configures a specific permission point for a workbook.
|
|
@@ -447,8 +447,8 @@ let O = class extends ae {
|
|
|
447
447
|
* ```
|
|
448
448
|
*/
|
|
449
449
|
setWorkbookPermissionPoint(e, t, n) {
|
|
450
|
-
const
|
|
451
|
-
this._permissionService.getPermissionPoint(
|
|
450
|
+
const s = new t(e);
|
|
451
|
+
this._permissionService.getPermissionPoint(s.id) || this._permissionService.addPermissionPoint(s), this._permissionService.updatePermissionPoint(s.id, n);
|
|
452
452
|
}
|
|
453
453
|
/**
|
|
454
454
|
* This function is used to set whether the workbook can be edited
|
|
@@ -464,7 +464,7 @@ let O = class extends ae {
|
|
|
464
464
|
* ```
|
|
465
465
|
*/
|
|
466
466
|
setWorkbookEditPermission(e, t) {
|
|
467
|
-
this.setWorkbookPermissionPoint(e,
|
|
467
|
+
this.setWorkbookPermissionPoint(e, $e, t);
|
|
468
468
|
}
|
|
469
469
|
/**
|
|
470
470
|
* This function is used to add a base permission for a worksheet.
|
|
@@ -491,8 +491,8 @@ let O = class extends ae {
|
|
|
491
491
|
async addWorksheetBasePermission(e, t) {
|
|
492
492
|
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length > 0)
|
|
493
493
|
throw new Error("sheet protection cannot intersect with range protection");
|
|
494
|
-
const
|
|
495
|
-
objectType:
|
|
494
|
+
const s = await this._authzIoService.create({
|
|
495
|
+
objectType: W.Worksheet,
|
|
496
496
|
worksheetObject: {
|
|
497
497
|
collaborators: [],
|
|
498
498
|
unitID: e,
|
|
@@ -501,17 +501,17 @@ let O = class extends ae {
|
|
|
501
501
|
scope: void 0
|
|
502
502
|
}
|
|
503
503
|
});
|
|
504
|
-
if (this._commandService.syncExecuteCommand(
|
|
504
|
+
if (this._commandService.syncExecuteCommand(lt.id, {
|
|
505
505
|
unitId: e,
|
|
506
506
|
subUnitId: t,
|
|
507
507
|
rule: {
|
|
508
|
-
permissionId:
|
|
509
|
-
unitType:
|
|
508
|
+
permissionId: s,
|
|
509
|
+
unitType: W.Worksheet,
|
|
510
510
|
unitId: e,
|
|
511
511
|
subUnitId: t
|
|
512
512
|
}
|
|
513
513
|
}))
|
|
514
|
-
return
|
|
514
|
+
return s;
|
|
515
515
|
}
|
|
516
516
|
/**
|
|
517
517
|
* Delete the entire table protection set for the worksheet and reset the point permissions of the worksheet to true
|
|
@@ -529,12 +529,12 @@ let O = class extends ae {
|
|
|
529
529
|
* ```
|
|
530
530
|
*/
|
|
531
531
|
removeWorksheetPermission(e, t) {
|
|
532
|
-
this._commandService.syncExecuteCommand(
|
|
532
|
+
this._commandService.syncExecuteCommand(mt.id, {
|
|
533
533
|
unitId: e,
|
|
534
534
|
subUnitId: t
|
|
535
|
-
}), [...
|
|
536
|
-
const
|
|
537
|
-
this._permissionService.updatePermissionPoint(
|
|
535
|
+
}), [..._t(), ...Se()].forEach((n) => {
|
|
536
|
+
const s = new n(e, t);
|
|
537
|
+
this._permissionService.updatePermissionPoint(s.id, !0);
|
|
538
538
|
}), this._worksheetProtectionPointRuleModel.deleteRule(e, t);
|
|
539
539
|
}
|
|
540
540
|
/**
|
|
@@ -559,10 +559,10 @@ let O = class extends ae {
|
|
|
559
559
|
* permission.setWorksheetPermissionPoint(unitId, subUnitId, permission.permissionPointsDefinition.WorksheetEditPermission, false);
|
|
560
560
|
* ```
|
|
561
561
|
*/
|
|
562
|
-
async setWorksheetPermissionPoint(e, t, n,
|
|
562
|
+
async setWorksheetPermissionPoint(e, t, n, s) {
|
|
563
563
|
const o = this._worksheetProtectionRuleModel.getRule(e, t);
|
|
564
564
|
let i;
|
|
565
|
-
if (n ===
|
|
565
|
+
if (n === ft || n === vt)
|
|
566
566
|
if (o)
|
|
567
567
|
i = o.permissionId;
|
|
568
568
|
else {
|
|
@@ -573,7 +573,7 @@ let O = class extends ae {
|
|
|
573
573
|
else {
|
|
574
574
|
const c = this._worksheetProtectionPointRuleModel.getRule(e, t);
|
|
575
575
|
c ? i = c.permissionId : (i = await this._authzIoService.create({
|
|
576
|
-
objectType:
|
|
576
|
+
objectType: W.Worksheet,
|
|
577
577
|
worksheetObject: {
|
|
578
578
|
collaborators: [],
|
|
579
579
|
unitID: e,
|
|
@@ -581,10 +581,10 @@ let O = class extends ae {
|
|
|
581
581
|
name: "",
|
|
582
582
|
scope: void 0
|
|
583
583
|
}
|
|
584
|
-
}), this._commandService.syncExecuteCommand(
|
|
584
|
+
}), this._commandService.syncExecuteCommand(wt.id, { unitId: e, subUnitId: t, rule: { unitId: e, subUnitId: t, permissionId: i } }));
|
|
585
585
|
}
|
|
586
586
|
const h = new n(e, t);
|
|
587
|
-
return this._permissionService.getPermissionPoint(h.id) || this._permissionService.addPermissionPoint(h), this._permissionService.updatePermissionPoint(h.id,
|
|
587
|
+
return this._permissionService.getPermissionPoint(h.id) || this._permissionService.addPermissionPoint(h), this._permissionService.updatePermissionPoint(h.id, s), i;
|
|
588
588
|
}
|
|
589
589
|
/**
|
|
590
590
|
* Adds a range protection to the worksheet.
|
|
@@ -613,25 +613,25 @@ let O = class extends ae {
|
|
|
613
613
|
* ```
|
|
614
614
|
*/
|
|
615
615
|
async addRangeBaseProtection(e, t, n) {
|
|
616
|
-
const
|
|
617
|
-
objectType:
|
|
616
|
+
const s = await this._authzIoService.create({
|
|
617
|
+
objectType: W.SelectRange,
|
|
618
618
|
selectRangeObject: {
|
|
619
619
|
collaborators: [],
|
|
620
620
|
unitID: e,
|
|
621
621
|
name: "",
|
|
622
622
|
scope: void 0
|
|
623
623
|
}
|
|
624
|
-
}), o = `ruleId_${
|
|
624
|
+
}), o = `ruleId_${Fe(6)}`;
|
|
625
625
|
if (this._worksheetProtectionRuleModel.getRule(e, t))
|
|
626
626
|
throw new Error("sheet protection cannot intersect with range protection");
|
|
627
|
-
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((c) => c.ranges.some((
|
|
627
|
+
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((c) => c.ranges.some((C) => n.some((_) => N.intersects(_.getRange(), C)))))
|
|
628
628
|
throw new Error("range protection cannot intersect");
|
|
629
|
-
if (this._commandService.syncExecuteCommand(
|
|
629
|
+
if (this._commandService.syncExecuteCommand(kt.id, {
|
|
630
630
|
unitId: e,
|
|
631
631
|
subUnitId: t,
|
|
632
632
|
rules: [{
|
|
633
|
-
permissionId:
|
|
634
|
-
unitType:
|
|
633
|
+
permissionId: s,
|
|
634
|
+
unitType: W.SelectRange,
|
|
635
635
|
unitId: e,
|
|
636
636
|
subUnitId: t,
|
|
637
637
|
ranges: n.map((c) => c.getRange()),
|
|
@@ -639,7 +639,7 @@ let O = class extends ae {
|
|
|
639
639
|
}]
|
|
640
640
|
}))
|
|
641
641
|
return {
|
|
642
|
-
permissionId:
|
|
642
|
+
permissionId: s,
|
|
643
643
|
ruleId: o
|
|
644
644
|
};
|
|
645
645
|
}
|
|
@@ -665,11 +665,11 @@ let O = class extends ae {
|
|
|
665
665
|
* ```
|
|
666
666
|
*/
|
|
667
667
|
removeRangeProtection(e, t, n) {
|
|
668
|
-
this._commandService.syncExecuteCommand(
|
|
668
|
+
this._commandService.syncExecuteCommand(St.id, {
|
|
669
669
|
unitId: e,
|
|
670
670
|
subUnitId: t,
|
|
671
671
|
ruleIds: n
|
|
672
|
-
}) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [...
|
|
672
|
+
}) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [...Se()].forEach((i) => {
|
|
673
673
|
const a = new i(e, t);
|
|
674
674
|
this._permissionService.updatePermissionPoint(a.id, a.value);
|
|
675
675
|
}));
|
|
@@ -701,8 +701,8 @@ let O = class extends ae {
|
|
|
701
701
|
* permission.setRangeProtectionPermissionPoint(unitId,subUnitId,permissionId, permission.permissionPointsDefinition.RangeProtectionPermissionEditPoint, false);
|
|
702
702
|
* ```
|
|
703
703
|
*/
|
|
704
|
-
setRangeProtectionPermissionPoint(e, t, n,
|
|
705
|
-
const i = new
|
|
704
|
+
setRangeProtectionPermissionPoint(e, t, n, s, o) {
|
|
705
|
+
const i = new s(e, t, n);
|
|
706
706
|
this._permissionService.getPermissionPoint(i.id) || this._permissionService.addPermissionPoint(i), this._permissionService.updatePermissionPoint(i.id, o);
|
|
707
707
|
}
|
|
708
708
|
/**
|
|
@@ -732,129 +732,129 @@ let O = class extends ae {
|
|
|
732
732
|
* permission.setRangeProtectionRanges(unitId, subUnitId, ruleId, [newRange]);
|
|
733
733
|
* ```
|
|
734
734
|
*/
|
|
735
|
-
setRangeProtectionRanges(e, t, n,
|
|
735
|
+
setRangeProtectionRanges(e, t, n, s) {
|
|
736
736
|
const o = this._rangeProtectionRuleModel.getRule(e, t, n);
|
|
737
737
|
if (o) {
|
|
738
|
-
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).filter((h) => h.id !== n).some((h) => h.ranges.some((d) =>
|
|
738
|
+
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).filter((h) => h.id !== n).some((h) => h.ranges.some((d) => s.some((c) => N.intersects(c.getRange(), d)))))
|
|
739
739
|
throw new Error("range protection cannot intersect");
|
|
740
|
-
this._commandService.syncExecuteCommand(
|
|
740
|
+
this._commandService.syncExecuteCommand(Ct.id, {
|
|
741
741
|
unitId: e,
|
|
742
742
|
subUnitId: t,
|
|
743
743
|
ruleId: n,
|
|
744
744
|
rule: {
|
|
745
745
|
...o,
|
|
746
|
-
ranges:
|
|
746
|
+
ranges: s.map((h) => h.getRange())
|
|
747
747
|
}
|
|
748
748
|
});
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
751
|
};
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
],
|
|
761
|
-
function
|
|
762
|
-
switch (
|
|
752
|
+
K = un([
|
|
753
|
+
y(0, u(x)),
|
|
754
|
+
y(1, l),
|
|
755
|
+
y(2, ue),
|
|
756
|
+
y(3, u(Le)),
|
|
757
|
+
y(4, u(ze)),
|
|
758
|
+
y(5, u(Ge)),
|
|
759
|
+
y(6, u(Be))
|
|
760
|
+
], K);
|
|
761
|
+
function gn(r) {
|
|
762
|
+
switch (r) {
|
|
763
763
|
case "left":
|
|
764
|
-
return
|
|
764
|
+
return T.LEFT;
|
|
765
765
|
case "center":
|
|
766
|
-
return
|
|
766
|
+
return T.CENTER;
|
|
767
767
|
case "normal":
|
|
768
|
-
return
|
|
768
|
+
return T.RIGHT;
|
|
769
769
|
default:
|
|
770
|
-
throw new Error(`Invalid horizontal alignment: ${
|
|
770
|
+
throw new Error(`Invalid horizontal alignment: ${r}`);
|
|
771
771
|
}
|
|
772
772
|
}
|
|
773
|
-
function
|
|
774
|
-
switch (
|
|
775
|
-
case
|
|
773
|
+
function Te(r) {
|
|
774
|
+
switch (r) {
|
|
775
|
+
case T.LEFT:
|
|
776
776
|
return "left";
|
|
777
|
-
case
|
|
777
|
+
case T.CENTER:
|
|
778
778
|
return "center";
|
|
779
|
-
case
|
|
779
|
+
case T.RIGHT:
|
|
780
780
|
return "normal";
|
|
781
781
|
default:
|
|
782
|
-
|
|
782
|
+
return "general";
|
|
783
783
|
}
|
|
784
784
|
}
|
|
785
|
-
function
|
|
786
|
-
switch (
|
|
785
|
+
function ln(r) {
|
|
786
|
+
switch (r) {
|
|
787
787
|
case "top":
|
|
788
|
-
return
|
|
788
|
+
return A.TOP;
|
|
789
789
|
case "middle":
|
|
790
|
-
return
|
|
790
|
+
return A.MIDDLE;
|
|
791
791
|
case "bottom":
|
|
792
|
-
return
|
|
792
|
+
return A.BOTTOM;
|
|
793
793
|
default:
|
|
794
|
-
throw new Error(`Invalid vertical alignment: ${
|
|
794
|
+
throw new Error(`Invalid vertical alignment: ${r}`);
|
|
795
795
|
}
|
|
796
796
|
}
|
|
797
|
-
function
|
|
798
|
-
switch (
|
|
799
|
-
case
|
|
797
|
+
function Ae(r) {
|
|
798
|
+
switch (r) {
|
|
799
|
+
case A.TOP:
|
|
800
800
|
return "top";
|
|
801
|
-
case
|
|
801
|
+
case A.MIDDLE:
|
|
802
802
|
return "middle";
|
|
803
|
-
case
|
|
803
|
+
case A.BOTTOM:
|
|
804
804
|
return "bottom";
|
|
805
805
|
default:
|
|
806
|
-
|
|
806
|
+
return "general";
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
|
-
function
|
|
810
|
-
return
|
|
811
|
-
f:
|
|
809
|
+
function O(r) {
|
|
810
|
+
return tt(r) ? {
|
|
811
|
+
f: r,
|
|
812
812
|
v: null,
|
|
813
813
|
p: null
|
|
814
|
-
} :
|
|
815
|
-
v:
|
|
814
|
+
} : nt(r) ? {
|
|
815
|
+
v: r,
|
|
816
816
|
p: null,
|
|
817
817
|
f: null
|
|
818
|
-
} : (
|
|
818
|
+
} : (rt(r), r);
|
|
819
819
|
}
|
|
820
|
-
function
|
|
821
|
-
const t = new
|
|
822
|
-
if (
|
|
820
|
+
function De(r, e) {
|
|
821
|
+
const t = new V(), { startRow: n, startColumn: s, endRow: o, endColumn: i } = e;
|
|
822
|
+
if (st.isArray(r))
|
|
823
823
|
for (let a = 0; a <= o - n; a++)
|
|
824
|
-
for (let h = 0; h <= i -
|
|
825
|
-
t.setValue(a + n, h +
|
|
824
|
+
for (let h = 0; h <= i - s; h++)
|
|
825
|
+
t.setValue(a + n, h + s, O(r[a][h]));
|
|
826
826
|
else
|
|
827
|
-
new
|
|
828
|
-
t.setValue(h, d,
|
|
827
|
+
new V(r).forValue((h, d, c) => {
|
|
828
|
+
t.setValue(h, d, O(c));
|
|
829
829
|
});
|
|
830
830
|
return t.getMatrix();
|
|
831
831
|
}
|
|
832
|
-
function
|
|
832
|
+
function ee(r, e) {
|
|
833
833
|
return {
|
|
834
|
-
startRow:
|
|
835
|
-
endRow:
|
|
834
|
+
startRow: r.startRow,
|
|
835
|
+
endRow: r.endRow,
|
|
836
836
|
startColumn: 0,
|
|
837
837
|
endColumn: e.getColumnCount() - 1,
|
|
838
|
-
rangeType:
|
|
838
|
+
rangeType: w.ROW
|
|
839
839
|
};
|
|
840
840
|
}
|
|
841
|
-
function
|
|
841
|
+
function te(r, e) {
|
|
842
842
|
return {
|
|
843
843
|
startRow: 0,
|
|
844
844
|
endRow: e.getRowCount() - 1,
|
|
845
|
-
startColumn:
|
|
846
|
-
endColumn:
|
|
847
|
-
rangeType:
|
|
845
|
+
startColumn: r.startColumn,
|
|
846
|
+
endColumn: r.endColumn,
|
|
847
|
+
rangeType: w.COLUMN
|
|
848
848
|
};
|
|
849
849
|
}
|
|
850
|
-
var
|
|
851
|
-
for (var
|
|
852
|
-
(i =
|
|
853
|
-
return
|
|
854
|
-
},
|
|
855
|
-
let
|
|
856
|
-
constructor(
|
|
857
|
-
super(n), this._workbook =
|
|
850
|
+
var mn = Object.getOwnPropertyDescriptor, _n = (r, e, t, n) => {
|
|
851
|
+
for (var s = n > 1 ? void 0 : n ? mn(e, t) : e, o = r.length - 1, i; o >= 0; o--)
|
|
852
|
+
(i = r[o]) && (s = i(s) || s);
|
|
853
|
+
return s;
|
|
854
|
+
}, ne = (r, e) => (t, n) => e(t, n, r);
|
|
855
|
+
let m = class extends le {
|
|
856
|
+
constructor(r, e, t, n, s, o) {
|
|
857
|
+
super(n), this._workbook = r, this._worksheet = e, this._range = t, this._injector = n, this._commandService = s, this._formulaDataModel = o;
|
|
858
858
|
}
|
|
859
859
|
/**
|
|
860
860
|
* Get the unit ID of the current workbook
|
|
@@ -915,33 +915,61 @@ let k = class extends he {
|
|
|
915
915
|
return this._range;
|
|
916
916
|
}
|
|
917
917
|
/**
|
|
918
|
-
* Gets the starting row
|
|
919
|
-
* @returns {number} The starting row
|
|
918
|
+
* Gets the starting row index of the range. index starts at 0.
|
|
919
|
+
* @returns {number} The starting row index of the range.
|
|
920
920
|
* @example
|
|
921
921
|
* ```ts
|
|
922
922
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
923
923
|
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
924
924
|
* const fRange = fWorksheet.getRange('A1:B2');
|
|
925
|
-
* console.log(fRange.getRow());
|
|
925
|
+
* console.log(fRange.getRow()); // 0
|
|
926
926
|
* ```
|
|
927
927
|
*/
|
|
928
928
|
getRow() {
|
|
929
929
|
return this._range.startRow;
|
|
930
930
|
}
|
|
931
931
|
/**
|
|
932
|
-
* Gets the
|
|
933
|
-
* @returns {number} The
|
|
932
|
+
* Gets the ending row index of the range. index starts at 0.
|
|
933
|
+
* @returns {number} The ending row index of the range.
|
|
934
934
|
* @example
|
|
935
935
|
* ```ts
|
|
936
936
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
937
937
|
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
938
938
|
* const fRange = fWorksheet.getRange('A1:B2');
|
|
939
|
-
* console.log(fRange.
|
|
939
|
+
* console.log(fRange.getLastRow()); // 1
|
|
940
|
+
* ```
|
|
941
|
+
*/
|
|
942
|
+
getLastRow() {
|
|
943
|
+
return this._range.endRow;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Gets the starting column index of the range. index starts at 0.
|
|
947
|
+
* @returns {number} The starting column index of the range.
|
|
948
|
+
* @example
|
|
949
|
+
* ```ts
|
|
950
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
951
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
952
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
953
|
+
* console.log(fRange.getColumn()); // 0
|
|
940
954
|
* ```
|
|
941
955
|
*/
|
|
942
956
|
getColumn() {
|
|
943
957
|
return this._range.startColumn;
|
|
944
958
|
}
|
|
959
|
+
/**
|
|
960
|
+
* Gets the ending column index of the range. index starts at 0.
|
|
961
|
+
* @returns {number} The ending column index of the range.
|
|
962
|
+
* @example
|
|
963
|
+
* ```ts
|
|
964
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
965
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
966
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
967
|
+
* console.log(fRange.getLastColumn()); // 1
|
|
968
|
+
* ```
|
|
969
|
+
*/
|
|
970
|
+
getLastColumn() {
|
|
971
|
+
return this._range.endColumn;
|
|
972
|
+
}
|
|
945
973
|
/**
|
|
946
974
|
* Gets the width of the applied area
|
|
947
975
|
* @returns {number} The width of the area
|
|
@@ -985,8 +1013,8 @@ let k = class extends he {
|
|
|
985
1013
|
* ```
|
|
986
1014
|
*/
|
|
987
1015
|
isMerged() {
|
|
988
|
-
const { startColumn:
|
|
989
|
-
return this._worksheet.getMergedCellRange(e,
|
|
1016
|
+
const { startColumn: r, startRow: e, endColumn: t, endRow: n } = this._range;
|
|
1017
|
+
return this._worksheet.getMergedCellRange(e, r, n, t).some((o) => N.equals(o, this._range));
|
|
990
1018
|
}
|
|
991
1019
|
/**
|
|
992
1020
|
* Return first cell style data in this range
|
|
@@ -1001,8 +1029,8 @@ let k = class extends he {
|
|
|
1001
1029
|
*/
|
|
1002
1030
|
getCellStyleData() {
|
|
1003
1031
|
var t;
|
|
1004
|
-
const
|
|
1005
|
-
return
|
|
1032
|
+
const r = this.getCellData(), e = this._workbook.getStyles();
|
|
1033
|
+
return r && e && (t = e.getStyleByCell(r)) != null ? t : null;
|
|
1006
1034
|
}
|
|
1007
1035
|
/**
|
|
1008
1036
|
* Return first cell style in this range
|
|
@@ -1016,8 +1044,8 @@ let k = class extends he {
|
|
|
1016
1044
|
* ```
|
|
1017
1045
|
*/
|
|
1018
1046
|
getCellStyle() {
|
|
1019
|
-
const
|
|
1020
|
-
return
|
|
1047
|
+
const r = this.getCellStyleData();
|
|
1048
|
+
return r ? we.create(r) : null;
|
|
1021
1049
|
}
|
|
1022
1050
|
/**
|
|
1023
1051
|
* Returns the cell styles for the cells in the range.
|
|
@@ -1031,30 +1059,188 @@ let k = class extends he {
|
|
|
1031
1059
|
* ```
|
|
1032
1060
|
*/
|
|
1033
1061
|
getCellStyles() {
|
|
1034
|
-
const
|
|
1035
|
-
return
|
|
1062
|
+
const r = this.getCellDatas(), e = this._workbook.getStyles();
|
|
1063
|
+
return r.map((t) => t.map((n) => {
|
|
1036
1064
|
if (!n) return null;
|
|
1037
|
-
const
|
|
1038
|
-
return
|
|
1065
|
+
const s = e.getStyleByCell(n);
|
|
1066
|
+
return s ? we.create(s) : null;
|
|
1039
1067
|
}));
|
|
1040
1068
|
}
|
|
1041
|
-
getValue(
|
|
1069
|
+
getValue(r) {
|
|
1042
1070
|
var e, t;
|
|
1043
|
-
return
|
|
1071
|
+
return r ? this.getValueAndRichTextValue() : (t = (e = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) == null ? void 0 : e.v) != null ? t : null;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Returns the raw value of the top-left cell in the range. Empty cells return `null`.
|
|
1075
|
+
* @returns {Nullable<CellValue>} The raw value of the cell. Returns `null` if the cell is empty.
|
|
1076
|
+
* @example
|
|
1077
|
+
* ```ts
|
|
1078
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1079
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1080
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1081
|
+
* fRange.setValueForCell({
|
|
1082
|
+
* v: 0.2,
|
|
1083
|
+
* s: {
|
|
1084
|
+
* n: {
|
|
1085
|
+
* pattern: '0%',
|
|
1086
|
+
* },
|
|
1087
|
+
* },
|
|
1088
|
+
* });
|
|
1089
|
+
* console.log(fRange.getRawValue()); // 0.2
|
|
1090
|
+
* ```
|
|
1091
|
+
*/
|
|
1092
|
+
getRawValue() {
|
|
1093
|
+
var e;
|
|
1094
|
+
const r = this._worksheet.getCellMatrix().getValue(this._range.startRow, this._range.startColumn);
|
|
1095
|
+
return r != null && r.p && ((e = r.p.body) != null && e.dataStream) ? r.p.body.dataStream : r != null && r.v ? r.v : null;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Returns the displayed value of the top-left cell in the range. The value is a String. Empty cells return an empty string.
|
|
1099
|
+
* @returns {string} The displayed value of the cell. Returns an empty string if the cell is empty.
|
|
1100
|
+
* @example
|
|
1101
|
+
* ```ts
|
|
1102
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1103
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1104
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1105
|
+
* fRange.setValueForCell({
|
|
1106
|
+
* v: 0.2,
|
|
1107
|
+
* s: {
|
|
1108
|
+
* n: {
|
|
1109
|
+
* pattern: '0%',
|
|
1110
|
+
* },
|
|
1111
|
+
* },
|
|
1112
|
+
* });
|
|
1113
|
+
* console.log(fRange.getDisplayValue()); // 20%
|
|
1114
|
+
* ```
|
|
1115
|
+
*/
|
|
1116
|
+
getDisplayValue() {
|
|
1117
|
+
var e;
|
|
1118
|
+
const r = this._worksheet.getCell(this._range.startRow, this._range.startColumn);
|
|
1119
|
+
return r != null && r.p && ((e = r.p.body) != null && e.dataStream) ? r.p.body.dataStream : r != null && r.v ? String(r.v) : "";
|
|
1044
1120
|
}
|
|
1045
|
-
getValues(
|
|
1121
|
+
getValues(r) {
|
|
1046
1122
|
var i, a;
|
|
1047
|
-
if (
|
|
1123
|
+
if (r)
|
|
1048
1124
|
return this.getValueAndRichTextValues();
|
|
1049
|
-
const { startRow: e, endRow: t, startColumn: n, endColumn:
|
|
1125
|
+
const { startRow: e, endRow: t, startColumn: n, endColumn: s } = this._range, o = [];
|
|
1050
1126
|
for (let h = e; h <= t; h++) {
|
|
1051
1127
|
const d = [];
|
|
1052
|
-
for (let c = n; c <=
|
|
1128
|
+
for (let c = n; c <= s; c++)
|
|
1053
1129
|
d.push((a = (i = this._worksheet.getCell(h, c)) == null ? void 0 : i.v) != null ? a : null);
|
|
1054
1130
|
o.push(d);
|
|
1055
1131
|
}
|
|
1056
1132
|
return o;
|
|
1057
1133
|
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Returns a two-dimensional array of the range raw values. Empty cells return `null`.
|
|
1136
|
+
* @returns {Array<Array<Nullable<CellValue>>>} The raw value of the cell. Returns `null` if the cell is empty.
|
|
1137
|
+
* @example
|
|
1138
|
+
* ```ts
|
|
1139
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1140
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1141
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1142
|
+
* fRange.setValues([
|
|
1143
|
+
* [
|
|
1144
|
+
* {
|
|
1145
|
+
* v: 0.2,
|
|
1146
|
+
* s: {
|
|
1147
|
+
* n: {
|
|
1148
|
+
* pattern: '0%',
|
|
1149
|
+
* },
|
|
1150
|
+
* },
|
|
1151
|
+
* },
|
|
1152
|
+
* {
|
|
1153
|
+
* v: 45658,
|
|
1154
|
+
* s: {
|
|
1155
|
+
* n: {
|
|
1156
|
+
* pattern: 'yyyy-mm-dd',
|
|
1157
|
+
* },
|
|
1158
|
+
* },
|
|
1159
|
+
* }
|
|
1160
|
+
* ],
|
|
1161
|
+
* [
|
|
1162
|
+
* {
|
|
1163
|
+
* v: 1234.567,
|
|
1164
|
+
* s: {
|
|
1165
|
+
* n: {
|
|
1166
|
+
* pattern: '#,##0.00',
|
|
1167
|
+
* }
|
|
1168
|
+
* }
|
|
1169
|
+
* },
|
|
1170
|
+
* null,
|
|
1171
|
+
* ],
|
|
1172
|
+
* ]);
|
|
1173
|
+
* console.log(fRange.getRawValues()); // [[0.2, 45658], [1234.567, null]]
|
|
1174
|
+
* ```
|
|
1175
|
+
*/
|
|
1176
|
+
getRawValues() {
|
|
1177
|
+
var i;
|
|
1178
|
+
const r = this._worksheet.getCellMatrix(), { startRow: e, endRow: t, startColumn: n, endColumn: s } = this._range, o = [];
|
|
1179
|
+
for (let a = e; a <= t; a++) {
|
|
1180
|
+
const h = [];
|
|
1181
|
+
for (let d = n; d <= s; d++) {
|
|
1182
|
+
const c = r.getValue(a, d);
|
|
1183
|
+
c != null && c.p && ((i = c.p.body) != null && i.dataStream) ? h.push(c.p.body.dataStream) : c != null && c.v ? h.push(c.v) : h.push(null);
|
|
1184
|
+
}
|
|
1185
|
+
o.push(h);
|
|
1186
|
+
}
|
|
1187
|
+
return o;
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Returns a two-dimensional array of the range displayed values. Empty cells return an empty string.
|
|
1191
|
+
* @returns {string[][]} A two-dimensional array of values.
|
|
1192
|
+
* @example
|
|
1193
|
+
* ```ts
|
|
1194
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1195
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1196
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1197
|
+
* fRange.setValues([
|
|
1198
|
+
* [
|
|
1199
|
+
* {
|
|
1200
|
+
* v: 0.2,
|
|
1201
|
+
* s: {
|
|
1202
|
+
* n: {
|
|
1203
|
+
* pattern: '0%',
|
|
1204
|
+
* },
|
|
1205
|
+
* },
|
|
1206
|
+
* },
|
|
1207
|
+
* {
|
|
1208
|
+
* v: 45658,
|
|
1209
|
+
* s: {
|
|
1210
|
+
* n: {
|
|
1211
|
+
* pattern: 'yyyy-mm-dd',
|
|
1212
|
+
* },
|
|
1213
|
+
* },
|
|
1214
|
+
* }
|
|
1215
|
+
* ],
|
|
1216
|
+
* [
|
|
1217
|
+
* {
|
|
1218
|
+
* v: 1234.567,
|
|
1219
|
+
* s: {
|
|
1220
|
+
* n: {
|
|
1221
|
+
* pattern: '#,##0.00',
|
|
1222
|
+
* }
|
|
1223
|
+
* }
|
|
1224
|
+
* },
|
|
1225
|
+
* null,
|
|
1226
|
+
* ],
|
|
1227
|
+
* ]);
|
|
1228
|
+
* console.log(fRange.getDisplayValues()); // [['20%', '2025-01-01'], ['1,234.57', '']]
|
|
1229
|
+
* ```
|
|
1230
|
+
*/
|
|
1231
|
+
getDisplayValues() {
|
|
1232
|
+
var o;
|
|
1233
|
+
const { startRow: r, endRow: e, startColumn: t, endColumn: n } = this._range, s = [];
|
|
1234
|
+
for (let i = r; i <= e; i++) {
|
|
1235
|
+
const a = [];
|
|
1236
|
+
for (let h = t; h <= n; h++) {
|
|
1237
|
+
const d = this._worksheet.getCell(i, h);
|
|
1238
|
+
d != null && d.p && ((o = d.p.body) != null && o.dataStream) ? a.push(d.p.body.dataStream) : d != null && d.v ? a.push(String(d.v)) : a.push("");
|
|
1239
|
+
}
|
|
1240
|
+
s.push(a);
|
|
1241
|
+
}
|
|
1242
|
+
return s;
|
|
1243
|
+
}
|
|
1058
1244
|
/**
|
|
1059
1245
|
* Return first cell model data in this range
|
|
1060
1246
|
* @returns {ICellData | null} The cell model data
|
|
@@ -1067,8 +1253,8 @@ let k = class extends he {
|
|
|
1067
1253
|
* ```
|
|
1068
1254
|
*/
|
|
1069
1255
|
getCellData() {
|
|
1070
|
-
var
|
|
1071
|
-
return (
|
|
1256
|
+
var r;
|
|
1257
|
+
return (r = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) != null ? r : null;
|
|
1072
1258
|
}
|
|
1073
1259
|
/**
|
|
1074
1260
|
* Alias for getCellDataGrid.
|
|
@@ -1096,14 +1282,14 @@ let k = class extends he {
|
|
|
1096
1282
|
* ```
|
|
1097
1283
|
*/
|
|
1098
1284
|
getCellDataGrid() {
|
|
1099
|
-
const { startRow:
|
|
1100
|
-
for (let o =
|
|
1285
|
+
const { startRow: r, endRow: e, startColumn: t, endColumn: n } = this._range, s = [];
|
|
1286
|
+
for (let o = r; o <= e; o++) {
|
|
1101
1287
|
const i = [];
|
|
1102
1288
|
for (let a = t; a <= n; a++)
|
|
1103
1289
|
i.push(this._worksheet.getCellRaw(o, a));
|
|
1104
|
-
|
|
1290
|
+
s.push(i);
|
|
1105
1291
|
}
|
|
1106
|
-
return
|
|
1292
|
+
return s;
|
|
1107
1293
|
}
|
|
1108
1294
|
/**
|
|
1109
1295
|
* Returns the rich text value for the cell at the start of this range.
|
|
@@ -1119,8 +1305,8 @@ let k = class extends he {
|
|
|
1119
1305
|
* ```
|
|
1120
1306
|
*/
|
|
1121
1307
|
getRichTextValue() {
|
|
1122
|
-
const
|
|
1123
|
-
return
|
|
1308
|
+
const r = this.getCellData();
|
|
1309
|
+
return r != null && r.p ? new P(r.p) : null;
|
|
1124
1310
|
}
|
|
1125
1311
|
/**
|
|
1126
1312
|
* Returns the rich text value for the cells in the range.
|
|
@@ -1136,7 +1322,7 @@ let k = class extends he {
|
|
|
1136
1322
|
* ```
|
|
1137
1323
|
*/
|
|
1138
1324
|
getRichTextValues() {
|
|
1139
|
-
return this.getCellDataGrid().map((e) => e.map((t) => t != null && t.p ? new
|
|
1325
|
+
return this.getCellDataGrid().map((e) => e.map((t) => t != null && t.p ? new P(t.p) : null));
|
|
1140
1326
|
}
|
|
1141
1327
|
/**
|
|
1142
1328
|
* Returns the value and rich text value for the cell at the start of this range.
|
|
@@ -1152,8 +1338,8 @@ let k = class extends he {
|
|
|
1152
1338
|
* ```
|
|
1153
1339
|
*/
|
|
1154
1340
|
getValueAndRichTextValue() {
|
|
1155
|
-
const
|
|
1156
|
-
return
|
|
1341
|
+
const r = this.getCellData();
|
|
1342
|
+
return r != null && r.p ? new P(r.p) : r == null ? void 0 : r.v;
|
|
1157
1343
|
}
|
|
1158
1344
|
/**
|
|
1159
1345
|
* Returns the value and rich text value for the cells in the range.
|
|
@@ -1167,7 +1353,27 @@ let k = class extends he {
|
|
|
1167
1353
|
* ```
|
|
1168
1354
|
*/
|
|
1169
1355
|
getValueAndRichTextValues() {
|
|
1170
|
-
return this.getCellDatas().map((e) => e.map((t) => t != null && t.p ? new
|
|
1356
|
+
return this.getCellDatas().map((e) => e.map((t) => t != null && t.p ? new P(t.p) : t == null ? void 0 : t.v));
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Returns the formula (A1 notation) of the top-left cell in the range, or an empty string if the cell is empty or doesn't contain a formula.
|
|
1360
|
+
* @returns {string} The formula for the cell.
|
|
1361
|
+
* @example
|
|
1362
|
+
* ```ts
|
|
1363
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1364
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1365
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1366
|
+
* console.log(fRange.getFormula());
|
|
1367
|
+
* ```
|
|
1368
|
+
*/
|
|
1369
|
+
getFormula() {
|
|
1370
|
+
var r;
|
|
1371
|
+
return (r = this._formulaDataModel.getFormulaStringByCell(
|
|
1372
|
+
this._range.startRow,
|
|
1373
|
+
this._range.startColumn,
|
|
1374
|
+
this._worksheet.getSheetId(),
|
|
1375
|
+
this._workbook.getUnitId()
|
|
1376
|
+
)) != null ? r : "";
|
|
1171
1377
|
}
|
|
1172
1378
|
/**
|
|
1173
1379
|
* Returns the formulas (A1 notation) for the cells in the range. Entries in the 2D array are empty strings for cells with no formula.
|
|
@@ -1181,20 +1387,20 @@ let k = class extends he {
|
|
|
1181
1387
|
* ```
|
|
1182
1388
|
*/
|
|
1183
1389
|
getFormulas() {
|
|
1184
|
-
const
|
|
1390
|
+
const r = [], { startRow: e, endRow: t, startColumn: n, endColumn: s } = this._range, o = this._worksheet.getSheetId(), i = this._workbook.getUnitId();
|
|
1185
1391
|
for (let a = e; a <= t; a++) {
|
|
1186
1392
|
const h = [];
|
|
1187
|
-
for (let d = n; d <=
|
|
1393
|
+
for (let d = n; d <= s; d++) {
|
|
1188
1394
|
const c = this._formulaDataModel.getFormulaStringByCell(a, d, o, i);
|
|
1189
1395
|
h.push(c || "");
|
|
1190
1396
|
}
|
|
1191
|
-
|
|
1397
|
+
r.push(h);
|
|
1192
1398
|
}
|
|
1193
|
-
return
|
|
1399
|
+
return r;
|
|
1194
1400
|
}
|
|
1195
1401
|
/**
|
|
1196
|
-
*
|
|
1197
|
-
* @returns {boolean}
|
|
1402
|
+
* Gets whether text wrapping is enabled for top-left cell in the range.
|
|
1403
|
+
* @returns {boolean} whether text wrapping is enabled for the cell.
|
|
1198
1404
|
* @example
|
|
1199
1405
|
* ```ts
|
|
1200
1406
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1206,6 +1412,23 @@ let k = class extends he {
|
|
|
1206
1412
|
getWrap() {
|
|
1207
1413
|
return this._worksheet.getRange(this._range).getWrap() === g.TRUE;
|
|
1208
1414
|
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Gets whether text wrapping is enabled for cells in the range.
|
|
1417
|
+
* @returns {boolean[][]} A two-dimensional array of whether text wrapping is enabled for each cell in the range.
|
|
1418
|
+
* @example
|
|
1419
|
+
* ```ts
|
|
1420
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1421
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1422
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1423
|
+
* console.log(fRange.getWraps());
|
|
1424
|
+
*/
|
|
1425
|
+
getWraps() {
|
|
1426
|
+
const r = this.getCellDatas(), e = this._workbook.getStyles();
|
|
1427
|
+
return r.map((t) => t.map((n) => {
|
|
1428
|
+
var s;
|
|
1429
|
+
return ((s = e.getStyleByCell(n)) == null ? void 0 : s.tb) === G.WRAP;
|
|
1430
|
+
}));
|
|
1431
|
+
}
|
|
1209
1432
|
/**
|
|
1210
1433
|
* Returns the text wrapping strategy for the top left cell of the range.
|
|
1211
1434
|
* @returns {WrapStrategy} The text wrapping strategy
|
|
@@ -1221,8 +1444,8 @@ let k = class extends he {
|
|
|
1221
1444
|
return this._worksheet.getRange(this._range).getWrapStrategy();
|
|
1222
1445
|
}
|
|
1223
1446
|
/**
|
|
1224
|
-
* Returns the horizontal alignment
|
|
1225
|
-
* @returns {string} The horizontal alignment
|
|
1447
|
+
* Returns the horizontal alignment of the text (left/center/right) of the top-left cell in the range.
|
|
1448
|
+
* @returns {string} The horizontal alignment of the text in the cell.
|
|
1226
1449
|
* @example
|
|
1227
1450
|
* ```ts
|
|
1228
1451
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1232,11 +1455,26 @@ let k = class extends he {
|
|
|
1232
1455
|
* ```
|
|
1233
1456
|
*/
|
|
1234
1457
|
getHorizontalAlignment() {
|
|
1235
|
-
|
|
1458
|
+
const r = this._worksheet.getRange(this._range).getHorizontalAlignment();
|
|
1459
|
+
return Te(r);
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Returns the horizontal alignments of the cells in the range.
|
|
1463
|
+
* @returns {string[][]} A two-dimensional array of horizontal alignments of text associated with cells in the range.
|
|
1464
|
+
* @example
|
|
1465
|
+
* ```ts
|
|
1466
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1467
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1468
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1469
|
+
* console.log(fRange.getHorizontalAlignments());
|
|
1470
|
+
* ```
|
|
1471
|
+
*/
|
|
1472
|
+
getHorizontalAlignments() {
|
|
1473
|
+
return this._worksheet.getRange(this._range).getHorizontalAlignments().map((e) => e.map((t) => Te(t)));
|
|
1236
1474
|
}
|
|
1237
1475
|
/**
|
|
1238
|
-
* Returns the vertical alignment
|
|
1239
|
-
* @returns {string} The vertical alignment
|
|
1476
|
+
* Returns the vertical alignment (top/middle/bottom) of the top-left cell in the range.
|
|
1477
|
+
* @returns {string} The vertical alignment of the text in the cell.
|
|
1240
1478
|
* @example
|
|
1241
1479
|
* ```ts
|
|
1242
1480
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1246,7 +1484,21 @@ let k = class extends he {
|
|
|
1246
1484
|
* ```
|
|
1247
1485
|
*/
|
|
1248
1486
|
getVerticalAlignment() {
|
|
1249
|
-
return
|
|
1487
|
+
return Ae(this._worksheet.getRange(this._range).getVerticalAlignment());
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Returns the vertical alignments of the cells in the range.
|
|
1491
|
+
* @returns {string[][]} A two-dimensional array of vertical alignments of text associated with cells in the range.
|
|
1492
|
+
* @example
|
|
1493
|
+
* ```ts
|
|
1494
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1495
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1496
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1497
|
+
* console.log(fRange.getVerticalAlignments());
|
|
1498
|
+
* ```
|
|
1499
|
+
*/
|
|
1500
|
+
getVerticalAlignments() {
|
|
1501
|
+
return this._worksheet.getRange(this._range).getVerticalAlignments().map((e) => e.map((t) => Ae(t)));
|
|
1250
1502
|
}
|
|
1251
1503
|
/**
|
|
1252
1504
|
* Set custom meta data for first cell in current range.
|
|
@@ -1260,9 +1512,9 @@ let k = class extends he {
|
|
|
1260
1512
|
* console.log(fRange.getCustomMetaData());
|
|
1261
1513
|
* ```
|
|
1262
1514
|
*/
|
|
1263
|
-
setCustomMetaData(
|
|
1515
|
+
setCustomMetaData(r) {
|
|
1264
1516
|
return this.setValue({
|
|
1265
|
-
custom:
|
|
1517
|
+
custom: r
|
|
1266
1518
|
});
|
|
1267
1519
|
}
|
|
1268
1520
|
/**
|
|
@@ -1280,8 +1532,8 @@ let k = class extends he {
|
|
|
1280
1532
|
* console.log(fRange.getCustomMetaDatas());
|
|
1281
1533
|
* ```
|
|
1282
1534
|
*/
|
|
1283
|
-
setCustomMetaDatas(
|
|
1284
|
-
return this.setValues(
|
|
1535
|
+
setCustomMetaDatas(r) {
|
|
1536
|
+
return this.setValues(r.map((e) => e.map((t) => ({ custom: t }))));
|
|
1285
1537
|
}
|
|
1286
1538
|
/**
|
|
1287
1539
|
* Returns the custom meta data for the cell at the start of this range.
|
|
@@ -1296,8 +1548,8 @@ let k = class extends he {
|
|
|
1296
1548
|
*/
|
|
1297
1549
|
getCustomMetaData() {
|
|
1298
1550
|
var e;
|
|
1299
|
-
const
|
|
1300
|
-
return (e =
|
|
1551
|
+
const r = this.getCellData();
|
|
1552
|
+
return (e = r == null ? void 0 : r.custom) != null ? e : null;
|
|
1301
1553
|
}
|
|
1302
1554
|
/**
|
|
1303
1555
|
* Returns the custom meta data for the cells in the range.
|
|
@@ -1330,19 +1582,52 @@ let k = class extends he {
|
|
|
1330
1582
|
* fRange.setBorder(univerAPI.Enum.BorderType.ALL, univerAPI.Enum.BorderStyleTypes.THIN, '#ff0000');
|
|
1331
1583
|
* ```
|
|
1332
1584
|
*/
|
|
1333
|
-
setBorder(
|
|
1334
|
-
return this._commandService.syncExecuteCommand(
|
|
1585
|
+
setBorder(r, e, t) {
|
|
1586
|
+
return this._commandService.syncExecuteCommand(It.id, {
|
|
1335
1587
|
unitId: this._workbook.getUnitId(),
|
|
1336
1588
|
subUnitId: this._worksheet.getSheetId(),
|
|
1337
1589
|
ranges: [this._range],
|
|
1338
1590
|
value: {
|
|
1339
|
-
type:
|
|
1591
|
+
type: r,
|
|
1340
1592
|
style: e,
|
|
1341
1593
|
color: t
|
|
1342
1594
|
}
|
|
1343
1595
|
}), this;
|
|
1344
1596
|
}
|
|
1345
1597
|
// #region editing
|
|
1598
|
+
/**
|
|
1599
|
+
* Returns the background color of the top-left cell in the range.
|
|
1600
|
+
* @returns {string} The color code of the background.
|
|
1601
|
+
* @example
|
|
1602
|
+
* ```ts
|
|
1603
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1604
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1605
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1606
|
+
* console.log(fRange.getBackground());
|
|
1607
|
+
* ```
|
|
1608
|
+
*/
|
|
1609
|
+
getBackground() {
|
|
1610
|
+
var e, t;
|
|
1611
|
+
const r = this.getCellStyle();
|
|
1612
|
+
return (t = (e = r == null ? void 0 : r.background) == null ? void 0 : e.rgb) != null ? t : ke.bg.rgb;
|
|
1613
|
+
}
|
|
1614
|
+
/**
|
|
1615
|
+
* Returns the background colors of the cells in the range.
|
|
1616
|
+
* @returns {string[][]} A two-dimensional array of color codes of the backgrounds.
|
|
1617
|
+
* @example
|
|
1618
|
+
* ```ts
|
|
1619
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1620
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1621
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1622
|
+
* console.log(fRange.getBackgrounds());
|
|
1623
|
+
* ```
|
|
1624
|
+
*/
|
|
1625
|
+
getBackgrounds() {
|
|
1626
|
+
return this.getCellStyles().map((e) => e.map((t) => {
|
|
1627
|
+
var n, s;
|
|
1628
|
+
return (s = (n = t == null ? void 0 : t.background) == null ? void 0 : n.rgb) != null ? s : ke.bg.rgb;
|
|
1629
|
+
}));
|
|
1630
|
+
}
|
|
1346
1631
|
/**
|
|
1347
1632
|
* Set background color for current range.
|
|
1348
1633
|
* @param {string} color The background color
|
|
@@ -1355,15 +1640,15 @@ let k = class extends he {
|
|
|
1355
1640
|
* fRange.setBackgroundColor('red');
|
|
1356
1641
|
* ```
|
|
1357
1642
|
*/
|
|
1358
|
-
setBackgroundColor(
|
|
1359
|
-
return this._commandService.syncExecuteCommand(
|
|
1643
|
+
setBackgroundColor(r) {
|
|
1644
|
+
return this._commandService.syncExecuteCommand(b.id, {
|
|
1360
1645
|
unitId: this._workbook.getUnitId(),
|
|
1361
1646
|
subUnitId: this._worksheet.getSheetId(),
|
|
1362
1647
|
range: this._range,
|
|
1363
1648
|
style: {
|
|
1364
1649
|
type: "bg",
|
|
1365
1650
|
value: {
|
|
1366
|
-
rgb:
|
|
1651
|
+
rgb: r
|
|
1367
1652
|
}
|
|
1368
1653
|
}
|
|
1369
1654
|
}), this;
|
|
@@ -1380,8 +1665,28 @@ let k = class extends he {
|
|
|
1380
1665
|
* fRange.setBackground('red');
|
|
1381
1666
|
* ```
|
|
1382
1667
|
*/
|
|
1383
|
-
setBackground(
|
|
1384
|
-
return this.setBackgroundColor(
|
|
1668
|
+
setBackground(r) {
|
|
1669
|
+
return this.setBackgroundColor(r), this;
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* Set rotation for text in current range.
|
|
1673
|
+
* @param {number} rotation - The rotation angle in degrees
|
|
1674
|
+
* @returns This range, for chaining
|
|
1675
|
+
* @example
|
|
1676
|
+
* ```typescript
|
|
1677
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1678
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1679
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1680
|
+
* fRange.setTextRotation(45);
|
|
1681
|
+
* ```
|
|
1682
|
+
*/
|
|
1683
|
+
setTextRotation(r) {
|
|
1684
|
+
return this._commandService.syncExecuteCommand(Rt.id, {
|
|
1685
|
+
unitId: this._workbook.getUnitId(),
|
|
1686
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
1687
|
+
range: this._range,
|
|
1688
|
+
value: r
|
|
1689
|
+
}), this;
|
|
1385
1690
|
}
|
|
1386
1691
|
/**
|
|
1387
1692
|
* Sets the value of the range.
|
|
@@ -1397,11 +1702,11 @@ let k = class extends he {
|
|
|
1397
1702
|
* fRange.setValue({ v: 234, s: { bg: { rgb: '#ff0000' } } });
|
|
1398
1703
|
* ```
|
|
1399
1704
|
*/
|
|
1400
|
-
setValue(
|
|
1401
|
-
const e =
|
|
1705
|
+
setValue(r) {
|
|
1706
|
+
const e = O(r);
|
|
1402
1707
|
if (!e)
|
|
1403
1708
|
throw new Error("Invalid value");
|
|
1404
|
-
return this._commandService.syncExecuteCommand(
|
|
1709
|
+
return this._commandService.syncExecuteCommand(B.id, {
|
|
1405
1710
|
unitId: this._workbook.getUnitId(),
|
|
1406
1711
|
subUnitId: this._worksheet.getSheetId(),
|
|
1407
1712
|
range: this._range,
|
|
@@ -1422,11 +1727,11 @@ let k = class extends he {
|
|
|
1422
1727
|
* fRange.setValueForCell({ v: 234, s: { bg: { rgb: '#ff0000' } } });
|
|
1423
1728
|
* ```
|
|
1424
1729
|
*/
|
|
1425
|
-
setValueForCell(
|
|
1426
|
-
const e =
|
|
1730
|
+
setValueForCell(r) {
|
|
1731
|
+
const e = O(r);
|
|
1427
1732
|
if (!e)
|
|
1428
1733
|
throw new Error("Invalid value");
|
|
1429
|
-
return this._commandService.syncExecuteCommand(
|
|
1734
|
+
return this._commandService.syncExecuteCommand(B.id, {
|
|
1430
1735
|
unitId: this._workbook.getUnitId(),
|
|
1431
1736
|
subUnitId: this._worksheet.getSheetId(),
|
|
1432
1737
|
range: {
|
|
@@ -1457,8 +1762,8 @@ let k = class extends he {
|
|
|
1457
1762
|
* console.log(fRange.getValue(true).toPlainText()); // Hello World
|
|
1458
1763
|
* ```
|
|
1459
1764
|
*/
|
|
1460
|
-
setRichTextValueForCell(
|
|
1461
|
-
const e =
|
|
1765
|
+
setRichTextValueForCell(r) {
|
|
1766
|
+
const e = r instanceof P ? r.getData() : r, t = {
|
|
1462
1767
|
unitId: this._workbook.getUnitId(),
|
|
1463
1768
|
subUnitId: this._worksheet.getSheetId(),
|
|
1464
1769
|
range: {
|
|
@@ -1469,7 +1774,7 @@ let k = class extends he {
|
|
|
1469
1774
|
},
|
|
1470
1775
|
value: { p: e }
|
|
1471
1776
|
};
|
|
1472
|
-
return this._commandService.syncExecuteCommand(
|
|
1777
|
+
return this._commandService.syncExecuteCommand(B.id, t), this;
|
|
1473
1778
|
}
|
|
1474
1779
|
/**
|
|
1475
1780
|
* Set the rich text value for the cells in the range.
|
|
@@ -1493,14 +1798,14 @@ let k = class extends he {
|
|
|
1493
1798
|
* console.log(fRange.getValue(true).toPlainText()); // Hello World
|
|
1494
1799
|
* ```
|
|
1495
1800
|
*/
|
|
1496
|
-
setRichTextValues(
|
|
1497
|
-
const e =
|
|
1801
|
+
setRichTextValues(r) {
|
|
1802
|
+
const e = r.map((s) => s.map((o) => o && { p: o instanceof P ? o.getData() : o })), t = De(e, this._range), n = {
|
|
1498
1803
|
unitId: this._workbook.getUnitId(),
|
|
1499
1804
|
subUnitId: this._worksheet.getSheetId(),
|
|
1500
1805
|
range: this._range,
|
|
1501
1806
|
value: t
|
|
1502
1807
|
};
|
|
1503
|
-
return this._commandService.syncExecuteCommand(
|
|
1808
|
+
return this._commandService.syncExecuteCommand(B.id, n), this;
|
|
1504
1809
|
}
|
|
1505
1810
|
/**
|
|
1506
1811
|
* Set the cell wrap of the given range.
|
|
@@ -1516,12 +1821,12 @@ let k = class extends he {
|
|
|
1516
1821
|
* console.log(fRange.getWrap());
|
|
1517
1822
|
* ```
|
|
1518
1823
|
*/
|
|
1519
|
-
setWrap(
|
|
1520
|
-
return this._commandService.syncExecuteCommand(
|
|
1824
|
+
setWrap(r) {
|
|
1825
|
+
return this._commandService.syncExecuteCommand(ie.id, {
|
|
1521
1826
|
unitId: this._workbook.getUnitId(),
|
|
1522
1827
|
subUnitId: this._worksheet.getSheetId(),
|
|
1523
1828
|
range: this._range,
|
|
1524
|
-
value:
|
|
1829
|
+
value: r ? G.WRAP : G.UNSPECIFIED
|
|
1525
1830
|
}), this;
|
|
1526
1831
|
}
|
|
1527
1832
|
/**
|
|
@@ -1537,12 +1842,12 @@ let k = class extends he {
|
|
|
1537
1842
|
* console.log(fRange.getWrapStrategy());
|
|
1538
1843
|
* ```
|
|
1539
1844
|
*/
|
|
1540
|
-
setWrapStrategy(
|
|
1541
|
-
return this._commandService.syncExecuteCommand(
|
|
1845
|
+
setWrapStrategy(r) {
|
|
1846
|
+
return this._commandService.syncExecuteCommand(ie.id, {
|
|
1542
1847
|
unitId: this._workbook.getUnitId(),
|
|
1543
1848
|
subUnitId: this._worksheet.getSheetId(),
|
|
1544
1849
|
range: this._range,
|
|
1545
|
-
value:
|
|
1850
|
+
value: r
|
|
1546
1851
|
}), this;
|
|
1547
1852
|
}
|
|
1548
1853
|
/**
|
|
@@ -1557,12 +1862,12 @@ let k = class extends he {
|
|
|
1557
1862
|
* fRange.setVerticalAlignment('top');
|
|
1558
1863
|
* ```
|
|
1559
1864
|
*/
|
|
1560
|
-
setVerticalAlignment(
|
|
1561
|
-
return this._commandService.syncExecuteCommand(
|
|
1865
|
+
setVerticalAlignment(r) {
|
|
1866
|
+
return this._commandService.syncExecuteCommand(bt.id, {
|
|
1562
1867
|
unitId: this._workbook.getUnitId(),
|
|
1563
1868
|
subUnitId: this._worksheet.getSheetId(),
|
|
1564
1869
|
range: this._range,
|
|
1565
|
-
value:
|
|
1870
|
+
value: ln(r)
|
|
1566
1871
|
}), this;
|
|
1567
1872
|
}
|
|
1568
1873
|
/**
|
|
@@ -1577,12 +1882,12 @@ let k = class extends he {
|
|
|
1577
1882
|
* fRange.setHorizontalAlignment('left');
|
|
1578
1883
|
* ```
|
|
1579
1884
|
*/
|
|
1580
|
-
setHorizontalAlignment(
|
|
1581
|
-
return this._commandService.syncExecuteCommand(
|
|
1885
|
+
setHorizontalAlignment(r) {
|
|
1886
|
+
return this._commandService.syncExecuteCommand(pt.id, {
|
|
1582
1887
|
unitId: this._workbook.getUnitId(),
|
|
1583
1888
|
subUnitId: this._worksheet.getSheetId(),
|
|
1584
1889
|
range: this._range,
|
|
1585
|
-
value:
|
|
1890
|
+
value: gn(r)
|
|
1586
1891
|
}), this;
|
|
1587
1892
|
}
|
|
1588
1893
|
/**
|
|
@@ -1600,9 +1905,9 @@ let k = class extends he {
|
|
|
1600
1905
|
* ]);
|
|
1601
1906
|
* ```
|
|
1602
1907
|
*/
|
|
1603
|
-
setValues(
|
|
1604
|
-
const e =
|
|
1605
|
-
return this._commandService.syncExecuteCommand(
|
|
1908
|
+
setValues(r) {
|
|
1909
|
+
const e = De(r, this._range);
|
|
1910
|
+
return this._commandService.syncExecuteCommand(B.id, {
|
|
1606
1911
|
unitId: this._workbook.getUnitId(),
|
|
1607
1912
|
subUnitId: this._worksheet.getSheetId(),
|
|
1608
1913
|
range: this._range,
|
|
@@ -1621,13 +1926,13 @@ let k = class extends he {
|
|
|
1621
1926
|
* fRange.setFontWeight('bold');
|
|
1622
1927
|
* ```
|
|
1623
1928
|
*/
|
|
1624
|
-
setFontWeight(
|
|
1929
|
+
setFontWeight(r) {
|
|
1625
1930
|
let e;
|
|
1626
|
-
if (
|
|
1931
|
+
if (r === "bold")
|
|
1627
1932
|
e = g.TRUE;
|
|
1628
|
-
else if (
|
|
1933
|
+
else if (r === "normal")
|
|
1629
1934
|
e = g.FALSE;
|
|
1630
|
-
else if (
|
|
1935
|
+
else if (r === null)
|
|
1631
1936
|
e = null;
|
|
1632
1937
|
else
|
|
1633
1938
|
throw new Error("Invalid fontWeight");
|
|
@@ -1640,7 +1945,7 @@ let k = class extends he {
|
|
|
1640
1945
|
range: this._range,
|
|
1641
1946
|
style: t
|
|
1642
1947
|
};
|
|
1643
|
-
return this._commandService.syncExecuteCommand(
|
|
1948
|
+
return this._commandService.syncExecuteCommand(b.id, n), this;
|
|
1644
1949
|
}
|
|
1645
1950
|
/**
|
|
1646
1951
|
* Sets the font style for the given range ('italic' or 'normal').
|
|
@@ -1654,13 +1959,13 @@ let k = class extends he {
|
|
|
1654
1959
|
* fRange.setFontStyle('italic');
|
|
1655
1960
|
* ```
|
|
1656
1961
|
*/
|
|
1657
|
-
setFontStyle(
|
|
1962
|
+
setFontStyle(r) {
|
|
1658
1963
|
let e;
|
|
1659
|
-
if (
|
|
1964
|
+
if (r === "italic")
|
|
1660
1965
|
e = g.TRUE;
|
|
1661
|
-
else if (
|
|
1966
|
+
else if (r === "normal")
|
|
1662
1967
|
e = g.FALSE;
|
|
1663
|
-
else if (
|
|
1968
|
+
else if (r === null)
|
|
1664
1969
|
e = null;
|
|
1665
1970
|
else
|
|
1666
1971
|
throw new Error("Invalid fontStyle");
|
|
@@ -1673,7 +1978,7 @@ let k = class extends he {
|
|
|
1673
1978
|
range: this._range,
|
|
1674
1979
|
style: t
|
|
1675
1980
|
};
|
|
1676
|
-
return this._commandService.syncExecuteCommand(
|
|
1981
|
+
return this._commandService.syncExecuteCommand(b.id, n), this;
|
|
1677
1982
|
}
|
|
1678
1983
|
/**
|
|
1679
1984
|
* Sets the font line style of the given range ('underline', 'line-through', or 'none').
|
|
@@ -1687,22 +1992,22 @@ let k = class extends he {
|
|
|
1687
1992
|
* fRange.setFontLine('underline');
|
|
1688
1993
|
* ```
|
|
1689
1994
|
*/
|
|
1690
|
-
setFontLine(
|
|
1691
|
-
if (
|
|
1995
|
+
setFontLine(r) {
|
|
1996
|
+
if (r === "underline")
|
|
1692
1997
|
this._setFontUnderline({
|
|
1693
1998
|
s: g.TRUE
|
|
1694
1999
|
});
|
|
1695
|
-
else if (
|
|
2000
|
+
else if (r === "line-through")
|
|
1696
2001
|
this._setFontStrikethrough({
|
|
1697
2002
|
s: g.TRUE
|
|
1698
2003
|
});
|
|
1699
|
-
else if (
|
|
2004
|
+
else if (r === "none")
|
|
1700
2005
|
this._setFontUnderline({
|
|
1701
2006
|
s: g.FALSE
|
|
1702
2007
|
}), this._setFontStrikethrough({
|
|
1703
2008
|
s: g.FALSE
|
|
1704
2009
|
});
|
|
1705
|
-
else if (
|
|
2010
|
+
else if (r === null)
|
|
1706
2011
|
this._setFontUnderline(null), this._setFontStrikethrough(null);
|
|
1707
2012
|
else
|
|
1708
2013
|
throw new Error("Invalid fontLine");
|
|
@@ -1713,34 +2018,34 @@ let k = class extends he {
|
|
|
1713
2018
|
* @param {ITextDecoration|null} value The font underline style of the given ITextDecoration; a null value resets the font underline style
|
|
1714
2019
|
* @returns {void}
|
|
1715
2020
|
*/
|
|
1716
|
-
_setFontUnderline(
|
|
2021
|
+
_setFontUnderline(r) {
|
|
1717
2022
|
const e = {
|
|
1718
2023
|
type: "ul",
|
|
1719
|
-
value:
|
|
2024
|
+
value: r
|
|
1720
2025
|
}, t = {
|
|
1721
2026
|
unitId: this._workbook.getUnitId(),
|
|
1722
2027
|
subUnitId: this._worksheet.getSheetId(),
|
|
1723
2028
|
range: this._range,
|
|
1724
2029
|
style: e
|
|
1725
2030
|
};
|
|
1726
|
-
this._commandService.syncExecuteCommand(
|
|
2031
|
+
this._commandService.syncExecuteCommand(b.id, t);
|
|
1727
2032
|
}
|
|
1728
2033
|
/**
|
|
1729
2034
|
* Sets the font strikethrough style of the given ITextDecoration
|
|
1730
2035
|
* @param {ITextDecoration|null} value The font strikethrough style of the given ITextDecoration; a null value resets the font strikethrough style
|
|
1731
2036
|
* @returns {void}
|
|
1732
2037
|
*/
|
|
1733
|
-
_setFontStrikethrough(
|
|
2038
|
+
_setFontStrikethrough(r) {
|
|
1734
2039
|
const e = {
|
|
1735
2040
|
type: "st",
|
|
1736
|
-
value:
|
|
2041
|
+
value: r
|
|
1737
2042
|
}, t = {
|
|
1738
2043
|
unitId: this._workbook.getUnitId(),
|
|
1739
2044
|
subUnitId: this._worksheet.getSheetId(),
|
|
1740
2045
|
range: this._range,
|
|
1741
2046
|
style: e
|
|
1742
2047
|
};
|
|
1743
|
-
this._commandService.syncExecuteCommand(
|
|
2048
|
+
this._commandService.syncExecuteCommand(b.id, t);
|
|
1744
2049
|
}
|
|
1745
2050
|
/**
|
|
1746
2051
|
* Sets the font family, such as "Arial" or "Helvetica".
|
|
@@ -1754,17 +2059,17 @@ let k = class extends he {
|
|
|
1754
2059
|
* fRange.setFontFamily('Arial');
|
|
1755
2060
|
* ```
|
|
1756
2061
|
*/
|
|
1757
|
-
setFontFamily(
|
|
2062
|
+
setFontFamily(r) {
|
|
1758
2063
|
const e = {
|
|
1759
2064
|
type: "ff",
|
|
1760
|
-
value:
|
|
2065
|
+
value: r
|
|
1761
2066
|
}, t = {
|
|
1762
2067
|
unitId: this._workbook.getUnitId(),
|
|
1763
2068
|
subUnitId: this._worksheet.getSheetId(),
|
|
1764
2069
|
range: this._range,
|
|
1765
2070
|
style: e
|
|
1766
2071
|
};
|
|
1767
|
-
return this._commandService.syncExecuteCommand(
|
|
2072
|
+
return this._commandService.syncExecuteCommand(b.id, t), this;
|
|
1768
2073
|
}
|
|
1769
2074
|
/**
|
|
1770
2075
|
* Sets the font size, with the size being the point size to use.
|
|
@@ -1778,17 +2083,17 @@ let k = class extends he {
|
|
|
1778
2083
|
* fRange.setFontSize(24);
|
|
1779
2084
|
* ```
|
|
1780
2085
|
*/
|
|
1781
|
-
setFontSize(
|
|
2086
|
+
setFontSize(r) {
|
|
1782
2087
|
const e = {
|
|
1783
2088
|
type: "fs",
|
|
1784
|
-
value:
|
|
2089
|
+
value: r
|
|
1785
2090
|
}, t = {
|
|
1786
2091
|
unitId: this._workbook.getUnitId(),
|
|
1787
2092
|
subUnitId: this._worksheet.getSheetId(),
|
|
1788
2093
|
range: this._range,
|
|
1789
2094
|
style: e
|
|
1790
2095
|
};
|
|
1791
|
-
return this._commandService.syncExecuteCommand(
|
|
2096
|
+
return this._commandService.syncExecuteCommand(b.id, t), this;
|
|
1792
2097
|
}
|
|
1793
2098
|
/**
|
|
1794
2099
|
* Sets the font color in CSS notation (such as '#ffffff' or 'white').
|
|
@@ -1802,17 +2107,17 @@ let k = class extends he {
|
|
|
1802
2107
|
* fRange.setFontColor('#ff0000');
|
|
1803
2108
|
* ```
|
|
1804
2109
|
*/
|
|
1805
|
-
setFontColor(
|
|
2110
|
+
setFontColor(r) {
|
|
1806
2111
|
const t = {
|
|
1807
2112
|
type: "cl",
|
|
1808
|
-
value:
|
|
2113
|
+
value: r === null ? null : { rgb: r }
|
|
1809
2114
|
}, n = {
|
|
1810
2115
|
unitId: this._workbook.getUnitId(),
|
|
1811
2116
|
subUnitId: this._worksheet.getSheetId(),
|
|
1812
2117
|
range: this._range,
|
|
1813
2118
|
style: t
|
|
1814
2119
|
};
|
|
1815
|
-
return this._commandService.syncExecuteCommand(
|
|
2120
|
+
return this._commandService.syncExecuteCommand(b.id, n), this;
|
|
1816
2121
|
}
|
|
1817
2122
|
// #endregion editing
|
|
1818
2123
|
//#region Merge cell
|
|
@@ -1829,9 +2134,9 @@ let k = class extends he {
|
|
|
1829
2134
|
* console.log(fRange.isMerged());
|
|
1830
2135
|
* ```
|
|
1831
2136
|
*/
|
|
1832
|
-
merge(
|
|
2137
|
+
merge(r = !0) {
|
|
1833
2138
|
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId();
|
|
1834
|
-
return
|
|
2139
|
+
return Q(this._injector, e, t, [this._range], r), this;
|
|
1835
2140
|
}
|
|
1836
2141
|
/**
|
|
1837
2142
|
* Merges cells in a range horizontally.
|
|
@@ -1851,9 +2156,9 @@ let k = class extends he {
|
|
|
1851
2156
|
* });
|
|
1852
2157
|
* ```
|
|
1853
2158
|
*/
|
|
1854
|
-
mergeAcross(
|
|
1855
|
-
const e =
|
|
1856
|
-
return
|
|
2159
|
+
mergeAcross(r = !0) {
|
|
2160
|
+
const e = Ce([this._range], M.ROWS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
2161
|
+
return Q(this._injector, t, n, e, r), this;
|
|
1857
2162
|
}
|
|
1858
2163
|
/**
|
|
1859
2164
|
* Merges cells in a range vertically.
|
|
@@ -1873,9 +2178,9 @@ let k = class extends he {
|
|
|
1873
2178
|
* });
|
|
1874
2179
|
* ```
|
|
1875
2180
|
*/
|
|
1876
|
-
mergeVertically(
|
|
1877
|
-
const e =
|
|
1878
|
-
return
|
|
2181
|
+
mergeVertically(r = !0) {
|
|
2182
|
+
const e = Ce([this._range], M.COLUMNS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
2183
|
+
return Q(this._injector, t, n, e, r), this;
|
|
1879
2184
|
}
|
|
1880
2185
|
/**
|
|
1881
2186
|
* Returns true if cells in the current range overlap a merged cell.
|
|
@@ -1891,8 +2196,8 @@ let k = class extends he {
|
|
|
1891
2196
|
* ```
|
|
1892
2197
|
*/
|
|
1893
2198
|
isPartOfMerge() {
|
|
1894
|
-
const { startRow:
|
|
1895
|
-
return this._worksheet.getMergedCellRange(
|
|
2199
|
+
const { startRow: r, startColumn: e, endRow: t, endColumn: n } = this._range;
|
|
2200
|
+
return this._worksheet.getMergedCellRange(r, e, t, n).length > 0;
|
|
1896
2201
|
}
|
|
1897
2202
|
/**
|
|
1898
2203
|
* Break all horizontally- or vertically-merged cells contained within the range list into individual cells again.
|
|
@@ -1910,7 +2215,7 @@ let k = class extends he {
|
|
|
1910
2215
|
* ```
|
|
1911
2216
|
*/
|
|
1912
2217
|
breakApart() {
|
|
1913
|
-
return this._commandService.syncExecuteCommand(
|
|
2218
|
+
return this._commandService.syncExecuteCommand(Et.id, { ranges: [this._range] }), this;
|
|
1914
2219
|
}
|
|
1915
2220
|
//#endregion
|
|
1916
2221
|
/**
|
|
@@ -1928,10 +2233,10 @@ let k = class extends he {
|
|
|
1928
2233
|
* });
|
|
1929
2234
|
* ```
|
|
1930
2235
|
*/
|
|
1931
|
-
forEach(
|
|
1932
|
-
const { startColumn: e, startRow: t, endColumn: n, endRow:
|
|
1933
|
-
this._worksheet.getMatrixWithMergedCells(t, e,
|
|
1934
|
-
|
|
2236
|
+
forEach(r) {
|
|
2237
|
+
const { startColumn: e, startRow: t, endColumn: n, endRow: s } = this._range;
|
|
2238
|
+
this._worksheet.getMatrixWithMergedCells(t, e, s, n).forValue((o, i, a) => {
|
|
2239
|
+
r(o, i, a);
|
|
1935
2240
|
});
|
|
1936
2241
|
}
|
|
1937
2242
|
/**
|
|
@@ -1945,8 +2250,8 @@ let k = class extends he {
|
|
|
1945
2250
|
* console.log(fRange.getA1Notation()); // A1:B2
|
|
1946
2251
|
* ```
|
|
1947
2252
|
*/
|
|
1948
|
-
getA1Notation(
|
|
1949
|
-
return
|
|
2253
|
+
getA1Notation(r) {
|
|
2254
|
+
return r ? sn(this._worksheet.getName(), this._range) : _e(this._range);
|
|
1950
2255
|
}
|
|
1951
2256
|
/**
|
|
1952
2257
|
* Sets the specified range as the active range, with the top left cell in the range as the current cell.
|
|
@@ -1960,7 +2265,7 @@ let k = class extends he {
|
|
|
1960
2265
|
* ```
|
|
1961
2266
|
*/
|
|
1962
2267
|
activate() {
|
|
1963
|
-
return this._injector.createInstance(
|
|
2268
|
+
return this._injector.createInstance(S, this._workbook).setActiveRange(this), this;
|
|
1964
2269
|
}
|
|
1965
2270
|
/**
|
|
1966
2271
|
* Sets the specified cell as the current cell.
|
|
@@ -1972,18 +2277,51 @@ let k = class extends he {
|
|
|
1972
2277
|
* ```ts
|
|
1973
2278
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1974
2279
|
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
2280
|
+
*
|
|
2281
|
+
* // Set the range A1:B2 as the active range, default active cell is A1
|
|
1975
2282
|
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1976
2283
|
* fRange.activate();
|
|
2284
|
+
* console.log(fWorksheet.getActiveRange().getA1Notation()); // A1:B2
|
|
2285
|
+
* console.log(fWorksheet.getActiveCell().getA1Notation()); // A1
|
|
2286
|
+
*
|
|
2287
|
+
* // Set the cell B2 as the active cell
|
|
2288
|
+
* // Because B2 is in the active range A1:B2, the active range will not change, and the active cell will be changed to B2
|
|
1977
2289
|
* const cell = fWorksheet.getRange('B2');
|
|
1978
|
-
* cell.activateAsCurrentCell();
|
|
1979
|
-
* console.log(fWorksheet.getActiveRange().getA1Notation()); // B2
|
|
2290
|
+
* cell.activateAsCurrentCell();
|
|
2291
|
+
* console.log(fWorksheet.getActiveRange().getA1Notation()); // A1:B2
|
|
2292
|
+
* console.log(fWorksheet.getActiveCell().getA1Notation()); // B2
|
|
2293
|
+
*
|
|
2294
|
+
* // Set the cell C3 as the active cell
|
|
2295
|
+
* // Because C3 is not in the active range A1:B2, a new active range C3:C3 will be created, and the active cell will be changed to C3
|
|
2296
|
+
* const cell2 = fWorksheet.getRange('C3');
|
|
2297
|
+
* cell2.activateAsCurrentCell();
|
|
2298
|
+
* console.log(fWorksheet.getActiveRange().getA1Notation()); // C3:C3
|
|
2299
|
+
* console.log(fWorksheet.getActiveCell().getA1Notation()); // C3
|
|
1980
2300
|
* ```
|
|
1981
2301
|
*/
|
|
1982
2302
|
activateAsCurrentCell() {
|
|
1983
|
-
const
|
|
1984
|
-
if (
|
|
2303
|
+
const r = this._worksheet.getMergedCell(this._range.startRow, this._range.startColumn);
|
|
2304
|
+
if (r && N.equals(r, this._range) || !r && this._range.startRow === this._range.endRow && this._range.startColumn === this._range.endColumn) {
|
|
2305
|
+
const n = this._injector.createInstance(S, this._workbook).getActiveRange();
|
|
2306
|
+
if (!n || n.getUnitId() !== this.getUnitId() || n.getSheetId() !== this.getSheetId())
|
|
2307
|
+
return this.activate();
|
|
2308
|
+
if (N.contains(n.getRange(), this._range)) {
|
|
2309
|
+
const s = {
|
|
2310
|
+
unitId: this.getUnitId(),
|
|
2311
|
+
subUnitId: this.getSheetId(),
|
|
2312
|
+
selections: [
|
|
2313
|
+
{
|
|
2314
|
+
range: n.getRange(),
|
|
2315
|
+
primary: $(this.getRange(), this._worksheet),
|
|
2316
|
+
style: null
|
|
2317
|
+
}
|
|
2318
|
+
]
|
|
2319
|
+
};
|
|
2320
|
+
return this._commandService.syncExecuteCommand(me.id, s), this;
|
|
2321
|
+
}
|
|
1985
2322
|
return this.activate();
|
|
1986
|
-
|
|
2323
|
+
} else
|
|
2324
|
+
throw new Error("The range is not a single cell");
|
|
1987
2325
|
}
|
|
1988
2326
|
/**
|
|
1989
2327
|
* Splits a column of text into multiple columns based on a custom specified delimiter.
|
|
@@ -2019,14 +2357,14 @@ let k = class extends he {
|
|
|
2019
2357
|
* fRange.splitTextToColumns(true, univerAPI.Enum.SplitDelimiterType.Custom, '#');
|
|
2020
2358
|
* ```
|
|
2021
2359
|
*/
|
|
2022
|
-
splitTextToColumns(
|
|
2023
|
-
this._commandService.syncExecuteCommand(
|
|
2360
|
+
splitTextToColumns(r, e, t) {
|
|
2361
|
+
this._commandService.syncExecuteCommand(yt.id, {
|
|
2024
2362
|
unitId: this._workbook.getUnitId(),
|
|
2025
2363
|
subUnitId: this._worksheet.getSheetId(),
|
|
2026
2364
|
range: this._range,
|
|
2027
2365
|
delimiter: e,
|
|
2028
2366
|
customDelimiter: t,
|
|
2029
|
-
treatMultipleDelimitersAsOne:
|
|
2367
|
+
treatMultipleDelimitersAsOne: r
|
|
2030
2368
|
});
|
|
2031
2369
|
}
|
|
2032
2370
|
/**
|
|
@@ -2040,16 +2378,16 @@ let k = class extends he {
|
|
|
2040
2378
|
* fRange.useThemeStyle('default');
|
|
2041
2379
|
* ```
|
|
2042
2380
|
*/
|
|
2043
|
-
useThemeStyle(
|
|
2044
|
-
if (
|
|
2381
|
+
useThemeStyle(r) {
|
|
2382
|
+
if (r == null) {
|
|
2045
2383
|
const e = this.getUsedThemeStyle();
|
|
2046
2384
|
e && this.removeThemeStyle(e);
|
|
2047
2385
|
} else
|
|
2048
|
-
this._commandService.syncExecuteCommand(
|
|
2386
|
+
this._commandService.syncExecuteCommand(Ut.id, {
|
|
2049
2387
|
unitId: this._workbook.getUnitId(),
|
|
2050
2388
|
subUnitId: this._worksheet.getSheetId(),
|
|
2051
2389
|
range: this._range,
|
|
2052
|
-
themeName:
|
|
2390
|
+
themeName: r
|
|
2053
2391
|
});
|
|
2054
2392
|
}
|
|
2055
2393
|
/**
|
|
@@ -2063,12 +2401,12 @@ let k = class extends he {
|
|
|
2063
2401
|
* fRange.removeThemeStyle('default');
|
|
2064
2402
|
* ```
|
|
2065
2403
|
*/
|
|
2066
|
-
removeThemeStyle(
|
|
2067
|
-
this._commandService.syncExecuteCommand(
|
|
2404
|
+
removeThemeStyle(r) {
|
|
2405
|
+
this._commandService.syncExecuteCommand(xt.id, {
|
|
2068
2406
|
unitId: this._workbook.getUnitId(),
|
|
2069
2407
|
subUnitId: this._worksheet.getSheetId(),
|
|
2070
2408
|
range: this._range,
|
|
2071
|
-
themeName:
|
|
2409
|
+
themeName: r
|
|
2072
2410
|
});
|
|
2073
2411
|
}
|
|
2074
2412
|
/**
|
|
@@ -2085,26 +2423,372 @@ let k = class extends he {
|
|
|
2085
2423
|
* ```
|
|
2086
2424
|
*/
|
|
2087
2425
|
getUsedThemeStyle() {
|
|
2088
|
-
return this._injector.get(
|
|
2426
|
+
return this._injector.get(qe).getAppliedRangeThemeStyle({
|
|
2427
|
+
unitId: this._workbook.getUnitId(),
|
|
2428
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
2429
|
+
range: this._range
|
|
2430
|
+
});
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Clears content and formatting information of the range. Or Optionally clears only the contents or only the formatting.
|
|
2434
|
+
* @param {IFacadeClearOptions} [options] - Options for clearing the range. If not provided, the contents and formatting are cleared both.
|
|
2435
|
+
* @param {boolean} [options.contentsOnly] - If true, the contents of the range are cleared. If false, the contents and formatting are cleared. Default is false.
|
|
2436
|
+
* @param {boolean} [options.formatOnly] - If true, the formatting of the range is cleared. If false, the contents and formatting are cleared. Default is false.
|
|
2437
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2438
|
+
* @example
|
|
2439
|
+
* ```ts
|
|
2440
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2441
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2442
|
+
* const fRange = fWorkSheet.getRange('A1:D10');
|
|
2443
|
+
*
|
|
2444
|
+
* // clear the content and format of the range A1:D10
|
|
2445
|
+
* fRange.clear();
|
|
2446
|
+
*
|
|
2447
|
+
* // clear the content only of the range A1:D10
|
|
2448
|
+
* fRange.clear({ contentsOnly: true });
|
|
2449
|
+
* ```
|
|
2450
|
+
*/
|
|
2451
|
+
clear(r) {
|
|
2452
|
+
return r && r.contentsOnly && !r.formatOnly ? this.clearContent() : r && r.formatOnly && !r.contentsOnly ? this.clearFormat() : (this._commandService.syncExecuteCommand(Ke.id, {
|
|
2453
|
+
unitId: this._workbook.getUnitId(),
|
|
2454
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
2455
|
+
ranges: [this._range],
|
|
2456
|
+
options: r
|
|
2457
|
+
}), this);
|
|
2458
|
+
}
|
|
2459
|
+
/**
|
|
2460
|
+
* Clears content of the range, while preserving formatting information.
|
|
2461
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2462
|
+
* @example
|
|
2463
|
+
* ```typescript
|
|
2464
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2465
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2466
|
+
* const fRange = fWorkSheet.getRange('A1:D10');
|
|
2467
|
+
*
|
|
2468
|
+
* // clear the content only of the range A1:D10
|
|
2469
|
+
* fRange.clearContent();
|
|
2470
|
+
* ```
|
|
2471
|
+
*/
|
|
2472
|
+
clearContent() {
|
|
2473
|
+
return this._commandService.syncExecuteCommand(Ye.id, {
|
|
2474
|
+
unitId: this._workbook.getUnitId(),
|
|
2475
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
2476
|
+
ranges: [this._range]
|
|
2477
|
+
}), this;
|
|
2478
|
+
}
|
|
2479
|
+
/**
|
|
2480
|
+
* Clears formatting information of the range, while preserving contents.
|
|
2481
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2482
|
+
* @example
|
|
2483
|
+
* ```typescript
|
|
2484
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2485
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2486
|
+
* const fRange = fWorkSheet.getRange('A1:D10');
|
|
2487
|
+
* // clear the format only of the range A1:D10
|
|
2488
|
+
* fRange.clearFormat();
|
|
2489
|
+
* ```
|
|
2490
|
+
*/
|
|
2491
|
+
clearFormat() {
|
|
2492
|
+
return this._commandService.syncExecuteCommand(Je.id, {
|
|
2089
2493
|
unitId: this._workbook.getUnitId(),
|
|
2090
2494
|
subUnitId: this._worksheet.getSheetId(),
|
|
2495
|
+
ranges: [this._range]
|
|
2496
|
+
}), this;
|
|
2497
|
+
}
|
|
2498
|
+
/**
|
|
2499
|
+
* Inserts empty cells into this range. Existing data in the sheet along the provided dimension is shifted away from the inserted range.
|
|
2500
|
+
* @param {Dimension} shiftDimension - The dimension along which to shift existing data.
|
|
2501
|
+
* @example
|
|
2502
|
+
* ```ts
|
|
2503
|
+
* // Assume the active sheet empty sheet.
|
|
2504
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2505
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
2506
|
+
* const values = [
|
|
2507
|
+
* [1, 2, 3, 4],
|
|
2508
|
+
* [2, 3, 4, 5],
|
|
2509
|
+
* [3, 4, 5, 6],
|
|
2510
|
+
* [4, 5, 6, 7],
|
|
2511
|
+
* [5, 6, 7, 8],
|
|
2512
|
+
* ];
|
|
2513
|
+
*
|
|
2514
|
+
* // Set the range A1:D5 with some values, the range A1:D5 will be:
|
|
2515
|
+
* // 1 | 2 | 3 | 4
|
|
2516
|
+
* // 2 | 3 | 4 | 5
|
|
2517
|
+
* // 3 | 4 | 5 | 6
|
|
2518
|
+
* // 4 | 5 | 6 | 7
|
|
2519
|
+
* // 5 | 6 | 7 | 8
|
|
2520
|
+
* const fRange = fWorksheet.getRange('A1:D5');
|
|
2521
|
+
* fRange.setValues(values);
|
|
2522
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]
|
|
2523
|
+
*
|
|
2524
|
+
* // Insert the empty cells into the range A1:B2 along the columns dimension, the range A1:D5 will be:
|
|
2525
|
+
* // | | 1 | 2
|
|
2526
|
+
* // | | 2 | 3
|
|
2527
|
+
* // 3 | 4 | 5 | 6
|
|
2528
|
+
* // 4 | 5 | 6 | 7
|
|
2529
|
+
* // 5 | 6 | 7 | 8
|
|
2530
|
+
* const fRange2 = fWorksheet.getRange('A1:B2');
|
|
2531
|
+
* fRange2.insertCells(univerAPI.Enum.Dimension.COLUMNS);
|
|
2532
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[null, null, 1, 2], [null, null, 2, 3], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]
|
|
2533
|
+
*
|
|
2534
|
+
* // Set the range A1:D5 values again, the range A1:D5 will be:
|
|
2535
|
+
* // 1 | 2 | 3 | 4
|
|
2536
|
+
* // 2 | 3 | 4 | 5
|
|
2537
|
+
* // 3 | 4 | 5 | 6
|
|
2538
|
+
* // 4 | 5 | 6 | 7
|
|
2539
|
+
* // 5 | 6 | 7 | 8
|
|
2540
|
+
* fRange.setValues(values);
|
|
2541
|
+
*
|
|
2542
|
+
* // Insert the empty cells into the range A1:B2 along the rows dimension, the range A1:D5 will be:
|
|
2543
|
+
* // | | 3 | 4
|
|
2544
|
+
* // | | 4 | 5
|
|
2545
|
+
* // 1 | 2 | 5 | 6
|
|
2546
|
+
* // 2 | 3 | 6 | 7
|
|
2547
|
+
* // 3 | 4 | 7 | 8
|
|
2548
|
+
* const fRange3 = fWorksheet.getRange('A1:B2');
|
|
2549
|
+
* fRange3.insertCells(univerAPI.Enum.Dimension.ROWS);
|
|
2550
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[null, null, 3, 4], [null, null, 4, 5], [1, 2, 5, 6], [2, 3, 6, 7], [3, 4, 7, 8]]
|
|
2551
|
+
* ```
|
|
2552
|
+
*/
|
|
2553
|
+
insertCells(r) {
|
|
2554
|
+
r === M.ROWS ? this._commandService.executeCommand(Pt.id, {
|
|
2555
|
+
range: this._range
|
|
2556
|
+
}) : this._commandService.executeCommand(Mt.id, {
|
|
2557
|
+
range: this._range
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2560
|
+
/**
|
|
2561
|
+
* Deletes this range of cells. Existing data in the sheet along the provided dimension is shifted towards the deleted range.
|
|
2562
|
+
* @param {Dimension} shiftDimension - The dimension along which to shift existing data.
|
|
2563
|
+
* @example
|
|
2564
|
+
* ```ts
|
|
2565
|
+
* // Assume the active sheet empty sheet.
|
|
2566
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2567
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
2568
|
+
* const values = [
|
|
2569
|
+
* [1, 2, 3, 4],
|
|
2570
|
+
* [2, 3, 4, 5],
|
|
2571
|
+
* [3, 4, 5, 6],
|
|
2572
|
+
* [4, 5, 6, 7],
|
|
2573
|
+
* [5, 6, 7, 8],
|
|
2574
|
+
* ];
|
|
2575
|
+
*
|
|
2576
|
+
* // Set the range A1:D5 with some values, the range A1:D5 will be:
|
|
2577
|
+
* // 1 | 2 | 3 | 4
|
|
2578
|
+
* // 2 | 3 | 4 | 5
|
|
2579
|
+
* // 3 | 4 | 5 | 6
|
|
2580
|
+
* // 4 | 5 | 6 | 7
|
|
2581
|
+
* // 5 | 6 | 7 | 8
|
|
2582
|
+
* const fRange = fWorksheet.getRange('A1:D5');
|
|
2583
|
+
* fRange.setValues(values);
|
|
2584
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]
|
|
2585
|
+
*
|
|
2586
|
+
* // Delete the range A1:B2 along the columns dimension, the range A1:D5 will be:
|
|
2587
|
+
* // 3 | 4 | |
|
|
2588
|
+
* // 4 | 5 | |
|
|
2589
|
+
* // 3 | 4 | 5 | 6
|
|
2590
|
+
* // 4 | 5 | 6 | 7
|
|
2591
|
+
* // 5 | 6 | 7 | 8
|
|
2592
|
+
* const fRange2 = fWorksheet.getRange('A1:B2');
|
|
2593
|
+
* fRange2.deleteCells(univerAPI.Enum.Dimension.COLUMNS);
|
|
2594
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[3, 4, null, null], [4, 5, null, null], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]
|
|
2595
|
+
*
|
|
2596
|
+
* // Set the range A1:D5 values again, the range A1:D5 will be:
|
|
2597
|
+
* // 1 | 2 | 3 | 4
|
|
2598
|
+
* // 2 | 3 | 4 | 5
|
|
2599
|
+
* // 3 | 4 | 5 | 6
|
|
2600
|
+
* // 4 | 5 | 6 | 7
|
|
2601
|
+
* // 5 | 6 | 7 | 8
|
|
2602
|
+
* fRange.setValues(values);
|
|
2603
|
+
*
|
|
2604
|
+
* // Delete the range A1:B2 along the rows dimension, the range A1:D5 will be:
|
|
2605
|
+
* // 3 | 4 | 3 | 4
|
|
2606
|
+
* // 4 | 5 | 4 | 5
|
|
2607
|
+
* // 5 | 6 | 5 | 6
|
|
2608
|
+
* // | | 6 | 7
|
|
2609
|
+
* // | | 7 | 8
|
|
2610
|
+
* const fRange3 = fWorksheet.getRange('A1:B2');
|
|
2611
|
+
* fRange3.deleteCells(univerAPI.Enum.Dimension.ROWS);
|
|
2612
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[3, 4, 3, 4], [4, 5, 4, 5], [5, 6, 5, 6], [null, null, 6, 7], [null, null, 7, 8]]
|
|
2613
|
+
* ```
|
|
2614
|
+
*/
|
|
2615
|
+
deleteCells(r) {
|
|
2616
|
+
r === M.ROWS ? this._commandService.executeCommand(Nt.id, {
|
|
2617
|
+
range: this._range
|
|
2618
|
+
}) : this._commandService.executeCommand(Tt.id, {
|
|
2091
2619
|
range: this._range
|
|
2092
2620
|
});
|
|
2093
2621
|
}
|
|
2622
|
+
/**
|
|
2623
|
+
* Returns a copy of the range expanded `Direction.UP` and `Direction.DOWN` if the specified dimension is `Dimension.ROWS`, or `Direction.NEXT` and `Direction.PREVIOUS` if the dimension is `Dimension.COLUMNS`.
|
|
2624
|
+
* The expansion of the range is based on detecting data next to the range that is organized like a table.
|
|
2625
|
+
* The expanded range covers all adjacent cells with data in them along the specified dimension including the table boundaries.
|
|
2626
|
+
* If the original range is surrounded by empty cells along the specified dimension, the range itself is returned.
|
|
2627
|
+
* @param {Dimension} [dimension] - The dimension along which to expand the range. If not provided, the range will be expanded in both dimensions.
|
|
2628
|
+
* @returns {FRange} The range's data region or a range covering each column or each row spanned by the original range.
|
|
2629
|
+
* @example
|
|
2630
|
+
* ```ts
|
|
2631
|
+
* // Assume the active sheet is a new sheet with no data.
|
|
2632
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2633
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
2634
|
+
*
|
|
2635
|
+
* // Set the range A1:D4 with some values, the range A1:D4 will be:
|
|
2636
|
+
* // | | |
|
|
2637
|
+
* // | | 100 |
|
|
2638
|
+
* // | 100 | | 100
|
|
2639
|
+
* // | | 100 |
|
|
2640
|
+
* fWorksheet.getRange('C2').setValue(100);
|
|
2641
|
+
* fWorksheet.getRange('B3').setValue(100);
|
|
2642
|
+
* fWorksheet.getRange('D3').setValue(100);
|
|
2643
|
+
* fWorksheet.getRange('C4').setValue(100);
|
|
2644
|
+
*
|
|
2645
|
+
* // Get C3 data region along the rows dimension, the range will be C2:D4
|
|
2646
|
+
* const range = fWorksheet.getRange('C3').getDataRegion(univerAPI.Enum.Dimension.ROWS);
|
|
2647
|
+
* console.log(range.getA1Notation()); // C2:C4
|
|
2648
|
+
*
|
|
2649
|
+
* // Get C3 data region along the columns dimension, the range will be B3:D3
|
|
2650
|
+
* const range2 = fWorksheet.getRange('C3').getDataRegion(univerAPI.Enum.Dimension.COLUMNS);
|
|
2651
|
+
* console.log(range2.getA1Notation()); // B3:D3
|
|
2652
|
+
*
|
|
2653
|
+
* // Get C3 data region along the both dimension, the range will be B2:D4
|
|
2654
|
+
* const range3 = fWorksheet.getRange('C3').getDataRegion();
|
|
2655
|
+
* console.log(range3.getA1Notation()); // B2:D4
|
|
2656
|
+
* ```
|
|
2657
|
+
*/
|
|
2658
|
+
// eslint-disable-next-line complexity
|
|
2659
|
+
getDataRegion(r) {
|
|
2660
|
+
const { startRow: e, startColumn: t, endRow: n, endColumn: s } = this._range, o = this._worksheet.getMaxRows(), i = this._worksheet.getMaxColumns(), a = this._worksheet.getCellMatrix();
|
|
2661
|
+
let h = e, d = t, c = n, C = s;
|
|
2662
|
+
if (r !== M.COLUMNS) {
|
|
2663
|
+
let _ = !1, p = !1;
|
|
2664
|
+
for (let f = t; f <= s && (e > 0 && !D(a.getValue(e - 1, f)) && (_ = !0), n < o - 1 && !D(a.getValue(n + 1, f)) && (p = !0), !(_ && p)); f++)
|
|
2665
|
+
;
|
|
2666
|
+
_ && (h = e - 1), p && (c = n + 1);
|
|
2667
|
+
}
|
|
2668
|
+
if (r !== M.ROWS) {
|
|
2669
|
+
let _ = !1, p = !1;
|
|
2670
|
+
for (let f = e; f <= n && (t > 0 && !D(a.getValue(f, t - 1)) && (_ = !0), s < i - 1 && !D(a.getValue(f, s + 1)) && (p = !0), !(_ && p)); f++)
|
|
2671
|
+
;
|
|
2672
|
+
_ && (d = t - 1), p && (C = s + 1);
|
|
2673
|
+
}
|
|
2674
|
+
return this._injector.createInstance(m, this._workbook, this._worksheet, {
|
|
2675
|
+
startRow: h,
|
|
2676
|
+
startColumn: d,
|
|
2677
|
+
endRow: c,
|
|
2678
|
+
endColumn: C
|
|
2679
|
+
});
|
|
2680
|
+
}
|
|
2681
|
+
/**
|
|
2682
|
+
* Returns true if the range is totally blank.
|
|
2683
|
+
* @returns {boolean} true if the range is blank; false otherwise.
|
|
2684
|
+
* @example
|
|
2685
|
+
* ```ts
|
|
2686
|
+
* // Assume the active sheet is a new sheet with no data.
|
|
2687
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2688
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
2689
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
2690
|
+
* console.log(fRange.isBlank()); // true
|
|
2691
|
+
*
|
|
2692
|
+
* // Set the range A1:B2 with some values
|
|
2693
|
+
* fRange.setValueForCell(123);
|
|
2694
|
+
* console.log(fRange.isBlank()); // false
|
|
2695
|
+
* ```
|
|
2696
|
+
*/
|
|
2697
|
+
isBlank() {
|
|
2698
|
+
const r = this._worksheet.getCellMatrix(), { startRow: e, startColumn: t, endRow: n, endColumn: s } = this._range;
|
|
2699
|
+
let o = !0;
|
|
2700
|
+
for (let i = e; i <= n; i++) {
|
|
2701
|
+
for (let a = t; a <= s; a++)
|
|
2702
|
+
if (!D(r.getValue(i, a))) {
|
|
2703
|
+
o = !1;
|
|
2704
|
+
break;
|
|
2705
|
+
}
|
|
2706
|
+
if (!o)
|
|
2707
|
+
break;
|
|
2708
|
+
}
|
|
2709
|
+
return o;
|
|
2710
|
+
}
|
|
2711
|
+
/**
|
|
2712
|
+
* Returns a new range that is relative to the current range, whose upper left point is offset from the current range by the given rows and columns, and with the given height and width in cells.
|
|
2713
|
+
* @param {number} rowOffset - The number of rows down from the range's top-left cell; negative values represent rows up from the range's top-left cell.
|
|
2714
|
+
* @param {number} columnOffset - The number of columns right from the range's top-left cell; negative values represent columns left from the range's top-left cell.
|
|
2715
|
+
* @param {number} numRows - The height in rows of the new range.
|
|
2716
|
+
* @param {number} numColumns - The width in columns of the new range.
|
|
2717
|
+
* @returns {FRange} The new range.
|
|
2718
|
+
* @example
|
|
2719
|
+
* ```ts
|
|
2720
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2721
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
2722
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
2723
|
+
* console.log(fRange.getA1Notation()); // A1:B2
|
|
2724
|
+
*
|
|
2725
|
+
* // Offset the range by 1 row and 1 column, and set the height of the new range to 3 and the width to 3
|
|
2726
|
+
* const newRange = fRange.offset(1, 1, 3, 3);
|
|
2727
|
+
* console.log(newRange.getA1Notation()); // B2:D4
|
|
2728
|
+
* ```
|
|
2729
|
+
*/
|
|
2730
|
+
offset(r, e, t, n) {
|
|
2731
|
+
const { startRow: s, startColumn: o, endRow: i, endColumn: a } = this._range, h = s + r, d = o + e, c = t ? h + t - 1 : i + r, C = n ? d + n - 1 : a + e;
|
|
2732
|
+
if (h < 0 || d < 0 || c < 0 || C < 0)
|
|
2733
|
+
throw new Error("The row or column index is out of range");
|
|
2734
|
+
return this._injector.createInstance(m, this._workbook, this._worksheet, {
|
|
2735
|
+
startRow: h,
|
|
2736
|
+
startColumn: d,
|
|
2737
|
+
endRow: c,
|
|
2738
|
+
endColumn: C
|
|
2739
|
+
});
|
|
2740
|
+
}
|
|
2741
|
+
/**
|
|
2742
|
+
* Updates the formula for this range. The given formula must be in A1 notation.
|
|
2743
|
+
* @param {string} formula - A string representing the formula to set for the cell.
|
|
2744
|
+
* @returns {FRange} This range instance for chaining.
|
|
2745
|
+
* @example
|
|
2746
|
+
* ```ts
|
|
2747
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2748
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
2749
|
+
* const fRange = fWorksheet.getRange('A1');
|
|
2750
|
+
* fRange.setFormula('=SUM(A2:A5)');
|
|
2751
|
+
* console.log(fRange.getFormula()); // '=SUM(A2:A5)'
|
|
2752
|
+
* ```
|
|
2753
|
+
*/
|
|
2754
|
+
setFormula(r) {
|
|
2755
|
+
return this.setValue({
|
|
2756
|
+
f: r
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
/**
|
|
2760
|
+
* Sets a rectangular grid of formulas (must match dimensions of this range). The given formulas must be in A1 notation.
|
|
2761
|
+
* @param {string[][]} formulas - A two-dimensional string array of formulas.
|
|
2762
|
+
* @returns {FRange} This range instance for chaining.
|
|
2763
|
+
* @example
|
|
2764
|
+
* ```ts
|
|
2765
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2766
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
2767
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
2768
|
+
* fRange.setFormulas([
|
|
2769
|
+
* ['=SUM(A2:A5)', '=SUM(B2:B5)'],
|
|
2770
|
+
* ['=SUM(A6:A9)', '=SUM(B6:B9)'],
|
|
2771
|
+
* ]);
|
|
2772
|
+
* console.log(fRange.getFormulas()); // [['=SUM(A2:A5)', '=SUM(B2:B5)'], ['=SUM(A6:A9)', '=SUM(B6:B9)']]
|
|
2773
|
+
* ```
|
|
2774
|
+
*/
|
|
2775
|
+
setFormulas(r) {
|
|
2776
|
+
return this.setValues(r.map((e) => e.map((t) => ({ f: t }))));
|
|
2777
|
+
}
|
|
2094
2778
|
};
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
],
|
|
2100
|
-
var
|
|
2101
|
-
for (var
|
|
2102
|
-
(i =
|
|
2103
|
-
return
|
|
2104
|
-
},
|
|
2105
|
-
let
|
|
2106
|
-
constructor(
|
|
2107
|
-
this._workbook =
|
|
2779
|
+
m = _n([
|
|
2780
|
+
ne(3, u(x)),
|
|
2781
|
+
ne(4, l),
|
|
2782
|
+
ne(5, u(rn))
|
|
2783
|
+
], m);
|
|
2784
|
+
var wn = Object.getOwnPropertyDescriptor, kn = (r, e, t, n) => {
|
|
2785
|
+
for (var s = n > 1 ? void 0 : n ? wn(e, t) : e, o = r.length - 1, i; o >= 0; o--)
|
|
2786
|
+
(i = r[o]) && (s = i(s) || s);
|
|
2787
|
+
return s;
|
|
2788
|
+
}, Sn = (r, e) => (t, n) => e(t, n, r);
|
|
2789
|
+
let Y = class {
|
|
2790
|
+
constructor(r, e, t, n) {
|
|
2791
|
+
this._workbook = r, this._worksheet = e, this._selections = t, this._injector = n;
|
|
2108
2792
|
}
|
|
2109
2793
|
/**
|
|
2110
2794
|
* Represents the active selection in the sheet. Which means the selection contains the active cell.
|
|
@@ -2120,8 +2804,8 @@ let j = class {
|
|
|
2120
2804
|
* ```
|
|
2121
2805
|
*/
|
|
2122
2806
|
getActiveRange() {
|
|
2123
|
-
const
|
|
2124
|
-
return
|
|
2807
|
+
const r = this._selections.find((e) => !!e.primary);
|
|
2808
|
+
return r ? this._injector.createInstance(m, this._workbook, this._worksheet, r.range) : null;
|
|
2125
2809
|
}
|
|
2126
2810
|
/**
|
|
2127
2811
|
* Represents the active selection list in the sheet.
|
|
@@ -2138,7 +2822,7 @@ let j = class {
|
|
|
2138
2822
|
* ```
|
|
2139
2823
|
*/
|
|
2140
2824
|
getActiveRangeList() {
|
|
2141
|
-
return this._selections.map((
|
|
2825
|
+
return this._selections.map((r) => this._injector.createInstance(m, this._workbook, this._worksheet, r.range));
|
|
2142
2826
|
}
|
|
2143
2827
|
/**
|
|
2144
2828
|
* Represents the current select cell in the sheet.
|
|
@@ -2157,8 +2841,8 @@ let j = class {
|
|
|
2157
2841
|
* ```
|
|
2158
2842
|
*/
|
|
2159
2843
|
getCurrentCell() {
|
|
2160
|
-
const
|
|
2161
|
-
return
|
|
2844
|
+
const r = this._selections.find((e) => !!e.primary);
|
|
2845
|
+
return r ? r.primary : null;
|
|
2162
2846
|
}
|
|
2163
2847
|
/**
|
|
2164
2848
|
* Returns the active sheet in the spreadsheet.
|
|
@@ -2173,8 +2857,8 @@ let j = class {
|
|
|
2173
2857
|
* ```
|
|
2174
2858
|
*/
|
|
2175
2859
|
getActiveSheet() {
|
|
2176
|
-
const
|
|
2177
|
-
return this._injector.createInstance(
|
|
2860
|
+
const r = this._injector.createInstance(S, this._workbook);
|
|
2861
|
+
return this._injector.createInstance(k, r, this._workbook, this._worksheet);
|
|
2178
2862
|
}
|
|
2179
2863
|
/**
|
|
2180
2864
|
* 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.
|
|
@@ -2198,13 +2882,13 @@ let j = class {
|
|
|
2198
2882
|
* console.log(`actualRow: ${actualRow}, actualColumn: ${actualColumn}`); // actualRow: 10, actualColumn: 1
|
|
2199
2883
|
* ```
|
|
2200
2884
|
*/
|
|
2201
|
-
updatePrimaryCell(
|
|
2202
|
-
const e = this._injector.get(
|
|
2885
|
+
updatePrimaryCell(r) {
|
|
2886
|
+
const e = this._injector.get(l);
|
|
2203
2887
|
let t = [], n = !1;
|
|
2204
2888
|
for (const { range: o, style: i } of this._selections)
|
|
2205
|
-
|
|
2889
|
+
N.contains(o, r.getRange()) ? (t.push({
|
|
2206
2890
|
range: o,
|
|
2207
|
-
primary:
|
|
2891
|
+
primary: $(r.getRange(), this._worksheet),
|
|
2208
2892
|
style: i
|
|
2209
2893
|
}), n = !0) : t.push({
|
|
2210
2894
|
range: o,
|
|
@@ -2213,16 +2897,16 @@ let j = class {
|
|
|
2213
2897
|
});
|
|
2214
2898
|
n || (t = [
|
|
2215
2899
|
{
|
|
2216
|
-
range:
|
|
2217
|
-
primary:
|
|
2900
|
+
range: r.getRange(),
|
|
2901
|
+
primary: $(r.getRange(), this._worksheet)
|
|
2218
2902
|
}
|
|
2219
2903
|
]);
|
|
2220
|
-
const
|
|
2904
|
+
const s = {
|
|
2221
2905
|
unitId: this._workbook.getUnitId(),
|
|
2222
2906
|
subUnitId: this._worksheet.getSheetId(),
|
|
2223
2907
|
selections: t
|
|
2224
2908
|
};
|
|
2225
|
-
return e.syncExecuteCommand(
|
|
2909
|
+
return e.syncExecuteCommand(me.id, s), new Y(this._workbook, this._worksheet, t, this._injector);
|
|
2226
2910
|
}
|
|
2227
2911
|
/**
|
|
2228
2912
|
* Get the next primary cell in the specified direction. If the primary cell not exists in selections, return null.
|
|
@@ -2249,22 +2933,22 @@ let j = class {
|
|
|
2249
2933
|
* console.log(nextCell2?.getA1Notation()); // A2
|
|
2250
2934
|
* ```
|
|
2251
2935
|
*/
|
|
2252
|
-
getNextDataRange(
|
|
2936
|
+
getNextDataRange(r) {
|
|
2253
2937
|
if (!this._selections.find((n) => !!n.primary))
|
|
2254
2938
|
return null;
|
|
2255
|
-
const t =
|
|
2256
|
-
return t ? this._injector.createInstance(
|
|
2939
|
+
const t = At(this._selections.concat(), r, this._worksheet);
|
|
2940
|
+
return t ? this._injector.createInstance(m, this._workbook, this._worksheet, t) : null;
|
|
2257
2941
|
}
|
|
2258
2942
|
};
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
],
|
|
2262
|
-
var
|
|
2263
|
-
for (var
|
|
2264
|
-
(i =
|
|
2265
|
-
return
|
|
2266
|
-
},
|
|
2267
|
-
let
|
|
2943
|
+
Y = kn([
|
|
2944
|
+
Sn(3, u(x))
|
|
2945
|
+
], Y);
|
|
2946
|
+
var Cn = Object.getOwnPropertyDescriptor, fn = (r, e, t, n) => {
|
|
2947
|
+
for (var s = n > 1 ? void 0 : n ? Cn(e, t) : e, o = r.length - 1, i; o >= 0; o--)
|
|
2948
|
+
(i = r[o]) && (s = i(s) || s);
|
|
2949
|
+
return s;
|
|
2950
|
+
}, z = (r, e) => (t, n) => e(t, n, r);
|
|
2951
|
+
let k = class extends le {
|
|
2268
2952
|
/**
|
|
2269
2953
|
* Creates a new worksheet facade instance
|
|
2270
2954
|
* @param {FWorkbook} _fWorkbook - The facade workbook instance
|
|
@@ -2275,8 +2959,8 @@ let l = class extends he {
|
|
|
2275
2959
|
* @param {ILogService} _logService - The log service
|
|
2276
2960
|
* @param {ICommandService} _commandService - The command service
|
|
2277
2961
|
*/
|
|
2278
|
-
constructor(e, t, n,
|
|
2279
|
-
super(
|
|
2962
|
+
constructor(e, t, n, s, o, i, a) {
|
|
2963
|
+
super(s);
|
|
2280
2964
|
/**
|
|
2281
2965
|
* Sets the active selection region for this sheet.
|
|
2282
2966
|
* @param range - The range to set as the active selection
|
|
@@ -2287,8 +2971,8 @@ let l = class extends he {
|
|
|
2287
2971
|
* fWorkSheet.setActiveSelection(fWorkSheet.getRange('A10:B10'));
|
|
2288
2972
|
* ```
|
|
2289
2973
|
*/
|
|
2290
|
-
|
|
2291
|
-
this._fWorkbook = e, this._workbook = t, this._worksheet = n, this._injector =
|
|
2974
|
+
E(this, "setActiveSelection", this.setActiveRange);
|
|
2975
|
+
this._fWorkbook = e, this._workbook = t, this._worksheet = n, this._injector = s, this._selectionManagerService = o, this._logService = i, this._commandService = a;
|
|
2292
2976
|
}
|
|
2293
2977
|
/**
|
|
2294
2978
|
* Get the worksheet instance.
|
|
@@ -2367,7 +3051,7 @@ let l = class extends he {
|
|
|
2367
3051
|
*/
|
|
2368
3052
|
getSelection() {
|
|
2369
3053
|
const e = this._selectionManagerService.getCurrentSelections();
|
|
2370
|
-
return e ? this._injector.createInstance(
|
|
3054
|
+
return e ? this._injector.createInstance(Y, this._workbook, this._worksheet, e) : null;
|
|
2371
3055
|
}
|
|
2372
3056
|
// #region rows
|
|
2373
3057
|
// #region default style
|
|
@@ -2436,7 +3120,7 @@ let l = class extends he {
|
|
|
2436
3120
|
*/
|
|
2437
3121
|
setDefaultStyle(e) {
|
|
2438
3122
|
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
2439
|
-
return this._commandService.syncExecuteCommand(
|
|
3123
|
+
return this._commandService.syncExecuteCommand(Dt.id, {
|
|
2440
3124
|
unitId: t,
|
|
2441
3125
|
subUnitId: n,
|
|
2442
3126
|
defaultStyle: e
|
|
@@ -2457,16 +3141,16 @@ let l = class extends he {
|
|
|
2457
3141
|
* ```
|
|
2458
3142
|
*/
|
|
2459
3143
|
setColumnDefaultStyle(e, t) {
|
|
2460
|
-
const n = this._workbook.getUnitId(),
|
|
3144
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = {
|
|
2461
3145
|
unitId: n,
|
|
2462
|
-
subUnitId:
|
|
3146
|
+
subUnitId: s,
|
|
2463
3147
|
columnData: {
|
|
2464
3148
|
[e]: {
|
|
2465
3149
|
s: t
|
|
2466
3150
|
}
|
|
2467
3151
|
}
|
|
2468
3152
|
};
|
|
2469
|
-
return this._commandService.syncExecuteCommand(
|
|
3153
|
+
return this._commandService.syncExecuteCommand(fe.id, o), this;
|
|
2470
3154
|
}
|
|
2471
3155
|
/**
|
|
2472
3156
|
* Set the default style of the worksheet column
|
|
@@ -2483,23 +3167,23 @@ let l = class extends he {
|
|
|
2483
3167
|
* ```
|
|
2484
3168
|
*/
|
|
2485
3169
|
setRowDefaultStyle(e, t) {
|
|
2486
|
-
const n = this._workbook.getUnitId(),
|
|
3170
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = {
|
|
2487
3171
|
unitId: n,
|
|
2488
|
-
subUnitId:
|
|
3172
|
+
subUnitId: s,
|
|
2489
3173
|
rowData: {
|
|
2490
3174
|
[e]: {
|
|
2491
3175
|
s: t
|
|
2492
3176
|
}
|
|
2493
3177
|
}
|
|
2494
3178
|
};
|
|
2495
|
-
return this._commandService.syncExecuteCommand(
|
|
3179
|
+
return this._commandService.syncExecuteCommand(ve.id, o), this;
|
|
2496
3180
|
}
|
|
2497
|
-
getRange(e, t, n,
|
|
3181
|
+
getRange(e, t, n, s) {
|
|
2498
3182
|
let o, i;
|
|
2499
3183
|
if (typeof e == "object")
|
|
2500
3184
|
o = e, i = this._worksheet;
|
|
2501
3185
|
else if (typeof e == "string") {
|
|
2502
|
-
const { range: a, sheetName: h } =
|
|
3186
|
+
const { range: a, sheetName: h } = on(e), d = h ? this._workbook.getSheetBySheetName(h) : this._worksheet;
|
|
2503
3187
|
if (!d)
|
|
2504
3188
|
throw new Error("Range not found");
|
|
2505
3189
|
i = d, o = {
|
|
@@ -2508,24 +3192,24 @@ let l = class extends he {
|
|
|
2508
3192
|
sheetId: i.getSheetId(),
|
|
2509
3193
|
// Use the current range instead of the future actual range to match Apps Script behavior.
|
|
2510
3194
|
// Users can create the latest range in real time when needed.
|
|
2511
|
-
rangeType:
|
|
2512
|
-
startRow: a.rangeType ===
|
|
2513
|
-
endRow: a.rangeType ===
|
|
2514
|
-
startColumn: a.rangeType ===
|
|
2515
|
-
endColumn: a.rangeType ===
|
|
3195
|
+
rangeType: w.NORMAL,
|
|
3196
|
+
startRow: a.rangeType === w.COLUMN ? 0 : a.startRow,
|
|
3197
|
+
endRow: a.rangeType === w.COLUMN ? i.getMaxRows() - 1 : a.endRow,
|
|
3198
|
+
startColumn: a.rangeType === w.ROW ? 0 : a.startColumn,
|
|
3199
|
+
endColumn: a.rangeType === w.ROW ? i.getMaxColumns() - 1 : a.endColumn
|
|
2516
3200
|
};
|
|
2517
3201
|
} else if (typeof e == "number" && t !== void 0)
|
|
2518
3202
|
i = this._worksheet, o = {
|
|
2519
3203
|
startRow: e,
|
|
2520
3204
|
endRow: e + (n != null ? n : 1) - 1,
|
|
2521
3205
|
startColumn: t,
|
|
2522
|
-
endColumn: t + (
|
|
3206
|
+
endColumn: t + (s != null ? s : 1) - 1,
|
|
2523
3207
|
unitId: this._workbook.getUnitId(),
|
|
2524
3208
|
sheetId: this._worksheet.getSheetId()
|
|
2525
3209
|
};
|
|
2526
3210
|
else
|
|
2527
3211
|
throw new Error("Invalid range specification");
|
|
2528
|
-
return this._injector.createInstance(
|
|
3212
|
+
return this._injector.createInstance(m, this._workbook, i, o);
|
|
2529
3213
|
}
|
|
2530
3214
|
/**
|
|
2531
3215
|
* Returns the current number of columns in the sheet, regardless of content.
|
|
@@ -2617,10 +3301,10 @@ let l = class extends he {
|
|
|
2617
3301
|
* ```
|
|
2618
3302
|
*/
|
|
2619
3303
|
insertRowsAfter(e, t) {
|
|
2620
|
-
const n = this._workbook.getUnitId(),
|
|
2621
|
-
return this._commandService.syncExecuteCommand(
|
|
3304
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = j.DOWN, i = e + 1, a = e + t, h = 0, d = this._worksheet.getColumnCount() - 1, c = L(this._worksheet, i, a, h, d, !0, e);
|
|
3305
|
+
return this._commandService.syncExecuteCommand(Ie.id, {
|
|
2622
3306
|
unitId: n,
|
|
2623
|
-
subUnitId:
|
|
3307
|
+
subUnitId: s,
|
|
2624
3308
|
direction: o,
|
|
2625
3309
|
range: {
|
|
2626
3310
|
startRow: i,
|
|
@@ -2646,10 +3330,10 @@ let l = class extends he {
|
|
|
2646
3330
|
* ```
|
|
2647
3331
|
*/
|
|
2648
3332
|
insertRowsBefore(e, t) {
|
|
2649
|
-
const n = this._workbook.getUnitId(),
|
|
2650
|
-
return this._commandService.syncExecuteCommand(
|
|
3333
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = j.UP, i = e, a = e + t - 1, h = 0, d = this._worksheet.getColumnCount() - 1, c = L(this._worksheet, i, a, h, d, !0, e - 1);
|
|
3334
|
+
return this._commandService.syncExecuteCommand(Ie.id, {
|
|
2651
3335
|
unitId: n,
|
|
2652
|
-
subUnitId:
|
|
3336
|
+
subUnitId: s,
|
|
2653
3337
|
direction: o,
|
|
2654
3338
|
range: {
|
|
2655
3339
|
startRow: i,
|
|
@@ -2697,7 +3381,7 @@ let l = class extends he {
|
|
|
2697
3381
|
startColumn: 0,
|
|
2698
3382
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2699
3383
|
};
|
|
2700
|
-
return this._commandService.syncExecuteCommand(
|
|
3384
|
+
return this._commandService.syncExecuteCommand(Wt.id, {
|
|
2701
3385
|
range: n,
|
|
2702
3386
|
unitId: this._workbook.getUnitId(),
|
|
2703
3387
|
subUnitId: this._worksheet.getSheetId()
|
|
@@ -2720,15 +3404,15 @@ let l = class extends he {
|
|
|
2720
3404
|
* ```
|
|
2721
3405
|
*/
|
|
2722
3406
|
moveRows(e, t) {
|
|
2723
|
-
const n = this._workbook.getUnitId(),
|
|
3407
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = ee(e.getRange(), this._worksheet), i = o, a = {
|
|
2724
3408
|
startRow: t,
|
|
2725
3409
|
endRow: t,
|
|
2726
3410
|
startColumn: o.startColumn,
|
|
2727
3411
|
endColumn: o.endColumn
|
|
2728
3412
|
};
|
|
2729
|
-
return this._commandService.syncExecuteCommand(
|
|
3413
|
+
return this._commandService.syncExecuteCommand(Bt.id, {
|
|
2730
3414
|
unitId: n,
|
|
2731
|
-
subUnitId:
|
|
3415
|
+
subUnitId: s,
|
|
2732
3416
|
range: o,
|
|
2733
3417
|
fromRange: i,
|
|
2734
3418
|
toRange: a
|
|
@@ -2750,11 +3434,11 @@ let l = class extends he {
|
|
|
2750
3434
|
* ```
|
|
2751
3435
|
*/
|
|
2752
3436
|
hideRow(e) {
|
|
2753
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2754
|
-
return this._commandService.syncExecuteCommand(
|
|
3437
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = ee(e.getRange(), this._worksheet);
|
|
3438
|
+
return this._commandService.syncExecuteCommand(Re.id, {
|
|
2755
3439
|
unitId: t,
|
|
2756
3440
|
subUnitId: n,
|
|
2757
|
-
ranges: [
|
|
3441
|
+
ranges: [s]
|
|
2758
3442
|
}), this;
|
|
2759
3443
|
}
|
|
2760
3444
|
/**
|
|
@@ -2772,16 +3456,16 @@ let l = class extends he {
|
|
|
2772
3456
|
* ```
|
|
2773
3457
|
*/
|
|
2774
3458
|
hideRows(e, t = 1) {
|
|
2775
|
-
const n = this._workbook.getUnitId(),
|
|
3459
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = {
|
|
2776
3460
|
startRow: e,
|
|
2777
3461
|
endRow: e + t - 1,
|
|
2778
3462
|
startColumn: 0,
|
|
2779
3463
|
endColumn: this._worksheet.getColumnCount() - 1,
|
|
2780
|
-
rangeType:
|
|
3464
|
+
rangeType: w.ROW
|
|
2781
3465
|
};
|
|
2782
|
-
return this._commandService.syncExecuteCommand(
|
|
3466
|
+
return this._commandService.syncExecuteCommand(Re.id, {
|
|
2783
3467
|
unitId: n,
|
|
2784
|
-
subUnitId:
|
|
3468
|
+
subUnitId: s,
|
|
2785
3469
|
ranges: [o]
|
|
2786
3470
|
}), this;
|
|
2787
3471
|
}
|
|
@@ -2801,17 +3485,17 @@ let l = class extends he {
|
|
|
2801
3485
|
* ```
|
|
2802
3486
|
*/
|
|
2803
3487
|
unhideRow(e) {
|
|
2804
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2805
|
-
return this._commandService.syncExecuteCommand(
|
|
3488
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = ee(e.getRange(), this._worksheet);
|
|
3489
|
+
return this._commandService.syncExecuteCommand(be.id, {
|
|
2806
3490
|
unitId: t,
|
|
2807
3491
|
subUnitId: n,
|
|
2808
|
-
ranges: [
|
|
3492
|
+
ranges: [s]
|
|
2809
3493
|
}), this;
|
|
2810
3494
|
}
|
|
2811
3495
|
/**
|
|
2812
3496
|
* Scrolling sheet to make specific rows visible.
|
|
2813
3497
|
* @param {number} rowIndex - The starting index of the rows
|
|
2814
|
-
* @param {number}
|
|
3498
|
+
* @param {number} numRows - The number of rows
|
|
2815
3499
|
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2816
3500
|
* @example
|
|
2817
3501
|
* ```typescript
|
|
@@ -2823,16 +3507,16 @@ let l = class extends he {
|
|
|
2823
3507
|
* ```
|
|
2824
3508
|
*/
|
|
2825
3509
|
showRows(e, t = 1) {
|
|
2826
|
-
const n = this._workbook.getUnitId(),
|
|
3510
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = {
|
|
2827
3511
|
startRow: e,
|
|
2828
3512
|
endRow: e + t - 1,
|
|
2829
3513
|
startColumn: 0,
|
|
2830
3514
|
endColumn: this._worksheet.getColumnCount() - 1,
|
|
2831
|
-
rangeType:
|
|
3515
|
+
rangeType: w.ROW
|
|
2832
3516
|
};
|
|
2833
|
-
return this._commandService.syncExecuteCommand(
|
|
3517
|
+
return this._commandService.syncExecuteCommand(be.id, {
|
|
2834
3518
|
unitId: n,
|
|
2835
|
-
subUnitId:
|
|
3519
|
+
subUnitId: s,
|
|
2836
3520
|
ranges: [o]
|
|
2837
3521
|
}), this;
|
|
2838
3522
|
}
|
|
@@ -2865,26 +3549,23 @@ let l = class extends he {
|
|
|
2865
3549
|
* ```
|
|
2866
3550
|
*/
|
|
2867
3551
|
autoFitRow(e, t = g.TRUE) {
|
|
2868
|
-
const n = this._workbook.getUnitId(),
|
|
3552
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = [{
|
|
2869
3553
|
startRow: e,
|
|
2870
3554
|
endRow: e,
|
|
2871
3555
|
startColumn: 0,
|
|
2872
3556
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2873
3557
|
}];
|
|
2874
|
-
return this._commandService.syncExecuteCommand(
|
|
3558
|
+
return this._commandService.syncExecuteCommand(ie.id, {
|
|
2875
3559
|
unitId: this._workbook.getUnitId(),
|
|
2876
3560
|
subUnitId: this._worksheet.getSheetId(),
|
|
2877
3561
|
range: o[0],
|
|
2878
|
-
value:
|
|
2879
|
-
}), this._commandService.syncExecuteCommand(
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
autoHeightInfo: t
|
|
2886
|
-
}
|
|
2887
|
-
), this;
|
|
3562
|
+
value: G.WRAP
|
|
3563
|
+
}), this._commandService.syncExecuteCommand(Vt.id, {
|
|
3564
|
+
unitId: n,
|
|
3565
|
+
subUnitId: s,
|
|
3566
|
+
ranges: o,
|
|
3567
|
+
autoHeightInfo: t
|
|
3568
|
+
}), this;
|
|
2888
3569
|
}
|
|
2889
3570
|
/**
|
|
2890
3571
|
* Sets the height of the given rows in pixels.
|
|
@@ -2901,27 +3582,47 @@ let l = class extends he {
|
|
|
2901
3582
|
*/
|
|
2902
3583
|
setRowHeights(e, t, n) {
|
|
2903
3584
|
var d;
|
|
2904
|
-
const
|
|
3585
|
+
const s = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = this._worksheet.getRowManager(), a = [], h = [];
|
|
2905
3586
|
for (let c = e; c < e + t; c++) {
|
|
2906
|
-
const
|
|
3587
|
+
const C = ((d = i.getRow(c)) == null ? void 0 : d.ah) || this._worksheet.getConfig().defaultRowHeight, _ = {
|
|
2907
3588
|
startRow: c,
|
|
2908
3589
|
endRow: c,
|
|
2909
3590
|
startColumn: 0,
|
|
2910
3591
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2911
3592
|
};
|
|
2912
|
-
n <=
|
|
3593
|
+
n <= C ? a.push(_) : h.push(_);
|
|
2913
3594
|
}
|
|
2914
|
-
return h.length > 0 && this._commandService.syncExecuteCommand(
|
|
2915
|
-
unitId:
|
|
3595
|
+
return h.length > 0 && this._commandService.syncExecuteCommand(pe.id, {
|
|
3596
|
+
unitId: s,
|
|
2916
3597
|
subUnitId: o,
|
|
2917
3598
|
ranges: h,
|
|
2918
3599
|
value: n
|
|
2919
|
-
}), a.length > 0 && this._commandService.syncExecuteCommand(
|
|
2920
|
-
unitId:
|
|
3600
|
+
}), a.length > 0 && this._commandService.syncExecuteCommand(X.id, {
|
|
3601
|
+
unitId: s,
|
|
2921
3602
|
subUnitId: o,
|
|
2922
3603
|
ranges: a
|
|
2923
3604
|
}), this;
|
|
2924
3605
|
}
|
|
3606
|
+
/**
|
|
3607
|
+
* Gets the height in pixels of the given row.
|
|
3608
|
+
* @param {number} rowPosition - The position of the row to examine. index starts at 0.
|
|
3609
|
+
* @returns {number} The height in pixels of the given row.
|
|
3610
|
+
* @example
|
|
3611
|
+
* ```typescript
|
|
3612
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3613
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
3614
|
+
*
|
|
3615
|
+
* // Set the value of the cell A1 to 'Hello, Univer!', set the font size to 30 and font weight to bold
|
|
3616
|
+
* const fRange = fWorksheet.getRange('A1');
|
|
3617
|
+
* fRange.setValue('Hello, Univer!').setFontSize(30).setFontWeight('bold');
|
|
3618
|
+
*
|
|
3619
|
+
* // Get the height of the first row
|
|
3620
|
+
* console.log(fWorksheet.getRowHeight(0));
|
|
3621
|
+
* ```
|
|
3622
|
+
*/
|
|
3623
|
+
getRowHeight(e) {
|
|
3624
|
+
return this._worksheet.getRowHeight(e);
|
|
3625
|
+
}
|
|
2925
3626
|
/**
|
|
2926
3627
|
* Sets the height of the given rows to auto.
|
|
2927
3628
|
* @param {number} startRow - The starting row position to change
|
|
@@ -2934,7 +3635,7 @@ let l = class extends he {
|
|
|
2934
3635
|
* ```
|
|
2935
3636
|
*/
|
|
2936
3637
|
setRowAutoHeight(e, t) {
|
|
2937
|
-
const n = this._workbook.getUnitId(),
|
|
3638
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = [
|
|
2938
3639
|
{
|
|
2939
3640
|
startRow: e,
|
|
2940
3641
|
endRow: e + t - 1,
|
|
@@ -2942,12 +3643,34 @@ let l = class extends he {
|
|
|
2942
3643
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2943
3644
|
}
|
|
2944
3645
|
];
|
|
2945
|
-
return this._commandService.syncExecuteCommand(
|
|
3646
|
+
return this._commandService.syncExecuteCommand(X.id, {
|
|
2946
3647
|
unitId: n,
|
|
2947
|
-
subUnitId:
|
|
3648
|
+
subUnitId: s,
|
|
2948
3649
|
ranges: o
|
|
2949
3650
|
}), this;
|
|
2950
3651
|
}
|
|
3652
|
+
/**
|
|
3653
|
+
* Sets the height of the given ranges to auto.
|
|
3654
|
+
* @param {IRange[]} ranges - The ranges to change
|
|
3655
|
+
* @returns {FWorksheet} This worksheet instance for chaining
|
|
3656
|
+
* @example
|
|
3657
|
+
* ```typescript
|
|
3658
|
+
* const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
3659
|
+
* const ranges = [
|
|
3660
|
+
* { startRow: 1, endRow: 10, startColumn: 0, endColumn: 10 },
|
|
3661
|
+
* { startRow: 11, endRow: 20, startColumn: 0, endColumn: 10 },
|
|
3662
|
+
* ]
|
|
3663
|
+
* fWorksheet.setRangesAutoHeight(ranges);
|
|
3664
|
+
* ```
|
|
3665
|
+
*/
|
|
3666
|
+
setRangesAutoHeight(e) {
|
|
3667
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
3668
|
+
return this._commandService.syncExecuteCommand(X.id, {
|
|
3669
|
+
unitId: t,
|
|
3670
|
+
subUnitId: n,
|
|
3671
|
+
ranges: e
|
|
3672
|
+
}), this;
|
|
3673
|
+
}
|
|
2951
3674
|
/**
|
|
2952
3675
|
* 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.
|
|
2953
3676
|
* @param {number} startRow - The starting row position to change
|
|
@@ -2961,7 +3684,7 @@ let l = class extends he {
|
|
|
2961
3684
|
* ```
|
|
2962
3685
|
*/
|
|
2963
3686
|
setRowHeightsForced(e, t, n) {
|
|
2964
|
-
const
|
|
3687
|
+
const s = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = [
|
|
2965
3688
|
{
|
|
2966
3689
|
startRow: e,
|
|
2967
3690
|
endRow: e + t - 1,
|
|
@@ -2969,8 +3692,8 @@ let l = class extends he {
|
|
|
2969
3692
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2970
3693
|
}
|
|
2971
3694
|
];
|
|
2972
|
-
return this._commandService.syncExecuteCommand(
|
|
2973
|
-
unitId:
|
|
3695
|
+
return this._commandService.syncExecuteCommand(pe.id, {
|
|
3696
|
+
unitId: s,
|
|
2974
3697
|
subUnitId: o,
|
|
2975
3698
|
ranges: i,
|
|
2976
3699
|
value: n
|
|
@@ -2988,17 +3711,17 @@ let l = class extends he {
|
|
|
2988
3711
|
* ```
|
|
2989
3712
|
*/
|
|
2990
3713
|
setRowCustom(e) {
|
|
2991
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
3714
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = {};
|
|
2992
3715
|
for (const [i, a] of Object.entries(e))
|
|
2993
|
-
|
|
3716
|
+
s[Number(i)] = {
|
|
2994
3717
|
custom: a
|
|
2995
3718
|
};
|
|
2996
3719
|
const o = {
|
|
2997
3720
|
unitId: t,
|
|
2998
3721
|
subUnitId: n,
|
|
2999
|
-
rowData:
|
|
3722
|
+
rowData: s
|
|
3000
3723
|
};
|
|
3001
|
-
return this._commandService.syncExecuteCommand(
|
|
3724
|
+
return this._commandService.syncExecuteCommand(ve.id, o), this;
|
|
3002
3725
|
}
|
|
3003
3726
|
// #region Column
|
|
3004
3727
|
/**
|
|
@@ -3065,10 +3788,10 @@ let l = class extends he {
|
|
|
3065
3788
|
* ```
|
|
3066
3789
|
*/
|
|
3067
3790
|
insertColumnsAfter(e, t) {
|
|
3068
|
-
const n = this._workbook.getUnitId(),
|
|
3069
|
-
return this._commandService.syncExecuteCommand(
|
|
3791
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = j.RIGHT, i = 0, a = this._worksheet.getRowCount() - 1, h = e + 1, d = e + t, c = L(this._worksheet, i, a, h, d, !1, e);
|
|
3792
|
+
return this._commandService.syncExecuteCommand(Ee.id, {
|
|
3070
3793
|
unitId: n,
|
|
3071
|
-
subUnitId:
|
|
3794
|
+
subUnitId: s,
|
|
3072
3795
|
direction: o,
|
|
3073
3796
|
range: {
|
|
3074
3797
|
startRow: i,
|
|
@@ -3094,10 +3817,10 @@ let l = class extends he {
|
|
|
3094
3817
|
* ```
|
|
3095
3818
|
*/
|
|
3096
3819
|
insertColumnsBefore(e, t) {
|
|
3097
|
-
const n = this._workbook.getUnitId(),
|
|
3098
|
-
return this._commandService.syncExecuteCommand(
|
|
3820
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = j.LEFT, i = 0, a = this._worksheet.getRowCount() - 1, h = e, d = e + t - 1, c = L(this._worksheet, i, a, h, d, !1, e - 1);
|
|
3821
|
+
return this._commandService.syncExecuteCommand(Ee.id, {
|
|
3099
3822
|
unitId: n,
|
|
3100
|
-
subUnitId:
|
|
3823
|
+
subUnitId: s,
|
|
3101
3824
|
direction: o,
|
|
3102
3825
|
range: {
|
|
3103
3826
|
startRow: i,
|
|
@@ -3145,7 +3868,7 @@ let l = class extends he {
|
|
|
3145
3868
|
startColumn: e,
|
|
3146
3869
|
endColumn: e + t - 1
|
|
3147
3870
|
};
|
|
3148
|
-
return this._commandService.syncExecuteCommand(
|
|
3871
|
+
return this._commandService.syncExecuteCommand(Ft.id, {
|
|
3149
3872
|
range: n,
|
|
3150
3873
|
unitId: this._workbook.getUnitId(),
|
|
3151
3874
|
subUnitId: this._worksheet.getSheetId()
|
|
@@ -3168,15 +3891,15 @@ let l = class extends he {
|
|
|
3168
3891
|
* ```
|
|
3169
3892
|
*/
|
|
3170
3893
|
moveColumns(e, t) {
|
|
3171
|
-
const n = this._workbook.getUnitId(),
|
|
3894
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = te(e.getRange(), this._worksheet), i = o, a = {
|
|
3172
3895
|
startRow: 0,
|
|
3173
3896
|
endRow: this._worksheet.getRowCount() - 1,
|
|
3174
3897
|
startColumn: t,
|
|
3175
3898
|
endColumn: t
|
|
3176
3899
|
};
|
|
3177
|
-
return this._commandService.syncExecuteCommand(
|
|
3900
|
+
return this._commandService.syncExecuteCommand(Ht.id, {
|
|
3178
3901
|
unitId: n,
|
|
3179
|
-
subUnitId:
|
|
3902
|
+
subUnitId: s,
|
|
3180
3903
|
range: o,
|
|
3181
3904
|
fromRange: i,
|
|
3182
3905
|
toRange: a
|
|
@@ -3198,11 +3921,11 @@ let l = class extends he {
|
|
|
3198
3921
|
* ```
|
|
3199
3922
|
*/
|
|
3200
3923
|
hideColumn(e) {
|
|
3201
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
3202
|
-
return this._commandService.syncExecuteCommand(
|
|
3924
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = te(e.getRange(), this._worksheet);
|
|
3925
|
+
return this._commandService.syncExecuteCommand(ye.id, {
|
|
3203
3926
|
unitId: t,
|
|
3204
3927
|
subUnitId: n,
|
|
3205
|
-
ranges: [
|
|
3928
|
+
ranges: [s]
|
|
3206
3929
|
}), this;
|
|
3207
3930
|
}
|
|
3208
3931
|
/**
|
|
@@ -3220,16 +3943,16 @@ let l = class extends he {
|
|
|
3220
3943
|
* ```
|
|
3221
3944
|
*/
|
|
3222
3945
|
hideColumns(e, t = 1) {
|
|
3223
|
-
const n = this._workbook.getUnitId(),
|
|
3946
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = {
|
|
3224
3947
|
startRow: 0,
|
|
3225
3948
|
endRow: this._worksheet.getRowCount() - 1,
|
|
3226
3949
|
startColumn: e,
|
|
3227
3950
|
endColumn: e + t - 1,
|
|
3228
|
-
rangeType:
|
|
3951
|
+
rangeType: w.COLUMN
|
|
3229
3952
|
};
|
|
3230
|
-
return this._commandService.syncExecuteCommand(
|
|
3953
|
+
return this._commandService.syncExecuteCommand(ye.id, {
|
|
3231
3954
|
unitId: n,
|
|
3232
|
-
subUnitId:
|
|
3955
|
+
subUnitId: s,
|
|
3233
3956
|
ranges: [o]
|
|
3234
3957
|
}), this;
|
|
3235
3958
|
}
|
|
@@ -3249,17 +3972,17 @@ let l = class extends he {
|
|
|
3249
3972
|
* ```
|
|
3250
3973
|
*/
|
|
3251
3974
|
unhideColumn(e) {
|
|
3252
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
3253
|
-
return this._commandService.syncExecuteCommand(
|
|
3975
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = te(e.getRange(), this._worksheet);
|
|
3976
|
+
return this._commandService.syncExecuteCommand(Ue.id, {
|
|
3254
3977
|
unitId: t,
|
|
3255
3978
|
subUnitId: n,
|
|
3256
|
-
ranges: [
|
|
3979
|
+
ranges: [s]
|
|
3257
3980
|
}), this;
|
|
3258
3981
|
}
|
|
3259
3982
|
/**
|
|
3260
3983
|
* Show one or more consecutive columns starting at the given index. Use 0-index for this method
|
|
3261
3984
|
* @param {number} columnIndex - The starting index of the columns to unhide
|
|
3262
|
-
* @param {number}
|
|
3985
|
+
* @param {number} numColumns - The number of columns to unhide
|
|
3263
3986
|
* @returns {FWorksheet} This sheet, for chaining
|
|
3264
3987
|
* @example
|
|
3265
3988
|
* ```typescript
|
|
@@ -3271,16 +3994,16 @@ let l = class extends he {
|
|
|
3271
3994
|
* ```
|
|
3272
3995
|
*/
|
|
3273
3996
|
showColumns(e, t = 1) {
|
|
3274
|
-
const n = this._workbook.getUnitId(),
|
|
3997
|
+
const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), o = {
|
|
3275
3998
|
startRow: 0,
|
|
3276
3999
|
endRow: this._worksheet.getRowCount() - 1,
|
|
3277
4000
|
startColumn: e,
|
|
3278
4001
|
endColumn: e + t - 1,
|
|
3279
|
-
rangeType:
|
|
4002
|
+
rangeType: w.COLUMN
|
|
3280
4003
|
};
|
|
3281
|
-
return this._commandService.syncExecuteCommand(
|
|
4004
|
+
return this._commandService.syncExecuteCommand(Ue.id, {
|
|
3282
4005
|
unitId: n,
|
|
3283
|
-
subUnitId:
|
|
4006
|
+
subUnitId: s,
|
|
3284
4007
|
ranges: [o]
|
|
3285
4008
|
}), this;
|
|
3286
4009
|
}
|
|
@@ -3313,7 +4036,7 @@ let l = class extends he {
|
|
|
3313
4036
|
* ```
|
|
3314
4037
|
*/
|
|
3315
4038
|
setColumnWidths(e, t, n) {
|
|
3316
|
-
const
|
|
4039
|
+
const s = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = [
|
|
3317
4040
|
{
|
|
3318
4041
|
startColumn: e,
|
|
3319
4042
|
endColumn: e + t - 1,
|
|
@@ -3321,13 +4044,36 @@ let l = class extends he {
|
|
|
3321
4044
|
endRow: this._worksheet.getRowCount() - 1
|
|
3322
4045
|
}
|
|
3323
4046
|
];
|
|
3324
|
-
return this._commandService.syncExecuteCommand(
|
|
3325
|
-
unitId:
|
|
4047
|
+
return this._commandService.syncExecuteCommand(Ot.id, {
|
|
4048
|
+
unitId: s,
|
|
3326
4049
|
subUnitId: o,
|
|
3327
4050
|
ranges: i,
|
|
3328
4051
|
value: n
|
|
3329
4052
|
}), this;
|
|
3330
4053
|
}
|
|
4054
|
+
/**
|
|
4055
|
+
* Gets the width in pixels of the given column.
|
|
4056
|
+
* @param {number} columnPosition - The position of the column to examine. index starts at 0.
|
|
4057
|
+
* @returns {number} The width of the column in pixels
|
|
4058
|
+
* @example
|
|
4059
|
+
* ```typescript
|
|
4060
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
4061
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
4062
|
+
*
|
|
4063
|
+
* // Set the long text value in cell A1
|
|
4064
|
+
* const fRange = fWorksheet.getRange('A1');
|
|
4065
|
+
* fRange.setValue('Whenever it is a damp, drizzly November in my soul...');
|
|
4066
|
+
*
|
|
4067
|
+
* // Set the column A to a width which fits the text
|
|
4068
|
+
* fWorksheet.autoResizeColumn(0);
|
|
4069
|
+
*
|
|
4070
|
+
* // Get the width of the column A
|
|
4071
|
+
* console.log(fWorksheet.getColumnWidth(0));
|
|
4072
|
+
* ```
|
|
4073
|
+
*/
|
|
4074
|
+
getColumnWidth(e) {
|
|
4075
|
+
return this._worksheet.getColumnWidth(e);
|
|
4076
|
+
}
|
|
3331
4077
|
// #endregion
|
|
3332
4078
|
/**
|
|
3333
4079
|
* Set custom properties for given columns.
|
|
@@ -3340,17 +4086,17 @@ let l = class extends he {
|
|
|
3340
4086
|
* ```
|
|
3341
4087
|
*/
|
|
3342
4088
|
setColumnCustom(e) {
|
|
3343
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
4089
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = {};
|
|
3344
4090
|
for (const [i, a] of Object.entries(e))
|
|
3345
|
-
|
|
4091
|
+
s[Number(i)] = {
|
|
3346
4092
|
custom: a
|
|
3347
4093
|
};
|
|
3348
4094
|
const o = {
|
|
3349
4095
|
unitId: t,
|
|
3350
4096
|
subUnitId: n,
|
|
3351
|
-
columnData:
|
|
4097
|
+
columnData: s
|
|
3352
4098
|
};
|
|
3353
|
-
return this._commandService.syncExecuteCommand(
|
|
4099
|
+
return this._commandService.syncExecuteCommand(fe.id, o), this;
|
|
3354
4100
|
}
|
|
3355
4101
|
// #region merge cells
|
|
3356
4102
|
/**
|
|
@@ -3368,7 +4114,7 @@ let l = class extends he {
|
|
|
3368
4114
|
* ```
|
|
3369
4115
|
*/
|
|
3370
4116
|
getMergeData() {
|
|
3371
|
-
return this._worksheet.getMergeData().map((e) => this._injector.createInstance(
|
|
4117
|
+
return this._worksheet.getMergeData().map((e) => this._injector.createInstance(m, this._workbook, this._worksheet, e));
|
|
3372
4118
|
}
|
|
3373
4119
|
/**
|
|
3374
4120
|
* Get all merged cells in the current sheet
|
|
@@ -3385,7 +4131,7 @@ let l = class extends he {
|
|
|
3385
4131
|
* ```
|
|
3386
4132
|
*/
|
|
3387
4133
|
getMergedRanges() {
|
|
3388
|
-
return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(
|
|
4134
|
+
return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(m, this._workbook, this._worksheet, t));
|
|
3389
4135
|
}
|
|
3390
4136
|
/**
|
|
3391
4137
|
* Get the merged cell data of the specified row and column.
|
|
@@ -3402,9 +4148,9 @@ let l = class extends he {
|
|
|
3402
4148
|
* ```
|
|
3403
4149
|
*/
|
|
3404
4150
|
getCellMergeData(e, t) {
|
|
3405
|
-
const
|
|
3406
|
-
if (
|
|
3407
|
-
return this._injector.createInstance(
|
|
4151
|
+
const s = this._worksheet.getMergedCell(e, t);
|
|
4152
|
+
if (s)
|
|
4153
|
+
return this._injector.createInstance(m, this._workbook, this._worksheet, s);
|
|
3408
4154
|
}
|
|
3409
4155
|
// #endregion
|
|
3410
4156
|
/**
|
|
@@ -3439,6 +4185,18 @@ let l = class extends he {
|
|
|
3439
4185
|
throw new Error("Specified range must be part of the sheet.");
|
|
3440
4186
|
return this._fWorkbook.setActiveRange(e), this;
|
|
3441
4187
|
}
|
|
4188
|
+
/**
|
|
4189
|
+
* Returns the active cell in this sheet.
|
|
4190
|
+
* @returns {FRange | null} The active cell
|
|
4191
|
+
* @example
|
|
4192
|
+
* ```typescript
|
|
4193
|
+
* const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();
|
|
4194
|
+
* console.log(fWorkSheet.getActiveCell().getA1Notation());
|
|
4195
|
+
* ```
|
|
4196
|
+
*/
|
|
4197
|
+
getActiveCell() {
|
|
4198
|
+
return this._fWorkbook.getActiveCell();
|
|
4199
|
+
}
|
|
3442
4200
|
/**
|
|
3443
4201
|
* Sets the frozen state of the current sheet.
|
|
3444
4202
|
* @param {IFreeze} freeze - the scrolling viewport start range and count of freezed rows and columns.
|
|
@@ -3458,7 +4216,7 @@ let l = class extends he {
|
|
|
3458
4216
|
* ```
|
|
3459
4217
|
*/
|
|
3460
4218
|
setFreeze(e) {
|
|
3461
|
-
return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(
|
|
4219
|
+
return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(Z.id, {
|
|
3462
4220
|
...e,
|
|
3463
4221
|
unitId: this._workbook.getUnitId(),
|
|
3464
4222
|
subUnitId: this.getSheetId()
|
|
@@ -3475,7 +4233,7 @@ let l = class extends he {
|
|
|
3475
4233
|
* ```
|
|
3476
4234
|
*/
|
|
3477
4235
|
cancelFreeze() {
|
|
3478
|
-
return this._commandService.syncExecuteCommand(
|
|
4236
|
+
return this._commandService.syncExecuteCommand(jt.id, {
|
|
3479
4237
|
unitId: this._workbook.getUnitId(),
|
|
3480
4238
|
subUnitId: this.getSheetId()
|
|
3481
4239
|
}), this;
|
|
@@ -3504,10 +4262,10 @@ let l = class extends he {
|
|
|
3504
4262
|
xSplit: n
|
|
3505
4263
|
});
|
|
3506
4264
|
} else if (arguments.length === 2) {
|
|
3507
|
-
let [n = 0,
|
|
3508
|
-
n >
|
|
3509
|
-
startColumn:
|
|
3510
|
-
xSplit:
|
|
4265
|
+
let [n = 0, s = 0] = e;
|
|
4266
|
+
n > s && ([n, s] = [s, n]), this._commandService.syncExecuteCommand(Z.id, {
|
|
4267
|
+
startColumn: s + 1,
|
|
4268
|
+
xSplit: s - n + 1,
|
|
3511
4269
|
startRow: t.startRow,
|
|
3512
4270
|
ySplit: t.ySplit,
|
|
3513
4271
|
unitId: this._workbook.getUnitId(),
|
|
@@ -3526,10 +4284,10 @@ let l = class extends he {
|
|
|
3526
4284
|
ySplit: n
|
|
3527
4285
|
});
|
|
3528
4286
|
} else if (arguments.length === 2) {
|
|
3529
|
-
let [n = 0,
|
|
3530
|
-
n >
|
|
3531
|
-
startRow:
|
|
3532
|
-
ySplit:
|
|
4287
|
+
let [n = 0, s = 0] = e;
|
|
4288
|
+
n > s && ([n, s] = [s, n]), this._commandService.syncExecuteCommand(Z.id, {
|
|
4289
|
+
startRow: s + 1,
|
|
4290
|
+
ySplit: s - n + 1,
|
|
3533
4291
|
startColumn: t.startColumn,
|
|
3534
4292
|
xSplit: t.xSplit,
|
|
3535
4293
|
unitId: this._workbook.getUnitId(),
|
|
@@ -3631,7 +4389,7 @@ let l = class extends he {
|
|
|
3631
4389
|
* ```
|
|
3632
4390
|
*/
|
|
3633
4391
|
setHiddenGridlines(e) {
|
|
3634
|
-
return this._commandService.syncExecuteCommand(
|
|
4392
|
+
return this._commandService.syncExecuteCommand(ae.id, {
|
|
3635
4393
|
unitId: this._workbook.getUnitId(),
|
|
3636
4394
|
subUnitId: this._worksheet.getSheetId(),
|
|
3637
4395
|
showGridlines: e ? g.FALSE : g.TRUE
|
|
@@ -3649,7 +4407,7 @@ let l = class extends he {
|
|
|
3649
4407
|
* ```
|
|
3650
4408
|
*/
|
|
3651
4409
|
setGridLinesColor(e) {
|
|
3652
|
-
return this._commandService.syncExecuteCommand(
|
|
4410
|
+
return this._commandService.syncExecuteCommand(he.id, {
|
|
3653
4411
|
unitId: this._workbook.getUnitId(),
|
|
3654
4412
|
subUnitId: this._worksheet.getSheetId(),
|
|
3655
4413
|
color: e
|
|
@@ -3682,7 +4440,7 @@ let l = class extends he {
|
|
|
3682
4440
|
* ```
|
|
3683
4441
|
*/
|
|
3684
4442
|
setTabColor(e) {
|
|
3685
|
-
return this._commandService.syncExecuteCommand(
|
|
4443
|
+
return this._commandService.syncExecuteCommand(Lt.id, {
|
|
3686
4444
|
unitId: this._workbook.getUnitId(),
|
|
3687
4445
|
subUnitId: this._worksheet.getSheetId(),
|
|
3688
4446
|
value: e
|
|
@@ -3708,10 +4466,10 @@ let l = class extends he {
|
|
|
3708
4466
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.SheetValueChanged, (params) => {})` instead
|
|
3709
4467
|
*/
|
|
3710
4468
|
onCellDataChange(e) {
|
|
3711
|
-
return this._injector.get(
|
|
3712
|
-
if (n.id ===
|
|
3713
|
-
const
|
|
3714
|
-
|
|
4469
|
+
return this._injector.get(l).onCommandExecuted((n) => {
|
|
4470
|
+
if (n.id === xe.id) {
|
|
4471
|
+
const s = n.params;
|
|
4472
|
+
s.unitId === this._workbook.getUnitId() && s.subUnitId === this._worksheet.getSheetId() && s.cellValue && e(new V(s.cellValue));
|
|
3715
4473
|
}
|
|
3716
4474
|
});
|
|
3717
4475
|
}
|
|
@@ -3720,10 +4478,10 @@ let l = class extends he {
|
|
|
3720
4478
|
* @deprecated use `univerAPI.addEvent(univerAPI.Event.SheetValueChanged, (params) => {})` instead
|
|
3721
4479
|
*/
|
|
3722
4480
|
onBeforeCellDataChange(e) {
|
|
3723
|
-
return this._injector.get(
|
|
3724
|
-
if (n.id ===
|
|
3725
|
-
const
|
|
3726
|
-
|
|
4481
|
+
return this._injector.get(l).beforeCommandExecuted((n) => {
|
|
4482
|
+
if (n.id === xe.id) {
|
|
4483
|
+
const s = n.params;
|
|
4484
|
+
s.unitId === this._workbook.getUnitId() && s.subUnitId === this._worksheet.getSheetId() && s.cellValue && e(new V(s.cellValue));
|
|
3727
4485
|
}
|
|
3728
4486
|
});
|
|
3729
4487
|
}
|
|
@@ -3739,10 +4497,10 @@ let l = class extends he {
|
|
|
3739
4497
|
* ```
|
|
3740
4498
|
*/
|
|
3741
4499
|
hideSheet() {
|
|
3742
|
-
const e = this._injector.get(
|
|
4500
|
+
const e = this._injector.get(l);
|
|
3743
4501
|
if (this._workbook.getSheets().filter((o) => o.isSheetHidden() !== g.TRUE).length <= 1)
|
|
3744
4502
|
throw new Error("Cannot hide the only visible sheet");
|
|
3745
|
-
return e.syncExecuteCommand(
|
|
4503
|
+
return e.syncExecuteCommand(zt.id, {
|
|
3746
4504
|
unitId: this._workbook.getUnitId(),
|
|
3747
4505
|
subUnitId: this._worksheet.getSheetId()
|
|
3748
4506
|
}), this;
|
|
@@ -3759,7 +4517,7 @@ let l = class extends he {
|
|
|
3759
4517
|
* ```
|
|
3760
4518
|
*/
|
|
3761
4519
|
showSheet() {
|
|
3762
|
-
return this._injector.get(
|
|
4520
|
+
return this._injector.get(l).syncExecuteCommand(Gt.id, {
|
|
3763
4521
|
unitId: this._workbook.getUnitId(),
|
|
3764
4522
|
subUnitId: this._worksheet.getSheetId()
|
|
3765
4523
|
}), this;
|
|
@@ -3791,7 +4549,7 @@ let l = class extends he {
|
|
|
3791
4549
|
* ```
|
|
3792
4550
|
*/
|
|
3793
4551
|
setName(e) {
|
|
3794
|
-
return this._commandService.syncExecuteCommand(
|
|
4552
|
+
return this._commandService.syncExecuteCommand(de.id, {
|
|
3795
4553
|
unitId: this._workbook.getUnitId(),
|
|
3796
4554
|
subUnitId: this._worksheet.getSheetId(),
|
|
3797
4555
|
name: e
|
|
@@ -3847,13 +4605,13 @@ let l = class extends he {
|
|
|
3847
4605
|
return this.clearContents();
|
|
3848
4606
|
if (e && e.formatOnly && !e.contentsOnly)
|
|
3849
4607
|
return this.clearFormats();
|
|
3850
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
4608
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = this._injector.get(l), o = {
|
|
3851
4609
|
startRow: 0,
|
|
3852
4610
|
endRow: this._worksheet.getRowCount() - 1,
|
|
3853
4611
|
startColumn: 0,
|
|
3854
4612
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
3855
4613
|
};
|
|
3856
|
-
return
|
|
4614
|
+
return s.syncExecuteCommand(Ke.id, {
|
|
3857
4615
|
unitId: t,
|
|
3858
4616
|
subUnitId: n,
|
|
3859
4617
|
ranges: [o],
|
|
@@ -3872,16 +4630,16 @@ let l = class extends he {
|
|
|
3872
4630
|
* ```
|
|
3873
4631
|
*/
|
|
3874
4632
|
clearContents() {
|
|
3875
|
-
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(
|
|
4633
|
+
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), s = {
|
|
3876
4634
|
startRow: 0,
|
|
3877
4635
|
endRow: this._worksheet.getRowCount() - 1,
|
|
3878
4636
|
startColumn: 0,
|
|
3879
4637
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
3880
4638
|
};
|
|
3881
|
-
return n.syncExecuteCommand(
|
|
4639
|
+
return n.syncExecuteCommand(Ye.id, {
|
|
3882
4640
|
unitId: e,
|
|
3883
4641
|
subUnitId: t,
|
|
3884
|
-
ranges: [
|
|
4642
|
+
ranges: [s]
|
|
3885
4643
|
}), this;
|
|
3886
4644
|
}
|
|
3887
4645
|
/**
|
|
@@ -3896,16 +4654,16 @@ let l = class extends he {
|
|
|
3896
4654
|
* ```
|
|
3897
4655
|
*/
|
|
3898
4656
|
clearFormats() {
|
|
3899
|
-
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(
|
|
4657
|
+
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), s = {
|
|
3900
4658
|
startRow: 0,
|
|
3901
4659
|
endRow: this._worksheet.getRowCount() - 1,
|
|
3902
4660
|
startColumn: 0,
|
|
3903
4661
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
3904
4662
|
};
|
|
3905
|
-
return n.syncExecuteCommand(
|
|
4663
|
+
return n.syncExecuteCommand(Je.id, {
|
|
3906
4664
|
unitId: e,
|
|
3907
4665
|
subUnitId: t,
|
|
3908
|
-
ranges: [
|
|
4666
|
+
ranges: [s]
|
|
3909
4667
|
}), this;
|
|
3910
4668
|
}
|
|
3911
4669
|
/**
|
|
@@ -3987,7 +4745,7 @@ let l = class extends he {
|
|
|
3987
4745
|
* ```
|
|
3988
4746
|
*/
|
|
3989
4747
|
equalTo(e) {
|
|
3990
|
-
return e instanceof
|
|
4748
|
+
return e instanceof k ? this._worksheet.getSheetId() === e.getSheetId() && this._workbook.getUnitId() === e.getWorkbook().getUnitId() : !1;
|
|
3991
4749
|
}
|
|
3992
4750
|
/**
|
|
3993
4751
|
* Insert a defined name for worksheet.
|
|
@@ -4001,8 +4759,8 @@ let l = class extends he {
|
|
|
4001
4759
|
* ```
|
|
4002
4760
|
*/
|
|
4003
4761
|
insertDefinedName(e, t) {
|
|
4004
|
-
const
|
|
4005
|
-
|
|
4762
|
+
const s = this._injector.createInstance(J).setName(e).setRef(t).build();
|
|
4763
|
+
s.localSheetId = this.getSheetId(), this._fWorkbook.insertDefinedNameBuilder(s);
|
|
4006
4764
|
}
|
|
4007
4765
|
/**
|
|
4008
4766
|
* Get all the defined names in the worksheet.
|
|
@@ -4092,23 +4850,50 @@ let l = class extends he {
|
|
|
4092
4850
|
getColumnCustomMetadata(e) {
|
|
4093
4851
|
return this._worksheet.getColumnManager().getCustomMetadata(e);
|
|
4094
4852
|
}
|
|
4853
|
+
/**
|
|
4854
|
+
* Appends a row to the bottom of the current data region in the sheet. If a cell's content begins with =, it's interpreted as a formula.
|
|
4855
|
+
* @param {CellValue[]} rowContents - An array of values for the new row.
|
|
4856
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining.
|
|
4857
|
+
* @example
|
|
4858
|
+
* ```ts
|
|
4859
|
+
* // Appends a new row with 4 columns to the bottom of the current
|
|
4860
|
+
* // data region in the sheet containing the values in the array.
|
|
4861
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
4862
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
4863
|
+
* fWorkSheet.appendRow([1, 'Hello Univer', true, '=A1']);
|
|
4864
|
+
* ```
|
|
4865
|
+
*/
|
|
4866
|
+
appendRow(e) {
|
|
4867
|
+
const t = this._worksheet.getCellMatrix().hasValue(), n = this._worksheet.getLastRowWithContent(), s = this._worksheet.getRowCount(), o = this._worksheet.getColumnCount(), i = t ? n + 1 : n, a = new V();
|
|
4868
|
+
for (let h = 0; h < e.length; h++)
|
|
4869
|
+
a.setValue(i, h, O(e[h]));
|
|
4870
|
+
return this._commandService.syncExecuteCommand($t.id, {
|
|
4871
|
+
unitId: this._workbook.getUnitId(),
|
|
4872
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
4873
|
+
cellValue: a.getMatrix(),
|
|
4874
|
+
insertRowNums: i > s - 1 ? 1 : 0,
|
|
4875
|
+
insertColumnNums: e.length > o ? e.length - o : 0,
|
|
4876
|
+
maxRows: s,
|
|
4877
|
+
maxColumns: o
|
|
4878
|
+
}), this;
|
|
4879
|
+
}
|
|
4095
4880
|
};
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
],
|
|
4102
|
-
var
|
|
4103
|
-
for (var
|
|
4104
|
-
(i =
|
|
4105
|
-
return
|
|
4106
|
-
},
|
|
4107
|
-
let
|
|
4108
|
-
constructor(e, t, n,
|
|
4881
|
+
k = fn([
|
|
4882
|
+
z(3, u(x)),
|
|
4883
|
+
z(4, u(Qe)),
|
|
4884
|
+
z(5, u(He)),
|
|
4885
|
+
z(6, l)
|
|
4886
|
+
], k);
|
|
4887
|
+
var vn = Object.getOwnPropertyDescriptor, In = (r, e, t, n) => {
|
|
4888
|
+
for (var s = n > 1 ? void 0 : n ? vn(e, t) : e, o = r.length - 1, i; o >= 0; o--)
|
|
4889
|
+
(i = r[o]) && (s = i(s) || s);
|
|
4890
|
+
return s;
|
|
4891
|
+
}, R = (r, e) => (t, n) => e(t, n, r);
|
|
4892
|
+
let S = class extends le {
|
|
4893
|
+
constructor(e, t, n, s, o, i, a, h, d, c) {
|
|
4109
4894
|
super(t);
|
|
4110
|
-
|
|
4111
|
-
this._workbook = e, this._injector = t, this._resourceLoaderService = n, this._selectionManagerService =
|
|
4895
|
+
E(this, "id");
|
|
4896
|
+
this._workbook = e, this._injector = t, this._resourceLoaderService = n, this._selectionManagerService = s, this._univerInstanceService = o, this._commandService = i, this._permissionService = a, this._logService = h, this._localeService = d, this._definedNamesService = c, this.id = this._workbook.getUnitId();
|
|
4112
4897
|
}
|
|
4113
4898
|
/**
|
|
4114
4899
|
* Get the Workbook instance.
|
|
@@ -4206,7 +4991,7 @@ let v = class extends he {
|
|
|
4206
4991
|
*/
|
|
4207
4992
|
getActiveSheet() {
|
|
4208
4993
|
const e = this._workbook.getActiveSheet();
|
|
4209
|
-
return this._injector.createInstance(
|
|
4994
|
+
return this._injector.createInstance(k, this, this._workbook, e);
|
|
4210
4995
|
}
|
|
4211
4996
|
/**
|
|
4212
4997
|
* Gets all the worksheets in this workbook
|
|
@@ -4220,7 +5005,7 @@ let v = class extends he {
|
|
|
4220
5005
|
* ```
|
|
4221
5006
|
*/
|
|
4222
5007
|
getSheets() {
|
|
4223
|
-
return this._workbook.getSheets().map((e) => this._injector.createInstance(
|
|
5008
|
+
return this._workbook.getSheets().map((e) => this._injector.createInstance(k, this, this._workbook, e));
|
|
4224
5009
|
}
|
|
4225
5010
|
/**
|
|
4226
5011
|
* Create a new worksheet and returns a handle to it.
|
|
@@ -4237,19 +5022,19 @@ let v = class extends he {
|
|
|
4237
5022
|
* ```
|
|
4238
5023
|
*/
|
|
4239
5024
|
create(e, t, n) {
|
|
4240
|
-
const
|
|
4241
|
-
|
|
5025
|
+
const s = it({});
|
|
5026
|
+
s.rowCount = t, s.columnCount = n, s.name = e, s.id = e.toLowerCase().replace(/ /g, "-"), this._commandService.syncExecuteCommand(F.id, {
|
|
4242
5027
|
unitId: this.id,
|
|
4243
5028
|
index: this._workbook.getSheets().length,
|
|
4244
|
-
sheet:
|
|
4245
|
-
}), this._commandService.syncExecuteCommand(
|
|
5029
|
+
sheet: s
|
|
5030
|
+
}), this._commandService.syncExecuteCommand(H.id, {
|
|
4246
5031
|
unitId: this.id,
|
|
4247
5032
|
subUnitId: this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId()
|
|
4248
5033
|
});
|
|
4249
5034
|
const o = this._workbook.getActiveSheet();
|
|
4250
5035
|
if (!o)
|
|
4251
5036
|
throw new Error("No active sheet found");
|
|
4252
|
-
return this._injector.createInstance(
|
|
5037
|
+
return this._injector.createInstance(k, this, this._workbook, o);
|
|
4253
5038
|
}
|
|
4254
5039
|
/**
|
|
4255
5040
|
* Get a worksheet by sheet id.
|
|
@@ -4265,7 +5050,7 @@ let v = class extends he {
|
|
|
4265
5050
|
*/
|
|
4266
5051
|
getSheetBySheetId(e) {
|
|
4267
5052
|
const t = this._workbook.getSheetBySheetId(e);
|
|
4268
|
-
return t ? this._injector.createInstance(
|
|
5053
|
+
return t ? this._injector.createInstance(k, this, this._workbook, t) : null;
|
|
4269
5054
|
}
|
|
4270
5055
|
/**
|
|
4271
5056
|
* Get a worksheet by sheet name.
|
|
@@ -4281,7 +5066,7 @@ let v = class extends he {
|
|
|
4281
5066
|
*/
|
|
4282
5067
|
getSheetByName(e) {
|
|
4283
5068
|
const t = this._workbook.getSheetBySheetName(e);
|
|
4284
|
-
return t ? this._injector.createInstance(
|
|
5069
|
+
return t ? this._injector.createInstance(k, this, this._workbook, t) : null;
|
|
4285
5070
|
}
|
|
4286
5071
|
/**
|
|
4287
5072
|
* Sets the given worksheet to be the active worksheet in the workbook.
|
|
@@ -4296,7 +5081,7 @@ let v = class extends he {
|
|
|
4296
5081
|
* ```
|
|
4297
5082
|
*/
|
|
4298
5083
|
setActiveSheet(e) {
|
|
4299
|
-
return this._commandService.syncExecuteCommand(
|
|
5084
|
+
return this._commandService.syncExecuteCommand(H.id, {
|
|
4300
5085
|
unitId: this.id,
|
|
4301
5086
|
subUnitId: typeof e == "string" ? e : e.getSheetId()
|
|
4302
5087
|
}), typeof e == "string" ? this.getSheetBySheetId(e) : e;
|
|
@@ -4318,16 +5103,16 @@ let v = class extends he {
|
|
|
4318
5103
|
* ```
|
|
4319
5104
|
*/
|
|
4320
5105
|
insertSheet(e) {
|
|
4321
|
-
e != null ? this._commandService.syncExecuteCommand(
|
|
5106
|
+
e != null ? this._commandService.syncExecuteCommand(F.id, { sheet: { name: e } }) : this._commandService.syncExecuteCommand(F.id);
|
|
4322
5107
|
const t = this.id, n = this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId();
|
|
4323
|
-
this._commandService.syncExecuteCommand(
|
|
5108
|
+
this._commandService.syncExecuteCommand(H.id, {
|
|
4324
5109
|
unitId: t,
|
|
4325
5110
|
subUnitId: n
|
|
4326
5111
|
});
|
|
4327
|
-
const
|
|
4328
|
-
if (!
|
|
5112
|
+
const s = this._workbook.getActiveSheet();
|
|
5113
|
+
if (!s)
|
|
4329
5114
|
throw new Error("No active sheet found");
|
|
4330
|
-
return this._injector.createInstance(
|
|
5115
|
+
return this._injector.createInstance(k, this, this._workbook, s);
|
|
4331
5116
|
}
|
|
4332
5117
|
/**
|
|
4333
5118
|
* Deletes the specified worksheet.
|
|
@@ -4343,7 +5128,7 @@ let v = class extends he {
|
|
|
4343
5128
|
*/
|
|
4344
5129
|
deleteSheet(e) {
|
|
4345
5130
|
const t = this.id, n = typeof e == "string" ? e : e.getSheetId();
|
|
4346
|
-
return this._commandService.syncExecuteCommand(
|
|
5131
|
+
return this._commandService.syncExecuteCommand(ce.id, {
|
|
4347
5132
|
unitId: t,
|
|
4348
5133
|
subUnitId: n
|
|
4349
5134
|
});
|
|
@@ -4360,7 +5145,7 @@ let v = class extends he {
|
|
|
4360
5145
|
* ```
|
|
4361
5146
|
*/
|
|
4362
5147
|
undo() {
|
|
4363
|
-
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(
|
|
5148
|
+
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(at.id), this;
|
|
4364
5149
|
}
|
|
4365
5150
|
/**
|
|
4366
5151
|
* Redo the last undone action.
|
|
@@ -4373,7 +5158,7 @@ let v = class extends he {
|
|
|
4373
5158
|
* ```
|
|
4374
5159
|
*/
|
|
4375
5160
|
redo() {
|
|
4376
|
-
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(
|
|
5161
|
+
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(ht.id), this;
|
|
4377
5162
|
}
|
|
4378
5163
|
/**
|
|
4379
5164
|
* Callback for command execution.
|
|
@@ -4442,9 +5227,9 @@ let v = class extends he {
|
|
|
4442
5227
|
* ```
|
|
4443
5228
|
*/
|
|
4444
5229
|
onSelectionChange(e) {
|
|
4445
|
-
return
|
|
5230
|
+
return Oe(
|
|
4446
5231
|
this._selectionManagerService.selectionMoveEnd$.subscribe((t) => {
|
|
4447
|
-
this._univerInstanceService.getCurrentUnitForType(
|
|
5232
|
+
this._univerInstanceService.getCurrentUnitForType(U.UNIVER_SHEET).getUnitId() === this.id && (t != null && t.length ? e(t.map((n) => n.range)) : e([]));
|
|
4448
5233
|
})
|
|
4449
5234
|
);
|
|
4450
5235
|
}
|
|
@@ -4460,7 +5245,7 @@ let v = class extends he {
|
|
|
4460
5245
|
* ```
|
|
4461
5246
|
*/
|
|
4462
5247
|
setEditable(e) {
|
|
4463
|
-
const t = new
|
|
5248
|
+
const t = new $e(this._workbook.getUnitId());
|
|
4464
5249
|
return this._permissionService.getPermissionPoint(t.id) || this._permissionService.addPermissionPoint(t), this._permissionService.updatePermissionPoint(t.id, e), this;
|
|
4465
5250
|
}
|
|
4466
5251
|
/**
|
|
@@ -4475,16 +5260,16 @@ let v = class extends he {
|
|
|
4475
5260
|
* ```
|
|
4476
5261
|
*/
|
|
4477
5262
|
setActiveRange(e) {
|
|
4478
|
-
const t = this.getActiveSheet(), n = e.getRange().sheetId || t.getSheetId(),
|
|
4479
|
-
if (!
|
|
5263
|
+
const t = this.getActiveSheet(), n = e.getRange().sheetId || t.getSheetId(), s = n ? this._workbook.getSheetBySheetId(n) : this._workbook.getActiveSheet(!0);
|
|
5264
|
+
if (!s)
|
|
4480
5265
|
throw new Error("No active sheet found");
|
|
4481
|
-
|
|
5266
|
+
s.getSheetId() !== t.getSheetId() && this.setActiveSheet(this._injector.createInstance(k, this, this._workbook, s));
|
|
4482
5267
|
const o = {
|
|
4483
5268
|
unitId: this.getId(),
|
|
4484
5269
|
subUnitId: n,
|
|
4485
|
-
selections: [e].map((i) => ({ range: i.getRange(), primary:
|
|
5270
|
+
selections: [e].map((i) => ({ range: i.getRange(), primary: $(i.getRange(), s), style: null }))
|
|
4486
5271
|
};
|
|
4487
|
-
return this._commandService.syncExecuteCommand(
|
|
5272
|
+
return this._commandService.syncExecuteCommand(me.id, o), this;
|
|
4488
5273
|
}
|
|
4489
5274
|
/**
|
|
4490
5275
|
* Returns the selected range in the active sheet, or null if there is no active range.
|
|
@@ -4498,8 +5283,27 @@ let v = class extends he {
|
|
|
4498
5283
|
*/
|
|
4499
5284
|
// could sheet have no active range ?
|
|
4500
5285
|
getActiveRange() {
|
|
4501
|
-
const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((
|
|
4502
|
-
return n ? this._injector.createInstance(
|
|
5286
|
+
const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((s) => !!s.primary);
|
|
5287
|
+
return n ? this._injector.createInstance(m, this._workbook, e, n.range) : null;
|
|
5288
|
+
}
|
|
5289
|
+
/**
|
|
5290
|
+
* Returns the active cell in this spreadsheet.
|
|
5291
|
+
* @returns {FRange | null} The active cell
|
|
5292
|
+
* @example
|
|
5293
|
+
* ```ts
|
|
5294
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
5295
|
+
* console.log(fWorkbook.getActiveCell().getA1Notation());
|
|
5296
|
+
* ```
|
|
5297
|
+
*/
|
|
5298
|
+
getActiveCell() {
|
|
5299
|
+
const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((o) => !!o.primary);
|
|
5300
|
+
if (!n)
|
|
5301
|
+
return null;
|
|
5302
|
+
const s = {
|
|
5303
|
+
...n.primary,
|
|
5304
|
+
rangeType: w.NORMAL
|
|
5305
|
+
};
|
|
5306
|
+
return this._injector.createInstance(m, this._workbook, e, s);
|
|
4503
5307
|
}
|
|
4504
5308
|
/**
|
|
4505
5309
|
* Deletes the currently active sheet.
|
|
@@ -4528,10 +5332,10 @@ let v = class extends he {
|
|
|
4528
5332
|
* ```
|
|
4529
5333
|
*/
|
|
4530
5334
|
duplicateSheet(e) {
|
|
4531
|
-
return this._commandService.syncExecuteCommand(
|
|
5335
|
+
return this._commandService.syncExecuteCommand(qt.id, {
|
|
4532
5336
|
unitId: e.getWorkbook().getUnitId(),
|
|
4533
5337
|
subUnitId: e.getSheetId()
|
|
4534
|
-
}), this._injector.createInstance(
|
|
5338
|
+
}), this._injector.createInstance(k, this, this._workbook, this._workbook.getActiveSheet());
|
|
4535
5339
|
}
|
|
4536
5340
|
/**
|
|
4537
5341
|
* Duplicates the active sheet.
|
|
@@ -4624,7 +5428,7 @@ let v = class extends he {
|
|
|
4624
5428
|
*/
|
|
4625
5429
|
moveSheet(e, t) {
|
|
4626
5430
|
let n = t;
|
|
4627
|
-
return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.syncExecuteCommand(
|
|
5431
|
+
return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.syncExecuteCommand(Kt.id, {
|
|
4628
5432
|
unitId: e.getWorkbook().getUnitId(),
|
|
4629
5433
|
order: n,
|
|
4630
5434
|
subUnitId: e.getSheetId()
|
|
@@ -4656,7 +5460,7 @@ let v = class extends he {
|
|
|
4656
5460
|
* ```
|
|
4657
5461
|
*/
|
|
4658
5462
|
getPermission() {
|
|
4659
|
-
return this._injector.createInstance(
|
|
5463
|
+
return this._injector.createInstance(K);
|
|
4660
5464
|
}
|
|
4661
5465
|
/**
|
|
4662
5466
|
* Get the defined name by name.
|
|
@@ -4672,7 +5476,7 @@ let v = class extends he {
|
|
|
4672
5476
|
*/
|
|
4673
5477
|
getDefinedName(e) {
|
|
4674
5478
|
const t = this._definedNamesService.getValueByName(this.id, e);
|
|
4675
|
-
return t ? this._injector.createInstance(
|
|
5479
|
+
return t ? this._injector.createInstance(q, { ...t, unitId: this.id }) : null;
|
|
4676
5480
|
}
|
|
4677
5481
|
/**
|
|
4678
5482
|
* Get all the defined names in the workbook.
|
|
@@ -4687,7 +5491,7 @@ let v = class extends he {
|
|
|
4687
5491
|
*/
|
|
4688
5492
|
getDefinedNames() {
|
|
4689
5493
|
const e = this._definedNamesService.getDefinedNameMap(this.id);
|
|
4690
|
-
return e ? Object.values(e).map((t) => this._injector.createInstance(
|
|
5494
|
+
return e ? Object.values(e).map((t) => this._injector.createInstance(q, { ...t, unitId: this.id })) : [];
|
|
4691
5495
|
}
|
|
4692
5496
|
/**
|
|
4693
5497
|
* Insert a defined name.
|
|
@@ -4702,8 +5506,8 @@ let v = class extends he {
|
|
|
4702
5506
|
* ```
|
|
4703
5507
|
*/
|
|
4704
5508
|
insertDefinedName(e, t) {
|
|
4705
|
-
const
|
|
4706
|
-
return
|
|
5509
|
+
const s = this._injector.createInstance(J).setName(e).setRef(t).build();
|
|
5510
|
+
return s.localSheetId = oe, this.insertDefinedNameBuilder(s), this;
|
|
4707
5511
|
}
|
|
4708
5512
|
/**
|
|
4709
5513
|
* Delete the defined name with the given name.
|
|
@@ -4737,7 +5541,7 @@ let v = class extends he {
|
|
|
4737
5541
|
* ```
|
|
4738
5542
|
*/
|
|
4739
5543
|
insertDefinedNameBuilder(e) {
|
|
4740
|
-
e.unitId = this.getId(), this._commandService.syncExecuteCommand(
|
|
5544
|
+
e.unitId = this.getId(), this._commandService.syncExecuteCommand(se.id, e);
|
|
4741
5545
|
}
|
|
4742
5546
|
/**
|
|
4743
5547
|
* Update the defined name with the given name.
|
|
@@ -4755,7 +5559,7 @@ let v = class extends he {
|
|
|
4755
5559
|
* ```
|
|
4756
5560
|
*/
|
|
4757
5561
|
updateDefinedNameBuilder(e) {
|
|
4758
|
-
this._commandService.syncExecuteCommand(
|
|
5562
|
+
this._commandService.syncExecuteCommand(se.id, e);
|
|
4759
5563
|
}
|
|
4760
5564
|
/**
|
|
4761
5565
|
* Gets the registered range themes.
|
|
@@ -4769,7 +5573,7 @@ let v = class extends he {
|
|
|
4769
5573
|
* ```
|
|
4770
5574
|
*/
|
|
4771
5575
|
getRegisteredRangeThemes() {
|
|
4772
|
-
return this._injector.get(
|
|
5576
|
+
return this._injector.get(qe).getRegisteredRangeThemes();
|
|
4773
5577
|
}
|
|
4774
5578
|
/**
|
|
4775
5579
|
* Register a custom range theme style.
|
|
@@ -4790,7 +5594,7 @@ let v = class extends he {
|
|
|
4790
5594
|
* ```
|
|
4791
5595
|
*/
|
|
4792
5596
|
registerRangeTheme(e) {
|
|
4793
|
-
this._commandService.syncExecuteCommand(
|
|
5597
|
+
this._commandService.syncExecuteCommand(Yt.id, {
|
|
4794
5598
|
unitId: this.getId(),
|
|
4795
5599
|
rangeThemeStyle: e
|
|
4796
5600
|
});
|
|
@@ -4806,7 +5610,7 @@ let v = class extends he {
|
|
|
4806
5610
|
* ```
|
|
4807
5611
|
*/
|
|
4808
5612
|
unregisterRangeTheme(e) {
|
|
4809
|
-
this._commandService.syncExecuteCommand(
|
|
5613
|
+
this._commandService.syncExecuteCommand(Jt.id, {
|
|
4810
5614
|
unitId: this.getId(),
|
|
4811
5615
|
themeName: e
|
|
4812
5616
|
});
|
|
@@ -4830,7 +5634,7 @@ let v = class extends he {
|
|
|
4830
5634
|
* ```
|
|
4831
5635
|
*/
|
|
4832
5636
|
createRangeThemeStyle(e, t) {
|
|
4833
|
-
return new
|
|
5637
|
+
return new Qt(e, t);
|
|
4834
5638
|
}
|
|
4835
5639
|
/**
|
|
4836
5640
|
* Set custom metadata of workbook
|
|
@@ -4859,18 +5663,18 @@ let v = class extends he {
|
|
|
4859
5663
|
return this._workbook.getCustomMetadata();
|
|
4860
5664
|
}
|
|
4861
5665
|
};
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
],
|
|
4873
|
-
class
|
|
5666
|
+
S = In([
|
|
5667
|
+
R(1, u(x)),
|
|
5668
|
+
R(2, u(ot)),
|
|
5669
|
+
R(3, u(Qe)),
|
|
5670
|
+
R(4, re),
|
|
5671
|
+
R(5, l),
|
|
5672
|
+
R(6, ue),
|
|
5673
|
+
R(7, He),
|
|
5674
|
+
R(8, u(Ve)),
|
|
5675
|
+
R(9, Xe)
|
|
5676
|
+
], S);
|
|
5677
|
+
class Rn extends je {
|
|
4874
5678
|
getCommandSheetTarget(e) {
|
|
4875
5679
|
var o;
|
|
4876
5680
|
const t = e.params;
|
|
@@ -4878,46 +5682,40 @@ class mn extends Ae {
|
|
|
4878
5682
|
const n = t.unitId ? this.getUniverSheet(t.unitId) : (o = this.getActiveWorkbook) == null ? void 0 : o.call(this);
|
|
4879
5683
|
if (!n)
|
|
4880
5684
|
return;
|
|
4881
|
-
const
|
|
4882
|
-
if (
|
|
4883
|
-
return { workbook: n, worksheet:
|
|
5685
|
+
const s = n.getSheetBySheetId(t.subUnitId || t.sheetId) || n.getActiveSheet();
|
|
5686
|
+
if (s)
|
|
5687
|
+
return { workbook: n, worksheet: s };
|
|
4884
5688
|
}
|
|
4885
5689
|
getSheetTarget(e, t) {
|
|
4886
5690
|
const n = this.getUniverSheet(e);
|
|
4887
5691
|
if (!n)
|
|
4888
5692
|
return;
|
|
4889
|
-
const
|
|
4890
|
-
if (
|
|
4891
|
-
return { workbook: n, worksheet:
|
|
5693
|
+
const s = n.getSheetBySheetId(t);
|
|
5694
|
+
if (s)
|
|
5695
|
+
return { workbook: n, worksheet: s };
|
|
4892
5696
|
}
|
|
4893
5697
|
_initWorkbookEvent(e) {
|
|
4894
|
-
const t = e.get(
|
|
5698
|
+
const t = e.get(re);
|
|
4895
5699
|
this.registerEventHandler(
|
|
4896
5700
|
this.Event.WorkbookDisposed,
|
|
4897
5701
|
() => t.unitDisposed$.subscribe((n) => {
|
|
4898
|
-
n.type ===
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
snapshot: n.getSnapshot()
|
|
4904
|
-
}
|
|
4905
|
-
);
|
|
5702
|
+
n.type === U.UNIVER_SHEET && this.fireEvent(this.Event.WorkbookDisposed, {
|
|
5703
|
+
unitId: n.getUnitId(),
|
|
5704
|
+
unitType: n.type,
|
|
5705
|
+
snapshot: n.getSnapshot()
|
|
5706
|
+
});
|
|
4906
5707
|
})
|
|
4907
5708
|
), this.registerEventHandler(
|
|
4908
5709
|
this.Event.WorkbookCreated,
|
|
4909
5710
|
() => t.unitAdded$.subscribe((n) => {
|
|
4910
|
-
if (n.type ===
|
|
4911
|
-
const
|
|
4912
|
-
this.fireEvent(
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
unit: o
|
|
4919
|
-
}
|
|
4920
|
-
);
|
|
5711
|
+
if (n.type === U.UNIVER_SHEET) {
|
|
5712
|
+
const s = n, o = e.createInstance(S, s);
|
|
5713
|
+
this.fireEvent(this.Event.WorkbookCreated, {
|
|
5714
|
+
unitId: n.getUnitId(),
|
|
5715
|
+
type: n.type,
|
|
5716
|
+
workbook: o,
|
|
5717
|
+
unit: o
|
|
5718
|
+
});
|
|
4921
5719
|
}
|
|
4922
5720
|
})
|
|
4923
5721
|
);
|
|
@@ -4927,13 +5725,13 @@ class mn extends Ae {
|
|
|
4927
5725
|
*/
|
|
4928
5726
|
// eslint-disable-next-line max-lines-per-function
|
|
4929
5727
|
_initialize(e) {
|
|
4930
|
-
const t = e.get(
|
|
5728
|
+
const t = e.get(l);
|
|
4931
5729
|
this.registerEventHandler(
|
|
4932
5730
|
this.Event.BeforeSheetCreate,
|
|
4933
5731
|
() => t.beforeCommandExecuted((n) => {
|
|
4934
|
-
var
|
|
4935
|
-
if (n.id ===
|
|
4936
|
-
const o = n.params, { unitId: i, index: a, sheet: h } = o || {}, d = i ? this.getUniverSheet(i) : (
|
|
5732
|
+
var s;
|
|
5733
|
+
if (n.id === F.id) {
|
|
5734
|
+
const o = n.params, { unitId: i, index: a, sheet: h } = o || {}, d = i ? this.getUniverSheet(i) : (s = this.getActiveWorkbook) == null ? void 0 : s.call(this);
|
|
4937
5735
|
if (!d)
|
|
4938
5736
|
return;
|
|
4939
5737
|
const c = {
|
|
@@ -4942,15 +5740,15 @@ class mn extends Ae {
|
|
|
4942
5740
|
sheet: h
|
|
4943
5741
|
};
|
|
4944
5742
|
if (this.fireEvent(this.Event.BeforeSheetCreate, c), c.cancel)
|
|
4945
|
-
throw new
|
|
5743
|
+
throw new v();
|
|
4946
5744
|
}
|
|
4947
5745
|
})
|
|
4948
5746
|
), this.registerEventHandler(
|
|
4949
5747
|
this.Event.BeforeActiveSheetChange,
|
|
4950
5748
|
() => t.beforeCommandExecuted((n) => {
|
|
4951
|
-
var
|
|
4952
|
-
if (n.id ===
|
|
4953
|
-
const { subUnitId: o, unitId: i } = n.params, a = i ? this.getUniverSheet(i) : (
|
|
5749
|
+
var s;
|
|
5750
|
+
if (n.id === H.id) {
|
|
5751
|
+
const { subUnitId: o, unitId: i } = n.params, a = i ? this.getUniverSheet(i) : (s = this.getActiveWorkbook) == null ? void 0 : s.call(this);
|
|
4954
5752
|
if (!a || !o) return;
|
|
4955
5753
|
const h = a.getSheetBySheetId(o), d = a.getActiveSheet();
|
|
4956
5754
|
if (!h || !d) return;
|
|
@@ -4960,122 +5758,122 @@ class mn extends Ae {
|
|
|
4960
5758
|
oldActiveSheet: d
|
|
4961
5759
|
};
|
|
4962
5760
|
if (this.fireEvent(this.Event.BeforeActiveSheetChange, c), c.cancel)
|
|
4963
|
-
throw new
|
|
5761
|
+
throw new v();
|
|
4964
5762
|
}
|
|
4965
5763
|
})
|
|
4966
5764
|
), this.registerEventHandler(
|
|
4967
5765
|
this.Event.BeforeSheetDelete,
|
|
4968
5766
|
() => t.beforeCommandExecuted((n) => {
|
|
4969
|
-
if (n.id ===
|
|
4970
|
-
const
|
|
4971
|
-
if (!
|
|
4972
|
-
const { workbook: o, worksheet: i } =
|
|
5767
|
+
if (n.id === ce.id) {
|
|
5768
|
+
const s = this.getCommandSheetTarget(n);
|
|
5769
|
+
if (!s) return;
|
|
5770
|
+
const { workbook: o, worksheet: i } = s, a = {
|
|
4973
5771
|
workbook: o,
|
|
4974
5772
|
worksheet: i
|
|
4975
5773
|
};
|
|
4976
5774
|
if (this.fireEvent(this.Event.BeforeSheetDelete, a), a.cancel)
|
|
4977
|
-
throw new
|
|
5775
|
+
throw new v();
|
|
4978
5776
|
}
|
|
4979
5777
|
})
|
|
4980
5778
|
), this.registerEventHandler(
|
|
4981
5779
|
this.Event.BeforeSheetMove,
|
|
4982
5780
|
() => t.beforeCommandExecuted((n) => {
|
|
4983
|
-
if (n.id ===
|
|
4984
|
-
const { fromOrder:
|
|
5781
|
+
if (n.id === Pe.id) {
|
|
5782
|
+
const { fromOrder: s, toOrder: o } = n.params, i = this.getCommandSheetTarget(n);
|
|
4985
5783
|
if (!i) return;
|
|
4986
5784
|
const a = {
|
|
4987
5785
|
workbook: i.workbook,
|
|
4988
5786
|
worksheet: i.worksheet,
|
|
4989
5787
|
newIndex: o,
|
|
4990
|
-
oldIndex:
|
|
5788
|
+
oldIndex: s
|
|
4991
5789
|
};
|
|
4992
5790
|
if (this.fireEvent(this.Event.BeforeSheetMove, a), a.cancel)
|
|
4993
|
-
throw new
|
|
5791
|
+
throw new v();
|
|
4994
5792
|
}
|
|
4995
5793
|
})
|
|
4996
5794
|
), this.registerEventHandler(
|
|
4997
5795
|
this.Event.BeforeSheetNameChange,
|
|
4998
5796
|
() => t.beforeCommandExecuted((n) => {
|
|
4999
|
-
if (n.id ===
|
|
5000
|
-
const { name:
|
|
5797
|
+
if (n.id === de.id) {
|
|
5798
|
+
const { name: s } = n.params, o = this.getCommandSheetTarget(n);
|
|
5001
5799
|
if (!o) return;
|
|
5002
5800
|
const i = {
|
|
5003
5801
|
workbook: o.workbook,
|
|
5004
5802
|
worksheet: o.worksheet,
|
|
5005
|
-
newName:
|
|
5803
|
+
newName: s,
|
|
5006
5804
|
oldName: o.worksheet.getSheetName()
|
|
5007
5805
|
};
|
|
5008
5806
|
if (this.fireEvent(this.Event.BeforeSheetNameChange, i), i.cancel)
|
|
5009
|
-
throw new
|
|
5807
|
+
throw new v();
|
|
5010
5808
|
}
|
|
5011
5809
|
})
|
|
5012
5810
|
), this.registerEventHandler(
|
|
5013
5811
|
this.Event.BeforeSheetTabColorChange,
|
|
5014
5812
|
() => t.beforeCommandExecuted((n) => {
|
|
5015
|
-
if (n.id ===
|
|
5016
|
-
const { color:
|
|
5813
|
+
if (n.id === Me.id) {
|
|
5814
|
+
const { color: s } = n.params, o = this.getCommandSheetTarget(n);
|
|
5017
5815
|
if (!o) return;
|
|
5018
5816
|
const i = {
|
|
5019
5817
|
workbook: o.workbook,
|
|
5020
5818
|
worksheet: o.worksheet,
|
|
5021
|
-
newColor:
|
|
5819
|
+
newColor: s,
|
|
5022
5820
|
oldColor: o.worksheet.getTabColor()
|
|
5023
5821
|
};
|
|
5024
5822
|
if (this.fireEvent(this.Event.BeforeSheetTabColorChange, i), i.cancel)
|
|
5025
|
-
throw new
|
|
5823
|
+
throw new v();
|
|
5026
5824
|
}
|
|
5027
5825
|
})
|
|
5028
5826
|
), this.registerEventHandler(
|
|
5029
5827
|
this.Event.BeforeSheetHideChange,
|
|
5030
5828
|
() => t.beforeCommandExecuted((n) => {
|
|
5031
|
-
if (n.id ===
|
|
5032
|
-
const { hidden:
|
|
5829
|
+
if (n.id === Ne.id) {
|
|
5830
|
+
const { hidden: s } = n.params, o = this.getCommandSheetTarget(n);
|
|
5033
5831
|
if (!o) return;
|
|
5034
5832
|
const i = {
|
|
5035
5833
|
workbook: o.workbook,
|
|
5036
5834
|
worksheet: o.worksheet,
|
|
5037
|
-
hidden: !!
|
|
5835
|
+
hidden: !!s
|
|
5038
5836
|
};
|
|
5039
5837
|
if (this.fireEvent(this.Event.BeforeSheetHideChange, i), i.cancel)
|
|
5040
|
-
throw new
|
|
5838
|
+
throw new v();
|
|
5041
5839
|
}
|
|
5042
5840
|
})
|
|
5043
5841
|
), this.registerEventHandler(
|
|
5044
5842
|
this.Event.BeforeGridlineColorChange,
|
|
5045
5843
|
() => t.beforeCommandExecuted((n) => {
|
|
5046
|
-
var
|
|
5047
|
-
if (n.id ===
|
|
5844
|
+
var s;
|
|
5845
|
+
if (n.id === he.id) {
|
|
5048
5846
|
const o = this.getCommandSheetTarget(n);
|
|
5049
5847
|
if (!o) return;
|
|
5050
5848
|
const i = {
|
|
5051
5849
|
...o,
|
|
5052
|
-
color: (
|
|
5850
|
+
color: (s = n.params) == null ? void 0 : s.color
|
|
5053
5851
|
};
|
|
5054
5852
|
if (this.fireEvent(this.Event.BeforeGridlineColorChange, i), i.cancel)
|
|
5055
|
-
throw new
|
|
5853
|
+
throw new v();
|
|
5056
5854
|
}
|
|
5057
5855
|
})
|
|
5058
5856
|
), this.registerEventHandler(
|
|
5059
5857
|
this.Event.BeforeGridlineEnableChange,
|
|
5060
5858
|
() => t.beforeCommandExecuted((n) => {
|
|
5061
|
-
var
|
|
5062
|
-
if (n.id ===
|
|
5859
|
+
var s;
|
|
5860
|
+
if (n.id === ae.id) {
|
|
5063
5861
|
const o = this.getCommandSheetTarget(n);
|
|
5064
5862
|
if (!o) return;
|
|
5065
5863
|
const i = {
|
|
5066
5864
|
...o,
|
|
5067
|
-
enabled: !!((
|
|
5865
|
+
enabled: !!((s = n.params) != null && s.showGridlines)
|
|
5068
5866
|
};
|
|
5069
5867
|
if (this.fireEvent(this.Event.BeforeGridlineEnableChange, i), i.cancel)
|
|
5070
|
-
throw new
|
|
5868
|
+
throw new v();
|
|
5071
5869
|
}
|
|
5072
5870
|
})
|
|
5073
5871
|
), this.registerEventHandler(
|
|
5074
5872
|
this.Event.SheetValueChanged,
|
|
5075
5873
|
() => t.onCommandExecuted((n) => {
|
|
5076
|
-
if (
|
|
5874
|
+
if (Xt.indexOf(n.id) > -1) {
|
|
5077
5875
|
if (!this.getActiveSheet()) return;
|
|
5078
|
-
const o =
|
|
5876
|
+
const o = Zt(n).map(
|
|
5079
5877
|
(i) => {
|
|
5080
5878
|
var a, h;
|
|
5081
5879
|
return (h = (a = this.getWorkbook(i.unitId)) == null ? void 0 : a.getSheetBySheetId(i.subUnitId)) == null ? void 0 : h.getRange(i.range);
|
|
@@ -5091,9 +5889,9 @@ class mn extends Ae {
|
|
|
5091
5889
|
), this.registerEventHandler(
|
|
5092
5890
|
this.Event.SheetCreated,
|
|
5093
5891
|
() => t.onCommandExecuted((n) => {
|
|
5094
|
-
var
|
|
5095
|
-
if (n.id ===
|
|
5096
|
-
const o = n.params, { unitId: i } = o || {}, a = i ? this.getUniverSheet(i) : (
|
|
5892
|
+
var s;
|
|
5893
|
+
if (n.id === F.id) {
|
|
5894
|
+
const o = n.params, { unitId: i } = o || {}, a = i ? this.getUniverSheet(i) : (s = this.getActiveWorkbook) == null ? void 0 : s.call(this);
|
|
5097
5895
|
if (!a)
|
|
5098
5896
|
return;
|
|
5099
5897
|
const h = a.getActiveSheet();
|
|
@@ -5112,19 +5910,19 @@ class mn extends Ae {
|
|
|
5112
5910
|
), this.registerEventHandler(
|
|
5113
5911
|
this.Event.ActiveSheetChanged,
|
|
5114
5912
|
() => t.onCommandExecuted((n) => {
|
|
5115
|
-
if (n.id ===
|
|
5116
|
-
const
|
|
5117
|
-
if (!
|
|
5118
|
-
const { workbook: o, worksheet: i } =
|
|
5913
|
+
if (n.id === H.id) {
|
|
5914
|
+
const s = this.getActiveSheet();
|
|
5915
|
+
if (!s) return;
|
|
5916
|
+
const { workbook: o, worksheet: i } = s;
|
|
5119
5917
|
this._fireActiveSheetChanged(o, i);
|
|
5120
5918
|
}
|
|
5121
5919
|
})
|
|
5122
5920
|
), this.registerEventHandler(
|
|
5123
5921
|
this.Event.SheetDeleted,
|
|
5124
5922
|
() => t.onCommandExecuted((n) => {
|
|
5125
|
-
var
|
|
5126
|
-
if (n.id ===
|
|
5127
|
-
const { subUnitId: o, unitId: i } = n.params, a = i ? this.getUniverSheet(i) : (
|
|
5923
|
+
var s;
|
|
5924
|
+
if (n.id === ce.id) {
|
|
5925
|
+
const { subUnitId: o, unitId: i } = n.params, a = i ? this.getUniverSheet(i) : (s = this.getActiveWorkbook) == null ? void 0 : s.call(this);
|
|
5128
5926
|
if (!a || !o) return;
|
|
5129
5927
|
this._fireSheetDeleted(a, o);
|
|
5130
5928
|
}
|
|
@@ -5132,87 +5930,87 @@ class mn extends Ae {
|
|
|
5132
5930
|
), this.registerEventHandler(
|
|
5133
5931
|
this.Event.SheetMoved,
|
|
5134
5932
|
() => t.onCommandExecuted((n) => {
|
|
5135
|
-
if (n.id ===
|
|
5136
|
-
const { toOrder:
|
|
5933
|
+
if (n.id === Pe.id) {
|
|
5934
|
+
const { toOrder: s } = n.params, o = this.getCommandSheetTarget(n);
|
|
5137
5935
|
if (!o) return;
|
|
5138
|
-
this._fireSheetMoved(o.workbook, o.worksheet,
|
|
5936
|
+
this._fireSheetMoved(o.workbook, o.worksheet, s);
|
|
5139
5937
|
}
|
|
5140
5938
|
})
|
|
5141
5939
|
), this.registerEventHandler(
|
|
5142
5940
|
this.Event.SheetNameChanged,
|
|
5143
5941
|
() => t.onCommandExecuted((n) => {
|
|
5144
|
-
if (n.id ===
|
|
5145
|
-
const { name:
|
|
5942
|
+
if (n.id === de.id) {
|
|
5943
|
+
const { name: s } = n.params, o = this.getCommandSheetTarget(n);
|
|
5146
5944
|
if (!o) return;
|
|
5147
|
-
this._fireSheetNameChanged(o.workbook, o.worksheet,
|
|
5945
|
+
this._fireSheetNameChanged(o.workbook, o.worksheet, s);
|
|
5148
5946
|
}
|
|
5149
5947
|
})
|
|
5150
5948
|
), this.registerEventHandler(
|
|
5151
5949
|
this.Event.SheetTabColorChanged,
|
|
5152
5950
|
() => t.onCommandExecuted((n) => {
|
|
5153
|
-
if (n.id ===
|
|
5154
|
-
const { color:
|
|
5951
|
+
if (n.id === Me.id) {
|
|
5952
|
+
const { color: s } = n.params, o = this.getCommandSheetTarget(n);
|
|
5155
5953
|
if (!o) return;
|
|
5156
|
-
this._fireSheetTabColorChanged(o.workbook, o.worksheet,
|
|
5954
|
+
this._fireSheetTabColorChanged(o.workbook, o.worksheet, s);
|
|
5157
5955
|
}
|
|
5158
5956
|
})
|
|
5159
5957
|
), this.registerEventHandler(
|
|
5160
5958
|
this.Event.SheetHideChanged,
|
|
5161
5959
|
() => t.onCommandExecuted((n) => {
|
|
5162
|
-
if (n.id ===
|
|
5163
|
-
const { hidden:
|
|
5960
|
+
if (n.id === Ne.id) {
|
|
5961
|
+
const { hidden: s } = n.params, o = this.getCommandSheetTarget(n);
|
|
5164
5962
|
if (!o) return;
|
|
5165
|
-
this._fireSheetHideChanged(o.workbook, o.worksheet, !!
|
|
5963
|
+
this._fireSheetHideChanged(o.workbook, o.worksheet, !!s);
|
|
5166
5964
|
}
|
|
5167
5965
|
})
|
|
5168
5966
|
), this.registerEventHandler(
|
|
5169
5967
|
this.Event.GridlineChanged,
|
|
5170
5968
|
() => t.onCommandExecuted((n) => {
|
|
5171
|
-
if (n.id ===
|
|
5172
|
-
const
|
|
5173
|
-
if (!
|
|
5969
|
+
if (n.id === he.id || n.id === ae.id) {
|
|
5970
|
+
const s = this.getCommandSheetTarget(n);
|
|
5971
|
+
if (!s) return;
|
|
5174
5972
|
this.fireEvent(this.Event.GridlineChanged, {
|
|
5175
|
-
...
|
|
5176
|
-
enabled: !
|
|
5177
|
-
color:
|
|
5973
|
+
...s,
|
|
5974
|
+
enabled: !s.worksheet.hasHiddenGridLines(),
|
|
5975
|
+
color: s.worksheet.getGridLinesColor()
|
|
5178
5976
|
});
|
|
5179
5977
|
}
|
|
5180
5978
|
})
|
|
5181
5979
|
), this._initWorkbookEvent(e);
|
|
5182
5980
|
}
|
|
5183
5981
|
createUniverSheet(e, t) {
|
|
5184
|
-
const
|
|
5185
|
-
return this._injector.createInstance(
|
|
5982
|
+
const s = this._injector.get(re).createUnit(U.UNIVER_SHEET, e, t);
|
|
5983
|
+
return this._injector.createInstance(S, s);
|
|
5186
5984
|
}
|
|
5187
5985
|
createWorkbook(e, t) {
|
|
5188
5986
|
return this.createUniverSheet(e, t);
|
|
5189
5987
|
}
|
|
5190
5988
|
getActiveWorkbook() {
|
|
5191
|
-
const e = this._univerInstanceService.getCurrentUnitForType(
|
|
5192
|
-
return e ? this._injector.createInstance(
|
|
5989
|
+
const e = this._univerInstanceService.getCurrentUnitForType(U.UNIVER_SHEET);
|
|
5990
|
+
return e ? this._injector.createInstance(S, e) : null;
|
|
5193
5991
|
}
|
|
5194
5992
|
getActiveUniverSheet() {
|
|
5195
5993
|
return this.getActiveWorkbook();
|
|
5196
5994
|
}
|
|
5197
5995
|
getUniverSheet(e) {
|
|
5198
|
-
const t = this._univerInstanceService.getUnit(e,
|
|
5199
|
-
return t ? this._injector.createInstance(
|
|
5996
|
+
const t = this._univerInstanceService.getUnit(e, U.UNIVER_SHEET);
|
|
5997
|
+
return t ? this._injector.createInstance(S, t) : null;
|
|
5200
5998
|
}
|
|
5201
5999
|
getWorkbook(e) {
|
|
5202
6000
|
return this.getUniverSheet(e);
|
|
5203
6001
|
}
|
|
5204
6002
|
getPermission() {
|
|
5205
|
-
return this._injector.createInstance(
|
|
6003
|
+
return this._injector.createInstance(K);
|
|
5206
6004
|
}
|
|
5207
6005
|
onUniverSheetCreated(e) {
|
|
5208
|
-
const t = this._univerInstanceService.getTypeOfUnitAdded$(
|
|
5209
|
-
const
|
|
5210
|
-
e(
|
|
6006
|
+
const t = this._univerInstanceService.getTypeOfUnitAdded$(U.UNIVER_SHEET).subscribe((n) => {
|
|
6007
|
+
const s = this._injector.createInstance(S, n);
|
|
6008
|
+
e(s);
|
|
5211
6009
|
});
|
|
5212
|
-
return
|
|
6010
|
+
return Oe(t);
|
|
5213
6011
|
}
|
|
5214
6012
|
newDefinedName() {
|
|
5215
|
-
return this._injector.createInstance(
|
|
6013
|
+
return this._injector.createInstance(J);
|
|
5216
6014
|
}
|
|
5217
6015
|
getActiveSheet() {
|
|
5218
6016
|
const e = this.getActiveWorkbook();
|
|
@@ -5262,20 +6060,20 @@ class mn extends Ae {
|
|
|
5262
6060
|
});
|
|
5263
6061
|
}
|
|
5264
6062
|
}
|
|
5265
|
-
|
|
5266
|
-
class
|
|
6063
|
+
je.extend(Rn);
|
|
6064
|
+
class bn {
|
|
5267
6065
|
get SheetValueChangeType() {
|
|
5268
|
-
return
|
|
6066
|
+
return en;
|
|
5269
6067
|
}
|
|
5270
6068
|
get SheetSkeletonChangeType() {
|
|
5271
|
-
return
|
|
6069
|
+
return tn;
|
|
5272
6070
|
}
|
|
5273
6071
|
get SplitDelimiterType() {
|
|
5274
|
-
return
|
|
6072
|
+
return nn;
|
|
5275
6073
|
}
|
|
5276
6074
|
}
|
|
5277
|
-
|
|
5278
|
-
class
|
|
6075
|
+
dt.extend(bn);
|
|
6076
|
+
class pn {
|
|
5279
6077
|
get SheetCreated() {
|
|
5280
6078
|
return "SheetCreated";
|
|
5281
6079
|
}
|
|
@@ -5337,27 +6135,27 @@ class _n {
|
|
|
5337
6135
|
return "SheetValueChanged";
|
|
5338
6136
|
}
|
|
5339
6137
|
}
|
|
5340
|
-
|
|
5341
|
-
var
|
|
5342
|
-
for (var
|
|
5343
|
-
(i =
|
|
5344
|
-
return
|
|
5345
|
-
},
|
|
5346
|
-
let
|
|
5347
|
-
constructor(
|
|
5348
|
-
super(), this._injector =
|
|
6138
|
+
ct.extend(pn);
|
|
6139
|
+
var En = Object.getOwnPropertyDescriptor, yn = (r, e, t, n) => {
|
|
6140
|
+
for (var s = n > 1 ? void 0 : n ? En(e, t) : e, o = r.length - 1, i; o >= 0; o--)
|
|
6141
|
+
(i = r[o]) && (s = i(s) || s);
|
|
6142
|
+
return s;
|
|
6143
|
+
}, Un = (r, e) => (t, n) => e(t, n, r);
|
|
6144
|
+
let We = class extends ge {
|
|
6145
|
+
constructor(r) {
|
|
6146
|
+
super(), this._injector = r;
|
|
5349
6147
|
}
|
|
5350
6148
|
};
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
],
|
|
6149
|
+
We = yn([
|
|
6150
|
+
Un(0, u(x))
|
|
6151
|
+
], We);
|
|
5354
6152
|
export {
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
6153
|
+
K as FPermission,
|
|
6154
|
+
m as FRange,
|
|
6155
|
+
Y as FSelection,
|
|
6156
|
+
pn as FSheetEventName,
|
|
6157
|
+
We as FSheetHooks,
|
|
6158
|
+
bn as FSheetsEnum,
|
|
6159
|
+
S as FWorkbook,
|
|
6160
|
+
k as FWorksheet
|
|
5363
6161
|
};
|