@univerjs/sheets 0.5.3 → 0.5.4
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 +1286 -755
- package/lib/es/index.js +3901 -3273
- package/lib/types/basics/cell-style.d.ts +8 -0
- package/lib/types/controllers/permission/sheet-permission-check.controller.d.ts +33 -0
- package/lib/types/controllers/permission/sheet-permission-init.controller.d.ts +29 -0
- package/lib/types/controllers/permission/sheet-permission-view-model.controller.d.ts +13 -0
- package/lib/types/facade/f-defined-name.d.ts +61 -61
- package/lib/types/facade/f-event.d.ts +85 -1
- package/lib/types/facade/f-permission.d.ts +3 -20
- package/lib/types/facade/f-range.d.ts +246 -35
- package/lib/types/facade/f-univer.d.ts +56 -11
- package/lib/types/facade/f-workbook.d.ts +87 -17
- package/lib/types/facade/f-worksheet.d.ts +158 -59
- package/lib/types/facade/index.d.ts +0 -1
- package/lib/types/facade/utils.d.ts +38 -2
- package/lib/types/index.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +3 -3
- package/package.json +7 -7
package/lib/es/facade.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Inject as
|
|
5
|
-
import { WorksheetProtectionRuleModel as
|
|
6
|
-
import { IDefinedNamesService as
|
|
7
|
-
var
|
|
8
|
-
for (var
|
|
9
|
-
(i = o
|
|
10
|
-
return n &&
|
|
11
|
-
},
|
|
12
|
-
function
|
|
13
|
-
const n = t.getDefinedNameMap(
|
|
1
|
+
var Ae = Object.defineProperty;
|
|
2
|
+
var Fe = (s, e, t) => e in s ? Ae(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var k = (s, e, t) => Fe(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Inject as u, Injector as b, IAuthzIoService as ve, LocaleService as Re, ICommandService as l, IPermissionService as ee, generateRandomId as be, FBase as te, Rectangle as N, HorizontalAlign as y, VerticalAlign as U, isFormulaString as je, isCellV as Oe, isICellData as Ve, ObjectMatrix as A, Tools as Be, RANGE_TYPE as _, FBaseInitialable as ne, RichTextValue as p, BooleanNumber as m, WrapStrategy as oe, Dimension as ie, ILogService as pe, Registry as ye, toDisposable as F, Direction as D, IResourceLoaderService as Le, FEnum as ze, FEventName as se, mergeWorksheetSnapshotWithDefault as $e, UndoCommand as He, RedoCommand as Ge, UniverInstanceType as R, IUniverInstanceService as J, FUniver as Ue, CanceledError as qe } from "@univerjs/core";
|
|
5
|
+
import { WorksheetProtectionRuleModel as Ee, RangeProtectionRuleModel as Pe, WorksheetProtectionPointModel as xe, SetDefinedNameCommand as Q, SCOPE_WORKBOOK_VALUE_DEFINED_NAME as X, RemoveDefinedNameCommand as Ke, PermissionPointsDefinitions as Ye, WorkbookEditablePermission as Ne, UnitObject as E, AddWorksheetProtectionMutation as Je, DeleteWorksheetProtectionMutation as Qe, getAllWorksheetPermissionPoint as Xe, getAllWorksheetPermissionPointByPointPanel as ae, SetWorksheetPermissionPointsMutation as Ze, AddRangeProtectionMutation as et, DeleteRangeProtectionMutation as tt, SetRangeProtectionMutation as nt, WorksheetEditPermission as st, WorksheetViewPermission as rt, SetStyleCommand as f, SetRangeValuesCommand as P, SetTextWrapCommand as he, SetVerticalTextAlignCommand as ot, SetHorizontalTextAlignCommand as it, addMergeCellsUtil as $, getAddMergeMutationRangeByType as ce, RemoveWorksheetMergeCommand as at, SplitTextToColumnsCommand as ht, SetWorksheetRangeThemeStyleCommand as ct, DeleteWorksheetRangeThemeStyleCommand as dt, SheetRangeThemeService as Me, getPrimaryForRange as Z, SetSelectionsOperation as De, getNextPrimaryCell as ut, SheetsSelectionsService as We, SetWorksheetDefaultStyleMutation as mt, SetColDataCommand as de, SetRowDataCommand as ue, copyRangeStyles as W, InsertRowByRangeCommand as me, RemoveRowByRangeCommand as lt, MoveRowsCommand as gt, SetRowHiddenCommand as le, SetSpecificRowsVisibleCommand as ge, SetRowHeightCommand as _e, SetWorksheetRowIsAutoHeightCommand as _t, InsertColByRangeCommand as we, RemoveColByRangeCommand as wt, MoveColsCommand as kt, SetColHiddenCommand as ke, SetSpecificColsVisibleCommand as Se, SetColWidthCommand as St, SetFrozenCommand as H, CancelFrozenCommand as Ct, ToggleGridlinesCommand as It, SetGridlinesColorCommand as ft, SetTabColorCommand as vt, SetRangeValuesMutation as Ce, SetWorksheetHideCommand as Rt, SetWorksheetShowCommand as bt, SetWorksheetNameCommand as pt, ClearSelectionAllCommand as yt, ClearSelectionContentCommand as Ut, ClearSelectionFormatCommand as Et, InsertSheetCommand as x, SetWorksheetActiveOperation as G, RemoveSheetCommand as Pt, CopySheetCommand as xt, SetWorksheetOrderCommand as Nt, RegisterWorksheetRangeThemeStyleCommand as Mt, UnregisterWorksheetRangeThemeStyleCommand as Dt } from "@univerjs/sheets";
|
|
6
|
+
import { IDefinedNamesService as Te, serializeRange as re, FormulaDataModel as Wt, serializeRangeWithSheet as Tt, deserializeRangeWithSheet as At } from "@univerjs/engine-formula";
|
|
7
|
+
var Ft = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, Ot = (s, e, t, n) => {
|
|
8
|
+
for (var r = n > 1 ? void 0 : n ? jt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
9
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
10
|
+
return n && r && Ft(e, t, r), r;
|
|
11
|
+
}, S = (s, e) => (t, n) => e(t, n, s);
|
|
12
|
+
function Vt(s, e, t) {
|
|
13
|
+
const n = t.getDefinedNameMap(s);
|
|
14
14
|
if (n == null)
|
|
15
15
|
return e.t("definedName.defaultName") + 1;
|
|
16
|
-
const
|
|
17
|
-
if (t.getValueByName(
|
|
16
|
+
const o = Array.from(Object.values(n)).length + 1, i = e.t("definedName.defaultName") + o;
|
|
17
|
+
if (t.getValueByName(s, i) == null)
|
|
18
18
|
return i;
|
|
19
|
-
let a =
|
|
19
|
+
let a = o + 1;
|
|
20
20
|
for (; ; ) {
|
|
21
21
|
const h = e.t("definedName.defaultName") + a;
|
|
22
|
-
if (t.getValueByName(
|
|
22
|
+
if (t.getValueByName(s, h) == null)
|
|
23
23
|
return h;
|
|
24
24
|
a++;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
class
|
|
27
|
+
class L {
|
|
28
28
|
constructor() {
|
|
29
|
-
|
|
29
|
+
k(this, "_definedNameParam");
|
|
30
30
|
this._definedNameParam = {
|
|
31
|
-
id:
|
|
31
|
+
id: be(10),
|
|
32
32
|
unitId: "",
|
|
33
33
|
name: "",
|
|
34
34
|
formulaOrRefString: ""
|
|
@@ -36,12 +36,12 @@ class F {
|
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Sets the name of the defined name builder.
|
|
39
|
-
* @param name
|
|
40
|
-
* @returns The defined name builder.
|
|
39
|
+
* @param {string} name The name of the defined name.
|
|
40
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
41
41
|
* @example
|
|
42
42
|
* ```ts
|
|
43
|
-
* const workbook =
|
|
44
|
-
* const definedNameBuilder =
|
|
43
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
44
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
45
45
|
* .setName('MyDefinedName')
|
|
46
46
|
* .build();
|
|
47
47
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
@@ -52,12 +52,12 @@ class F {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Sets the formula of the defined name builder.
|
|
55
|
-
* @param formula The formula of the defined name.
|
|
56
|
-
* @returns The defined name builder.
|
|
55
|
+
* @param {string }formula The formula of the defined name.
|
|
56
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
57
57
|
* @example
|
|
58
58
|
* ```ts
|
|
59
|
-
* const workbook =
|
|
60
|
-
* const definedNameBuilder =
|
|
59
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
60
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
61
61
|
* .setFormula('SUM(Sheet1!$A$1)')
|
|
62
62
|
* .setName('MyDefinedName')
|
|
63
63
|
* .build();
|
|
@@ -69,12 +69,12 @@ class F {
|
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Sets the reference of the defined name builder.
|
|
72
|
-
* @param
|
|
73
|
-
* @returns The defined name builder.
|
|
72
|
+
* @param {string} a1Notation The reference of the defined name.
|
|
73
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
74
74
|
* @example
|
|
75
75
|
* ```ts
|
|
76
|
-
* const workbook =
|
|
77
|
-
* const definedNameBuilder =
|
|
76
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
77
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
78
78
|
* .setRef('Sheet1!$A$1')
|
|
79
79
|
* .build();
|
|
80
80
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
@@ -85,36 +85,36 @@ class F {
|
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Sets the reference of the defined name builder by range .
|
|
88
|
-
* @param row The start row of the range.
|
|
89
|
-
* @param column The start column of the range.
|
|
90
|
-
* @param numRows The number of rows in the range.
|
|
91
|
-
* @param numColumns The number of columns in the range.
|
|
92
|
-
* @returns The defined name builder.
|
|
88
|
+
* @param {number} row The start row of the range.
|
|
89
|
+
* @param {number} column The start column of the range.
|
|
90
|
+
* @param {number} numRows The number of rows in the range.
|
|
91
|
+
* @param {number} numColumns The number of columns in the range.
|
|
92
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
93
93
|
* @example
|
|
94
94
|
* ```ts
|
|
95
|
-
* const workbook =
|
|
96
|
-
* const definedNameBuilder =
|
|
95
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
96
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
97
97
|
* .setRefByRange(1, 3, 2, 5)
|
|
98
98
|
* .build();
|
|
99
99
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
100
100
|
* ```
|
|
101
101
|
*/
|
|
102
|
-
setRefByRange(e, t, n,
|
|
103
|
-
return this._definedNameParam.formulaOrRefString =
|
|
102
|
+
setRefByRange(e, t, n, r) {
|
|
103
|
+
return this._definedNameParam.formulaOrRefString = re({
|
|
104
104
|
startRow: e,
|
|
105
105
|
endRow: e + (n != null ? n : 1) - 1,
|
|
106
106
|
startColumn: t,
|
|
107
|
-
endColumn: t + (
|
|
107
|
+
endColumn: t + (r != null ? r : 1) - 1
|
|
108
108
|
}), this;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* Sets the comment of the defined name builder.
|
|
112
|
-
* @param comment The comment of the defined name.
|
|
113
|
-
* @returns The defined name builder.
|
|
112
|
+
* @param {string} comment The comment of the defined name.
|
|
113
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
114
114
|
* @example
|
|
115
115
|
* ```ts
|
|
116
|
-
* const workbook =
|
|
117
|
-
* const definedNameBuilder =
|
|
116
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
117
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
118
118
|
* .setComment('This is a comment')
|
|
119
119
|
* .build();
|
|
120
120
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
@@ -125,12 +125,12 @@ class F {
|
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
127
127
|
* Sets the hidden status of the defined name builder.
|
|
128
|
-
* @param hidden The hidden status of the defined name.
|
|
129
|
-
* @returns The defined name builder.
|
|
128
|
+
* @param {boolean} hidden The hidden status of the defined name.
|
|
129
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
130
130
|
* @example
|
|
131
131
|
* ```ts
|
|
132
|
-
* const workbook =
|
|
133
|
-
* const definedNameBuilder =
|
|
132
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
133
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
134
134
|
* .setHidden(true)
|
|
135
135
|
* .build();
|
|
136
136
|
* workbook.insertDefinedNameBuilder(definedNameBuilder);
|
|
@@ -141,11 +141,11 @@ class F {
|
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* Builds the defined name.
|
|
144
|
-
* @returns The defined name mutation parameter.
|
|
144
|
+
* @returns {FDefinedNameBuilder} The defined name mutation parameter.
|
|
145
145
|
* @example
|
|
146
146
|
* ```ts
|
|
147
|
-
* const workbook =
|
|
148
|
-
* const definedNameBuilder =
|
|
147
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
148
|
+
* const definedNameBuilder = univerAPI.newDefinedName()
|
|
149
149
|
* .setRef('Sheet1!$A$1')
|
|
150
150
|
* .setName('MyDefinedName')
|
|
151
151
|
* .build();
|
|
@@ -159,19 +159,19 @@ class F {
|
|
|
159
159
|
return this._definedNameParam = e, this;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
let
|
|
163
|
-
constructor(
|
|
164
|
-
super(), this._definedNameParam =
|
|
162
|
+
let j = class extends te {
|
|
163
|
+
constructor(s, e, t, n, r, o, i, a, h, c) {
|
|
164
|
+
super(), this._definedNameParam = s, this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = r, this._rangeProtectionRuleModel = o, this._worksheetProtectionPointRuleModel = i, this._authzIoService = a, this._localeService = h, this._definedNamesService = c;
|
|
165
165
|
}
|
|
166
166
|
_apply() {
|
|
167
|
-
this._definedNameParam.name === "" && (this._definedNameParam.name =
|
|
167
|
+
this._definedNameParam.name === "" && (this._definedNameParam.name = Vt(this._definedNameParam.unitId, this._localeService, this._definedNamesService)), this._commandService.syncExecuteCommand(Q.id, this._definedNameParam);
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* Gets the name of the defined name.
|
|
171
|
-
* @returns The name of the defined name.
|
|
171
|
+
* @returns {string} The name of the defined name.
|
|
172
172
|
* @example
|
|
173
173
|
* ```ts
|
|
174
|
-
* const workbook =
|
|
174
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
175
175
|
* const definedName = workbook.getDefinedNames[0];
|
|
176
176
|
* console.log(definedName.getName());
|
|
177
177
|
* ```
|
|
@@ -181,49 +181,49 @@ let M = class extends Q {
|
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
183
|
* Sets the name of the defined name.
|
|
184
|
-
* @param name The name of the defined name.
|
|
184
|
+
* @param {string} name The name of the defined name.
|
|
185
185
|
* @example
|
|
186
186
|
* ```ts
|
|
187
|
-
* const workbook =
|
|
187
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
188
188
|
* const definedName = workbook.getDefinedName('MyDefinedName');
|
|
189
189
|
* definedName.setName('NewDefinedName');
|
|
190
190
|
* ```
|
|
191
191
|
*/
|
|
192
|
-
setName(
|
|
193
|
-
this._definedNameParam.name =
|
|
192
|
+
setName(s) {
|
|
193
|
+
this._definedNameParam.name = s, this._apply();
|
|
194
194
|
}
|
|
195
195
|
/**
|
|
196
196
|
* Sets the formula of the defined name.
|
|
197
|
-
* @param formula The formula of the defined name.
|
|
197
|
+
* @param {string} formula The formula of the defined name.
|
|
198
198
|
* @example
|
|
199
199
|
* ```ts
|
|
200
|
-
* const workbook =
|
|
200
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
201
201
|
* const definedName = workbook.getDefinedName('MyDefinedName');
|
|
202
202
|
* definedName.setFormula('SUM(Sheet1!$A$1)');
|
|
203
203
|
* ```
|
|
204
204
|
*/
|
|
205
|
-
setFormula(
|
|
206
|
-
this._definedNameParam.formulaOrRefString = `=${
|
|
205
|
+
setFormula(s) {
|
|
206
|
+
this._definedNameParam.formulaOrRefString = `=${s}`, this._apply();
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
209
|
* Sets the reference of the defined name.
|
|
210
|
-
* @param refString The reference of the defined name.
|
|
210
|
+
* @param {string} refString The reference of the defined name.
|
|
211
211
|
* @example
|
|
212
212
|
* ```ts
|
|
213
|
-
* const workbook =
|
|
213
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
214
214
|
* const definedName = workbook.getDefinedNames[0];
|
|
215
215
|
* definedName.setRef('Sheet1!$A$1');
|
|
216
216
|
* ```
|
|
217
217
|
*/
|
|
218
|
-
setRef(
|
|
219
|
-
this._definedNameParam.formulaOrRefString =
|
|
218
|
+
setRef(s) {
|
|
219
|
+
this._definedNameParam.formulaOrRefString = s, this._apply();
|
|
220
220
|
}
|
|
221
221
|
/**
|
|
222
222
|
* Gets the reference of the defined name.
|
|
223
|
-
* @returns The reference of the defined name.
|
|
223
|
+
* @returns {string} The reference of the defined name.
|
|
224
224
|
* @example
|
|
225
225
|
* ```ts
|
|
226
|
-
* const workbook =
|
|
226
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
227
227
|
* const definedName = workbook.getDefinedNames[0];
|
|
228
228
|
* console.log(definedName.getFormulaOrRefString());
|
|
229
229
|
* ```
|
|
@@ -233,31 +233,31 @@ let M = class extends Q {
|
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* Sets the reference of the defined name by range.
|
|
236
|
-
* @param row The start row of the range.
|
|
237
|
-
* @param column The start column of the range.
|
|
238
|
-
* @param numRows The number of rows in the range.
|
|
239
|
-
* @param numColumns The number of columns in the range.
|
|
236
|
+
* @param {number} row The start row of the range.
|
|
237
|
+
* @param {number} column The start column of the range.
|
|
238
|
+
* @param {number} numRows The number of rows in the range.
|
|
239
|
+
* @param {number} numColumns The number of columns in the range.
|
|
240
240
|
* @example
|
|
241
241
|
* ```ts
|
|
242
|
-
* const workbook =
|
|
242
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
243
243
|
* const definedName = workbook.getDefinedNames[0];
|
|
244
244
|
* definedName.setRefByRange(1, 3, 2, 5);
|
|
245
245
|
* ```
|
|
246
246
|
*/
|
|
247
|
-
setRefByRange(
|
|
248
|
-
this._definedNameParam.formulaOrRefString =
|
|
249
|
-
startRow:
|
|
250
|
-
endRow:
|
|
247
|
+
setRefByRange(s, e, t, n) {
|
|
248
|
+
this._definedNameParam.formulaOrRefString = re({
|
|
249
|
+
startRow: s,
|
|
250
|
+
endRow: s + (t != null ? t : 1) - 1,
|
|
251
251
|
startColumn: e,
|
|
252
252
|
endColumn: e + (n != null ? n : 1) - 1
|
|
253
253
|
}), this._apply();
|
|
254
254
|
}
|
|
255
255
|
/**
|
|
256
256
|
* Gets the comment of the defined name.
|
|
257
|
-
* @returns The comment of the defined name.
|
|
257
|
+
* @returns {string | undefined} The comment of the defined name.
|
|
258
258
|
* @example
|
|
259
259
|
* ```ts
|
|
260
|
-
* const workbook =
|
|
260
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
261
261
|
* const definedName = workbook.getDefinedNames[0];
|
|
262
262
|
* console.log(definedName.getComment());
|
|
263
263
|
* ```
|
|
@@ -267,74 +267,74 @@ let M = class extends Q {
|
|
|
267
267
|
}
|
|
268
268
|
/**
|
|
269
269
|
* Sets the comment of the defined name.
|
|
270
|
-
* @param comment The comment of the defined name.
|
|
270
|
+
* @param {string} comment The comment of the defined name.
|
|
271
271
|
* @example
|
|
272
272
|
* ```ts
|
|
273
|
-
* const workbook =
|
|
273
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
274
274
|
* const definedName = workbook.getDefinedNames[0];
|
|
275
275
|
* definedName.setComment('This is a comment');
|
|
276
276
|
* ```
|
|
277
277
|
*/
|
|
278
|
-
setComment(
|
|
279
|
-
this._definedNameParam.comment =
|
|
278
|
+
setComment(s) {
|
|
279
|
+
this._definedNameParam.comment = s, this._apply();
|
|
280
280
|
}
|
|
281
281
|
/**
|
|
282
282
|
* Sets the scope of the defined name to the worksheet.
|
|
283
|
-
* @param worksheet The worksheet to set the scope to.
|
|
283
|
+
* @param {FWorksheet} worksheet The worksheet to set the scope to.
|
|
284
284
|
* @example
|
|
285
285
|
* ```ts
|
|
286
|
-
* const workbook =
|
|
286
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
287
287
|
* const worksheet = workbook.getWorksheets[0];
|
|
288
288
|
* const definedName = workbook.getDefinedNames[0];
|
|
289
289
|
* definedName.setScopeToWorksheet(worksheet);
|
|
290
290
|
* ```
|
|
291
291
|
*/
|
|
292
|
-
setScopeToWorksheet(
|
|
293
|
-
this._definedNameParam.localSheetId =
|
|
292
|
+
setScopeToWorksheet(s) {
|
|
293
|
+
this._definedNameParam.localSheetId = s.getSheetId(), this._apply();
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
* Sets the scope of the defined name to the workbook.
|
|
297
297
|
* @example
|
|
298
298
|
* ```ts
|
|
299
|
-
* const workbook =
|
|
299
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
300
300
|
* const definedName = workbook.getDefinedNames[0];
|
|
301
301
|
* definedName.setScopeToWorkbook();
|
|
302
302
|
* ```
|
|
303
303
|
*/
|
|
304
304
|
setScopeToWorkbook() {
|
|
305
|
-
this._definedNameParam.localSheetId =
|
|
305
|
+
this._definedNameParam.localSheetId = X, this._apply();
|
|
306
306
|
}
|
|
307
307
|
/**
|
|
308
308
|
* Sets the hidden status of the defined name.
|
|
309
|
-
* @param hidden The hidden status of the defined name.
|
|
309
|
+
* @param {boolean} hidden The hidden status of the defined name.
|
|
310
310
|
* @example
|
|
311
311
|
* ```ts
|
|
312
|
-
* const workbook =
|
|
312
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
313
313
|
* const definedName = workbook.getDefinedNames[0];
|
|
314
314
|
* definedName.setHidden(true);
|
|
315
315
|
* ```
|
|
316
316
|
*/
|
|
317
|
-
setHidden(
|
|
318
|
-
this._definedNameParam.hidden =
|
|
317
|
+
setHidden(s) {
|
|
318
|
+
this._definedNameParam.hidden = s, this._apply();
|
|
319
319
|
}
|
|
320
320
|
/**
|
|
321
321
|
* Deletes the defined name.
|
|
322
322
|
* @example
|
|
323
323
|
* ```ts
|
|
324
|
-
* const workbook =
|
|
324
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
325
325
|
* const definedName = workbook.getDefinedNames[0];
|
|
326
326
|
* definedName.delete();
|
|
327
327
|
* ```
|
|
328
328
|
*/
|
|
329
329
|
delete() {
|
|
330
|
-
this._commandService.syncExecuteCommand(
|
|
330
|
+
this._commandService.syncExecuteCommand(Ke.id, this._definedNameParam);
|
|
331
331
|
}
|
|
332
332
|
/**
|
|
333
333
|
* Gets the local sheet id of the defined name.
|
|
334
|
-
* @returns The local sheet id of the defined name.
|
|
334
|
+
* @returns {string | undefined} The local sheet id of the defined name.
|
|
335
335
|
* @example
|
|
336
336
|
* ```ts
|
|
337
|
-
* const workbook =
|
|
337
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
338
338
|
* const definedName = workbook.getDefinedNames[0];
|
|
339
339
|
* console.log(definedName.getLocalSheetId());
|
|
340
340
|
* ```
|
|
@@ -344,23 +344,23 @@ let M = class extends Q {
|
|
|
344
344
|
}
|
|
345
345
|
/**
|
|
346
346
|
* Checks if the defined name is in the workbook scope.
|
|
347
|
-
* @returns True if the defined name is in the workbook scope, false otherwise.
|
|
347
|
+
* @returns {boolean} True if the defined name is in the workbook scope, false otherwise.
|
|
348
348
|
* @example
|
|
349
349
|
* ```ts
|
|
350
|
-
* const workbook =
|
|
350
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
351
351
|
* const definedName = workbook.getDefinedNames[0];
|
|
352
352
|
* console.log(definedName.isWorkbookScope());
|
|
353
353
|
* ```
|
|
354
354
|
*/
|
|
355
355
|
isWorkbookScope() {
|
|
356
|
-
return this._definedNameParam.localSheetId ===
|
|
356
|
+
return this._definedNameParam.localSheetId === X;
|
|
357
357
|
}
|
|
358
358
|
/**
|
|
359
359
|
* Converts the defined name to a defined name builder.
|
|
360
|
-
* @returns The defined name builder.
|
|
360
|
+
* @returns {FDefinedNameBuilder} The defined name builder.
|
|
361
361
|
* @example
|
|
362
362
|
* ```ts
|
|
363
|
-
* const workbook =
|
|
363
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
364
364
|
* const definedName = workbook.getDefinedNames[0];
|
|
365
365
|
* const definedNameBuilder = definedName.toBuilder();
|
|
366
366
|
* const param definedNameBuilder.setName('NewDefinedName').setFormula('SUM(Sheet1!$A$1)').build();
|
|
@@ -368,70 +368,66 @@ let M = class extends Q {
|
|
|
368
368
|
* ```
|
|
369
369
|
*/
|
|
370
370
|
toBuilder() {
|
|
371
|
-
const
|
|
372
|
-
return
|
|
371
|
+
const s = this._injector.createInstance(L);
|
|
372
|
+
return s.load(this._definedNameParam), s;
|
|
373
373
|
}
|
|
374
374
|
};
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
],
|
|
386
|
-
var
|
|
387
|
-
for (var
|
|
388
|
-
(i = o
|
|
389
|
-
return n &&
|
|
390
|
-
},
|
|
391
|
-
let
|
|
392
|
-
constructor(e, t, n,
|
|
375
|
+
j = Ot([
|
|
376
|
+
S(1, u(b)),
|
|
377
|
+
S(2, l),
|
|
378
|
+
S(3, ee),
|
|
379
|
+
S(4, u(Ee)),
|
|
380
|
+
S(5, u(Pe)),
|
|
381
|
+
S(6, u(xe)),
|
|
382
|
+
S(7, u(ve)),
|
|
383
|
+
S(8, u(Re)),
|
|
384
|
+
S(9, Te)
|
|
385
|
+
], j);
|
|
386
|
+
var Bt = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, zt = (s, e, t, n) => {
|
|
387
|
+
for (var r = n > 1 ? void 0 : n ? Lt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
388
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
389
|
+
return n && r && Bt(e, t, r), r;
|
|
390
|
+
}, v = (s, e) => (t, n) => e(t, n, s);
|
|
391
|
+
let O = class extends te {
|
|
392
|
+
constructor(e, t, n, r, o, i, a) {
|
|
393
393
|
super();
|
|
394
|
-
|
|
395
|
-
this
|
|
394
|
+
k(this, "permissionPointsDefinition", Ye);
|
|
395
|
+
k(this, "rangeRuleChangedAfterAuth$");
|
|
396
|
+
k(this, "sheetRuleChangedAfterAuth$");
|
|
397
|
+
this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = r, this._rangeProtectionRuleModel = o, this._worksheetProtectionPointRuleModel = i, this._authzIoService = a, this.rangeRuleChangedAfterAuth$ = this._rangeProtectionRuleModel.ruleRefresh$, this.sheetRuleChangedAfterAuth$ = this._worksheetProtectionRuleModel.ruleRefresh$;
|
|
396
398
|
}
|
|
397
399
|
/**
|
|
398
400
|
* Configures a specific permission point for a workbook.
|
|
399
401
|
*
|
|
400
402
|
* This function sets or updates a permission point for a workbook identified by `unitId`.
|
|
401
403
|
* It creates a new permission point if it does not already exist, and updates the point with the provided value.
|
|
402
|
-
*
|
|
403
404
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
404
405
|
* @param {WorkbookPermissionPointConstructor} FPointClass - The constructor function for creating a permission point instance. Other point constructors can See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
|
|
405
406
|
* @param {boolean} value - The boolean value to determine whether the permission point is enabled or disabled.
|
|
406
|
-
*
|
|
407
407
|
*/
|
|
408
408
|
setWorkbookPermissionPoint(e, t, n) {
|
|
409
|
-
const
|
|
410
|
-
this._permissionService.getPermissionPoint(
|
|
409
|
+
const r = new t(e);
|
|
410
|
+
this._permissionService.getPermissionPoint(r.id) || this._permissionService.addPermissionPoint(r), this._permissionService.updatePermissionPoint(r.id, n);
|
|
411
411
|
}
|
|
412
412
|
/**
|
|
413
413
|
* This function is used to set whether the workbook can be edited
|
|
414
|
-
*
|
|
415
414
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
416
415
|
* @param {boolean} value - A value that controls whether the workbook can be edited
|
|
417
|
-
*
|
|
418
416
|
*/
|
|
419
417
|
setWorkbookEditPermission(e, t) {
|
|
420
|
-
this.setWorkbookPermissionPoint(e,
|
|
418
|
+
this.setWorkbookPermissionPoint(e, Ne, t);
|
|
421
419
|
}
|
|
422
420
|
/**
|
|
423
421
|
* This function is used to add a base permission for a worksheet.
|
|
424
|
-
*
|
|
425
422
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
426
423
|
* @param {string} subUnitId - The unique identifier of the worksheet for which the permission is being set.
|
|
427
|
-
*
|
|
428
424
|
* @returns {Promise<string | undefined>} - Returns the `permissionId` if the permission is successfully added. If the operation fails or no result is returned, it resolves to `undefined`.
|
|
429
425
|
*/
|
|
430
426
|
async addWorksheetBasePermission(e, t) {
|
|
431
427
|
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length > 0)
|
|
432
428
|
throw new Error("sheet protection cannot intersect with range protection");
|
|
433
|
-
const
|
|
434
|
-
objectType:
|
|
429
|
+
const r = await this._authzIoService.create({
|
|
430
|
+
objectType: E.Worksheet,
|
|
435
431
|
worksheetObject: {
|
|
436
432
|
collaborators: [],
|
|
437
433
|
unitID: e,
|
|
@@ -440,51 +436,48 @@ let j = class extends Q {
|
|
|
440
436
|
scope: void 0
|
|
441
437
|
}
|
|
442
438
|
});
|
|
443
|
-
if (this._commandService.syncExecuteCommand(
|
|
439
|
+
if (this._commandService.syncExecuteCommand(Je.id, {
|
|
444
440
|
unitId: e,
|
|
445
441
|
subUnitId: t,
|
|
446
442
|
rule: {
|
|
447
|
-
permissionId:
|
|
448
|
-
unitType:
|
|
443
|
+
permissionId: r,
|
|
444
|
+
unitType: E.Worksheet,
|
|
449
445
|
unitId: e,
|
|
450
446
|
subUnitId: t
|
|
451
447
|
}
|
|
452
448
|
}))
|
|
453
|
-
return
|
|
449
|
+
return r;
|
|
454
450
|
}
|
|
455
451
|
/**
|
|
456
452
|
* Delete the entire table protection set for the worksheet and reset the point permissions of the worksheet to true
|
|
457
|
-
*
|
|
458
453
|
* @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
|
|
459
454
|
* @param {string} subUnitId - The unique identifier of the worksheet for which the permission is being set.
|
|
460
455
|
*/
|
|
461
456
|
removeWorksheetPermission(e, t) {
|
|
462
|
-
this._commandService.syncExecuteCommand(
|
|
457
|
+
this._commandService.syncExecuteCommand(Qe.id, {
|
|
463
458
|
unitId: e,
|
|
464
459
|
subUnitId: t
|
|
465
|
-
}), [...
|
|
466
|
-
const
|
|
467
|
-
this._permissionService.updatePermissionPoint(
|
|
460
|
+
}), [...Xe(), ...ae()].forEach((n) => {
|
|
461
|
+
const r = new n(e, t);
|
|
462
|
+
this._permissionService.updatePermissionPoint(r.id, !0);
|
|
468
463
|
}), this._worksheetProtectionPointRuleModel.deleteRule(e, t);
|
|
469
464
|
}
|
|
470
465
|
/**
|
|
471
466
|
* Sets the worksheet permission point by updating or adding the permission point for the worksheet.
|
|
472
467
|
* If the worksheet doesn't have a base permission, it creates one to used render
|
|
473
|
-
*
|
|
474
468
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
475
469
|
* @param {string} subUnitId - The unique identifier of the worksheet.
|
|
476
470
|
* @param {WorkSheetPermissionPointConstructor} FPointClass - The constructor for the permission point class.
|
|
477
471
|
* See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
|
|
478
472
|
* @param {boolean} value - The new permission value to be set for the worksheet.
|
|
479
|
-
*
|
|
480
473
|
* @returns {Promise<string | undefined>} - Returns the `permissionId` if the permission point is successfully set or created. If no permission is set, it resolves to `undefined`.
|
|
481
474
|
*/
|
|
482
|
-
async setWorksheetPermissionPoint(e, t, n,
|
|
483
|
-
const
|
|
475
|
+
async setWorksheetPermissionPoint(e, t, n, r) {
|
|
476
|
+
const o = this._worksheetProtectionRuleModel.getRule(e, t);
|
|
484
477
|
let i;
|
|
485
|
-
if (n ===
|
|
486
|
-
if (
|
|
487
|
-
i =
|
|
478
|
+
if (n === st || n === rt)
|
|
479
|
+
if (o)
|
|
480
|
+
i = o.permissionId;
|
|
488
481
|
else {
|
|
489
482
|
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length > 0)
|
|
490
483
|
throw new Error("sheet protection cannot intersect with range protection");
|
|
@@ -493,7 +486,7 @@ let j = class extends Q {
|
|
|
493
486
|
else {
|
|
494
487
|
const d = this._worksheetProtectionPointRuleModel.getRule(e, t);
|
|
495
488
|
d ? i = d.permissionId : (i = await this._authzIoService.create({
|
|
496
|
-
objectType:
|
|
489
|
+
objectType: E.Worksheet,
|
|
497
490
|
worksheetObject: {
|
|
498
491
|
collaborators: [],
|
|
499
492
|
unitID: e,
|
|
@@ -501,71 +494,67 @@ let j = class extends Q {
|
|
|
501
494
|
name: "",
|
|
502
495
|
scope: void 0
|
|
503
496
|
}
|
|
504
|
-
}), this._commandService.executeCommand(
|
|
497
|
+
}), this._commandService.executeCommand(Ze.id, { unitId: e, subUnitId: t, permissionId: i }));
|
|
505
498
|
}
|
|
506
499
|
const h = new n(e, t);
|
|
507
|
-
return this._permissionService.getPermissionPoint(h.id) || this._permissionService.addPermissionPoint(h), this._permissionService.updatePermissionPoint(h.id,
|
|
500
|
+
return this._permissionService.getPermissionPoint(h.id) || this._permissionService.addPermissionPoint(h), this._permissionService.updatePermissionPoint(h.id, r), i;
|
|
508
501
|
}
|
|
509
502
|
/**
|
|
510
503
|
* Adds a range protection to the worksheet.
|
|
511
|
-
*
|
|
512
504
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
513
505
|
* @param {string} subUnitId - The unique identifier of the worksheet.
|
|
514
506
|
* @param {IRange[]} ranges - The ranges to be protected.
|
|
515
|
-
*
|
|
516
507
|
* @returns {Promise<{ permissionId: string, ruleId: string } | undefined>} - Returns an object containing the `permissionId` and `ruleId` if the range protection is successfully added. If the operation fails or no result is returned, it resolves to `undefined`. permissionId is used to stitch permission point ID,ruleId is used to store permission rules
|
|
517
508
|
*/
|
|
518
509
|
async addRangeBaseProtection(e, t, n) {
|
|
519
|
-
const
|
|
520
|
-
objectType:
|
|
510
|
+
const r = await this._authzIoService.create({
|
|
511
|
+
objectType: E.SelectRange,
|
|
521
512
|
selectRangeObject: {
|
|
522
513
|
collaborators: [],
|
|
523
514
|
unitID: e,
|
|
524
515
|
name: "",
|
|
525
516
|
scope: void 0
|
|
526
517
|
}
|
|
527
|
-
}),
|
|
518
|
+
}), o = `ruleId_${be(6)}`;
|
|
528
519
|
if (this._worksheetProtectionRuleModel.getRule(e, t))
|
|
529
520
|
throw new Error("sheet protection cannot intersect with range protection");
|
|
530
|
-
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((d) => d.ranges.some((
|
|
521
|
+
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((d) => d.ranges.some((z) => n.some((M) => N.intersects(M, z)))))
|
|
531
522
|
throw new Error("range protection cannot intersect");
|
|
532
|
-
if (this._commandService.syncExecuteCommand(
|
|
523
|
+
if (this._commandService.syncExecuteCommand(et.id, {
|
|
533
524
|
unitId: e,
|
|
534
525
|
subUnitId: t,
|
|
535
526
|
rules: [{
|
|
536
|
-
permissionId:
|
|
537
|
-
unitType:
|
|
527
|
+
permissionId: r,
|
|
528
|
+
unitType: E.SelectRange,
|
|
538
529
|
unitId: e,
|
|
539
530
|
subUnitId: t,
|
|
540
531
|
ranges: n,
|
|
541
|
-
id:
|
|
532
|
+
id: o
|
|
542
533
|
}]
|
|
543
534
|
}))
|
|
544
535
|
return {
|
|
545
|
-
permissionId:
|
|
546
|
-
ruleId:
|
|
536
|
+
permissionId: r,
|
|
537
|
+
ruleId: o
|
|
547
538
|
};
|
|
548
539
|
}
|
|
549
540
|
/**
|
|
550
541
|
* Removes the range protection from the worksheet.
|
|
551
|
-
*
|
|
552
542
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
553
543
|
* @param {string} subUnitId - The unique identifier of the worksheet.
|
|
554
544
|
* @param {string[]} ruleIds - The rule IDs of the range protection to be removed.
|
|
555
545
|
*/
|
|
556
546
|
removeRangeProtection(e, t, n) {
|
|
557
|
-
this._commandService.syncExecuteCommand(
|
|
547
|
+
this._commandService.syncExecuteCommand(tt.id, {
|
|
558
548
|
unitId: e,
|
|
559
549
|
subUnitId: t,
|
|
560
550
|
ruleIds: n
|
|
561
|
-
}) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [...
|
|
551
|
+
}) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [...ae()].forEach((i) => {
|
|
562
552
|
const a = new i(e, t);
|
|
563
553
|
this._permissionService.updatePermissionPoint(a.id, a.value);
|
|
564
554
|
}));
|
|
565
555
|
}
|
|
566
556
|
/**
|
|
567
557
|
* Modify the permission points of a custom area
|
|
568
|
-
*
|
|
569
558
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
570
559
|
* @param {string} subUnitId - The unique identifier of the worksheet within the workbook.
|
|
571
560
|
* @param {string} permissionId - The unique identifier of the permission that controls access to the range.
|
|
@@ -573,9 +562,9 @@ let j = class extends Q {
|
|
|
573
562
|
* See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
|
|
574
563
|
* @param {boolean} value - The new permission value to be set for the range (e.g., true for allowing access, false for restricting access).
|
|
575
564
|
*/
|
|
576
|
-
setRangeProtectionPermissionPoint(e, t, n,
|
|
577
|
-
const i = new
|
|
578
|
-
this._permissionService.getPermissionPoint(i.id) || this._permissionService.addPermissionPoint(i), this._permissionService.updatePermissionPoint(i.id,
|
|
565
|
+
setRangeProtectionPermissionPoint(e, t, n, r, o) {
|
|
566
|
+
const i = new r(e, t, n);
|
|
567
|
+
this._permissionService.getPermissionPoint(i.id) || this._permissionService.addPermissionPoint(i), this._permissionService.updatePermissionPoint(i.id, o);
|
|
579
568
|
}
|
|
580
569
|
/**
|
|
581
570
|
* Sets the ranges for range protection in a worksheet.
|
|
@@ -583,286 +572,425 @@ let j = class extends Q {
|
|
|
583
572
|
* This method finds the rule by unitId, subUnitId, and ruleId, and updates the rule with the provided ranges.
|
|
584
573
|
* It checks for overlaps with existing ranges in the same subunit and shows an error message if any overlap is detected.
|
|
585
574
|
* If no overlap is found, it executes the command to update the range protection with the new ranges.
|
|
586
|
-
*
|
|
587
575
|
* @param {string} unitId - The unique identifier of the workbook.
|
|
588
576
|
* @param {string} subUnitId - The unique identifier of the worksheet within the workbook.
|
|
589
577
|
* @param {string} ruleId - The ruleId of the range protection rule that is being updated.
|
|
590
578
|
* @param {IRange[]} ranges - The array of new ranges to be set for the range protection rule.
|
|
591
579
|
*/
|
|
592
|
-
setRangeProtectionRanges(e, t, n,
|
|
593
|
-
const
|
|
594
|
-
if (
|
|
595
|
-
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).filter((h) => h.id !== n).some((h) => h.ranges.some((c) =>
|
|
580
|
+
setRangeProtectionRanges(e, t, n, r) {
|
|
581
|
+
const o = this._rangeProtectionRuleModel.getRule(e, t, n);
|
|
582
|
+
if (o) {
|
|
583
|
+
if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).filter((h) => h.id !== n).some((h) => h.ranges.some((c) => r.some((d) => N.intersects(d, c)))))
|
|
596
584
|
throw new Error("range protection cannot intersect");
|
|
597
|
-
this._commandService.syncExecuteCommand(
|
|
585
|
+
this._commandService.syncExecuteCommand(nt.id, {
|
|
598
586
|
unitId: e,
|
|
599
587
|
subUnitId: t,
|
|
600
588
|
ruleId: n,
|
|
601
589
|
rule: {
|
|
602
|
-
...
|
|
603
|
-
ranges:
|
|
590
|
+
...o,
|
|
591
|
+
ranges: r
|
|
604
592
|
}
|
|
605
593
|
});
|
|
606
594
|
}
|
|
607
595
|
}
|
|
608
|
-
/**
|
|
609
|
-
* Set visibility of unauthorized pop-up window
|
|
610
|
-
*
|
|
611
|
-
* @param {boolean} visible
|
|
612
|
-
*/
|
|
613
|
-
setPermissionDialogVisible(e) {
|
|
614
|
-
this._permissionService.setShowComponents(e);
|
|
615
|
-
}
|
|
616
596
|
};
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
],
|
|
626
|
-
function
|
|
627
|
-
switch (
|
|
597
|
+
O = zt([
|
|
598
|
+
v(0, u(b)),
|
|
599
|
+
v(1, l),
|
|
600
|
+
v(2, ee),
|
|
601
|
+
v(3, u(Ee)),
|
|
602
|
+
v(4, u(Pe)),
|
|
603
|
+
v(5, u(xe)),
|
|
604
|
+
v(6, u(ve))
|
|
605
|
+
], O);
|
|
606
|
+
function $t(s) {
|
|
607
|
+
switch (s) {
|
|
628
608
|
case "left":
|
|
629
|
-
return
|
|
609
|
+
return y.LEFT;
|
|
630
610
|
case "center":
|
|
631
|
-
return
|
|
611
|
+
return y.CENTER;
|
|
632
612
|
case "normal":
|
|
633
|
-
return
|
|
613
|
+
return y.RIGHT;
|
|
634
614
|
default:
|
|
635
|
-
throw new Error(`Invalid horizontal alignment: ${
|
|
615
|
+
throw new Error(`Invalid horizontal alignment: ${s}`);
|
|
636
616
|
}
|
|
637
617
|
}
|
|
638
|
-
function
|
|
639
|
-
switch (
|
|
640
|
-
case
|
|
618
|
+
function Ht(s) {
|
|
619
|
+
switch (s) {
|
|
620
|
+
case y.LEFT:
|
|
641
621
|
return "left";
|
|
642
|
-
case
|
|
622
|
+
case y.CENTER:
|
|
643
623
|
return "center";
|
|
644
|
-
case
|
|
624
|
+
case y.RIGHT:
|
|
645
625
|
return "normal";
|
|
646
626
|
default:
|
|
647
|
-
throw new Error(`Invalid horizontal alignment: ${
|
|
627
|
+
throw new Error(`Invalid horizontal alignment: ${s}`);
|
|
648
628
|
}
|
|
649
629
|
}
|
|
650
|
-
function
|
|
651
|
-
switch (
|
|
630
|
+
function Gt(s) {
|
|
631
|
+
switch (s) {
|
|
652
632
|
case "top":
|
|
653
|
-
return
|
|
633
|
+
return U.TOP;
|
|
654
634
|
case "middle":
|
|
655
|
-
return
|
|
635
|
+
return U.MIDDLE;
|
|
656
636
|
case "bottom":
|
|
657
|
-
return
|
|
637
|
+
return U.BOTTOM;
|
|
658
638
|
default:
|
|
659
|
-
throw new Error(`Invalid vertical alignment: ${
|
|
639
|
+
throw new Error(`Invalid vertical alignment: ${s}`);
|
|
660
640
|
}
|
|
661
641
|
}
|
|
662
|
-
function
|
|
663
|
-
switch (
|
|
664
|
-
case
|
|
642
|
+
function qt(s) {
|
|
643
|
+
switch (s) {
|
|
644
|
+
case U.TOP:
|
|
665
645
|
return "top";
|
|
666
|
-
case
|
|
646
|
+
case U.MIDDLE:
|
|
667
647
|
return "middle";
|
|
668
|
-
case
|
|
648
|
+
case U.BOTTOM:
|
|
669
649
|
return "bottom";
|
|
670
650
|
default:
|
|
671
|
-
throw new Error(`Invalid vertical alignment: ${
|
|
651
|
+
throw new Error(`Invalid vertical alignment: ${s}`);
|
|
672
652
|
}
|
|
673
653
|
}
|
|
674
|
-
function
|
|
675
|
-
return
|
|
676
|
-
f:
|
|
677
|
-
} :
|
|
678
|
-
v:
|
|
679
|
-
} : (
|
|
654
|
+
function V(s) {
|
|
655
|
+
return je(s) ? {
|
|
656
|
+
f: s
|
|
657
|
+
} : Oe(s) ? {
|
|
658
|
+
v: s
|
|
659
|
+
} : (Ve(s), s);
|
|
680
660
|
}
|
|
681
|
-
function
|
|
682
|
-
const t = new
|
|
683
|
-
if (
|
|
684
|
-
for (let a = 0; a <=
|
|
685
|
-
for (let h = 0; h <= i -
|
|
686
|
-
t.setValue(a + n, h +
|
|
661
|
+
function Ie(s, e) {
|
|
662
|
+
const t = new A(), { startRow: n, startColumn: r, endRow: o, endColumn: i } = e;
|
|
663
|
+
if (Be.isArray(s))
|
|
664
|
+
for (let a = 0; a <= o - n; a++)
|
|
665
|
+
for (let h = 0; h <= i - r; h++)
|
|
666
|
+
t.setValue(a + n, h + r, V(s[a][h]));
|
|
687
667
|
else
|
|
688
|
-
new
|
|
689
|
-
t.setValue(h, c,
|
|
668
|
+
new A(s).forValue((h, c, d) => {
|
|
669
|
+
t.setValue(h, c, V(d));
|
|
690
670
|
});
|
|
691
671
|
return t.getMatrix();
|
|
692
672
|
}
|
|
693
|
-
function
|
|
673
|
+
function q(s, e) {
|
|
694
674
|
return {
|
|
695
|
-
startRow:
|
|
696
|
-
endRow:
|
|
675
|
+
startRow: s.startRow,
|
|
676
|
+
endRow: s.endRow,
|
|
697
677
|
startColumn: 0,
|
|
698
678
|
endColumn: e.getColumnCount() - 1,
|
|
699
679
|
rangeType: _.ROW
|
|
700
680
|
};
|
|
701
681
|
}
|
|
702
|
-
function
|
|
682
|
+
function K(s, e) {
|
|
703
683
|
return {
|
|
704
684
|
startRow: 0,
|
|
705
685
|
endRow: e.getRowCount() - 1,
|
|
706
|
-
startColumn:
|
|
707
|
-
endColumn:
|
|
686
|
+
startColumn: s.startColumn,
|
|
687
|
+
endColumn: s.endColumn,
|
|
708
688
|
rangeType: _.COLUMN
|
|
709
689
|
};
|
|
710
690
|
}
|
|
711
|
-
var
|
|
712
|
-
for (var
|
|
713
|
-
(i = o
|
|
714
|
-
return n &&
|
|
715
|
-
},
|
|
716
|
-
let
|
|
717
|
-
constructor(
|
|
718
|
-
super(n), this._workbook =
|
|
691
|
+
var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Jt = (s, e, t, n) => {
|
|
692
|
+
for (var r = n > 1 ? void 0 : n ? Yt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
693
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
694
|
+
return n && r && Kt(e, t, r), r;
|
|
695
|
+
}, Y = (s, e) => (t, n) => e(t, n, s);
|
|
696
|
+
let w = class extends ne {
|
|
697
|
+
constructor(s, e, t, n, r, o) {
|
|
698
|
+
super(n), this._workbook = s, this._worksheet = e, this._range = t, this._injector = n, this._commandService = r, this._formulaDataModel = o;
|
|
719
699
|
}
|
|
720
700
|
/**
|
|
721
701
|
* Get the unit ID of the current workbook
|
|
722
|
-
*
|
|
723
|
-
* @return The unit ID of the workbook
|
|
702
|
+
* @returns The unit ID of the workbook
|
|
724
703
|
*/
|
|
725
704
|
getUnitId() {
|
|
726
705
|
return this._workbook.getUnitId();
|
|
727
706
|
}
|
|
728
707
|
/**
|
|
729
708
|
* Gets the name of the worksheet
|
|
730
|
-
*
|
|
731
|
-
* @return The name of the worksheet
|
|
709
|
+
* @returns The name of the worksheet
|
|
732
710
|
*/
|
|
733
711
|
getSheetName() {
|
|
734
712
|
return this._worksheet.getName();
|
|
735
713
|
}
|
|
714
|
+
/**
|
|
715
|
+
* Gets the ID of the worksheet
|
|
716
|
+
* @returns The ID of the worksheet
|
|
717
|
+
*/
|
|
718
|
+
getSheetId() {
|
|
719
|
+
return this._worksheet.getSheetId();
|
|
720
|
+
}
|
|
736
721
|
/**
|
|
737
722
|
* Gets the area where the statement is applied
|
|
738
|
-
*
|
|
739
|
-
* @return The area where the statement is applied
|
|
723
|
+
* @returns The area where the statement is applied
|
|
740
724
|
*/
|
|
741
725
|
getRange() {
|
|
742
726
|
return this._range;
|
|
743
727
|
}
|
|
744
728
|
/**
|
|
745
729
|
* Gets the starting row number of the applied area
|
|
746
|
-
*
|
|
747
|
-
* @return The starting row number of the area
|
|
730
|
+
* @returns The starting row number of the area
|
|
748
731
|
*/
|
|
749
732
|
getRow() {
|
|
750
733
|
return this._range.startRow;
|
|
751
734
|
}
|
|
752
735
|
/**
|
|
753
736
|
* Gets the starting column number of the applied area
|
|
754
|
-
*
|
|
755
|
-
* @return The starting column number of the area
|
|
737
|
+
* @returns The starting column number of the area
|
|
756
738
|
*/
|
|
757
739
|
getColumn() {
|
|
758
740
|
return this._range.startColumn;
|
|
759
741
|
}
|
|
760
742
|
/**
|
|
761
743
|
* Gets the width of the applied area
|
|
762
|
-
*
|
|
763
|
-
* @return The width of the area
|
|
744
|
+
* @returns The width of the area
|
|
764
745
|
*/
|
|
765
746
|
getWidth() {
|
|
766
747
|
return this._range.endColumn - this._range.startColumn + 1;
|
|
767
748
|
}
|
|
768
749
|
/**
|
|
769
750
|
* Gets the height of the applied area
|
|
770
|
-
*
|
|
771
|
-
* @return The height of the area
|
|
751
|
+
* @returns The height of the area
|
|
772
752
|
*/
|
|
773
753
|
getHeight() {
|
|
774
754
|
return this._range.endRow - this._range.startRow + 1;
|
|
775
755
|
}
|
|
776
|
-
/**
|
|
777
|
-
* Return first cell model data in this range
|
|
778
|
-
* @returns The cell model data
|
|
779
|
-
*/
|
|
780
|
-
getCellData() {
|
|
781
|
-
var o;
|
|
782
|
-
return (o = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) != null ? o : null;
|
|
783
|
-
}
|
|
784
756
|
/**
|
|
785
757
|
* Return range whether this range is merged
|
|
786
758
|
* @returns if true is merged
|
|
787
759
|
*/
|
|
788
760
|
isMerged() {
|
|
789
|
-
const { startColumn:
|
|
790
|
-
return this._worksheet.getMergedCellRange(e,
|
|
761
|
+
const { startColumn: s, startRow: e, endColumn: t, endRow: n } = this._range;
|
|
762
|
+
return this._worksheet.getMergedCellRange(e, s, n, t).some((o) => N.equals(o, this._range));
|
|
791
763
|
}
|
|
792
764
|
/**
|
|
793
765
|
* Return first cell style data in this range
|
|
794
|
-
* @returns The cell style data
|
|
766
|
+
* @returns {IStyleData | null} The cell style data
|
|
795
767
|
*/
|
|
796
768
|
getCellStyleData() {
|
|
797
769
|
var t;
|
|
798
|
-
const
|
|
799
|
-
return
|
|
770
|
+
const s = this.getCellData(), e = this._workbook.getStyles();
|
|
771
|
+
return s && e && (t = e.getStyleByCell(s)) != null ? t : null;
|
|
800
772
|
}
|
|
801
773
|
/**
|
|
802
774
|
* Returns the value of the cell at the start of this range.
|
|
803
|
-
* @returns The value of the cell.
|
|
775
|
+
* @returns {CellValue | null} The value of the cell.
|
|
804
776
|
*/
|
|
805
777
|
getValue() {
|
|
806
|
-
var
|
|
807
|
-
return (e = (
|
|
778
|
+
var s, e;
|
|
779
|
+
return (e = (s = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) == null ? void 0 : s.v) != null ? e : null;
|
|
808
780
|
}
|
|
809
781
|
/**
|
|
810
782
|
* Returns the rectangular grid of values for this range.
|
|
811
783
|
* Returns a two-dimensional array of values, indexed by row, then by column.
|
|
812
|
-
* @returns A two-dimensional array of values.
|
|
784
|
+
* @returns {Nullable<CellValue>[][]} A two-dimensional array of values.
|
|
813
785
|
*/
|
|
814
786
|
getValues() {
|
|
815
|
-
var
|
|
816
|
-
const { startRow:
|
|
817
|
-
for (let a =
|
|
787
|
+
var o, i;
|
|
788
|
+
const { startRow: s, endRow: e, startColumn: t, endColumn: n } = this._range, r = [];
|
|
789
|
+
for (let a = s; a <= e; a++) {
|
|
818
790
|
const h = [];
|
|
819
791
|
for (let c = t; c <= n; c++)
|
|
820
|
-
h.push((i = (
|
|
821
|
-
|
|
792
|
+
h.push((i = (o = this._worksheet.getCell(a, c)) == null ? void 0 : o.v) != null ? i : null);
|
|
793
|
+
r.push(h);
|
|
822
794
|
}
|
|
823
|
-
return
|
|
795
|
+
return r;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Return first cell model data in this range
|
|
799
|
+
* @returns {ICellData | null} The cell model data
|
|
800
|
+
* @example
|
|
801
|
+
* ```
|
|
802
|
+
* univerAPI.getActiveWorkbook()
|
|
803
|
+
* .getActiveSheet()
|
|
804
|
+
* .getActiveRange()
|
|
805
|
+
* .getCellData()
|
|
806
|
+
* ```
|
|
807
|
+
*/
|
|
808
|
+
getCellData() {
|
|
809
|
+
var s;
|
|
810
|
+
return (s = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) != null ? s : null;
|
|
824
811
|
}
|
|
825
812
|
/**
|
|
826
813
|
* Returns the cell data for the cells in the range.
|
|
827
|
-
* @returns A two-dimensional array of cell data.
|
|
814
|
+
* @returns {Nullable<ICellData>[][]} A two-dimensional array of cell data.
|
|
815
|
+
* @example
|
|
816
|
+
* ```
|
|
817
|
+
* univerAPI.getActiveWorkbook()
|
|
818
|
+
* .getActiveSheet()
|
|
819
|
+
* .getActiveRange()
|
|
820
|
+
* .getCellDatas()
|
|
821
|
+
* ```
|
|
828
822
|
*/
|
|
829
|
-
|
|
830
|
-
const { startRow:
|
|
831
|
-
for (let
|
|
823
|
+
getCellDatas() {
|
|
824
|
+
const { startRow: s, endRow: e, startColumn: t, endColumn: n } = this._range, r = [];
|
|
825
|
+
for (let o = s; o <= e; o++) {
|
|
832
826
|
const i = [];
|
|
833
827
|
for (let a = t; a <= n; a++)
|
|
834
|
-
i.push(this._worksheet.getCellRaw(
|
|
835
|
-
|
|
828
|
+
i.push(this._worksheet.getCellRaw(o, a));
|
|
829
|
+
r.push(i);
|
|
836
830
|
}
|
|
837
|
-
return
|
|
831
|
+
return r;
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* @deprecated use `getCellDatas` instead.
|
|
835
|
+
*/
|
|
836
|
+
getCellDataGrid() {
|
|
837
|
+
return this.getCellDatas();
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Returns the rich text value for the cell at the start of this range.
|
|
841
|
+
* @returns {Nullable<RichTextValue>} The rich text value
|
|
842
|
+
* @example
|
|
843
|
+
* ```
|
|
844
|
+
* univerAPI.getActiveWorkbook()
|
|
845
|
+
* .getActiveSheet()
|
|
846
|
+
* .getActiveRange()
|
|
847
|
+
* .getRichTextValue()
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
getRichTextValue() {
|
|
851
|
+
const s = this.getCellData();
|
|
852
|
+
return s != null && s.p ? new p(s.p) : null;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Returns the rich text value for the cells in the range.
|
|
856
|
+
* @returns {Nullable<RichTextValue>[][]} A two-dimensional array of RichTextValue objects.
|
|
857
|
+
* @example
|
|
858
|
+
* ```
|
|
859
|
+
* univerAPI.getActiveWorkbook()
|
|
860
|
+
* .getActiveSheet()
|
|
861
|
+
* .getActiveRange()
|
|
862
|
+
* .getRichTextValues()
|
|
863
|
+
* ```
|
|
864
|
+
*/
|
|
865
|
+
getRichTextValues() {
|
|
866
|
+
return this.getCellDataGrid().map((e) => e.map((t) => t != null && t.p ? new p(t.p) : null));
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Returns the value and rich text value for the cell at the start of this range.
|
|
870
|
+
* @returns {Nullable<CellValue | RichTextValue>} The value and rich text value
|
|
871
|
+
* @example
|
|
872
|
+
* ```
|
|
873
|
+
* univerAPI.getActiveWorkbook()
|
|
874
|
+
* .getActiveSheet()
|
|
875
|
+
* .getActiveRange()
|
|
876
|
+
* .getValueAndRichTextValue()
|
|
877
|
+
* ```
|
|
878
|
+
*/
|
|
879
|
+
getValueAndRichTextValue() {
|
|
880
|
+
const s = this.getCellData();
|
|
881
|
+
return s != null && s.p ? new p(s.p) : s == null ? void 0 : s.v;
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Returns the value and rich text value for the cells in the range.
|
|
885
|
+
* @returns {Nullable<CellValue | RichTextValue>[][]} A two-dimensional array of value and rich text value
|
|
886
|
+
* @example
|
|
887
|
+
* ```
|
|
888
|
+
* univerAPI.getActiveWorkbook()
|
|
889
|
+
* .getActiveSheet()
|
|
890
|
+
* .getActiveRange()
|
|
891
|
+
* .getValueAndRichTextValues()
|
|
892
|
+
* ```
|
|
893
|
+
*/
|
|
894
|
+
getValueAndRichTextValues() {
|
|
895
|
+
return this.getCellDatas().map((e) => e.map((t) => t != null && t.p ? new p(t.p) : t == null ? void 0 : t.v));
|
|
838
896
|
}
|
|
839
897
|
/**
|
|
840
898
|
* Returns the formulas (A1 notation) for the cells in the range. Entries in the 2D array are empty strings for cells with no formula.
|
|
841
|
-
* @returns A two-dimensional array of formulas in string format.
|
|
899
|
+
* @returns {string[][]} A two-dimensional array of formulas in string format.
|
|
900
|
+
* @example
|
|
901
|
+
* ```ts
|
|
902
|
+
* univerAPI.getActiveWorkbook()
|
|
903
|
+
* .getActiveSheet()
|
|
904
|
+
* .getActiveRange()
|
|
905
|
+
* .getFormulas()
|
|
906
|
+
* ```
|
|
842
907
|
*/
|
|
843
908
|
getFormulas() {
|
|
844
|
-
const
|
|
909
|
+
const s = [], { startRow: e, endRow: t, startColumn: n, endColumn: r } = this._range, o = this._worksheet.getSheetId(), i = this._workbook.getUnitId();
|
|
845
910
|
for (let a = e; a <= t; a++) {
|
|
846
911
|
const h = [];
|
|
847
|
-
for (let c = n; c <=
|
|
848
|
-
const d = this._formulaDataModel.getFormulaStringByCell(a, c,
|
|
912
|
+
for (let c = n; c <= r; c++) {
|
|
913
|
+
const d = this._formulaDataModel.getFormulaStringByCell(a, c, o, i);
|
|
849
914
|
h.push(d || "");
|
|
850
915
|
}
|
|
851
|
-
|
|
916
|
+
s.push(h);
|
|
852
917
|
}
|
|
853
|
-
return
|
|
918
|
+
return s;
|
|
854
919
|
}
|
|
855
920
|
getWrap() {
|
|
856
|
-
return this._worksheet.getRange(this._range).getWrap() ===
|
|
921
|
+
return this._worksheet.getRange(this._range).getWrap() === m.TRUE;
|
|
857
922
|
}
|
|
858
923
|
getWrapStrategy() {
|
|
859
924
|
return this._worksheet.getRange(this._range).getWrapStrategy();
|
|
860
925
|
}
|
|
861
926
|
getHorizontalAlignment() {
|
|
862
|
-
return
|
|
927
|
+
return Ht(this._worksheet.getRange(this._range).getHorizontalAlignment());
|
|
863
928
|
}
|
|
864
929
|
getVerticalAlignment() {
|
|
865
|
-
return
|
|
930
|
+
return qt(this._worksheet.getRange(this._range).getVerticalAlignment());
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Set custom meta data for first cell in current range.
|
|
934
|
+
* @param {CustomData} data The custom meta data
|
|
935
|
+
* @returns {FRange} This range, for chaining
|
|
936
|
+
* ```ts
|
|
937
|
+
* univerAPI.getActiveWorkbook()
|
|
938
|
+
* .getActiveSheet()
|
|
939
|
+
* .getActiveRange()
|
|
940
|
+
* .setCustomMetaData({ key: 'value' });
|
|
941
|
+
* ```
|
|
942
|
+
*/
|
|
943
|
+
setCustomMetaData(s) {
|
|
944
|
+
return this.setValue({
|
|
945
|
+
custom: s
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Set custom meta data for current range.
|
|
950
|
+
* @param {CustomData[][]} datas The custom meta data
|
|
951
|
+
* @returns {FRange} This range, for chaining
|
|
952
|
+
* ```ts
|
|
953
|
+
* univerAPI.getActiveWorkbook()
|
|
954
|
+
* .getActiveSheet()
|
|
955
|
+
* .getActiveRange()
|
|
956
|
+
* .setCustomMetaDatas([[{ key: 'value' }]]);
|
|
957
|
+
* ```
|
|
958
|
+
*/
|
|
959
|
+
setCustomMetaDatas(s) {
|
|
960
|
+
return this.setValues(s.map((e) => e.map((t) => ({ custom: t }))));
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* Returns the custom meta data for the cell at the start of this range.
|
|
964
|
+
* @returns {CustomData | null} The custom meta data
|
|
965
|
+
* @example
|
|
966
|
+
* ```
|
|
967
|
+
* univerAPI.getActiveWorkbook()
|
|
968
|
+
* .getActiveSheet()
|
|
969
|
+
* .getActiveRange()
|
|
970
|
+
* .getCustomMetaData()
|
|
971
|
+
* ```
|
|
972
|
+
*/
|
|
973
|
+
getCustomMetaData() {
|
|
974
|
+
var e;
|
|
975
|
+
const s = this.getCellData();
|
|
976
|
+
return (e = s == null ? void 0 : s.custom) != null ? e : null;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Returns the custom meta data for the cells in the range.
|
|
980
|
+
* @returns {CustomData[][]} A two-dimensional array of custom meta data
|
|
981
|
+
* @example
|
|
982
|
+
* ```
|
|
983
|
+
* univerAPI.getActiveWorkbook()
|
|
984
|
+
* .getActiveSheet()
|
|
985
|
+
* .getActiveRange()
|
|
986
|
+
* .getCustomMetaDatas()
|
|
987
|
+
* ```
|
|
988
|
+
*/
|
|
989
|
+
getCustomMetaDatas() {
|
|
990
|
+
return this.getCellDataGrid().map((e) => e.map((t) => {
|
|
991
|
+
var n;
|
|
992
|
+
return (n = t == null ? void 0 : t.custom) != null ? n : null;
|
|
993
|
+
}));
|
|
866
994
|
}
|
|
867
995
|
// #region editing
|
|
868
996
|
/**
|
|
@@ -870,18 +998,21 @@ let k = class extends X {
|
|
|
870
998
|
* @param color {string}
|
|
871
999
|
* @example
|
|
872
1000
|
* ```
|
|
873
|
-
* univerAPI.getActiveWorkbook()
|
|
1001
|
+
* univerAPI.getActiveWorkbook()
|
|
1002
|
+
* .getActiveSheet()
|
|
1003
|
+
* .getActiveRange()
|
|
1004
|
+
* .setBackgroundColor('red')
|
|
874
1005
|
* ```
|
|
875
1006
|
*/
|
|
876
|
-
setBackgroundColor(
|
|
877
|
-
return this._commandService.syncExecuteCommand(
|
|
1007
|
+
setBackgroundColor(s) {
|
|
1008
|
+
return this._commandService.syncExecuteCommand(f.id, {
|
|
878
1009
|
unitId: this._workbook.getUnitId(),
|
|
879
1010
|
subUnitId: this._worksheet.getSheetId(),
|
|
880
1011
|
range: this._range,
|
|
881
1012
|
style: {
|
|
882
1013
|
type: "bg",
|
|
883
1014
|
value: {
|
|
884
|
-
rgb:
|
|
1015
|
+
rgb: s
|
|
885
1016
|
}
|
|
886
1017
|
}
|
|
887
1018
|
}), this;
|
|
@@ -889,81 +1020,159 @@ let k = class extends X {
|
|
|
889
1020
|
/**
|
|
890
1021
|
* Set background color for current range.
|
|
891
1022
|
* @example
|
|
892
|
-
* ```
|
|
1023
|
+
* ```typescript
|
|
893
1024
|
* univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackground('red')
|
|
894
1025
|
* ```
|
|
895
1026
|
* @param color {string}
|
|
896
1027
|
*/
|
|
897
|
-
setBackground(
|
|
898
|
-
return this.setBackgroundColor(
|
|
1028
|
+
setBackground(s) {
|
|
1029
|
+
return this.setBackgroundColor(s), this;
|
|
899
1030
|
}
|
|
900
1031
|
/**
|
|
901
|
-
*
|
|
902
|
-
* @param value
|
|
1032
|
+
* Set new value for current cell, first cell in this range.
|
|
1033
|
+
* @param {CellValue | ICellData} value The value can be a number, string, boolean, or standard cell format. If it begins with `=`, it is interpreted as a formula. The value is tiled to all cells in the range.
|
|
903
1034
|
*/
|
|
904
|
-
setValue(
|
|
905
|
-
const e =
|
|
1035
|
+
setValue(s) {
|
|
1036
|
+
const e = V(s);
|
|
906
1037
|
if (!e)
|
|
907
1038
|
throw new Error("Invalid value");
|
|
908
|
-
return this._commandService.syncExecuteCommand(
|
|
1039
|
+
return this._commandService.syncExecuteCommand(P.id, {
|
|
909
1040
|
unitId: this._workbook.getUnitId(),
|
|
910
1041
|
subUnitId: this._worksheet.getSheetId(),
|
|
911
1042
|
range: this._range,
|
|
912
1043
|
value: e
|
|
913
1044
|
}), this;
|
|
914
1045
|
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Set new value for current cell, first cell in this range.
|
|
1048
|
+
* @param {CellValue | ICellData} value The value can be a number, string, boolean, or standard cell format. If it begins with `=`, it is interpreted as a formula. The value is tiled to all cells in the range.
|
|
1049
|
+
* ```ts
|
|
1050
|
+
* univerAPI.getActiveWorkbook()
|
|
1051
|
+
* .getActiveSheet()
|
|
1052
|
+
* .getActiveRange()
|
|
1053
|
+
* .setValueForCell(1);
|
|
1054
|
+
* ```
|
|
1055
|
+
*/
|
|
1056
|
+
setValueForCell(s) {
|
|
1057
|
+
const e = V(s);
|
|
1058
|
+
if (!e)
|
|
1059
|
+
throw new Error("Invalid value");
|
|
1060
|
+
return this._commandService.syncExecuteCommand(P.id, {
|
|
1061
|
+
unitId: this._workbook.getUnitId(),
|
|
1062
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
1063
|
+
range: {
|
|
1064
|
+
startColumn: this._range.startColumn,
|
|
1065
|
+
startRow: this._range.startRow,
|
|
1066
|
+
endColumn: this._range.endColumn,
|
|
1067
|
+
endRow: this._range.endRow
|
|
1068
|
+
},
|
|
1069
|
+
value: e
|
|
1070
|
+
}), this;
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Set the rich text value for the cell at the start of this range.
|
|
1074
|
+
* @param {RichTextValue | IDocumentData} value The rich text value
|
|
1075
|
+
* @returns {FRange} The range
|
|
1076
|
+
* @example
|
|
1077
|
+
* ```
|
|
1078
|
+
* univerAPI.getActiveWorkbook()
|
|
1079
|
+
* .getActiveSheet()
|
|
1080
|
+
* .getActiveRange()
|
|
1081
|
+
* .setRichTextValueForCell(new RichTextValue().insertText('Hello'));
|
|
1082
|
+
* ```
|
|
1083
|
+
*/
|
|
1084
|
+
setRichTextValueForCell(s) {
|
|
1085
|
+
const e = s instanceof p ? s.getData() : s, t = {
|
|
1086
|
+
unitId: this._workbook.getUnitId(),
|
|
1087
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
1088
|
+
range: {
|
|
1089
|
+
startColumn: this._range.startColumn,
|
|
1090
|
+
startRow: this._range.startRow,
|
|
1091
|
+
endColumn: this._range.endColumn,
|
|
1092
|
+
endRow: this._range.endRow
|
|
1093
|
+
},
|
|
1094
|
+
value: { p: e }
|
|
1095
|
+
};
|
|
1096
|
+
return this._commandService.syncExecuteCommand(P.id, t), this;
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Set the rich text value for the cells in the range.
|
|
1100
|
+
* @param {RichTextValue[][]} values The rich text value
|
|
1101
|
+
* @returns {FRange} The range
|
|
1102
|
+
* @example
|
|
1103
|
+
* ```ts
|
|
1104
|
+
* univerAPI
|
|
1105
|
+
* .getActiveWorkbook()
|
|
1106
|
+
* .getActiveSheet()
|
|
1107
|
+
* .getActiveRange()
|
|
1108
|
+
* .setRichTextValues([[new RichTextValue().insertText('Hello')]]);
|
|
1109
|
+
* ```
|
|
1110
|
+
*/
|
|
1111
|
+
setRichTextValues(s) {
|
|
1112
|
+
const e = s.map((r) => r.map((o) => o && { p: o instanceof p ? o.getData() : o })), t = Ie(e, this._range), n = {
|
|
1113
|
+
unitId: this._workbook.getUnitId(),
|
|
1114
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
1115
|
+
range: this._range,
|
|
1116
|
+
value: t
|
|
1117
|
+
};
|
|
1118
|
+
return this._commandService.syncExecuteCommand(P.id, n), this;
|
|
1119
|
+
}
|
|
915
1120
|
/**
|
|
916
1121
|
* Set the cell wrap of the given range.
|
|
917
1122
|
* Cells with wrap enabled (the default) resize to display their full content. Cells with wrap disabled display as much as possible in the cell without resizing or running to multiple lines.
|
|
1123
|
+
* @param isWrapEnabled
|
|
918
1124
|
*/
|
|
919
|
-
setWrap(
|
|
920
|
-
return this._commandService.syncExecuteCommand(
|
|
1125
|
+
setWrap(s) {
|
|
1126
|
+
return this._commandService.syncExecuteCommand(he.id, {
|
|
921
1127
|
unitId: this._workbook.getUnitId(),
|
|
922
1128
|
subUnitId: this._worksheet.getSheetId(),
|
|
923
1129
|
range: this._range,
|
|
924
|
-
value:
|
|
1130
|
+
value: s ? oe.WRAP : oe.UNSPECIFIED
|
|
925
1131
|
}), this;
|
|
926
1132
|
}
|
|
927
1133
|
/**
|
|
928
1134
|
* Sets the text wrapping strategy for the cells in the range.
|
|
1135
|
+
* @param strategy
|
|
929
1136
|
*/
|
|
930
|
-
setWrapStrategy(
|
|
931
|
-
return this._commandService.syncExecuteCommand(
|
|
1137
|
+
setWrapStrategy(s) {
|
|
1138
|
+
return this._commandService.syncExecuteCommand(he.id, {
|
|
932
1139
|
unitId: this._workbook.getUnitId(),
|
|
933
1140
|
subUnitId: this._worksheet.getSheetId(),
|
|
934
1141
|
range: this._range,
|
|
935
|
-
value:
|
|
1142
|
+
value: s
|
|
936
1143
|
}), this;
|
|
937
1144
|
}
|
|
938
1145
|
/**
|
|
939
1146
|
* Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
|
|
1147
|
+
* @param alignment
|
|
940
1148
|
*/
|
|
941
|
-
setVerticalAlignment(
|
|
942
|
-
return this._commandService.syncExecuteCommand(
|
|
1149
|
+
setVerticalAlignment(s) {
|
|
1150
|
+
return this._commandService.syncExecuteCommand(ot.id, {
|
|
943
1151
|
unitId: this._workbook.getUnitId(),
|
|
944
1152
|
subUnitId: this._worksheet.getSheetId(),
|
|
945
1153
|
range: this._range,
|
|
946
|
-
value:
|
|
1154
|
+
value: Gt(s)
|
|
947
1155
|
}), this;
|
|
948
1156
|
}
|
|
949
1157
|
/**
|
|
950
1158
|
* Set the horizontal (left to right) alignment for the given range (left/center/right).
|
|
1159
|
+
* @param alignment
|
|
951
1160
|
*/
|
|
952
|
-
setHorizontalAlignment(
|
|
953
|
-
return this._commandService.syncExecuteCommand(
|
|
1161
|
+
setHorizontalAlignment(s) {
|
|
1162
|
+
return this._commandService.syncExecuteCommand(it.id, {
|
|
954
1163
|
unitId: this._workbook.getUnitId(),
|
|
955
1164
|
subUnitId: this._worksheet.getSheetId(),
|
|
956
1165
|
range: this._range,
|
|
957
|
-
value:
|
|
1166
|
+
value: $t(s)
|
|
958
1167
|
}), this;
|
|
959
1168
|
}
|
|
960
1169
|
/**
|
|
961
1170
|
* Sets a different value for each cell in the range. The value can be a two-dimensional array or a standard range matrix (must match the dimensions of this range), consisting of numbers, strings, Boolean values or Composed of standard cell formats. If a value begins with `=`, it is interpreted as a formula.
|
|
962
1171
|
* @param value
|
|
963
1172
|
*/
|
|
964
|
-
setValues(
|
|
965
|
-
const e =
|
|
966
|
-
return this._commandService.syncExecuteCommand(
|
|
1173
|
+
setValues(s) {
|
|
1174
|
+
const e = Ie(s, this._range);
|
|
1175
|
+
return this._commandService.syncExecuteCommand(P.id, {
|
|
967
1176
|
unitId: this._workbook.getUnitId(),
|
|
968
1177
|
subUnitId: this._worksheet.getSheetId(),
|
|
969
1178
|
range: this._range,
|
|
@@ -974,13 +1183,13 @@ let k = class extends X {
|
|
|
974
1183
|
* Sets the font weight for the given range (normal/bold),
|
|
975
1184
|
* @param fontWeight The font weight, either 'normal' or 'bold'; a null value resets the font weight.
|
|
976
1185
|
*/
|
|
977
|
-
setFontWeight(
|
|
1186
|
+
setFontWeight(s) {
|
|
978
1187
|
let e;
|
|
979
|
-
if (
|
|
980
|
-
e =
|
|
981
|
-
else if (
|
|
982
|
-
e =
|
|
983
|
-
else if (
|
|
1188
|
+
if (s === "bold")
|
|
1189
|
+
e = m.TRUE;
|
|
1190
|
+
else if (s === "normal")
|
|
1191
|
+
e = m.FALSE;
|
|
1192
|
+
else if (s === null)
|
|
984
1193
|
e = null;
|
|
985
1194
|
else
|
|
986
1195
|
throw new Error("Invalid fontWeight");
|
|
@@ -993,19 +1202,19 @@ let k = class extends X {
|
|
|
993
1202
|
range: this._range,
|
|
994
1203
|
style: t
|
|
995
1204
|
};
|
|
996
|
-
return this._commandService.executeCommand(
|
|
1205
|
+
return this._commandService.executeCommand(f.id, n), this;
|
|
997
1206
|
}
|
|
998
1207
|
/**
|
|
999
1208
|
* Sets the font style for the given range ('italic' or 'normal').
|
|
1000
1209
|
* @param fontStyle The font style, either 'italic' or 'normal'; a null value resets the font style.
|
|
1001
1210
|
*/
|
|
1002
|
-
setFontStyle(
|
|
1211
|
+
setFontStyle(s) {
|
|
1003
1212
|
let e;
|
|
1004
|
-
if (
|
|
1005
|
-
e =
|
|
1006
|
-
else if (
|
|
1007
|
-
e =
|
|
1008
|
-
else if (
|
|
1213
|
+
if (s === "italic")
|
|
1214
|
+
e = m.TRUE;
|
|
1215
|
+
else if (s === "normal")
|
|
1216
|
+
e = m.FALSE;
|
|
1217
|
+
else if (s === null)
|
|
1009
1218
|
e = null;
|
|
1010
1219
|
else
|
|
1011
1220
|
throw new Error("Invalid fontStyle");
|
|
@@ -1018,28 +1227,28 @@ let k = class extends X {
|
|
|
1018
1227
|
range: this._range,
|
|
1019
1228
|
style: t
|
|
1020
1229
|
};
|
|
1021
|
-
return this._commandService.executeCommand(
|
|
1230
|
+
return this._commandService.executeCommand(f.id, n), this;
|
|
1022
1231
|
}
|
|
1023
1232
|
/**
|
|
1024
1233
|
* Sets the font line style of the given range ('underline', 'line-through', or 'none').
|
|
1025
1234
|
* @param fontLine The font line style, either 'underline', 'line-through', or 'none'; a null value resets the font line style.
|
|
1026
1235
|
*/
|
|
1027
|
-
setFontLine(
|
|
1028
|
-
if (
|
|
1236
|
+
setFontLine(s) {
|
|
1237
|
+
if (s === "underline")
|
|
1029
1238
|
this._setFontUnderline({
|
|
1030
|
-
s:
|
|
1239
|
+
s: m.TRUE
|
|
1031
1240
|
});
|
|
1032
|
-
else if (
|
|
1241
|
+
else if (s === "line-through")
|
|
1033
1242
|
this._setFontStrikethrough({
|
|
1034
|
-
s:
|
|
1243
|
+
s: m.TRUE
|
|
1035
1244
|
});
|
|
1036
|
-
else if (
|
|
1245
|
+
else if (s === "none")
|
|
1037
1246
|
this._setFontUnderline({
|
|
1038
|
-
s:
|
|
1247
|
+
s: m.FALSE
|
|
1039
1248
|
}), this._setFontStrikethrough({
|
|
1040
|
-
s:
|
|
1249
|
+
s: m.FALSE
|
|
1041
1250
|
});
|
|
1042
|
-
else if (
|
|
1251
|
+
else if (s === null)
|
|
1043
1252
|
this._setFontUnderline(null), this._setFontStrikethrough(null);
|
|
1044
1253
|
else
|
|
1045
1254
|
throw new Error("Invalid fontLine");
|
|
@@ -1047,131 +1256,177 @@ let k = class extends X {
|
|
|
1047
1256
|
}
|
|
1048
1257
|
/**
|
|
1049
1258
|
* Sets the font underline style of the given ITextDecoration
|
|
1259
|
+
* @param value
|
|
1050
1260
|
*/
|
|
1051
|
-
_setFontUnderline(
|
|
1261
|
+
_setFontUnderline(s) {
|
|
1052
1262
|
const e = {
|
|
1053
1263
|
type: "ul",
|
|
1054
|
-
value:
|
|
1264
|
+
value: s
|
|
1055
1265
|
}, t = {
|
|
1056
1266
|
unitId: this._workbook.getUnitId(),
|
|
1057
1267
|
subUnitId: this._worksheet.getSheetId(),
|
|
1058
1268
|
range: this._range,
|
|
1059
1269
|
style: e
|
|
1060
1270
|
};
|
|
1061
|
-
this._commandService.executeCommand(
|
|
1271
|
+
this._commandService.executeCommand(f.id, t);
|
|
1062
1272
|
}
|
|
1063
1273
|
/**
|
|
1064
1274
|
* Sets the font strikethrough style of the given ITextDecoration
|
|
1275
|
+
* @param value
|
|
1065
1276
|
*/
|
|
1066
|
-
_setFontStrikethrough(
|
|
1277
|
+
_setFontStrikethrough(s) {
|
|
1067
1278
|
const e = {
|
|
1068
1279
|
type: "st",
|
|
1069
|
-
value:
|
|
1280
|
+
value: s
|
|
1070
1281
|
}, t = {
|
|
1071
1282
|
unitId: this._workbook.getUnitId(),
|
|
1072
1283
|
subUnitId: this._worksheet.getSheetId(),
|
|
1073
1284
|
range: this._range,
|
|
1074
1285
|
style: e
|
|
1075
1286
|
};
|
|
1076
|
-
this._commandService.executeCommand(
|
|
1287
|
+
this._commandService.executeCommand(f.id, t);
|
|
1077
1288
|
}
|
|
1078
1289
|
/**
|
|
1079
1290
|
* Sets the font family, such as "Arial" or "Helvetica".
|
|
1080
1291
|
* @param fontFamily The font family to set; a null value resets the font family.
|
|
1081
1292
|
*/
|
|
1082
|
-
setFontFamily(
|
|
1293
|
+
setFontFamily(s) {
|
|
1083
1294
|
const e = {
|
|
1084
1295
|
type: "ff",
|
|
1085
|
-
value:
|
|
1296
|
+
value: s
|
|
1086
1297
|
}, t = {
|
|
1087
1298
|
unitId: this._workbook.getUnitId(),
|
|
1088
1299
|
subUnitId: this._worksheet.getSheetId(),
|
|
1089
1300
|
range: this._range,
|
|
1090
1301
|
style: e
|
|
1091
1302
|
};
|
|
1092
|
-
return this._commandService.executeCommand(
|
|
1303
|
+
return this._commandService.executeCommand(f.id, t), this;
|
|
1093
1304
|
}
|
|
1094
1305
|
/**
|
|
1095
1306
|
* Sets the font size, with the size being the point size to use.
|
|
1096
1307
|
* @param size A font size in point size. A null value resets the font size.
|
|
1097
1308
|
*/
|
|
1098
|
-
setFontSize(
|
|
1309
|
+
setFontSize(s) {
|
|
1099
1310
|
const e = {
|
|
1100
1311
|
type: "fs",
|
|
1101
|
-
value:
|
|
1312
|
+
value: s
|
|
1102
1313
|
}, t = {
|
|
1103
1314
|
unitId: this._workbook.getUnitId(),
|
|
1104
1315
|
subUnitId: this._worksheet.getSheetId(),
|
|
1105
1316
|
range: this._range,
|
|
1106
1317
|
style: e
|
|
1107
1318
|
};
|
|
1108
|
-
return this._commandService.executeCommand(
|
|
1319
|
+
return this._commandService.executeCommand(f.id, t), this;
|
|
1109
1320
|
}
|
|
1110
1321
|
/**
|
|
1111
1322
|
* Sets the font color in CSS notation (such as '#ffffff' or 'white').
|
|
1112
1323
|
* @param color The font color in CSS notation (such as '#ffffff' or 'white'); a null value resets the color.
|
|
1113
1324
|
*/
|
|
1114
|
-
setFontColor(
|
|
1325
|
+
setFontColor(s) {
|
|
1115
1326
|
const t = {
|
|
1116
1327
|
type: "cl",
|
|
1117
|
-
value:
|
|
1328
|
+
value: s === null ? null : { rgb: s }
|
|
1118
1329
|
}, n = {
|
|
1119
1330
|
unitId: this._workbook.getUnitId(),
|
|
1120
1331
|
subUnitId: this._worksheet.getSheetId(),
|
|
1121
1332
|
range: this._range,
|
|
1122
1333
|
style: t
|
|
1123
1334
|
};
|
|
1124
|
-
return this._commandService.executeCommand(
|
|
1335
|
+
return this._commandService.executeCommand(f.id, n), this;
|
|
1125
1336
|
}
|
|
1126
1337
|
// #endregion editing
|
|
1127
1338
|
//#region Merge cell
|
|
1128
1339
|
/**
|
|
1129
1340
|
* Merge cells in a range into one merged cell
|
|
1130
|
-
*
|
|
1131
1341
|
* @param [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1132
|
-
*
|
|
1133
1342
|
* @returns This range, for chaining
|
|
1343
|
+
* @example
|
|
1344
|
+
* ```ts
|
|
1345
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
1346
|
+
* const worksheet = workbook.getActiveSheet();
|
|
1347
|
+
* const range = worksheet.getRange(0, 0, 2, 2);
|
|
1348
|
+
* const merge = range.merge();
|
|
1349
|
+
* const isMerged = merge.isMerged();
|
|
1350
|
+
* console.log('debugger', isMerged);
|
|
1351
|
+
* ```
|
|
1134
1352
|
*/
|
|
1135
|
-
merge(
|
|
1353
|
+
merge(s = !0) {
|
|
1136
1354
|
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId();
|
|
1137
|
-
return
|
|
1355
|
+
return $(this._injector, e, t, [this._range], s), this;
|
|
1138
1356
|
}
|
|
1139
1357
|
/**
|
|
1140
1358
|
* Merges cells in a range horizontally.
|
|
1141
|
-
*
|
|
1142
1359
|
* @param [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1143
|
-
*
|
|
1144
1360
|
* @returns This range, for chaining
|
|
1361
|
+
* @example
|
|
1362
|
+
* ```ts
|
|
1363
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
1364
|
+
* const worksheet = workbook.getActiveSheet();
|
|
1365
|
+
* const range = worksheet.getRange(2, 2, 2, 2);
|
|
1366
|
+
* const merge = range.mergeAcross();
|
|
1367
|
+
* const allMerge = worksheet.getMergeData();
|
|
1368
|
+
* console.log(allMerge.length); // There will be two merged cells.
|
|
1369
|
+
* ```
|
|
1145
1370
|
*/
|
|
1146
|
-
mergeAcross(
|
|
1147
|
-
const e =
|
|
1148
|
-
return
|
|
1371
|
+
mergeAcross(s = !0) {
|
|
1372
|
+
const e = ce([this._range], ie.ROWS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
1373
|
+
return $(this._injector, t, n, e, s), this;
|
|
1149
1374
|
}
|
|
1150
1375
|
/**
|
|
1151
1376
|
* Merges cells in a range vertically.
|
|
1152
|
-
*
|
|
1153
1377
|
* @param [defaultMerge] - If true, only the value in the upper left cell is retained.
|
|
1154
|
-
*
|
|
1155
1378
|
* @returns This range, for chaining
|
|
1379
|
+
* @example
|
|
1380
|
+
* ```ts
|
|
1381
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
1382
|
+
* const worksheet = workbook.getActiveSheet();
|
|
1383
|
+
* const range = worksheet.getRange(4, 4, 2, 2);
|
|
1384
|
+
* const merge = range.mergeVertically();
|
|
1385
|
+
* const allMerge = worksheet.getMergeData();
|
|
1386
|
+
* console.log(allMerge.length); // There will be two merged cells.
|
|
1387
|
+
* ```
|
|
1156
1388
|
*/
|
|
1157
|
-
mergeVertically(
|
|
1158
|
-
const e =
|
|
1159
|
-
return
|
|
1389
|
+
mergeVertically(s = !0) {
|
|
1390
|
+
const e = ce([this._range], ie.COLUMNS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
1391
|
+
return $(this._injector, t, n, e, s), this;
|
|
1160
1392
|
}
|
|
1161
1393
|
/**
|
|
1162
1394
|
* Returns true if cells in the current range overlap a merged cell.
|
|
1163
1395
|
* @returns {boolean} is overlap with a merged cell
|
|
1396
|
+
* @example
|
|
1397
|
+
* ```ts
|
|
1398
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
1399
|
+
* const worksheet = workbook.getActiveSheet();
|
|
1400
|
+
* const range = worksheet.getRange(0,0,2,2);
|
|
1401
|
+
* const merge = range.merge();
|
|
1402
|
+
* const anchor = worksheet.getRange(0,0);
|
|
1403
|
+
* const isPartOfMerge = anchor.isPartOfMerge();
|
|
1404
|
+
* console.log('debugger, isPartOfMerge) // true
|
|
1405
|
+
* ```
|
|
1164
1406
|
*/
|
|
1165
1407
|
isPartOfMerge() {
|
|
1166
|
-
const { startRow:
|
|
1167
|
-
return this._worksheet.getMergedCellRange(
|
|
1408
|
+
const { startRow: s, startColumn: e, endRow: t, endColumn: n } = this._range;
|
|
1409
|
+
return this._worksheet.getMergedCellRange(s, e, t, n).length > 0;
|
|
1168
1410
|
}
|
|
1169
1411
|
/**
|
|
1170
1412
|
* Break all horizontally- or vertically-merged cells contained within the range list into individual cells again.
|
|
1171
1413
|
* @returns This range, for chaining
|
|
1414
|
+
* @example
|
|
1415
|
+
* ```ts
|
|
1416
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
1417
|
+
* const worksheet = workbook.getActiveSheet();
|
|
1418
|
+
* const range = worksheet.getRange(0,0,2,2);
|
|
1419
|
+
* const merge = range.merge();
|
|
1420
|
+
* const anchor = worksheet.getRange(0,0);
|
|
1421
|
+
* const isPartOfMergeFirst = anchor.isPartOfMerge();
|
|
1422
|
+
* console.log('debugger' isPartOfMergeFirst) // true
|
|
1423
|
+
* range.breakApart();
|
|
1424
|
+
* const isPartOfMergeSecond = anchor.isPartOfMerge();
|
|
1425
|
+
* console.log('debugger' isPartOfMergeSecond) // false
|
|
1426
|
+
* ```
|
|
1172
1427
|
*/
|
|
1173
1428
|
breakApart() {
|
|
1174
|
-
return this._commandService.executeCommand(
|
|
1429
|
+
return this._commandService.executeCommand(at.id, { ranges: [this._range] }), this;
|
|
1175
1430
|
}
|
|
1176
1431
|
//#endregion
|
|
1177
1432
|
/**
|
|
@@ -1189,14 +1444,15 @@ let k = class extends X {
|
|
|
1189
1444
|
* });
|
|
1190
1445
|
* ```
|
|
1191
1446
|
*/
|
|
1192
|
-
forEach(
|
|
1193
|
-
const { startColumn: e, startRow: t, endColumn: n, endRow:
|
|
1194
|
-
this._worksheet.getMatrixWithMergedCells(t, e,
|
|
1195
|
-
o
|
|
1447
|
+
forEach(s) {
|
|
1448
|
+
const { startColumn: e, startRow: t, endColumn: n, endRow: r } = this._range;
|
|
1449
|
+
this._worksheet.getMatrixWithMergedCells(t, e, r, n).forValue((o, i, a) => {
|
|
1450
|
+
s(o, i, a);
|
|
1196
1451
|
});
|
|
1197
1452
|
}
|
|
1198
1453
|
/**
|
|
1199
1454
|
* Returns a string description of the range, in A1 notation.
|
|
1455
|
+
* @param withSheet
|
|
1200
1456
|
* @returns {string} The A1 notation of the range.
|
|
1201
1457
|
* ```ts
|
|
1202
1458
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1205,8 +1461,8 @@ let k = class extends X {
|
|
|
1205
1461
|
* console.log(fRange.getA1Notation()); // A1:B2
|
|
1206
1462
|
* ```
|
|
1207
1463
|
*/
|
|
1208
|
-
getA1Notation(
|
|
1209
|
-
return
|
|
1464
|
+
getA1Notation(s) {
|
|
1465
|
+
return s ? Tt(this._worksheet.getName(), this._range) : re(this._range);
|
|
1210
1466
|
}
|
|
1211
1467
|
/**
|
|
1212
1468
|
* Sets the specified range as the active range, with the top left cell in the range as the current cell.
|
|
@@ -1230,8 +1486,8 @@ let k = class extends X {
|
|
|
1230
1486
|
* @description If the range is not a single cell, an error will be thrown.
|
|
1231
1487
|
*/
|
|
1232
1488
|
activateAsCurrentCell() {
|
|
1233
|
-
const
|
|
1234
|
-
if (
|
|
1489
|
+
const s = this._worksheet.getMergedCell(this._range.startRow, this._range.startColumn);
|
|
1490
|
+
if (s && N.equals(s, this._range) || !s && this._range.startRow === this._range.endRow && this._range.startColumn === this._range.endColumn)
|
|
1235
1491
|
return this.activate();
|
|
1236
1492
|
throw new Error("The range is not a single cell");
|
|
1237
1493
|
}
|
|
@@ -1267,14 +1523,14 @@ let k = class extends X {
|
|
|
1267
1523
|
* // 1 | 2 | 3
|
|
1268
1524
|
* // 4 | 5 | 6
|
|
1269
1525
|
*/
|
|
1270
|
-
splitTextToColumns(
|
|
1271
|
-
this._commandService.executeCommand(
|
|
1526
|
+
splitTextToColumns(s, e, t) {
|
|
1527
|
+
this._commandService.executeCommand(ht.id, {
|
|
1272
1528
|
unitId: this._workbook.getUnitId(),
|
|
1273
1529
|
subUnitId: this._worksheet.getSheetId(),
|
|
1274
1530
|
range: this._range,
|
|
1275
1531
|
delimiter: e,
|
|
1276
1532
|
customDelimiter: t,
|
|
1277
|
-
treatMultipleDelimitersAsOne:
|
|
1533
|
+
treatMultipleDelimitersAsOne: s
|
|
1278
1534
|
});
|
|
1279
1535
|
}
|
|
1280
1536
|
/**
|
|
@@ -1288,16 +1544,16 @@ let k = class extends X {
|
|
|
1288
1544
|
* fRange.useThemeStyle('default');
|
|
1289
1545
|
* ```
|
|
1290
1546
|
*/
|
|
1291
|
-
useThemeStyle(
|
|
1292
|
-
if (
|
|
1547
|
+
useThemeStyle(s) {
|
|
1548
|
+
if (s == null) {
|
|
1293
1549
|
const e = this.getUsedThemeStyle();
|
|
1294
1550
|
e && this.removeThemeStyle(e);
|
|
1295
1551
|
} else
|
|
1296
|
-
this._commandService.executeCommand(
|
|
1552
|
+
this._commandService.executeCommand(ct.id, {
|
|
1297
1553
|
unitId: this._workbook.getUnitId(),
|
|
1298
1554
|
subUnitId: this._worksheet.getSheetId(),
|
|
1299
1555
|
range: this._range,
|
|
1300
|
-
themeName:
|
|
1556
|
+
themeName: s
|
|
1301
1557
|
});
|
|
1302
1558
|
}
|
|
1303
1559
|
/**
|
|
@@ -1311,12 +1567,12 @@ let k = class extends X {
|
|
|
1311
1567
|
* fRange.removeThemeStyle('default');
|
|
1312
1568
|
* ```
|
|
1313
1569
|
*/
|
|
1314
|
-
removeThemeStyle(
|
|
1315
|
-
this._commandService.executeCommand(
|
|
1570
|
+
removeThemeStyle(s) {
|
|
1571
|
+
this._commandService.executeCommand(dt.id, {
|
|
1316
1572
|
unitId: this._workbook.getUnitId(),
|
|
1317
1573
|
subUnitId: this._worksheet.getSheetId(),
|
|
1318
1574
|
range: this._range,
|
|
1319
|
-
themeName:
|
|
1575
|
+
themeName: s
|
|
1320
1576
|
});
|
|
1321
1577
|
}
|
|
1322
1578
|
/**
|
|
@@ -1333,49 +1589,49 @@ let k = class extends X {
|
|
|
1333
1589
|
* ```
|
|
1334
1590
|
*/
|
|
1335
1591
|
getUsedThemeStyle() {
|
|
1336
|
-
return this._injector.get(
|
|
1592
|
+
return this._injector.get(Me).getAppliedRangeThemeStyle({
|
|
1337
1593
|
unitId: this._workbook.getUnitId(),
|
|
1338
1594
|
subUnitId: this._worksheet.getSheetId(),
|
|
1339
1595
|
range: this._range
|
|
1340
1596
|
});
|
|
1341
1597
|
}
|
|
1342
1598
|
};
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
],
|
|
1348
|
-
var
|
|
1349
|
-
for (var
|
|
1350
|
-
(i = o
|
|
1351
|
-
return n &&
|
|
1352
|
-
},
|
|
1353
|
-
let
|
|
1354
|
-
constructor(
|
|
1355
|
-
this._workbook =
|
|
1599
|
+
w = Jt([
|
|
1600
|
+
Y(3, u(b)),
|
|
1601
|
+
Y(4, l),
|
|
1602
|
+
Y(5, u(Wt))
|
|
1603
|
+
], w);
|
|
1604
|
+
var Qt = Object.defineProperty, Xt = Object.getOwnPropertyDescriptor, Zt = (s, e, t, n) => {
|
|
1605
|
+
for (var r = n > 1 ? void 0 : n ? Xt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
1606
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
1607
|
+
return n && r && Qt(e, t, r), r;
|
|
1608
|
+
}, en = (s, e) => (t, n) => e(t, n, s);
|
|
1609
|
+
let B = class {
|
|
1610
|
+
constructor(s, e, t, n) {
|
|
1611
|
+
this._workbook = s, this._worksheet = e, this._selections = t, this._injector = n;
|
|
1356
1612
|
}
|
|
1357
1613
|
/**
|
|
1358
1614
|
* Represents the active selection in the sheet. Which means the selection contains the active cell.
|
|
1359
1615
|
* @returns {FRange | null} The active selection.
|
|
1360
1616
|
*/
|
|
1361
1617
|
getActiveRange() {
|
|
1362
|
-
const
|
|
1363
|
-
return
|
|
1618
|
+
const s = this._selections.find((e) => !!e.primary);
|
|
1619
|
+
return s ? this._injector.createInstance(w, this._workbook, this._worksheet, s.range) : null;
|
|
1364
1620
|
}
|
|
1365
1621
|
/**
|
|
1366
1622
|
* Represents the active selection list in the sheet.
|
|
1367
1623
|
* @returns {FRange[]} The active selection list.
|
|
1368
1624
|
*/
|
|
1369
1625
|
getActiveRangeList() {
|
|
1370
|
-
return this._selections.map((
|
|
1626
|
+
return this._selections.map((s) => this._injector.createInstance(w, this._workbook, this._worksheet, s.range));
|
|
1371
1627
|
}
|
|
1372
1628
|
/**
|
|
1373
1629
|
* Represents the current select cell in the sheet.
|
|
1374
1630
|
* @returns {ISelectionCell} The current select cell info.Pay attention to the type of the return value.
|
|
1375
1631
|
*/
|
|
1376
1632
|
getCurrentCell() {
|
|
1377
|
-
const
|
|
1378
|
-
return
|
|
1633
|
+
const s = this._selections.find((e) => !!e.primary);
|
|
1634
|
+
return s ? s.primary : null;
|
|
1379
1635
|
}
|
|
1380
1636
|
/**
|
|
1381
1637
|
* Returns the active sheet in the spreadsheet.
|
|
@@ -1390,8 +1646,8 @@ let A = class {
|
|
|
1390
1646
|
* ```
|
|
1391
1647
|
*/
|
|
1392
1648
|
getActiveSheet() {
|
|
1393
|
-
const
|
|
1394
|
-
return this._injector.createInstance(g,
|
|
1649
|
+
const s = this._injector.createInstance(I, this._workbook);
|
|
1650
|
+
return this._injector.createInstance(g, s, this._workbook, this._worksheet);
|
|
1395
1651
|
}
|
|
1396
1652
|
/**
|
|
1397
1653
|
* 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.
|
|
@@ -1407,31 +1663,31 @@ let A = class {
|
|
|
1407
1663
|
* console.log(newSelection.getActiveRange().getA1Notation()); // A1
|
|
1408
1664
|
* ```
|
|
1409
1665
|
*/
|
|
1410
|
-
updatePrimaryCell(
|
|
1666
|
+
updatePrimaryCell(s) {
|
|
1411
1667
|
const e = this._injector.get(l);
|
|
1412
1668
|
let t = [], n = !1;
|
|
1413
|
-
for (const { range:
|
|
1414
|
-
|
|
1415
|
-
range:
|
|
1416
|
-
primary:
|
|
1669
|
+
for (const { range: o, style: i } of this._selections)
|
|
1670
|
+
N.contains(o, s.getRange()) ? (t.push({
|
|
1671
|
+
range: o,
|
|
1672
|
+
primary: Z(s.getRange(), this._worksheet),
|
|
1417
1673
|
style: i
|
|
1418
1674
|
}), n = !0) : t.push({
|
|
1419
|
-
range:
|
|
1675
|
+
range: o,
|
|
1420
1676
|
primary: null,
|
|
1421
1677
|
style: i
|
|
1422
1678
|
});
|
|
1423
1679
|
n || (t = [
|
|
1424
1680
|
{
|
|
1425
|
-
range:
|
|
1426
|
-
primary:
|
|
1681
|
+
range: s.getRange(),
|
|
1682
|
+
primary: Z(s.getRange(), this._worksheet)
|
|
1427
1683
|
}
|
|
1428
1684
|
]);
|
|
1429
|
-
const
|
|
1685
|
+
const r = {
|
|
1430
1686
|
unitId: this._workbook.getUnitId(),
|
|
1431
1687
|
subUnitId: this._worksheet.getSheetId(),
|
|
1432
1688
|
selections: t
|
|
1433
1689
|
};
|
|
1434
|
-
return e.syncExecuteCommand(
|
|
1690
|
+
return e.syncExecuteCommand(De.id, r), new B(this._workbook, this._worksheet, t, this._injector);
|
|
1435
1691
|
}
|
|
1436
1692
|
/**
|
|
1437
1693
|
*Get the next primary cell in the specified direction. If the primary cell not exists in selections, return null.
|
|
@@ -1448,30 +1704,68 @@ let A = class {
|
|
|
1448
1704
|
* console.log(nextCell?.getA1Notation()); // B1
|
|
1449
1705
|
* ```
|
|
1450
1706
|
*/
|
|
1451
|
-
getNextDataRange(
|
|
1707
|
+
getNextDataRange(s) {
|
|
1452
1708
|
if (!this._selections.find((n) => !!n.primary))
|
|
1453
1709
|
return null;
|
|
1454
|
-
const t =
|
|
1455
|
-
return t ? this._injector.createInstance(
|
|
1710
|
+
const t = ut(this._selections.concat(), s, this._worksheet);
|
|
1711
|
+
return t ? this._injector.createInstance(w, this._workbook, this._worksheet, t) : null;
|
|
1456
1712
|
}
|
|
1457
1713
|
};
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
],
|
|
1461
|
-
var
|
|
1462
|
-
for (var
|
|
1463
|
-
(i = o
|
|
1464
|
-
return n &&
|
|
1465
|
-
},
|
|
1466
|
-
let g = class extends
|
|
1467
|
-
constructor(e, t, n,
|
|
1468
|
-
super(
|
|
1714
|
+
B = Zt([
|
|
1715
|
+
en(3, u(b))
|
|
1716
|
+
], B);
|
|
1717
|
+
var tn = Object.defineProperty, nn = Object.getOwnPropertyDescriptor, sn = (s, e, t, n) => {
|
|
1718
|
+
for (var r = n > 1 ? void 0 : n ? nn(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
1719
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
1720
|
+
return n && r && tn(e, t, r), r;
|
|
1721
|
+
}, T = (s, e) => (t, n) => e(t, n, s);
|
|
1722
|
+
let g = class extends ne {
|
|
1723
|
+
constructor(e, t, n, r, o, i, a) {
|
|
1724
|
+
super(r);
|
|
1725
|
+
k(this, "_eventRegistry", /* @__PURE__ */ new Map());
|
|
1469
1726
|
/**
|
|
1470
1727
|
* Sets the active selection region for this sheet.
|
|
1471
1728
|
* @param range The range to set as the active selection.
|
|
1472
1729
|
*/
|
|
1473
|
-
|
|
1474
|
-
this._fWorkbook = e, this._workbook = t, this._worksheet = n, this._injector =
|
|
1730
|
+
k(this, "setActiveSelection", this.setActiveRange);
|
|
1731
|
+
this._fWorkbook = e, this._workbook = t, this._worksheet = n, this._injector = r, this._selectionManagerService = o, this._logService = i, this._commandService = a;
|
|
1732
|
+
}
|
|
1733
|
+
getSheet() {
|
|
1734
|
+
return this._worksheet;
|
|
1735
|
+
}
|
|
1736
|
+
_ensureEventRegistry(e) {
|
|
1737
|
+
return this._eventRegistry.has(e) || this._eventRegistry.set(e, new ye()), this._eventRegistry.get(e);
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* Add an event listener
|
|
1741
|
+
* @param event key of event
|
|
1742
|
+
* @param callback callback when event triggered
|
|
1743
|
+
* @returns {Disposable} The Disposable instance, for remove the listener
|
|
1744
|
+
* @example
|
|
1745
|
+
* ```ts
|
|
1746
|
+
* univerAPI.addEvent(univerAPI.event.UnitCreated, (params) => {
|
|
1747
|
+
* console.log('unit created', params);
|
|
1748
|
+
* });
|
|
1749
|
+
* ```
|
|
1750
|
+
*/
|
|
1751
|
+
addEvent(e, t) {
|
|
1752
|
+
return this._ensureEventRegistry(e).add(t), F(() => this._ensureEventRegistry(e).delete(t));
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Fire an event, used in internal only.
|
|
1756
|
+
* @param event {string} key of event
|
|
1757
|
+
* @param params {any} params of event
|
|
1758
|
+
* @returns {boolean} should cancel
|
|
1759
|
+
* @example
|
|
1760
|
+
* ```ts
|
|
1761
|
+
* this.fireEvent(univerAPI.event.UnitCreated, params);
|
|
1762
|
+
* ```
|
|
1763
|
+
*/
|
|
1764
|
+
fireEvent(e, t) {
|
|
1765
|
+
var n;
|
|
1766
|
+
return (n = this._eventRegistry.get(e)) == null || n.getData().forEach((r) => {
|
|
1767
|
+
r(t);
|
|
1768
|
+
}), t.cancel;
|
|
1475
1769
|
}
|
|
1476
1770
|
/**
|
|
1477
1771
|
* Returns the injector
|
|
@@ -1507,7 +1801,7 @@ let g = class extends X {
|
|
|
1507
1801
|
*/
|
|
1508
1802
|
getSelection() {
|
|
1509
1803
|
const e = this._selectionManagerService.getCurrentSelections();
|
|
1510
|
-
return e ? this._injector.createInstance(
|
|
1804
|
+
return e ? this._injector.createInstance(B, this._workbook, this._worksheet, e) : null;
|
|
1511
1805
|
}
|
|
1512
1806
|
// #region rows
|
|
1513
1807
|
// #region default style
|
|
@@ -1530,7 +1824,7 @@ let g = class extends X {
|
|
|
1530
1824
|
/**
|
|
1531
1825
|
* Get the default style of the worksheet column
|
|
1532
1826
|
* @param {number} index The column index
|
|
1533
|
-
* @param
|
|
1827
|
+
* @param {boolean} [keepRaw] If true, return the raw style data maybe the style name or style data, otherwise return the data from col manager
|
|
1534
1828
|
* @returns {Nullable<IStyleData> | string} The default style of the worksheet column name or style data
|
|
1535
1829
|
*/
|
|
1536
1830
|
getColumnDefaultStyle(e, t = !1) {
|
|
@@ -1543,7 +1837,7 @@ let g = class extends X {
|
|
|
1543
1837
|
*/
|
|
1544
1838
|
setDefaultStyle(e) {
|
|
1545
1839
|
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
|
|
1546
|
-
return this._commandService.syncExecuteCommand(
|
|
1840
|
+
return this._commandService.syncExecuteCommand(mt.id, {
|
|
1547
1841
|
unitId: t,
|
|
1548
1842
|
subUnitId: n,
|
|
1549
1843
|
defaultStyle: e
|
|
@@ -1556,16 +1850,16 @@ let g = class extends X {
|
|
|
1556
1850
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
1557
1851
|
*/
|
|
1558
1852
|
setColumnDefaultStyle(e, t) {
|
|
1559
|
-
const n = this._workbook.getUnitId(),
|
|
1853
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
1560
1854
|
unitId: n,
|
|
1561
|
-
subUnitId:
|
|
1855
|
+
subUnitId: r,
|
|
1562
1856
|
columnData: {
|
|
1563
1857
|
[e]: {
|
|
1564
1858
|
s: t
|
|
1565
1859
|
}
|
|
1566
1860
|
}
|
|
1567
1861
|
};
|
|
1568
|
-
return this._commandService.syncExecuteCommand(
|
|
1862
|
+
return this._commandService.syncExecuteCommand(de.id, o), this;
|
|
1569
1863
|
}
|
|
1570
1864
|
/**
|
|
1571
1865
|
* Set the default style of the worksheet column
|
|
@@ -1574,24 +1868,24 @@ let g = class extends X {
|
|
|
1574
1868
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
1575
1869
|
*/
|
|
1576
1870
|
setRowDefaultStyle(e, t) {
|
|
1577
|
-
const n = this._workbook.getUnitId(),
|
|
1871
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
1578
1872
|
unitId: n,
|
|
1579
|
-
subUnitId:
|
|
1873
|
+
subUnitId: r,
|
|
1580
1874
|
rowData: {
|
|
1581
1875
|
[e]: {
|
|
1582
1876
|
s: t
|
|
1583
1877
|
}
|
|
1584
1878
|
}
|
|
1585
1879
|
};
|
|
1586
|
-
return this._commandService.syncExecuteCommand(
|
|
1880
|
+
return this._commandService.syncExecuteCommand(ue.id, o), this;
|
|
1587
1881
|
}
|
|
1588
|
-
getRange(e, t, n,
|
|
1589
|
-
let
|
|
1882
|
+
getRange(e, t, n, r) {
|
|
1883
|
+
let o, i;
|
|
1590
1884
|
if (typeof e == "string") {
|
|
1591
|
-
const { range: a, sheetName: h } =
|
|
1885
|
+
const { range: a, sheetName: h } = At(e), c = h ? this._workbook.getSheetBySheetName(h) : this._worksheet;
|
|
1592
1886
|
if (!c)
|
|
1593
1887
|
throw new Error("Range not found");
|
|
1594
|
-
i = c,
|
|
1888
|
+
i = c, o = {
|
|
1595
1889
|
...a,
|
|
1596
1890
|
unitId: this._workbook.getUnitId(),
|
|
1597
1891
|
sheetId: i.getSheetId(),
|
|
@@ -1604,44 +1898,44 @@ let g = class extends X {
|
|
|
1604
1898
|
endColumn: a.rangeType === _.ROW ? i.getMaxColumns() - 1 : a.endColumn
|
|
1605
1899
|
};
|
|
1606
1900
|
} else if (typeof e == "number" && t !== void 0)
|
|
1607
|
-
i = this._worksheet,
|
|
1901
|
+
i = this._worksheet, o = {
|
|
1608
1902
|
startRow: e,
|
|
1609
1903
|
endRow: e + (n != null ? n : 1) - 1,
|
|
1610
1904
|
startColumn: t,
|
|
1611
|
-
endColumn: t + (
|
|
1905
|
+
endColumn: t + (r != null ? r : 1) - 1,
|
|
1612
1906
|
unitId: this._workbook.getUnitId(),
|
|
1613
1907
|
sheetId: this._worksheet.getSheetId()
|
|
1614
1908
|
};
|
|
1615
1909
|
else
|
|
1616
1910
|
throw new Error("Invalid range specification");
|
|
1617
|
-
return this._injector.createInstance(
|
|
1911
|
+
return this._injector.createInstance(w, this._workbook, i, o);
|
|
1618
1912
|
}
|
|
1619
1913
|
/**
|
|
1620
1914
|
* Returns the current number of columns in the sheet, regardless of content.
|
|
1621
|
-
* @
|
|
1915
|
+
* @returns {number} The maximum columns count of the sheet
|
|
1622
1916
|
*/
|
|
1623
1917
|
getMaxColumns() {
|
|
1624
1918
|
return this._worksheet.getMaxColumns();
|
|
1625
1919
|
}
|
|
1626
1920
|
/**
|
|
1627
1921
|
* Returns the current number of rows in the sheet, regardless of content.
|
|
1628
|
-
* @
|
|
1922
|
+
* @returns {number}The maximum rows count of the sheet
|
|
1629
1923
|
*/
|
|
1630
1924
|
getMaxRows() {
|
|
1631
1925
|
return this._worksheet.getMaxRows();
|
|
1632
1926
|
}
|
|
1633
1927
|
/**
|
|
1634
1928
|
* Inserts a row after the given row position.
|
|
1635
|
-
* @param afterPosition The row after which the new row should be added, starting at 0 for the first row.
|
|
1636
|
-
* @returns This sheet, for chaining.
|
|
1929
|
+
* @param {number} afterPosition The row after which the new row should be added, starting at 0 for the first row.
|
|
1930
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1637
1931
|
*/
|
|
1638
1932
|
insertRowAfter(e) {
|
|
1639
1933
|
return this.insertRowsAfter(e, 1);
|
|
1640
1934
|
}
|
|
1641
1935
|
/**
|
|
1642
1936
|
* Inserts a row before the given row position.
|
|
1643
|
-
* @param beforePosition The row before which the new row should be added, starting at 0 for the first row.
|
|
1644
|
-
* @returns This sheet, for chaining.
|
|
1937
|
+
* @param {number} beforePosition The row before which the new row should be added, starting at 0 for the first row.
|
|
1938
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1645
1939
|
*/
|
|
1646
1940
|
insertRowBefore(e) {
|
|
1647
1941
|
return this.insertRowsBefore(e, 1);
|
|
@@ -1662,11 +1956,11 @@ let g = class extends X {
|
|
|
1662
1956
|
* @returns This sheet, for chaining.
|
|
1663
1957
|
*/
|
|
1664
1958
|
insertRowsAfter(e, t) {
|
|
1665
|
-
const n = this._workbook.getUnitId(),
|
|
1666
|
-
return this._commandService.syncExecuteCommand(
|
|
1959
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.DOWN, i = e + 1, a = e + t, h = 0, c = this._worksheet.getColumnCount() - 1, d = W(this._worksheet, i, a, h, c, !0, e);
|
|
1960
|
+
return this._commandService.syncExecuteCommand(me.id, {
|
|
1667
1961
|
unitId: n,
|
|
1668
|
-
subUnitId:
|
|
1669
|
-
direction:
|
|
1962
|
+
subUnitId: r,
|
|
1963
|
+
direction: o,
|
|
1670
1964
|
range: {
|
|
1671
1965
|
startRow: i,
|
|
1672
1966
|
endRow: a,
|
|
@@ -1683,11 +1977,11 @@ let g = class extends X {
|
|
|
1683
1977
|
* @returns This sheet, for chaining.
|
|
1684
1978
|
*/
|
|
1685
1979
|
insertRowsBefore(e, t) {
|
|
1686
|
-
const n = this._workbook.getUnitId(),
|
|
1687
|
-
return this._commandService.syncExecuteCommand(
|
|
1980
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.UP, i = e, a = e + t - 1, h = 0, c = this._worksheet.getColumnCount() - 1, d = W(this._worksheet, i, a, h, c, !0, e - 1);
|
|
1981
|
+
return this._commandService.syncExecuteCommand(me.id, {
|
|
1688
1982
|
unitId: n,
|
|
1689
|
-
subUnitId:
|
|
1690
|
-
direction:
|
|
1983
|
+
subUnitId: r,
|
|
1984
|
+
direction: o,
|
|
1691
1985
|
range: {
|
|
1692
1986
|
startRow: i,
|
|
1693
1987
|
endRow: a,
|
|
@@ -1718,7 +2012,7 @@ let g = class extends X {
|
|
|
1718
2012
|
startColumn: 0,
|
|
1719
2013
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
1720
2014
|
};
|
|
1721
|
-
return this._commandService.syncExecuteCommand(
|
|
2015
|
+
return this._commandService.syncExecuteCommand(lt.id, {
|
|
1722
2016
|
range: n,
|
|
1723
2017
|
unitId: this._workbook.getUnitId(),
|
|
1724
2018
|
subUnitId: this._worksheet.getSheetId()
|
|
@@ -1731,16 +2025,16 @@ let g = class extends X {
|
|
|
1731
2025
|
* @returns This sheet, for chaining.
|
|
1732
2026
|
*/
|
|
1733
2027
|
moveRows(e, t) {
|
|
1734
|
-
const n = this._workbook.getUnitId(),
|
|
2028
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = q(e.getRange(), this._worksheet), i = o, a = {
|
|
1735
2029
|
startRow: t,
|
|
1736
2030
|
endRow: t,
|
|
1737
|
-
startColumn:
|
|
1738
|
-
endColumn:
|
|
2031
|
+
startColumn: o.startColumn,
|
|
2032
|
+
endColumn: o.endColumn
|
|
1739
2033
|
};
|
|
1740
|
-
return this._commandService.syncExecuteCommand(
|
|
2034
|
+
return this._commandService.syncExecuteCommand(gt.id, {
|
|
1741
2035
|
unitId: n,
|
|
1742
|
-
subUnitId:
|
|
1743
|
-
range:
|
|
2036
|
+
subUnitId: r,
|
|
2037
|
+
range: o,
|
|
1744
2038
|
fromRange: i,
|
|
1745
2039
|
toRange: a
|
|
1746
2040
|
}), this;
|
|
@@ -1751,114 +2045,115 @@ let g = class extends X {
|
|
|
1751
2045
|
* @returns This sheet, for chaining.
|
|
1752
2046
|
*/
|
|
1753
2047
|
hideRow(e) {
|
|
1754
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
1755
|
-
return this._commandService.syncExecuteCommand(
|
|
2048
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = q(e.getRange(), this._worksheet);
|
|
2049
|
+
return this._commandService.syncExecuteCommand(le.id, {
|
|
1756
2050
|
unitId: t,
|
|
1757
2051
|
subUnitId: n,
|
|
1758
|
-
ranges: [
|
|
2052
|
+
ranges: [r]
|
|
1759
2053
|
}), this;
|
|
1760
2054
|
}
|
|
1761
2055
|
/**
|
|
1762
2056
|
* Hides one or more consecutive rows starting at the given index. Use 0-index for this method.
|
|
1763
|
-
* @param rowIndex The starting index of the rows to hide.
|
|
1764
|
-
* @param numRows The number of rows to hide.
|
|
1765
|
-
* @returns This sheet, for chaining.
|
|
2057
|
+
* @param {number} rowIndex The starting index of the rows to hide.
|
|
2058
|
+
* @param {number} numRows The number of rows to hide.
|
|
2059
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1766
2060
|
*/
|
|
1767
2061
|
hideRows(e, t = 1) {
|
|
1768
|
-
const n = this._workbook.getUnitId(),
|
|
2062
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
1769
2063
|
startRow: e,
|
|
1770
2064
|
endRow: e + t - 1,
|
|
1771
2065
|
startColumn: 0,
|
|
1772
2066
|
endColumn: this._worksheet.getColumnCount() - 1,
|
|
1773
2067
|
rangeType: _.ROW
|
|
1774
2068
|
};
|
|
1775
|
-
return this._commandService.syncExecuteCommand(
|
|
2069
|
+
return this._commandService.syncExecuteCommand(le.id, {
|
|
1776
2070
|
unitId: n,
|
|
1777
|
-
subUnitId:
|
|
1778
|
-
ranges: [
|
|
2071
|
+
subUnitId: r,
|
|
2072
|
+
ranges: [o]
|
|
1779
2073
|
}), this;
|
|
1780
2074
|
}
|
|
1781
2075
|
/**
|
|
1782
|
-
*
|
|
1783
|
-
* @param row The range to unhide, if hidden.
|
|
1784
|
-
* @returns This sheet, for chaining.
|
|
2076
|
+
* Make the row in the given range visible.
|
|
2077
|
+
* @param {FRange} row The range to unhide, if hidden.
|
|
2078
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1785
2079
|
*/
|
|
1786
2080
|
unhideRow(e) {
|
|
1787
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
1788
|
-
return this._commandService.syncExecuteCommand(
|
|
2081
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = q(e.getRange(), this._worksheet);
|
|
2082
|
+
return this._commandService.syncExecuteCommand(ge.id, {
|
|
1789
2083
|
unitId: t,
|
|
1790
2084
|
subUnitId: n,
|
|
1791
|
-
ranges: [
|
|
2085
|
+
ranges: [r]
|
|
1792
2086
|
}), this;
|
|
1793
2087
|
}
|
|
1794
2088
|
/**
|
|
1795
|
-
*
|
|
1796
|
-
* @param rowIndex The starting index of the rows
|
|
1797
|
-
* @param numRows The number of rows
|
|
1798
|
-
* @returns This sheet, for chaining.
|
|
2089
|
+
* Scrolling sheet to make specific rows visible.
|
|
2090
|
+
* @param {number} rowIndex The starting index of the rows
|
|
2091
|
+
* @param {number} numRows The number of rows
|
|
2092
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1799
2093
|
*/
|
|
1800
2094
|
showRows(e, t = 1) {
|
|
1801
|
-
const n = this._workbook.getUnitId(),
|
|
2095
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
1802
2096
|
startRow: e,
|
|
1803
2097
|
endRow: e + t - 1,
|
|
1804
2098
|
startColumn: 0,
|
|
1805
2099
|
endColumn: this._worksheet.getColumnCount() - 1,
|
|
1806
2100
|
rangeType: _.ROW
|
|
1807
2101
|
};
|
|
1808
|
-
return this._commandService.syncExecuteCommand(
|
|
2102
|
+
return this._commandService.syncExecuteCommand(ge.id, {
|
|
1809
2103
|
unitId: n,
|
|
1810
|
-
subUnitId:
|
|
1811
|
-
ranges: [
|
|
2104
|
+
subUnitId: r,
|
|
2105
|
+
ranges: [o]
|
|
1812
2106
|
}), this;
|
|
1813
2107
|
}
|
|
1814
2108
|
/**
|
|
1815
2109
|
* Sets the row height of the given row in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).
|
|
1816
|
-
* @param rowPosition The row position to change.
|
|
1817
|
-
* @param height The height in pixels to set it to.
|
|
1818
|
-
* @returns This sheet, for chaining.
|
|
2110
|
+
* @param {number} rowPosition The row position to change.
|
|
2111
|
+
* @param {number} height The height in pixels to set it to.
|
|
2112
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1819
2113
|
*/
|
|
1820
2114
|
setRowHeight(e, t) {
|
|
1821
2115
|
return this.setRowHeights(e, 1, t);
|
|
1822
2116
|
}
|
|
1823
2117
|
/**
|
|
1824
|
-
* Sets the height of the given rows in pixels.
|
|
1825
|
-
*
|
|
1826
|
-
* @param
|
|
1827
|
-
* @param
|
|
1828
|
-
* @
|
|
2118
|
+
* Sets the height of the given rows in pixels.
|
|
2119
|
+
* By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).
|
|
2120
|
+
* @param {number} startRow The starting row position to change.
|
|
2121
|
+
* @param {number} numRows The number of rows to change.
|
|
2122
|
+
* @param {number} height The height in pixels to set it to.
|
|
2123
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1829
2124
|
*/
|
|
1830
2125
|
setRowHeights(e, t, n) {
|
|
1831
2126
|
var c;
|
|
1832
|
-
const
|
|
2127
|
+
const r = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = this._worksheet.getRowManager(), a = [], h = [];
|
|
1833
2128
|
for (let d = e; d < e + t; d++) {
|
|
1834
|
-
const
|
|
2129
|
+
const z = ((c = i.getRow(d)) == null ? void 0 : c.ah) || this._worksheet.getConfig().defaultRowHeight, M = {
|
|
1835
2130
|
startRow: d,
|
|
1836
2131
|
endRow: d,
|
|
1837
2132
|
startColumn: 0,
|
|
1838
2133
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
1839
2134
|
};
|
|
1840
|
-
n <=
|
|
2135
|
+
n <= z ? a.push(M) : h.push(M);
|
|
1841
2136
|
}
|
|
1842
|
-
return h.length > 0 && this._commandService.syncExecuteCommand(
|
|
1843
|
-
unitId:
|
|
1844
|
-
subUnitId:
|
|
2137
|
+
return h.length > 0 && this._commandService.syncExecuteCommand(_e.id, {
|
|
2138
|
+
unitId: r,
|
|
2139
|
+
subUnitId: o,
|
|
1845
2140
|
ranges: h,
|
|
1846
2141
|
value: n
|
|
1847
|
-
}), a.length > 0 && this._commandService.syncExecuteCommand(
|
|
1848
|
-
unitId:
|
|
1849
|
-
subUnitId:
|
|
2142
|
+
}), a.length > 0 && this._commandService.syncExecuteCommand(_t.id, {
|
|
2143
|
+
unitId: r,
|
|
2144
|
+
subUnitId: o,
|
|
1850
2145
|
ranges: a
|
|
1851
2146
|
}), this;
|
|
1852
2147
|
}
|
|
1853
2148
|
/**
|
|
1854
2149
|
* 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.
|
|
1855
|
-
* @param startRow The starting row position to change.
|
|
1856
|
-
* @param numRows The number of rows to change.
|
|
1857
|
-
* @param height The height in pixels to set it to.
|
|
1858
|
-
* @returns This sheet, for chaining.
|
|
2150
|
+
* @param {number} startRow The starting row position to change.
|
|
2151
|
+
* @param {number} numRows The number of rows to change.
|
|
2152
|
+
* @param {number} height The height in pixels to set it to.
|
|
2153
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
1859
2154
|
*/
|
|
1860
2155
|
setRowHeightsForced(e, t, n) {
|
|
1861
|
-
const
|
|
2156
|
+
const r = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = [
|
|
1862
2157
|
{
|
|
1863
2158
|
startRow: e,
|
|
1864
2159
|
endRow: e + t - 1,
|
|
@@ -1866,9 +2161,9 @@ let g = class extends X {
|
|
|
1866
2161
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
1867
2162
|
}
|
|
1868
2163
|
];
|
|
1869
|
-
return this._commandService.syncExecuteCommand(
|
|
1870
|
-
unitId:
|
|
1871
|
-
subUnitId:
|
|
2164
|
+
return this._commandService.syncExecuteCommand(_e.id, {
|
|
2165
|
+
unitId: r,
|
|
2166
|
+
subUnitId: o,
|
|
1872
2167
|
ranges: i,
|
|
1873
2168
|
value: n
|
|
1874
2169
|
}), this;
|
|
@@ -1880,17 +2175,17 @@ let g = class extends X {
|
|
|
1880
2175
|
* @returns This sheet, for chaining.
|
|
1881
2176
|
*/
|
|
1882
2177
|
setRowCustom(e) {
|
|
1883
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2178
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = {};
|
|
1884
2179
|
for (const [i, a] of Object.entries(e))
|
|
1885
|
-
|
|
2180
|
+
r[Number(i)] = {
|
|
1886
2181
|
custom: a
|
|
1887
2182
|
};
|
|
1888
|
-
const
|
|
2183
|
+
const o = {
|
|
1889
2184
|
unitId: t,
|
|
1890
2185
|
subUnitId: n,
|
|
1891
|
-
rowData:
|
|
2186
|
+
rowData: r
|
|
1892
2187
|
};
|
|
1893
|
-
return this._commandService.syncExecuteCommand(
|
|
2188
|
+
return this._commandService.syncExecuteCommand(ue.id, o), this;
|
|
1894
2189
|
}
|
|
1895
2190
|
// #region Column
|
|
1896
2191
|
/**
|
|
@@ -1925,11 +2220,11 @@ let g = class extends X {
|
|
|
1925
2220
|
* @returns This sheet, for chaining.
|
|
1926
2221
|
*/
|
|
1927
2222
|
insertColumnsAfter(e, t) {
|
|
1928
|
-
const n = this._workbook.getUnitId(),
|
|
1929
|
-
return this._commandService.syncExecuteCommand(
|
|
2223
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.RIGHT, i = 0, a = this._worksheet.getRowCount() - 1, h = e + 1, c = e + t, d = W(this._worksheet, i, a, h, c, !1, e);
|
|
2224
|
+
return this._commandService.syncExecuteCommand(we.id, {
|
|
1930
2225
|
unitId: n,
|
|
1931
|
-
subUnitId:
|
|
1932
|
-
direction:
|
|
2226
|
+
subUnitId: r,
|
|
2227
|
+
direction: o,
|
|
1933
2228
|
range: {
|
|
1934
2229
|
startRow: i,
|
|
1935
2230
|
endRow: a,
|
|
@@ -1946,11 +2241,11 @@ let g = class extends X {
|
|
|
1946
2241
|
* @returns This sheet, for chaining.
|
|
1947
2242
|
*/
|
|
1948
2243
|
insertColumnsBefore(e, t) {
|
|
1949
|
-
const n = this._workbook.getUnitId(),
|
|
1950
|
-
return this._commandService.syncExecuteCommand(
|
|
2244
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.LEFT, i = 0, a = this._worksheet.getRowCount() - 1, h = e, c = e + t - 1, d = W(this._worksheet, i, a, h, c, !1, e - 1);
|
|
2245
|
+
return this._commandService.syncExecuteCommand(we.id, {
|
|
1951
2246
|
unitId: n,
|
|
1952
|
-
subUnitId:
|
|
1953
|
-
direction:
|
|
2247
|
+
subUnitId: r,
|
|
2248
|
+
direction: o,
|
|
1954
2249
|
range: {
|
|
1955
2250
|
startRow: i,
|
|
1956
2251
|
endRow: a,
|
|
@@ -1981,7 +2276,7 @@ let g = class extends X {
|
|
|
1981
2276
|
startColumn: e,
|
|
1982
2277
|
endColumn: e + t - 1
|
|
1983
2278
|
};
|
|
1984
|
-
return this._commandService.syncExecuteCommand(
|
|
2279
|
+
return this._commandService.syncExecuteCommand(wt.id, {
|
|
1985
2280
|
range: n,
|
|
1986
2281
|
unitId: this._workbook.getUnitId(),
|
|
1987
2282
|
subUnitId: this._worksheet.getSheetId()
|
|
@@ -1994,16 +2289,16 @@ let g = class extends X {
|
|
|
1994
2289
|
* @returns This sheet, for chaining.
|
|
1995
2290
|
*/
|
|
1996
2291
|
moveColumns(e, t) {
|
|
1997
|
-
const n = this._workbook.getUnitId(),
|
|
2292
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = K(e.getRange(), this._worksheet), i = o, a = {
|
|
1998
2293
|
startRow: 0,
|
|
1999
2294
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2000
2295
|
startColumn: t,
|
|
2001
2296
|
endColumn: t
|
|
2002
2297
|
};
|
|
2003
|
-
return this._commandService.syncExecuteCommand(
|
|
2298
|
+
return this._commandService.syncExecuteCommand(kt.id, {
|
|
2004
2299
|
unitId: n,
|
|
2005
|
-
subUnitId:
|
|
2006
|
-
range:
|
|
2300
|
+
subUnitId: r,
|
|
2301
|
+
range: o,
|
|
2007
2302
|
fromRange: i,
|
|
2008
2303
|
toRange: a
|
|
2009
2304
|
}), this;
|
|
@@ -2014,11 +2309,11 @@ let g = class extends X {
|
|
|
2014
2309
|
* @returns This sheet, for chaining.
|
|
2015
2310
|
*/
|
|
2016
2311
|
hideColumn(e) {
|
|
2017
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2018
|
-
return this._commandService.syncExecuteCommand(
|
|
2312
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = K(e.getRange(), this._worksheet);
|
|
2313
|
+
return this._commandService.syncExecuteCommand(ke.id, {
|
|
2019
2314
|
unitId: t,
|
|
2020
2315
|
subUnitId: n,
|
|
2021
|
-
ranges: [
|
|
2316
|
+
ranges: [r]
|
|
2022
2317
|
}), this;
|
|
2023
2318
|
}
|
|
2024
2319
|
/**
|
|
@@ -2028,50 +2323,50 @@ let g = class extends X {
|
|
|
2028
2323
|
* @returns This sheet, for chaining.
|
|
2029
2324
|
*/
|
|
2030
2325
|
hideColumns(e, t = 1) {
|
|
2031
|
-
const n = this._workbook.getUnitId(),
|
|
2326
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
2032
2327
|
startRow: 0,
|
|
2033
2328
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2034
2329
|
startColumn: e,
|
|
2035
2330
|
endColumn: e + t - 1,
|
|
2036
2331
|
rangeType: _.COLUMN
|
|
2037
2332
|
};
|
|
2038
|
-
return this._commandService.syncExecuteCommand(
|
|
2333
|
+
return this._commandService.syncExecuteCommand(ke.id, {
|
|
2039
2334
|
unitId: n,
|
|
2040
|
-
subUnitId:
|
|
2041
|
-
ranges: [
|
|
2335
|
+
subUnitId: r,
|
|
2336
|
+
ranges: [o]
|
|
2042
2337
|
}), this;
|
|
2043
2338
|
}
|
|
2044
2339
|
/**
|
|
2045
|
-
*
|
|
2340
|
+
* Show the column in the given range.
|
|
2046
2341
|
* @param column The range to unhide, if hidden.
|
|
2047
2342
|
* @returns This sheet, for chaining.
|
|
2048
2343
|
*/
|
|
2049
2344
|
unhideColumn(e) {
|
|
2050
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2051
|
-
return this._commandService.syncExecuteCommand(
|
|
2345
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = K(e.getRange(), this._worksheet);
|
|
2346
|
+
return this._commandService.syncExecuteCommand(Se.id, {
|
|
2052
2347
|
unitId: t,
|
|
2053
2348
|
subUnitId: n,
|
|
2054
|
-
ranges: [
|
|
2349
|
+
ranges: [r]
|
|
2055
2350
|
}), this;
|
|
2056
2351
|
}
|
|
2057
2352
|
/**
|
|
2058
|
-
*
|
|
2353
|
+
* Show one or more consecutive columns starting at the given index. Use 0-index for this method.
|
|
2059
2354
|
* @param columnIndex The starting index of the columns to unhide.
|
|
2060
2355
|
* @param numColumns The number of columns to unhide.
|
|
2061
2356
|
* @returns This sheet, for chaining.
|
|
2062
2357
|
*/
|
|
2063
2358
|
showColumns(e, t = 1) {
|
|
2064
|
-
const n = this._workbook.getUnitId(),
|
|
2359
|
+
const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
|
|
2065
2360
|
startRow: 0,
|
|
2066
2361
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2067
2362
|
startColumn: e,
|
|
2068
2363
|
endColumn: e + t - 1,
|
|
2069
2364
|
rangeType: _.COLUMN
|
|
2070
2365
|
};
|
|
2071
|
-
return this._commandService.syncExecuteCommand(
|
|
2366
|
+
return this._commandService.syncExecuteCommand(Se.id, {
|
|
2072
2367
|
unitId: n,
|
|
2073
|
-
subUnitId:
|
|
2074
|
-
ranges: [
|
|
2368
|
+
subUnitId: r,
|
|
2369
|
+
ranges: [o]
|
|
2075
2370
|
}), this;
|
|
2076
2371
|
}
|
|
2077
2372
|
/**
|
|
@@ -2091,7 +2386,7 @@ let g = class extends X {
|
|
|
2091
2386
|
* @returns This sheet, for chaining.
|
|
2092
2387
|
*/
|
|
2093
2388
|
setColumnWidths(e, t, n) {
|
|
2094
|
-
const
|
|
2389
|
+
const r = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = [
|
|
2095
2390
|
{
|
|
2096
2391
|
startColumn: e,
|
|
2097
2392
|
endColumn: e + t - 1,
|
|
@@ -2099,9 +2394,9 @@ let g = class extends X {
|
|
|
2099
2394
|
endRow: this._worksheet.getRowCount() - 1
|
|
2100
2395
|
}
|
|
2101
2396
|
];
|
|
2102
|
-
return this._commandService.syncExecuteCommand(
|
|
2103
|
-
unitId:
|
|
2104
|
-
subUnitId:
|
|
2397
|
+
return this._commandService.syncExecuteCommand(St.id, {
|
|
2398
|
+
unitId: r,
|
|
2399
|
+
subUnitId: o,
|
|
2105
2400
|
ranges: i,
|
|
2106
2401
|
value: n
|
|
2107
2402
|
}), this;
|
|
@@ -2113,17 +2408,17 @@ let g = class extends X {
|
|
|
2113
2408
|
* @returns This sheet, for chaining.
|
|
2114
2409
|
*/
|
|
2115
2410
|
setColumnCustom(e) {
|
|
2116
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(),
|
|
2411
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = {};
|
|
2117
2412
|
for (const [i, a] of Object.entries(e))
|
|
2118
|
-
|
|
2413
|
+
r[Number(i)] = {
|
|
2119
2414
|
custom: a
|
|
2120
2415
|
};
|
|
2121
|
-
const
|
|
2416
|
+
const o = {
|
|
2122
2417
|
unitId: t,
|
|
2123
2418
|
subUnitId: n,
|
|
2124
|
-
columnData:
|
|
2419
|
+
columnData: r
|
|
2125
2420
|
};
|
|
2126
|
-
return this._commandService.syncExecuteCommand(
|
|
2421
|
+
return this._commandService.syncExecuteCommand(de.id, o), this;
|
|
2127
2422
|
}
|
|
2128
2423
|
// #region merge cells
|
|
2129
2424
|
/**
|
|
@@ -2131,7 +2426,7 @@ let g = class extends X {
|
|
|
2131
2426
|
* @returns all merged cells
|
|
2132
2427
|
*/
|
|
2133
2428
|
getMergedRanges() {
|
|
2134
|
-
return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(
|
|
2429
|
+
return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(w, this._workbook, this._worksheet, t));
|
|
2135
2430
|
}
|
|
2136
2431
|
/**
|
|
2137
2432
|
* Get the merged cell data of the specified row and column.
|
|
@@ -2140,9 +2435,9 @@ let g = class extends X {
|
|
|
2140
2435
|
* @returns {FRange|undefined} The merged cell data, or undefined if the cell is not merged.
|
|
2141
2436
|
*/
|
|
2142
2437
|
getCellMergeData(e, t) {
|
|
2143
|
-
const
|
|
2144
|
-
if (
|
|
2145
|
-
return this._injector.createInstance(
|
|
2438
|
+
const r = this._worksheet.getMergedCell(e, t);
|
|
2439
|
+
if (r)
|
|
2440
|
+
return this._injector.createInstance(w, this._workbook, this._worksheet, r);
|
|
2146
2441
|
}
|
|
2147
2442
|
// #endregion
|
|
2148
2443
|
/**
|
|
@@ -2154,24 +2449,24 @@ let g = class extends X {
|
|
|
2154
2449
|
}
|
|
2155
2450
|
/**
|
|
2156
2451
|
* Sets the active selection region for this sheet.
|
|
2157
|
-
* @param range The range to set as the active selection.
|
|
2452
|
+
* @param {FRange} range The range to set as the active selection.
|
|
2453
|
+
* @returns {FWorksheet} This sheet, for chaining.
|
|
2158
2454
|
*/
|
|
2159
2455
|
setActiveRange(e) {
|
|
2160
2456
|
const { unitId: t, sheetId: n } = e.getRange();
|
|
2161
2457
|
if (t !== this._workbook.getUnitId() || n !== this._worksheet.getSheetId())
|
|
2162
2458
|
throw new Error("Specified range must be part of the sheet.");
|
|
2163
|
-
this._fWorkbook.setActiveRange(e);
|
|
2459
|
+
return this._fWorkbook.setActiveRange(e), this;
|
|
2164
2460
|
}
|
|
2165
2461
|
/**
|
|
2166
2462
|
* Sets the frozen state of the current sheet.
|
|
2167
2463
|
* @param freeze - the scrolling viewport start range and count of freezed rows and columns.
|
|
2168
2464
|
* that means if you want to freeze the first 3 rows and 2 columns, you should set freeze as { startRow: 3, startColumn: 2, xSplit: 2, ySplit: 3 }
|
|
2169
|
-
*
|
|
2170
2465
|
* @deprecated use `setFrozenRows` and `setFrozenColumns` instead.
|
|
2171
2466
|
* @returns True if the command was successful, false otherwise.
|
|
2172
2467
|
*/
|
|
2173
2468
|
setFreeze(e) {
|
|
2174
|
-
return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(
|
|
2469
|
+
return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(H.id, {
|
|
2175
2470
|
...e,
|
|
2176
2471
|
unitId: this._workbook.getUnitId(),
|
|
2177
2472
|
subUnitId: this.getSheetId()
|
|
@@ -2182,7 +2477,7 @@ let g = class extends X {
|
|
|
2182
2477
|
* @returns True if the command was successful, false otherwise.
|
|
2183
2478
|
*/
|
|
2184
2479
|
cancelFreeze() {
|
|
2185
|
-
return this._commandService.syncExecuteCommand(
|
|
2480
|
+
return this._commandService.syncExecuteCommand(Ct.id, {
|
|
2186
2481
|
unitId: this._workbook.getUnitId(),
|
|
2187
2482
|
subUnitId: this.getSheetId()
|
|
2188
2483
|
}), this;
|
|
@@ -2190,7 +2485,6 @@ let g = class extends X {
|
|
|
2190
2485
|
/**
|
|
2191
2486
|
* Get the freeze state of the current sheet.
|
|
2192
2487
|
* @returns The freeze state of the current sheet.
|
|
2193
|
-
*
|
|
2194
2488
|
* @deprecated use `getRowFreezeStatus` and `getColumnFreezeStatus` instead.
|
|
2195
2489
|
*/
|
|
2196
2490
|
getFreeze() {
|
|
@@ -2206,10 +2500,10 @@ let g = class extends X {
|
|
|
2206
2500
|
xSplit: n
|
|
2207
2501
|
});
|
|
2208
2502
|
} else if (arguments.length === 2) {
|
|
2209
|
-
let [n = 0,
|
|
2210
|
-
n >
|
|
2211
|
-
startColumn:
|
|
2212
|
-
xSplit:
|
|
2503
|
+
let [n = 0, r = 0] = e;
|
|
2504
|
+
n > r && ([n, r] = [r, n]), this._commandService.syncExecuteCommand(H.id, {
|
|
2505
|
+
startColumn: r + 1,
|
|
2506
|
+
xSplit: r - n + 1,
|
|
2213
2507
|
startRow: t.startRow,
|
|
2214
2508
|
ySplit: t.ySplit,
|
|
2215
2509
|
unitId: this._workbook.getUnitId(),
|
|
@@ -2228,10 +2522,10 @@ let g = class extends X {
|
|
|
2228
2522
|
ySplit: n
|
|
2229
2523
|
});
|
|
2230
2524
|
} else if (arguments.length === 2) {
|
|
2231
|
-
let [n = 0,
|
|
2232
|
-
n >
|
|
2233
|
-
startRow:
|
|
2234
|
-
ySplit:
|
|
2525
|
+
let [n = 0, r = 0] = e;
|
|
2526
|
+
n > r && ([n, r] = [r, n]), this._commandService.syncExecuteCommand(H.id, {
|
|
2527
|
+
startRow: r + 1,
|
|
2528
|
+
ySplit: r - n + 1,
|
|
2235
2529
|
startColumn: t.startColumn,
|
|
2236
2530
|
xSplit: t.xSplit,
|
|
2237
2531
|
unitId: this._workbook.getUnitId(),
|
|
@@ -2242,8 +2536,7 @@ let g = class extends X {
|
|
|
2242
2536
|
}
|
|
2243
2537
|
/**
|
|
2244
2538
|
* Get the number of frozen columns.
|
|
2245
|
-
* @returns The number of frozen columns.
|
|
2246
|
-
* Returns 0 if no columns are frozen.
|
|
2539
|
+
* @returns The number of frozen columns, returns 0 if no columns are frozen.
|
|
2247
2540
|
*/
|
|
2248
2541
|
getFrozenColumns() {
|
|
2249
2542
|
const e = this.getFreeze();
|
|
@@ -2251,8 +2544,7 @@ let g = class extends X {
|
|
|
2251
2544
|
}
|
|
2252
2545
|
/**
|
|
2253
2546
|
* Get the number of frozen rows.
|
|
2254
|
-
* @returns The number of frozen rows.
|
|
2255
|
-
* Returns 0 if no rows are frozen.
|
|
2547
|
+
* @returns The number of frozen rows. returns 0 if no rows are frozen.
|
|
2256
2548
|
*/
|
|
2257
2549
|
getFrozenRows() {
|
|
2258
2550
|
const e = this.getFreeze();
|
|
@@ -2260,6 +2552,7 @@ let g = class extends X {
|
|
|
2260
2552
|
}
|
|
2261
2553
|
/**
|
|
2262
2554
|
* Get freezed rows.
|
|
2555
|
+
* @returns {IRowRange} The range of the frozen rows.
|
|
2263
2556
|
*/
|
|
2264
2557
|
getFrozenRowRange() {
|
|
2265
2558
|
const e = this._worksheet.getFreeze();
|
|
@@ -2270,6 +2563,7 @@ let g = class extends X {
|
|
|
2270
2563
|
}
|
|
2271
2564
|
/**
|
|
2272
2565
|
* Get freezed columns
|
|
2566
|
+
* @returns {IColumnRange} The range of the frozen columns.
|
|
2273
2567
|
*/
|
|
2274
2568
|
getFrozenColumnRange() {
|
|
2275
2569
|
const e = this._worksheet.getFreeze();
|
|
@@ -2292,11 +2586,12 @@ let g = class extends X {
|
|
|
2292
2586
|
* ```
|
|
2293
2587
|
*/
|
|
2294
2588
|
hasHiddenGridLines() {
|
|
2295
|
-
return this._worksheet.getConfig().showGridlines ===
|
|
2589
|
+
return this._worksheet.getConfig().showGridlines === m.FALSE;
|
|
2296
2590
|
}
|
|
2297
2591
|
/**
|
|
2298
2592
|
* Hides or reveals the sheet gridlines.
|
|
2299
2593
|
* @param {boolean} hidden If `true`, hide gridlines in this sheet; otherwise show the gridlines.
|
|
2594
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2300
2595
|
* @example
|
|
2301
2596
|
* ``` ts
|
|
2302
2597
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -2306,10 +2601,10 @@ let g = class extends X {
|
|
|
2306
2601
|
* ```
|
|
2307
2602
|
*/
|
|
2308
2603
|
setHiddenGridlines(e) {
|
|
2309
|
-
return this._commandService.executeCommand(
|
|
2604
|
+
return this._commandService.executeCommand(It.id, {
|
|
2310
2605
|
unitId: this._workbook.getUnitId(),
|
|
2311
2606
|
subUnitId: this._worksheet.getSheetId(),
|
|
2312
|
-
showGridlines: e ?
|
|
2607
|
+
showGridlines: e ? m.FALSE : m.TRUE
|
|
2313
2608
|
}), this;
|
|
2314
2609
|
}
|
|
2315
2610
|
/**
|
|
@@ -2325,7 +2620,7 @@ let g = class extends X {
|
|
|
2325
2620
|
* ```
|
|
2326
2621
|
*/
|
|
2327
2622
|
setGridLinesColor(e) {
|
|
2328
|
-
return this._commandService.syncExecuteCommand(
|
|
2623
|
+
return this._commandService.syncExecuteCommand(ft.id, {
|
|
2329
2624
|
unitId: this._workbook.getUnitId(),
|
|
2330
2625
|
subUnitId: this._worksheet.getSheetId(),
|
|
2331
2626
|
color: e
|
|
@@ -2351,7 +2646,7 @@ let g = class extends X {
|
|
|
2351
2646
|
* ```
|
|
2352
2647
|
*/
|
|
2353
2648
|
setTabColor(e) {
|
|
2354
|
-
return this._commandService.executeCommand(
|
|
2649
|
+
return this._commandService.executeCommand(vt.id, {
|
|
2355
2650
|
unitId: this._workbook.getUnitId(),
|
|
2356
2651
|
subUnitId: this._worksheet.getSheetId(),
|
|
2357
2652
|
color: e
|
|
@@ -2390,9 +2685,9 @@ let g = class extends X {
|
|
|
2390
2685
|
*/
|
|
2391
2686
|
onCellDataChange(e) {
|
|
2392
2687
|
return this._injector.get(l).onCommandExecuted((n) => {
|
|
2393
|
-
if (n.id ===
|
|
2394
|
-
const
|
|
2395
|
-
|
|
2688
|
+
if (n.id === Ce.id) {
|
|
2689
|
+
const r = n.params;
|
|
2690
|
+
r.unitId === this._workbook.getUnitId() && r.subUnitId === this._worksheet.getSheetId() && r.cellValue && e(new A(r.cellValue));
|
|
2396
2691
|
}
|
|
2397
2692
|
});
|
|
2398
2693
|
}
|
|
@@ -2414,27 +2709,28 @@ let g = class extends X {
|
|
|
2414
2709
|
*/
|
|
2415
2710
|
onBeforeCellDataChange(e) {
|
|
2416
2711
|
return this._injector.get(l).beforeCommandExecuted((n) => {
|
|
2417
|
-
if (n.id ===
|
|
2418
|
-
const
|
|
2419
|
-
|
|
2712
|
+
if (n.id === Ce.id) {
|
|
2713
|
+
const r = n.params;
|
|
2714
|
+
r.unitId === this._workbook.getUnitId() && r.subUnitId === this._worksheet.getSheetId() && r.cellValue && e(new A(r.cellValue));
|
|
2420
2715
|
}
|
|
2421
2716
|
});
|
|
2422
2717
|
}
|
|
2423
2718
|
/**
|
|
2424
2719
|
* Hides this sheet. Has no effect if the sheet is already hidden. If this method is called on the only visible sheet, it throws an exception.
|
|
2720
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
2425
2721
|
* @example
|
|
2426
2722
|
* ```ts
|
|
2427
2723
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
2428
2724
|
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
2429
2725
|
* // hide the active sheet
|
|
2430
2726
|
* fWorkSheet.hideSheet();
|
|
2431
|
-
*
|
|
2727
|
+
* ```
|
|
2432
2728
|
*/
|
|
2433
2729
|
hideSheet() {
|
|
2434
2730
|
const e = this._injector.get(l);
|
|
2435
|
-
if (this._workbook.getSheets().filter((
|
|
2731
|
+
if (this._workbook.getSheets().filter((o) => o.isSheetHidden() !== m.TRUE).length <= 1)
|
|
2436
2732
|
throw new Error("Cannot hide the only visible sheet");
|
|
2437
|
-
return e.syncExecuteCommand(
|
|
2733
|
+
return e.syncExecuteCommand(Rt.id, {
|
|
2438
2734
|
unitId: this._workbook.getUnitId(),
|
|
2439
2735
|
subUnitId: this._worksheet.getSheetId()
|
|
2440
2736
|
}), this;
|
|
@@ -2451,7 +2747,7 @@ let g = class extends X {
|
|
|
2451
2747
|
* ```
|
|
2452
2748
|
*/
|
|
2453
2749
|
showSheet() {
|
|
2454
|
-
return this._injector.get(l).syncExecuteCommand(
|
|
2750
|
+
return this._injector.get(l).syncExecuteCommand(bt.id, {
|
|
2455
2751
|
unitId: this._workbook.getUnitId(),
|
|
2456
2752
|
subUnitId: this._worksheet.getSheetId()
|
|
2457
2753
|
}), this;
|
|
@@ -2461,7 +2757,7 @@ let g = class extends X {
|
|
|
2461
2757
|
* @returns {boolean} True if the sheet is hidden; otherwise, false.
|
|
2462
2758
|
*/
|
|
2463
2759
|
isSheetHidden() {
|
|
2464
|
-
return this._worksheet.isSheetHidden() ===
|
|
2760
|
+
return this._worksheet.isSheetHidden() === m.TRUE;
|
|
2465
2761
|
}
|
|
2466
2762
|
/**
|
|
2467
2763
|
* Sets the sheet name.
|
|
@@ -2476,7 +2772,7 @@ let g = class extends X {
|
|
|
2476
2772
|
* ```
|
|
2477
2773
|
*/
|
|
2478
2774
|
setName(e) {
|
|
2479
|
-
return this._commandService.syncExecuteCommand(
|
|
2775
|
+
return this._commandService.syncExecuteCommand(pt.id, {
|
|
2480
2776
|
unitId: this._workbook.getUnitId(),
|
|
2481
2777
|
subUnitId: this._worksheet.getSheetId(),
|
|
2482
2778
|
name: e
|
|
@@ -2521,20 +2817,17 @@ let g = class extends X {
|
|
|
2521
2817
|
* ```
|
|
2522
2818
|
*/
|
|
2523
2819
|
clear(e) {
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
if (e && e.formatOnly && !e.contentsOnly)
|
|
2527
|
-
return this.clearFormats();
|
|
2528
|
-
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = this._injector.get(l), r = {
|
|
2820
|
+
e && e.contentsOnly && !e.formatOnly && this.clearContents(), e && e.formatOnly && !e.contentsOnly && this.clearFormats();
|
|
2821
|
+
const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = this._injector.get(l), o = {
|
|
2529
2822
|
startRow: 0,
|
|
2530
2823
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2531
2824
|
startColumn: 0,
|
|
2532
2825
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2533
2826
|
};
|
|
2534
|
-
return
|
|
2827
|
+
return r.syncExecuteCommand(yt.id, {
|
|
2535
2828
|
unitId: t,
|
|
2536
2829
|
subUnitId: n,
|
|
2537
|
-
ranges: [
|
|
2830
|
+
ranges: [o],
|
|
2538
2831
|
options: e
|
|
2539
2832
|
}), this;
|
|
2540
2833
|
}
|
|
@@ -2550,16 +2843,16 @@ let g = class extends X {
|
|
|
2550
2843
|
* ```
|
|
2551
2844
|
*/
|
|
2552
2845
|
clearContents() {
|
|
2553
|
-
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l),
|
|
2846
|
+
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), r = {
|
|
2554
2847
|
startRow: 0,
|
|
2555
2848
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2556
2849
|
startColumn: 0,
|
|
2557
2850
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2558
2851
|
};
|
|
2559
|
-
return n.syncExecuteCommand(
|
|
2852
|
+
return n.syncExecuteCommand(Ut.id, {
|
|
2560
2853
|
unitId: e,
|
|
2561
2854
|
subUnitId: t,
|
|
2562
|
-
ranges: [
|
|
2855
|
+
ranges: [r]
|
|
2563
2856
|
}), this;
|
|
2564
2857
|
}
|
|
2565
2858
|
/**
|
|
@@ -2574,16 +2867,16 @@ let g = class extends X {
|
|
|
2574
2867
|
* ```
|
|
2575
2868
|
*/
|
|
2576
2869
|
clearFormats() {
|
|
2577
|
-
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l),
|
|
2870
|
+
const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), r = {
|
|
2578
2871
|
startRow: 0,
|
|
2579
2872
|
endRow: this._worksheet.getRowCount() - 1,
|
|
2580
2873
|
startColumn: 0,
|
|
2581
2874
|
endColumn: this._worksheet.getColumnCount() - 1
|
|
2582
2875
|
};
|
|
2583
|
-
return n.syncExecuteCommand(
|
|
2876
|
+
return n.syncExecuteCommand(Et.id, {
|
|
2584
2877
|
unitId: e,
|
|
2585
2878
|
subUnitId: t,
|
|
2586
|
-
ranges: [
|
|
2879
|
+
ranges: [r]
|
|
2587
2880
|
}), this;
|
|
2588
2881
|
}
|
|
2589
2882
|
/**
|
|
@@ -2619,6 +2912,7 @@ let g = class extends X {
|
|
|
2619
2912
|
return this._worksheet.getLastColumnWithContent();
|
|
2620
2913
|
}
|
|
2621
2914
|
/**
|
|
2915
|
+
* @deprecated use getLastColumn instead.
|
|
2622
2916
|
* Returns the position of the last column that has content. Same as getLastColumns.
|
|
2623
2917
|
* @returns {number} the last column of the sheet that contains content.
|
|
2624
2918
|
* @example
|
|
@@ -2633,6 +2927,7 @@ let g = class extends X {
|
|
|
2633
2927
|
return this._worksheet.getLastColumnWithContent();
|
|
2634
2928
|
}
|
|
2635
2929
|
/**
|
|
2930
|
+
* @deprecated use getLastRow instead.
|
|
2636
2931
|
* Returns the position of the last row that has content.
|
|
2637
2932
|
* @returns {number} the last row of the sheet that contains content.
|
|
2638
2933
|
* @example
|
|
@@ -2688,8 +2983,8 @@ let g = class extends X {
|
|
|
2688
2983
|
* ```
|
|
2689
2984
|
*/
|
|
2690
2985
|
insertDefinedName(e, t) {
|
|
2691
|
-
const
|
|
2692
|
-
|
|
2986
|
+
const r = this._injector.createInstance(L).setName(e).setRef(t).build();
|
|
2987
|
+
r.localSheetId = this.getSheetId(), this._fWorkbook.insertDefinedNameBuilder(r);
|
|
2693
2988
|
}
|
|
2694
2989
|
/**
|
|
2695
2990
|
* Get all the defined names in the worksheet.
|
|
@@ -2705,23 +3000,159 @@ let g = class extends X {
|
|
|
2705
3000
|
getDefinedNames() {
|
|
2706
3001
|
return this._fWorkbook.getDefinedNames().filter((t) => t.getLocalSheetId() === this.getSheetId());
|
|
2707
3002
|
}
|
|
3003
|
+
/**
|
|
3004
|
+
* Set custom metadata of worksheet
|
|
3005
|
+
* @param {CustomData | undefined} custom custom metadata
|
|
3006
|
+
* @example
|
|
3007
|
+
* ```ts
|
|
3008
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3009
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3010
|
+
* fWorkSheet.setCustomMetadata({ key: 'value' });
|
|
3011
|
+
* ```
|
|
3012
|
+
*/
|
|
3013
|
+
setCustomMetadata(e) {
|
|
3014
|
+
return this._worksheet.setCustomMetadata(e), this;
|
|
3015
|
+
}
|
|
3016
|
+
/**
|
|
3017
|
+
* Set custom metadata of row
|
|
3018
|
+
* @param {number} index row index
|
|
3019
|
+
* @param {CustomData | undefined} custom custom metadata
|
|
3020
|
+
* @example
|
|
3021
|
+
* ```ts
|
|
3022
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3023
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3024
|
+
* fWorkSheet.setRowCustomMetadata(0, { key: 'value' });
|
|
3025
|
+
* ```
|
|
3026
|
+
*/
|
|
3027
|
+
setRowCustomMetadata(e, t) {
|
|
3028
|
+
return this._worksheet.getRowManager().setCustomMetadata(e, t), this;
|
|
3029
|
+
}
|
|
3030
|
+
/**
|
|
3031
|
+
* Set custom metadata of column
|
|
3032
|
+
* @param {number} index column index
|
|
3033
|
+
* @param {CustomData | undefined} custom custom metadata
|
|
3034
|
+
* @example
|
|
3035
|
+
* ```ts
|
|
3036
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3037
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3038
|
+
* fWorkSheet.setColumnCustomMetadata(0, { key: 'value' });
|
|
3039
|
+
* ```
|
|
3040
|
+
*/
|
|
3041
|
+
setColumnCustomMetadata(e, t) {
|
|
3042
|
+
return this._worksheet.getColumnManager().setCustomMetadata(e, t), this;
|
|
3043
|
+
}
|
|
3044
|
+
/**
|
|
3045
|
+
* Get custom metadata of row
|
|
3046
|
+
* @param {number} index row index
|
|
3047
|
+
* @returns {CustomData | undefined} custom metadata
|
|
3048
|
+
* @example
|
|
3049
|
+
* ```ts
|
|
3050
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3051
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3052
|
+
* const custom = fWorkSheet.getRowCustomMetadata(0);
|
|
3053
|
+
* ```
|
|
3054
|
+
*/
|
|
3055
|
+
getRowCustomMetadata(e) {
|
|
3056
|
+
return this._worksheet.getRowManager().getCustomMetadata(e);
|
|
3057
|
+
}
|
|
3058
|
+
/**
|
|
3059
|
+
* Get custom metadata of column
|
|
3060
|
+
* @param {number} index column index
|
|
3061
|
+
* @returns {CustomData | undefined} custom metadata
|
|
3062
|
+
* @example
|
|
3063
|
+
* ```ts
|
|
3064
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3065
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
3066
|
+
* const custom = fWorkSheet.getColumnCustomMetadata(0);
|
|
3067
|
+
* ```
|
|
3068
|
+
*/
|
|
3069
|
+
getColumnCustomMetadata(e) {
|
|
3070
|
+
return this._worksheet.getColumnManager().getCustomMetadata(e);
|
|
3071
|
+
}
|
|
3072
|
+
/**
|
|
3073
|
+
* Get all merged cells in the current worksheet
|
|
3074
|
+
* @returns {FRange[]} All the merged cells in the worksheet
|
|
3075
|
+
* @example
|
|
3076
|
+
* ```ts
|
|
3077
|
+
* const workbook = univerAPI.getActiveWorkbook();
|
|
3078
|
+
* const worksheet = workbook.getActiveSheet();
|
|
3079
|
+
* const rangeFirst = worksheet.getRange(0, 0, 2, 2);
|
|
3080
|
+
* const mergeFirst = rangeFirst.merge();
|
|
3081
|
+
* const rangeSecond = worksheet.getRange(5, 0, 2, 2);
|
|
3082
|
+
* const mergeSecond = rangeSecond.merge();
|
|
3083
|
+
* const mergeData = worksheet.getMergeData();
|
|
3084
|
+
* console.log('debugger', mergeData);
|
|
3085
|
+
* ```
|
|
3086
|
+
*/
|
|
3087
|
+
getMergeData() {
|
|
3088
|
+
return this._worksheet.getMergeData().map((e) => this._injector.createInstance(w, this._workbook, this._worksheet, e));
|
|
3089
|
+
}
|
|
2708
3090
|
};
|
|
2709
|
-
g =
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
3091
|
+
g = sn([
|
|
3092
|
+
T(3, u(b)),
|
|
3093
|
+
T(4, u(We)),
|
|
3094
|
+
T(5, u(pe)),
|
|
3095
|
+
T(6, l)
|
|
2714
3096
|
], g);
|
|
2715
|
-
var
|
|
2716
|
-
for (var
|
|
2717
|
-
(i = o
|
|
2718
|
-
return n &&
|
|
2719
|
-
},
|
|
2720
|
-
let I = class extends
|
|
2721
|
-
constructor(e, t, n,
|
|
3097
|
+
var rn = Object.defineProperty, on = Object.getOwnPropertyDescriptor, an = (s, e, t, n) => {
|
|
3098
|
+
for (var r = n > 1 ? void 0 : n ? on(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
3099
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
3100
|
+
return n && r && rn(e, t, r), r;
|
|
3101
|
+
}, C = (s, e) => (t, n) => e(t, n, s);
|
|
3102
|
+
let I = class extends ne {
|
|
3103
|
+
constructor(e, t, n, r, o, i, a, h, c, d) {
|
|
2722
3104
|
super(t);
|
|
2723
|
-
|
|
2724
|
-
this
|
|
3105
|
+
k(this, "id");
|
|
3106
|
+
k(this, "_eventRegistry", /* @__PURE__ */ new Map());
|
|
3107
|
+
this._workbook = e, this._injector = t, this._resourceLoaderService = n, this._selectionManagerService = r, this._univerInstanceService = o, this._commandService = i, this._permissionService = a, this._logService = h, this._localeService = c, this._definedNamesService = d, this.id = this._workbook.getUnitId();
|
|
3108
|
+
}
|
|
3109
|
+
getWorkbook() {
|
|
3110
|
+
return this._workbook;
|
|
3111
|
+
}
|
|
3112
|
+
_ensureEventRegistry(e) {
|
|
3113
|
+
return this._eventRegistry.has(e) || this._eventRegistry.set(e, new ye()), this._eventRegistry.get(e);
|
|
3114
|
+
}
|
|
3115
|
+
/**
|
|
3116
|
+
* Add an event listener
|
|
3117
|
+
* @param event key of event
|
|
3118
|
+
* @param callback callback when event triggered
|
|
3119
|
+
* @returns {Disposable} The Disposable instance, for remove the listener
|
|
3120
|
+
* @example
|
|
3121
|
+
* ```ts
|
|
3122
|
+
* univerAPI.addEvent(univerAPI.event.UnitCreated, (params) => {
|
|
3123
|
+
* console.log('unit created', params);
|
|
3124
|
+
* });
|
|
3125
|
+
* ```
|
|
3126
|
+
*/
|
|
3127
|
+
addEvent(e, t) {
|
|
3128
|
+
return this._ensureEventRegistry(e).add(t), this.addUIEvent(e, t), F(() => this._ensureEventRegistry(e).delete(t));
|
|
3129
|
+
}
|
|
3130
|
+
/**
|
|
3131
|
+
* Fire an event, used in internal only.
|
|
3132
|
+
* @param event {string} key of event
|
|
3133
|
+
* @param params {any} params of event
|
|
3134
|
+
* @returns {boolean} should cancel
|
|
3135
|
+
* @example
|
|
3136
|
+
* ```ts
|
|
3137
|
+
* this.fireEvent(univerAPI.event.UnitCreated, params);
|
|
3138
|
+
* ```
|
|
3139
|
+
*/
|
|
3140
|
+
fireEvent(e, t) {
|
|
3141
|
+
var n;
|
|
3142
|
+
return (n = this._eventRegistry.get(e)) == null || n.getData().forEach((r) => {
|
|
3143
|
+
r(t);
|
|
3144
|
+
}), t.cancel;
|
|
3145
|
+
}
|
|
3146
|
+
addUIEvent(e, t) {
|
|
3147
|
+
}
|
|
3148
|
+
get Enum() {
|
|
3149
|
+
return ze.get();
|
|
3150
|
+
}
|
|
3151
|
+
/**
|
|
3152
|
+
* @returns {FEventName} The event name.
|
|
3153
|
+
*/
|
|
3154
|
+
get Event() {
|
|
3155
|
+
return se.get();
|
|
2725
3156
|
}
|
|
2726
3157
|
/**
|
|
2727
3158
|
* Get the id of the workbook.
|
|
@@ -2763,8 +3194,8 @@ let I = class extends X {
|
|
|
2763
3194
|
this._workbook.setName(e);
|
|
2764
3195
|
}
|
|
2765
3196
|
/**
|
|
2766
|
-
*
|
|
2767
|
-
* @
|
|
3197
|
+
* Save workbook snapshot data, including conditional formatting, data validation, and other plugin data.
|
|
3198
|
+
* @returns {IWorkbookData} Workbook snapshot data
|
|
2768
3199
|
* @example
|
|
2769
3200
|
* ```ts
|
|
2770
3201
|
* // The code below saves the workbook snapshot data
|
|
@@ -2777,7 +3208,7 @@ let I = class extends X {
|
|
|
2777
3208
|
}
|
|
2778
3209
|
/**
|
|
2779
3210
|
* @deprecated use 'save' instead.
|
|
2780
|
-
* @
|
|
3211
|
+
* @returns {*} {IWorkbookData} Workbook snapshot data
|
|
2781
3212
|
* @memberof FWorkbook
|
|
2782
3213
|
*/
|
|
2783
3214
|
getSnapshot() {
|
|
@@ -2785,7 +3216,7 @@ let I = class extends X {
|
|
|
2785
3216
|
}
|
|
2786
3217
|
/**
|
|
2787
3218
|
* Get the active sheet of the workbook.
|
|
2788
|
-
* @returns The active sheet of the workbook
|
|
3219
|
+
* @returns {FWorksheet} The active sheet of the workbook
|
|
2789
3220
|
* @example
|
|
2790
3221
|
* ```ts
|
|
2791
3222
|
* // The code below gets the active sheet of the workbook
|
|
@@ -2799,7 +3230,7 @@ let I = class extends X {
|
|
|
2799
3230
|
}
|
|
2800
3231
|
/**
|
|
2801
3232
|
* Gets all the worksheets in this workbook
|
|
2802
|
-
* @returns An array of all the worksheets in the workbook
|
|
3233
|
+
* @returns {FWorksheet[]} An array of all the worksheets in the workbook
|
|
2803
3234
|
* @example
|
|
2804
3235
|
* ```ts
|
|
2805
3236
|
* // The code below gets all the worksheets in the workbook
|
|
@@ -2824,24 +3255,24 @@ let I = class extends X {
|
|
|
2824
3255
|
* ```
|
|
2825
3256
|
*/
|
|
2826
3257
|
create(e, t, n) {
|
|
2827
|
-
const
|
|
2828
|
-
|
|
3258
|
+
const r = $e({});
|
|
3259
|
+
r.rowCount = t, r.columnCount = n, r.name = e, r.id = e.toLowerCase().replace(/ /g, "-"), this._commandService.syncExecuteCommand(x.id, {
|
|
2829
3260
|
unitId: this.id,
|
|
2830
3261
|
index: this._workbook.getSheets().length,
|
|
2831
|
-
sheet:
|
|
2832
|
-
}), this._commandService.syncExecuteCommand(
|
|
3262
|
+
sheet: r
|
|
3263
|
+
}), this._commandService.syncExecuteCommand(G.id, {
|
|
2833
3264
|
unitId: this.id,
|
|
2834
3265
|
subUnitId: this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId()
|
|
2835
3266
|
});
|
|
2836
|
-
const
|
|
2837
|
-
if (!
|
|
3267
|
+
const o = this._workbook.getActiveSheet();
|
|
3268
|
+
if (!o)
|
|
2838
3269
|
throw new Error("No active sheet found");
|
|
2839
|
-
return this._injector.createInstance(g, this, this._workbook,
|
|
3270
|
+
return this._injector.createInstance(g, this, this._workbook, o);
|
|
2840
3271
|
}
|
|
2841
3272
|
/**
|
|
2842
3273
|
* Get a worksheet by sheet id.
|
|
2843
3274
|
* @param sheetId The id of the sheet to get.
|
|
2844
|
-
* @
|
|
3275
|
+
* @returns The worksheet with given sheet id
|
|
2845
3276
|
* @example
|
|
2846
3277
|
* ```ts
|
|
2847
3278
|
* // The code below gets a worksheet by sheet id
|
|
@@ -2881,7 +3312,7 @@ let I = class extends X {
|
|
|
2881
3312
|
* ```
|
|
2882
3313
|
*/
|
|
2883
3314
|
setActiveSheet(e) {
|
|
2884
|
-
return this._commandService.syncExecuteCommand(
|
|
3315
|
+
return this._commandService.syncExecuteCommand(G.id, {
|
|
2885
3316
|
unitId: this.id,
|
|
2886
3317
|
subUnitId: e.getSheetId()
|
|
2887
3318
|
}), e;
|
|
@@ -2903,20 +3334,21 @@ let I = class extends X {
|
|
|
2903
3334
|
* ```
|
|
2904
3335
|
*/
|
|
2905
3336
|
insertSheet(e) {
|
|
2906
|
-
e != null ? this._commandService.syncExecuteCommand(
|
|
3337
|
+
e != null ? this._commandService.syncExecuteCommand(x.id, { sheet: { name: e } }) : this._commandService.syncExecuteCommand(x.id);
|
|
2907
3338
|
const t = this.id, n = this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId();
|
|
2908
|
-
this._commandService.syncExecuteCommand(
|
|
3339
|
+
this._commandService.syncExecuteCommand(G.id, {
|
|
2909
3340
|
unitId: t,
|
|
2910
3341
|
subUnitId: n
|
|
2911
3342
|
});
|
|
2912
|
-
const
|
|
2913
|
-
if (!
|
|
3343
|
+
const r = this._workbook.getActiveSheet();
|
|
3344
|
+
if (!r)
|
|
2914
3345
|
throw new Error("No active sheet found");
|
|
2915
|
-
return this._injector.createInstance(g, this, this._workbook,
|
|
3346
|
+
return this._injector.createInstance(g, this, this._workbook, r);
|
|
2916
3347
|
}
|
|
2917
3348
|
/**
|
|
2918
3349
|
* Deletes the specified worksheet.
|
|
2919
3350
|
* @param sheet The worksheet to delete.
|
|
3351
|
+
* @returns {boolean} True if the worksheet was deleted, false otherwise.
|
|
2920
3352
|
* @example
|
|
2921
3353
|
* ```ts
|
|
2922
3354
|
* // The code below deletes the specified worksheet
|
|
@@ -2927,7 +3359,7 @@ let I = class extends X {
|
|
|
2927
3359
|
*/
|
|
2928
3360
|
deleteSheet(e) {
|
|
2929
3361
|
const t = this.id, n = e.getSheetId();
|
|
2930
|
-
return this._commandService.syncExecuteCommand(
|
|
3362
|
+
return this._commandService.syncExecuteCommand(Pt.id, {
|
|
2931
3363
|
unitId: t,
|
|
2932
3364
|
subUnitId: n
|
|
2933
3365
|
});
|
|
@@ -2935,7 +3367,7 @@ let I = class extends X {
|
|
|
2935
3367
|
// #region editing
|
|
2936
3368
|
/**
|
|
2937
3369
|
* Undo the last action.
|
|
2938
|
-
* @returns A promise that resolves to true if the undo was successful, false otherwise.
|
|
3370
|
+
* @returns {FWorkbook} A promise that resolves to true if the undo was successful, false otherwise.
|
|
2939
3371
|
* @example
|
|
2940
3372
|
* ```ts
|
|
2941
3373
|
* // The code below undoes the last action
|
|
@@ -2944,7 +3376,7 @@ let I = class extends X {
|
|
|
2944
3376
|
* ```
|
|
2945
3377
|
*/
|
|
2946
3378
|
undo() {
|
|
2947
|
-
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(
|
|
3379
|
+
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(He.id), this;
|
|
2948
3380
|
}
|
|
2949
3381
|
/**
|
|
2950
3382
|
* Redo the last undone action.
|
|
@@ -2957,7 +3389,7 @@ let I = class extends X {
|
|
|
2957
3389
|
* ```
|
|
2958
3390
|
*/
|
|
2959
3391
|
redo() {
|
|
2960
|
-
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(
|
|
3392
|
+
return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(Ge.id), this;
|
|
2961
3393
|
}
|
|
2962
3394
|
/**
|
|
2963
3395
|
* Callback for command execution.
|
|
@@ -3008,7 +3440,6 @@ let I = class extends X {
|
|
|
3008
3440
|
}
|
|
3009
3441
|
/**
|
|
3010
3442
|
* Callback for selection changes.
|
|
3011
|
-
*
|
|
3012
3443
|
* @callback onSelectionChangeCallback
|
|
3013
3444
|
* @param {IRange[]} selections The new selection.
|
|
3014
3445
|
*/
|
|
@@ -3018,46 +3449,50 @@ let I = class extends X {
|
|
|
3018
3449
|
* @returns A function to dispose the listening
|
|
3019
3450
|
*/
|
|
3020
3451
|
onSelectionChange(e) {
|
|
3021
|
-
return
|
|
3452
|
+
return F(
|
|
3022
3453
|
this._selectionManagerService.selectionMoveEnd$.subscribe((t) => {
|
|
3023
|
-
this._univerInstanceService.getCurrentUnitForType(
|
|
3454
|
+
this._univerInstanceService.getCurrentUnitForType(R.UNIVER_SHEET).getUnitId() === this.id && (t != null && t.length ? e(t.map((n) => n.range)) : e([]));
|
|
3024
3455
|
})
|
|
3025
3456
|
);
|
|
3026
3457
|
}
|
|
3027
3458
|
/**
|
|
3028
3459
|
* Used to modify the editing permissions of the workbook. When the value is false, editing is not allowed.
|
|
3029
3460
|
* @param {boolean} value editable value want to set
|
|
3461
|
+
* @returns {FWorkbook} FWorkbook instance
|
|
3030
3462
|
*/
|
|
3031
3463
|
setEditable(e) {
|
|
3032
|
-
const t = new
|
|
3033
|
-
this._permissionService.getPermissionPoint(t.id) || this._permissionService.addPermissionPoint(t), this._permissionService.updatePermissionPoint(t.id, e);
|
|
3464
|
+
const t = new Ne(this._workbook.getUnitId());
|
|
3465
|
+
return this._permissionService.getPermissionPoint(t.id) || this._permissionService.addPermissionPoint(t), this._permissionService.updatePermissionPoint(t.id, e), this;
|
|
3034
3466
|
}
|
|
3035
3467
|
/**
|
|
3036
|
-
* Sets the
|
|
3468
|
+
* Sets the selection region for active sheet.
|
|
3037
3469
|
* @param range The range to set as the active selection.
|
|
3470
|
+
* @returns {FWorkbook} FWorkbook instance
|
|
3038
3471
|
*/
|
|
3039
3472
|
setActiveRange(e) {
|
|
3040
|
-
const t = this.getActiveSheet(), n = e.getRange().sheetId || t.getSheetId(),
|
|
3041
|
-
if (!
|
|
3473
|
+
const t = this.getActiveSheet(), n = e.getRange().sheetId || t.getSheetId(), r = n ? this._workbook.getSheetBySheetId(n) : this._workbook.getActiveSheet(!0);
|
|
3474
|
+
if (!r)
|
|
3042
3475
|
throw new Error("No active sheet found");
|
|
3043
|
-
|
|
3044
|
-
const
|
|
3476
|
+
r.getSheetId() !== t.getSheetId() && this.setActiveSheet(this._injector.createInstance(g, this, this._workbook, r));
|
|
3477
|
+
const o = {
|
|
3045
3478
|
unitId: this.getId(),
|
|
3046
3479
|
subUnitId: n,
|
|
3047
|
-
selections: [e].map((i) => ({ range: i.getRange(), primary:
|
|
3480
|
+
selections: [e].map((i) => ({ range: i.getRange(), primary: Z(i.getRange(), r), style: null }))
|
|
3048
3481
|
};
|
|
3049
|
-
this._commandService.syncExecuteCommand(
|
|
3482
|
+
return this._commandService.syncExecuteCommand(De.id, o), this;
|
|
3050
3483
|
}
|
|
3051
3484
|
/**
|
|
3052
3485
|
* Returns the selected range in the active sheet, or null if there is no active range.
|
|
3053
3486
|
* @returns the active range
|
|
3054
3487
|
*/
|
|
3488
|
+
// could sheet have no active range ?
|
|
3055
3489
|
getActiveRange() {
|
|
3056
|
-
const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((
|
|
3057
|
-
return n ? this._injector.createInstance(
|
|
3490
|
+
const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((r) => !!r.primary);
|
|
3491
|
+
return n ? this._injector.createInstance(w, this._workbook, e, n.range) : null;
|
|
3058
3492
|
}
|
|
3059
3493
|
/**
|
|
3060
3494
|
* Deletes the currently active sheet.
|
|
3495
|
+
* @returns {boolean} true if the sheet was deleted, false otherwise
|
|
3061
3496
|
* @example
|
|
3062
3497
|
* ```ts
|
|
3063
3498
|
* // The code below deletes the currently active sheet and stores the new active
|
|
@@ -3082,7 +3517,7 @@ let I = class extends X {
|
|
|
3082
3517
|
* ```
|
|
3083
3518
|
*/
|
|
3084
3519
|
duplicateSheet(e) {
|
|
3085
|
-
return this._commandService.syncExecuteCommand(
|
|
3520
|
+
return this._commandService.syncExecuteCommand(xt.id, {
|
|
3086
3521
|
unitId: e.getWorkbook().getUnitId(),
|
|
3087
3522
|
subUnitId: e.getSheetId()
|
|
3088
3523
|
}), this._injector.createInstance(g, this, this._workbook, this._workbook.getActiveSheet());
|
|
@@ -3127,9 +3562,17 @@ let I = class extends X {
|
|
|
3127
3562
|
getLocale() {
|
|
3128
3563
|
return this._localeService.getCurrentLocale();
|
|
3129
3564
|
}
|
|
3565
|
+
/**
|
|
3566
|
+
* @deprecated use setSpreadsheetLocale instead.
|
|
3567
|
+
* @param {LocaleType} locale - The locale to set
|
|
3568
|
+
*/
|
|
3569
|
+
setLocale(e) {
|
|
3570
|
+
this._localeService.setLocale(e);
|
|
3571
|
+
}
|
|
3130
3572
|
/**
|
|
3131
3573
|
* Set the locale of the workbook.
|
|
3132
3574
|
* @param {LocaleType} locale The locale to set
|
|
3575
|
+
* @returns {FWorkbook} This workbook, for chaining
|
|
3133
3576
|
* @example
|
|
3134
3577
|
* ```ts
|
|
3135
3578
|
* // The code below sets the locale of the workbook
|
|
@@ -3137,8 +3580,8 @@ let I = class extends X {
|
|
|
3137
3580
|
* activeSpreadsheet.setLocale(LocaleType.EN_US);
|
|
3138
3581
|
* ```
|
|
3139
3582
|
*/
|
|
3140
|
-
|
|
3141
|
-
this._localeService.setLocale(e);
|
|
3583
|
+
setSpreadsheetLocale(e) {
|
|
3584
|
+
return this._localeService.setLocale(e), this;
|
|
3142
3585
|
}
|
|
3143
3586
|
/**
|
|
3144
3587
|
* Get the URL of the workbook.
|
|
@@ -3168,7 +3611,7 @@ let I = class extends X {
|
|
|
3168
3611
|
*/
|
|
3169
3612
|
moveSheet(e, t) {
|
|
3170
3613
|
let n = t;
|
|
3171
|
-
return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.syncExecuteCommand(
|
|
3614
|
+
return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.syncExecuteCommand(Nt.id, {
|
|
3172
3615
|
unitId: e.getWorkbook().getUnitId(),
|
|
3173
3616
|
order: n,
|
|
3174
3617
|
subUnitId: e.getSheetId()
|
|
@@ -3191,11 +3634,10 @@ let I = class extends X {
|
|
|
3191
3634
|
}
|
|
3192
3635
|
/**
|
|
3193
3636
|
* Get the PermissionInstance.
|
|
3194
|
-
*
|
|
3195
3637
|
* @returns {FPermission} - The PermissionInstance.
|
|
3196
3638
|
*/
|
|
3197
3639
|
getPermission() {
|
|
3198
|
-
return this._injector.createInstance(
|
|
3640
|
+
return this._injector.createInstance(O);
|
|
3199
3641
|
}
|
|
3200
3642
|
/**
|
|
3201
3643
|
* Get the defined name by name.
|
|
@@ -3210,7 +3652,7 @@ let I = class extends X {
|
|
|
3210
3652
|
*/
|
|
3211
3653
|
getDefinedName(e) {
|
|
3212
3654
|
const t = this._definedNamesService.getValueByName(this.id, e);
|
|
3213
|
-
return t ? this._injector.createInstance(
|
|
3655
|
+
return t ? this._injector.createInstance(j, { ...t, unitId: this.id }) : null;
|
|
3214
3656
|
}
|
|
3215
3657
|
/**
|
|
3216
3658
|
* Get all the defined names in the workbook.
|
|
@@ -3224,12 +3666,13 @@ let I = class extends X {
|
|
|
3224
3666
|
*/
|
|
3225
3667
|
getDefinedNames() {
|
|
3226
3668
|
const e = this._definedNamesService.getDefinedNameMap(this.id);
|
|
3227
|
-
return e ? Object.values(e).map((t) => this._injector.createInstance(
|
|
3669
|
+
return e ? Object.values(e).map((t) => this._injector.createInstance(j, { ...t, unitId: this.id })) : [];
|
|
3228
3670
|
}
|
|
3229
3671
|
/**
|
|
3230
3672
|
* Insert a defined name.
|
|
3231
3673
|
* @param {string} name The name of the defined name to insert
|
|
3232
3674
|
* @param {string} formulaOrRefString The formula(=sum(A2:b10)) or reference(A1) string of the defined name to insert
|
|
3675
|
+
* @returns {FWorkbook} The current FWorkbook instance
|
|
3233
3676
|
* @example
|
|
3234
3677
|
* ```ts
|
|
3235
3678
|
* // The code below inserts a defined name
|
|
@@ -3238,8 +3681,8 @@ let I = class extends X {
|
|
|
3238
3681
|
* ```
|
|
3239
3682
|
*/
|
|
3240
3683
|
insertDefinedName(e, t) {
|
|
3241
|
-
const
|
|
3242
|
-
|
|
3684
|
+
const r = this._injector.createInstance(L).setName(e).setRef(t).build();
|
|
3685
|
+
return r.localSheetId = X, this.insertDefinedNameBuilder(r), this;
|
|
3243
3686
|
}
|
|
3244
3687
|
/**
|
|
3245
3688
|
* Delete the defined name with the given name.
|
|
@@ -3257,7 +3700,7 @@ let I = class extends X {
|
|
|
3257
3700
|
return t ? (t.delete(), !0) : !1;
|
|
3258
3701
|
}
|
|
3259
3702
|
/**
|
|
3260
|
-
*
|
|
3703
|
+
* Insert a defined name by builder param.
|
|
3261
3704
|
* @param {ISetDefinedNameMutationParam} param The param to insert the defined name
|
|
3262
3705
|
* @example
|
|
3263
3706
|
* ```ts
|
|
@@ -3269,7 +3712,7 @@ let I = class extends X {
|
|
|
3269
3712
|
* ```
|
|
3270
3713
|
*/
|
|
3271
3714
|
insertDefinedNameBuilder(e) {
|
|
3272
|
-
e.unitId = this.getId(), this._commandService.syncExecuteCommand(
|
|
3715
|
+
e.unitId = this.getId(), this._commandService.syncExecuteCommand(Q.id, e);
|
|
3273
3716
|
}
|
|
3274
3717
|
/**
|
|
3275
3718
|
* Update the defined name with the given name.
|
|
@@ -3284,7 +3727,7 @@ let I = class extends X {
|
|
|
3284
3727
|
* ```
|
|
3285
3728
|
*/
|
|
3286
3729
|
updateDefinedNameBuilder(e) {
|
|
3287
|
-
this._commandService.syncExecuteCommand(
|
|
3730
|
+
this._commandService.syncExecuteCommand(Q.id, e);
|
|
3288
3731
|
}
|
|
3289
3732
|
/**
|
|
3290
3733
|
* Gets the registered range themes.
|
|
@@ -3298,10 +3741,11 @@ let I = class extends X {
|
|
|
3298
3741
|
* ```
|
|
3299
3742
|
*/
|
|
3300
3743
|
getRegisteredRangeThemes() {
|
|
3301
|
-
return this._injector.get(
|
|
3744
|
+
return this._injector.get(Me).getRegisteredRangeThemes();
|
|
3302
3745
|
}
|
|
3303
3746
|
/**
|
|
3304
3747
|
* Register a custom range theme style.
|
|
3748
|
+
* @param rangeThemeStyle
|
|
3305
3749
|
* @example
|
|
3306
3750
|
* ```ts
|
|
3307
3751
|
* // import {RangeThemeStyle} from '@univerjs/sheets';
|
|
@@ -3316,13 +3760,14 @@ let I = class extends X {
|
|
|
3316
3760
|
* ```
|
|
3317
3761
|
*/
|
|
3318
3762
|
registerRangeTheme(e) {
|
|
3319
|
-
this._commandService.syncExecuteCommand(
|
|
3763
|
+
this._commandService.syncExecuteCommand(Mt.id, {
|
|
3320
3764
|
unitId: this.getId(),
|
|
3321
3765
|
rangeThemeStyle: e
|
|
3322
3766
|
});
|
|
3323
3767
|
}
|
|
3324
3768
|
/**
|
|
3325
3769
|
* Unregister a custom range theme style.
|
|
3770
|
+
* @param themeName
|
|
3326
3771
|
* @example
|
|
3327
3772
|
* ```ts
|
|
3328
3773
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -3330,32 +3775,106 @@ let I = class extends X {
|
|
|
3330
3775
|
* ```
|
|
3331
3776
|
*/
|
|
3332
3777
|
unregisterRangeTheme(e) {
|
|
3333
|
-
this._commandService.syncExecuteCommand(
|
|
3778
|
+
this._commandService.syncExecuteCommand(Dt.id, {
|
|
3334
3779
|
unitId: this.getId(),
|
|
3335
3780
|
themeName: e
|
|
3336
3781
|
});
|
|
3337
3782
|
}
|
|
3783
|
+
/**
|
|
3784
|
+
* Set custom metadata of workbook
|
|
3785
|
+
* @param {CustomData | undefined} custom custom metadata
|
|
3786
|
+
* @returns {FWorkbook} FWorkbook
|
|
3787
|
+
* @example
|
|
3788
|
+
* ```ts
|
|
3789
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3790
|
+
* fWorkbook.setCustomMetadata({ key: 'value' });
|
|
3791
|
+
* ```
|
|
3792
|
+
*/
|
|
3793
|
+
setCustomMetadata(e) {
|
|
3794
|
+
return this._workbook.setCustomMetadata(e), this;
|
|
3795
|
+
}
|
|
3796
|
+
/**
|
|
3797
|
+
* Get custom metadata of workbook
|
|
3798
|
+
* @returns {CustomData | undefined} custom metadata
|
|
3799
|
+
* @example
|
|
3800
|
+
* ```ts
|
|
3801
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
3802
|
+
* const custom = fWorkbook.getCustomMetadata();
|
|
3803
|
+
* ```
|
|
3804
|
+
*/
|
|
3805
|
+
getCustomMetadata() {
|
|
3806
|
+
return this._workbook.getCustomMetadata();
|
|
3807
|
+
}
|
|
3338
3808
|
};
|
|
3339
|
-
I =
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3809
|
+
I = an([
|
|
3810
|
+
C(1, u(b)),
|
|
3811
|
+
C(2, u(Le)),
|
|
3812
|
+
C(3, u(We)),
|
|
3813
|
+
C(4, J),
|
|
3814
|
+
C(5, l),
|
|
3815
|
+
C(6, ee),
|
|
3816
|
+
C(7, pe),
|
|
3817
|
+
C(8, u(Re)),
|
|
3818
|
+
C(9, Te)
|
|
3349
3819
|
], I);
|
|
3350
|
-
class
|
|
3820
|
+
class hn extends Ue {
|
|
3821
|
+
getCommandSheetTarget(e) {
|
|
3822
|
+
var o;
|
|
3823
|
+
const t = e.params;
|
|
3824
|
+
if (!t) return;
|
|
3825
|
+
const n = t.unitId ? this.getUniverSheet(t.unitId) : (o = this.getActiveWorkbook) == null ? void 0 : o.call(this);
|
|
3826
|
+
if (!n)
|
|
3827
|
+
return;
|
|
3828
|
+
const r = n.getSheetBySheetId(t.subUnitId || t.sheetId) || n.getActiveSheet();
|
|
3829
|
+
if (r)
|
|
3830
|
+
return { workbook: n, worksheet: r };
|
|
3831
|
+
}
|
|
3832
|
+
getSheetTarget(e, t) {
|
|
3833
|
+
const n = this.getUniverSheet(e);
|
|
3834
|
+
if (!n)
|
|
3835
|
+
return;
|
|
3836
|
+
const r = n.getSheetBySheetId(t);
|
|
3837
|
+
if (r)
|
|
3838
|
+
return { workbook: n, worksheet: r };
|
|
3839
|
+
}
|
|
3840
|
+
_initWorkbookEvent(e) {
|
|
3841
|
+
const t = e.get(J);
|
|
3842
|
+
this.disposeWithMe(
|
|
3843
|
+
t.unitDisposed$.subscribe((n) => {
|
|
3844
|
+
this._eventRegistry.get(this.Event.WorkbookDisposed) && n.type === R.UNIVER_SHEET && this.fireEvent(
|
|
3845
|
+
this.Event.WorkbookDisposed,
|
|
3846
|
+
{
|
|
3847
|
+
unitId: n.getUnitId(),
|
|
3848
|
+
unitType: n.type,
|
|
3849
|
+
snapshot: n.getSnapshot()
|
|
3850
|
+
}
|
|
3851
|
+
);
|
|
3852
|
+
})
|
|
3853
|
+
), this.disposeWithMe(
|
|
3854
|
+
t.unitAdded$.subscribe((n) => {
|
|
3855
|
+
if (this._eventRegistry.get(this.Event.WorkbookCreated) && n.type === R.UNIVER_SHEET) {
|
|
3856
|
+
const r = n, o = e.createInstance(I, r);
|
|
3857
|
+
this.fireEvent(
|
|
3858
|
+
this.Event.WorkbookCreated,
|
|
3859
|
+
{
|
|
3860
|
+
unitId: n.getUnitId(),
|
|
3861
|
+
type: n.type,
|
|
3862
|
+
workbook: o,
|
|
3863
|
+
unit: o
|
|
3864
|
+
}
|
|
3865
|
+
);
|
|
3866
|
+
}
|
|
3867
|
+
})
|
|
3868
|
+
);
|
|
3869
|
+
}
|
|
3351
3870
|
_initialize(e) {
|
|
3352
3871
|
const t = e.get(l);
|
|
3353
3872
|
this.disposeWithMe(
|
|
3354
3873
|
t.beforeCommandExecuted((n) => {
|
|
3355
|
-
var
|
|
3874
|
+
var r;
|
|
3356
3875
|
switch (n.id) {
|
|
3357
|
-
case
|
|
3358
|
-
const
|
|
3876
|
+
case x.id: {
|
|
3877
|
+
const o = n.params, { unitId: i, index: a, sheet: h } = o || {}, c = i ? this.getUniverSheet(i) : (r = this.getActiveWorkbook) == null ? void 0 : r.call(this);
|
|
3359
3878
|
if (!c)
|
|
3360
3879
|
return;
|
|
3361
3880
|
const d = {
|
|
@@ -3367,17 +3886,17 @@ class sn extends Re {
|
|
|
3367
3886
|
this.Event.BeforeSheetCreate,
|
|
3368
3887
|
d
|
|
3369
3888
|
), d.cancel)
|
|
3370
|
-
throw new
|
|
3889
|
+
throw new qe();
|
|
3371
3890
|
break;
|
|
3372
3891
|
}
|
|
3373
3892
|
}
|
|
3374
3893
|
})
|
|
3375
3894
|
), this.disposeWithMe(
|
|
3376
3895
|
t.onCommandExecuted((n) => {
|
|
3377
|
-
var
|
|
3896
|
+
var r;
|
|
3378
3897
|
switch (n.id) {
|
|
3379
|
-
case
|
|
3380
|
-
const
|
|
3898
|
+
case x.id: {
|
|
3899
|
+
const o = n.params, { unitId: i } = o || {}, a = i ? this.getUniverSheet(i) : (r = this.getActiveWorkbook) == null ? void 0 : r.call(this);
|
|
3381
3900
|
if (!a)
|
|
3382
3901
|
return;
|
|
3383
3902
|
const h = a.getActiveSheet();
|
|
@@ -3395,66 +3914,78 @@ class sn extends Re {
|
|
|
3395
3914
|
}
|
|
3396
3915
|
}
|
|
3397
3916
|
})
|
|
3398
|
-
);
|
|
3917
|
+
), this._initWorkbookEvent(e);
|
|
3399
3918
|
}
|
|
3400
3919
|
createUniverSheet(e) {
|
|
3401
|
-
const n = this._injector.get(
|
|
3920
|
+
const n = this._injector.get(J).createUnit(R.UNIVER_SHEET, e);
|
|
3402
3921
|
return this._injector.createInstance(I, n);
|
|
3403
3922
|
}
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
return e ? this._injector.createInstance(I, e) : null;
|
|
3923
|
+
createWorkbook(e) {
|
|
3924
|
+
return this.createUniverSheet(e);
|
|
3407
3925
|
}
|
|
3408
3926
|
getActiveWorkbook() {
|
|
3409
|
-
|
|
3927
|
+
const e = this._univerInstanceService.getCurrentUnitForType(R.UNIVER_SHEET);
|
|
3928
|
+
return e ? this._injector.createInstance(I, e) : null;
|
|
3929
|
+
}
|
|
3930
|
+
getActiveUniverSheet() {
|
|
3931
|
+
return this.getActiveWorkbook();
|
|
3410
3932
|
}
|
|
3411
3933
|
getUniverSheet(e) {
|
|
3412
|
-
const t = this._univerInstanceService.getUnit(e,
|
|
3934
|
+
const t = this._univerInstanceService.getUnit(e, R.UNIVER_SHEET);
|
|
3413
3935
|
return t ? this._injector.createInstance(I, t) : null;
|
|
3414
3936
|
}
|
|
3937
|
+
getWorkbook(e) {
|
|
3938
|
+
return this.getUniverSheet(e);
|
|
3939
|
+
}
|
|
3415
3940
|
getPermission() {
|
|
3416
|
-
return this._injector.createInstance(
|
|
3941
|
+
return this._injector.createInstance(O);
|
|
3417
3942
|
}
|
|
3418
3943
|
onUniverSheetCreated(e) {
|
|
3419
|
-
const t = this._univerInstanceService.getTypeOfUnitAdded$(
|
|
3420
|
-
const
|
|
3421
|
-
e(
|
|
3944
|
+
const t = this._univerInstanceService.getTypeOfUnitAdded$(R.UNIVER_SHEET).subscribe((n) => {
|
|
3945
|
+
const r = this._injector.createInstance(I, n);
|
|
3946
|
+
e(r);
|
|
3422
3947
|
});
|
|
3423
|
-
return
|
|
3948
|
+
return F(t);
|
|
3424
3949
|
}
|
|
3425
3950
|
newDefinedName() {
|
|
3426
|
-
return this._injector.createInstance(
|
|
3951
|
+
return this._injector.createInstance(L);
|
|
3427
3952
|
}
|
|
3428
3953
|
}
|
|
3429
|
-
|
|
3430
|
-
class
|
|
3954
|
+
Ue.extend(hn);
|
|
3955
|
+
class cn extends se {
|
|
3431
3956
|
get SheetCreated() {
|
|
3432
3957
|
return "SheetCreated";
|
|
3433
3958
|
}
|
|
3434
3959
|
get BeforeSheetCreate() {
|
|
3435
3960
|
return "BeforeSheetCreate";
|
|
3436
3961
|
}
|
|
3962
|
+
get WorkbookCreated() {
|
|
3963
|
+
return "WorkbookCreated";
|
|
3964
|
+
}
|
|
3965
|
+
get WorkbookDisposed() {
|
|
3966
|
+
return "WorkbookDisposed";
|
|
3967
|
+
}
|
|
3437
3968
|
}
|
|
3438
|
-
|
|
3439
|
-
var
|
|
3440
|
-
for (var
|
|
3441
|
-
(i = o
|
|
3442
|
-
return n &&
|
|
3443
|
-
},
|
|
3444
|
-
let
|
|
3445
|
-
constructor(
|
|
3446
|
-
super(), this._injector =
|
|
3969
|
+
se.extend(cn);
|
|
3970
|
+
var dn = Object.defineProperty, un = Object.getOwnPropertyDescriptor, mn = (s, e, t, n) => {
|
|
3971
|
+
for (var r = n > 1 ? void 0 : n ? un(e, t) : e, o = s.length - 1, i; o >= 0; o--)
|
|
3972
|
+
(i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
|
|
3973
|
+
return n && r && dn(e, t, r), r;
|
|
3974
|
+
}, ln = (s, e) => (t, n) => e(t, n, s);
|
|
3975
|
+
let fe = class extends te {
|
|
3976
|
+
constructor(s) {
|
|
3977
|
+
super(), this._injector = s;
|
|
3447
3978
|
}
|
|
3448
3979
|
};
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
],
|
|
3980
|
+
fe = mn([
|
|
3981
|
+
ln(0, u(b))
|
|
3982
|
+
], fe);
|
|
3452
3983
|
export {
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3984
|
+
O as FPermission,
|
|
3985
|
+
w as FRange,
|
|
3986
|
+
B as FSelection,
|
|
3987
|
+
cn as FSheetEventName,
|
|
3988
|
+
fe as FSheetHooks,
|
|
3458
3989
|
I as FWorkbook,
|
|
3459
3990
|
g as FWorksheet
|
|
3460
3991
|
};
|