@univerjs/sheets 1.0.0-rc.0 → 1.0.1
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 +211 -110
- package/lib/cjs/index.js +350 -246
- package/lib/cjs/locale/ar-SA.js +0 -1
- package/lib/cjs/locale/ca-ES.js +0 -1
- package/lib/cjs/locale/de-DE.js +0 -1
- package/lib/cjs/locale/en-US.js +0 -1
- package/lib/cjs/locale/es-ES.js +0 -1
- package/lib/cjs/locale/fa-IR.js +0 -1
- package/lib/cjs/locale/fr-FR.js +0 -1
- package/lib/cjs/locale/id-ID.js +0 -1
- package/lib/cjs/locale/it-IT.js +0 -1
- package/lib/cjs/locale/ja-JP.js +0 -1
- package/lib/cjs/locale/ko-KR.js +0 -1
- package/lib/cjs/locale/pl-PL.js +0 -1
- package/lib/cjs/locale/pt-BR.js +0 -1
- package/lib/cjs/locale/ru-RU.js +0 -1
- package/lib/cjs/locale/sk-SK.js +0 -1
- package/lib/cjs/locale/vi-VN.js +0 -1
- package/lib/cjs/locale/zh-CN.js +0 -1
- package/lib/cjs/locale/zh-HK.js +0 -1
- package/lib/cjs/locale/zh-TW.js +0 -1
- package/lib/es/facade.js +212 -111
- package/lib/es/index.js +351 -248
- package/lib/facade.js +212 -111
- package/lib/index.js +351 -248
- package/lib/types/commands/commands/set-worksheet-hide.command.d.ts +4 -0
- package/lib/types/commands/mutations/set-range-values.mutation.d.ts +12 -1
- package/lib/types/commands/mutations/set-worksheet-hide.mutation.d.ts +2 -1
- package/lib/types/controllers/calculate-result-apply.controller.d.ts +1 -1
- package/lib/types/facade/f-defined-name.d.ts +2 -2
- package/lib/types/facade/f-range.d.ts +118 -45
- package/lib/types/facade/f-selection.d.ts +1 -1
- package/lib/types/facade/f-univer.d.ts +4 -5
- package/lib/types/facade/f-workbook.d.ts +8 -13
- package/lib/types/facade/f-worksheet.d.ts +43 -28
- package/lib/types/facade/permission/f-range-permission.d.ts +1 -1
- package/lib/types/facade/permission/f-range-protection-rule.d.ts +2 -2
- package/lib/types/facade/permission/f-workbook-permission.d.ts +3 -3
- package/lib/types/facade/permission/f-worksheet-permission.d.ts +5 -4
- package/lib/types/facade/utils.d.ts +1 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/services/auto-fill/tools.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +9 -9
package/lib/cjs/facade.js
CHANGED
|
@@ -24,7 +24,7 @@ let _univerjs_protocol = require("@univerjs/protocol");
|
|
|
24
24
|
const SHEETS_CUSTOM_FIELD_WARNING_MESSAGE = "[Facade]: The sheets custom field is not recommended for external use. Use it at your own risk.";
|
|
25
25
|
|
|
26
26
|
//#endregion
|
|
27
|
-
//#region \0@oxc-project+runtime@0.
|
|
27
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
28
28
|
function _typeof(o) {
|
|
29
29
|
"@babel/helpers - typeof";
|
|
30
30
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -35,7 +35,7 @@ function _typeof(o) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
//#endregion
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
39
39
|
function toPrimitive(t, r) {
|
|
40
40
|
if ("object" != _typeof(t) || !t) return t;
|
|
41
41
|
var e = t[Symbol.toPrimitive];
|
|
@@ -48,14 +48,14 @@ function toPrimitive(t, r) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
|
-
//#region \0@oxc-project+runtime@0.
|
|
51
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
52
52
|
function toPropertyKey(t) {
|
|
53
53
|
var i = toPrimitive(t, "string");
|
|
54
54
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region \0@oxc-project+runtime@0.
|
|
58
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
59
59
|
function _defineProperty(e, r, t) {
|
|
60
60
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
61
61
|
value: t,
|
|
@@ -66,7 +66,7 @@ function _defineProperty(e, r, t) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
//#endregion
|
|
69
|
-
//#region \0@oxc-project+runtime@0.
|
|
69
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
70
70
|
function __decorateParam(paramIndex, decorator) {
|
|
71
71
|
return function(target, key) {
|
|
72
72
|
decorator(target, key, paramIndex);
|
|
@@ -74,7 +74,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
//#endregion
|
|
77
|
-
//#region \0@oxc-project+runtime@0.
|
|
77
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
78
78
|
function __decorate(decorators, target, key, desc) {
|
|
79
79
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
80
80
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -137,7 +137,7 @@ let FDefinedNameBuilder = class FDefinedNameBuilder {
|
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Sets the formula of the defined name builder.
|
|
140
|
-
* @param {string
|
|
140
|
+
* @param {string} formula The formula without the leading `=`; this method prepends it.
|
|
141
141
|
* @returns {FDefinedNameBuilder} The instance of `FDefinedNameBuilder` for method chaining.
|
|
142
142
|
* @example
|
|
143
143
|
* ```ts
|
|
@@ -378,7 +378,7 @@ let FDefinedName = class FDefinedName extends _univerjs_core_facade.FBase {
|
|
|
378
378
|
}
|
|
379
379
|
/**
|
|
380
380
|
* Sets the formula of the defined name.
|
|
381
|
-
* @param {string} formula The formula
|
|
381
|
+
* @param {string} formula The formula without the leading `=`; this method prepends it.
|
|
382
382
|
* @example
|
|
383
383
|
* ```ts
|
|
384
384
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -634,7 +634,7 @@ let FSelection = _FSelection = class FSelection {
|
|
|
634
634
|
}
|
|
635
635
|
/**
|
|
636
636
|
* Represents the current select cell in the sheet.
|
|
637
|
-
* @returns {ISelectionCell} The
|
|
637
|
+
* @returns {Nullable<ISelectionCell>} The primary cell of the current selection, or `null` when none exists.
|
|
638
638
|
* @example
|
|
639
639
|
* ```ts
|
|
640
640
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1083,7 +1083,7 @@ let FRangeProtectionRule = class FRangeProtectionRule {
|
|
|
1083
1083
|
/**
|
|
1084
1084
|
* Update the protected ranges.
|
|
1085
1085
|
* @param {FRange[]} ranges New ranges to protect.
|
|
1086
|
-
* @returns {Promise<
|
|
1086
|
+
* @returns {Promise<boolean>} A promise resolving to whether the protected ranges were updated.
|
|
1087
1087
|
* @example
|
|
1088
1088
|
* ```ts
|
|
1089
1089
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1120,7 +1120,7 @@ let FRangeProtectionRule = class FRangeProtectionRule {
|
|
|
1120
1120
|
}
|
|
1121
1121
|
/**
|
|
1122
1122
|
* Delete the current protection rule.
|
|
1123
|
-
* @returns {Promise<
|
|
1123
|
+
* @returns {Promise<boolean>} A promise resolving to whether the rule was removed.
|
|
1124
1124
|
* @example
|
|
1125
1125
|
* ```ts
|
|
1126
1126
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1371,7 +1371,7 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
|
|
|
1371
1371
|
/**
|
|
1372
1372
|
* Create worksheet protection with collaborators support.
|
|
1373
1373
|
* This must be called before setting permission points for collaboration to work.
|
|
1374
|
-
* @param {IWorksheetProtectionOptions} options Protection options including allowed users.
|
|
1374
|
+
* @param {IWorksheetProtectionOptions} [options] Protection options including allowed users.
|
|
1375
1375
|
* @returns {Promise<string>} The permissionId for the created protection.
|
|
1376
1376
|
* @example
|
|
1377
1377
|
* ```ts
|
|
@@ -1451,7 +1451,7 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
|
|
|
1451
1451
|
/**
|
|
1452
1452
|
* Remove worksheet protection.
|
|
1453
1453
|
* This deletes the protection rule and resets all permission points to allowed.
|
|
1454
|
-
* @returns {Promise<
|
|
1454
|
+
* @returns {Promise<boolean>} A promise resolving to whether protection was removed; also resolves to `true` if already unprotected.
|
|
1455
1455
|
* @example
|
|
1456
1456
|
* ```ts
|
|
1457
1457
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1512,7 +1512,6 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
|
|
|
1512
1512
|
pointsToSet["WorksheetView"] = true;
|
|
1513
1513
|
pointsToSet["WorksheetSort"] = true;
|
|
1514
1514
|
pointsToSet["WorksheetFilter"] = true;
|
|
1515
|
-
break;
|
|
1516
1515
|
}
|
|
1517
1516
|
return pointsToSet;
|
|
1518
1517
|
}
|
|
@@ -1636,6 +1635,7 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
|
|
|
1636
1635
|
* if (fWorksheet.getWorksheetPermission().canView()) {
|
|
1637
1636
|
* console.log('Worksheet is viewable');
|
|
1638
1637
|
* }
|
|
1638
|
+
* ```
|
|
1639
1639
|
*/
|
|
1640
1640
|
canView() {
|
|
1641
1641
|
return this.getPoint("WorksheetView");
|
|
@@ -1831,7 +1831,7 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
|
|
|
1831
1831
|
/**
|
|
1832
1832
|
* Remove multiple protection rules at once.
|
|
1833
1833
|
* @param {string[]} ruleIds Array of rule IDs to remove.
|
|
1834
|
-
* @returns {Promise<
|
|
1834
|
+
* @returns {Promise<boolean>} A promise resolving to whether the rules were removed; also resolves to `true` for an empty ID list.
|
|
1835
1835
|
* @example
|
|
1836
1836
|
* ```ts
|
|
1837
1837
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1880,7 +1880,7 @@ let FWorksheetPermission = class FWorksheetPermission extends _univerjs_core_fac
|
|
|
1880
1880
|
* Debug cell permission information.
|
|
1881
1881
|
* @param {number} row Row index.
|
|
1882
1882
|
* @param {number} col Column index.
|
|
1883
|
-
* @returns {FRangeProtectionRule | undefined}
|
|
1883
|
+
* @returns {Promise<FRangeProtectionRule | undefined>} A promise resolving to the protection rule affecting this cell, or `undefined` if no range protection rule applies.
|
|
1884
1884
|
* @example
|
|
1885
1885
|
* ```ts
|
|
1886
1886
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -2059,6 +2059,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2059
2059
|
this.setActiveRange
|
|
2060
2060
|
);
|
|
2061
2061
|
}
|
|
2062
|
+
/** Releases this facade's resources. Use `univerAPI.disposeUnit()` to unload the owning unit. */
|
|
2062
2063
|
dispose() {
|
|
2063
2064
|
super.dispose();
|
|
2064
2065
|
delete this._fWorkbook;
|
|
@@ -2137,7 +2138,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2137
2138
|
}
|
|
2138
2139
|
/**
|
|
2139
2140
|
* Get the current selection of the worksheet.
|
|
2140
|
-
* @returns {FSelection}
|
|
2141
|
+
* @returns {FSelection | null} The current selections, or `null` when no selection data is available.
|
|
2141
2142
|
* @example
|
|
2142
2143
|
* ```typescript
|
|
2143
2144
|
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
@@ -2153,7 +2154,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2153
2154
|
}
|
|
2154
2155
|
/**
|
|
2155
2156
|
* Get the default style of the worksheet.
|
|
2156
|
-
* @returns {IStyleData}
|
|
2157
|
+
* @returns {Nullable<IStyleData> | string} The default style object or style ID, or a nullish value when no default style is set.
|
|
2157
2158
|
* @example
|
|
2158
2159
|
* ```typescript
|
|
2159
2160
|
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
@@ -2207,7 +2208,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2207
2208
|
}
|
|
2208
2209
|
/**
|
|
2209
2210
|
* Set the default style of the worksheet
|
|
2210
|
-
* @param {string} style -
|
|
2211
|
+
* @param {string | Nullable<IStyleData>} style - A style ID or style object, or `null` to clear the default style.
|
|
2211
2212
|
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2212
2213
|
* @example
|
|
2213
2214
|
* ```typescript
|
|
@@ -2230,8 +2231,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2230
2231
|
return this;
|
|
2231
2232
|
}
|
|
2232
2233
|
/**
|
|
2233
|
-
* Set the default style of the worksheet
|
|
2234
|
-
* @param {number} index - The
|
|
2234
|
+
* Set the default style of the worksheet column
|
|
2235
|
+
* @param {number} index - The zero-based column index
|
|
2235
2236
|
* @param {string | Nullable<IStyleData>} style - The style name or style data
|
|
2236
2237
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2237
2238
|
* @example
|
|
@@ -2254,8 +2255,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2254
2255
|
return this;
|
|
2255
2256
|
}
|
|
2256
2257
|
/**
|
|
2257
|
-
* Set the default style of the worksheet
|
|
2258
|
-
* @param {number} index - The
|
|
2258
|
+
* Set the default style of the worksheet row
|
|
2259
|
+
* @param {number} index - The zero-based row index
|
|
2259
2260
|
* @param {string | Nullable<IStyleData>} style - The style name or style data
|
|
2260
2261
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2261
2262
|
* @example
|
|
@@ -2376,7 +2377,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2376
2377
|
/**
|
|
2377
2378
|
* Inserts one or more consecutive blank rows in a sheet starting at the specified location.
|
|
2378
2379
|
* @param {number} rowIndex - The existing row before which rows are inserted. The index is zero-based and must be between 0 and `getMaxRows() - 1`.
|
|
2379
|
-
* @param {number} numRows - The positive number of rows to insert.
|
|
2380
|
+
* @param {number} [numRows] - The positive number of rows to insert.
|
|
2380
2381
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2381
2382
|
* @example
|
|
2382
2383
|
* ```typescript
|
|
@@ -2601,7 +2602,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2601
2602
|
/**
|
|
2602
2603
|
* Hides one or more consecutive rows starting at the given index. Use 0-index for this method
|
|
2603
2604
|
* @param {number} rowIndex - The starting index of the rows to hide
|
|
2604
|
-
* @param {number} numRow - The number of rows to hide
|
|
2605
|
+
* @param {number} [numRow] - The number of rows to hide
|
|
2605
2606
|
* @returns {FWorksheet} This sheet, for chaining.
|
|
2606
2607
|
* @example
|
|
2607
2608
|
* ```typescript
|
|
@@ -2658,9 +2659,9 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2658
2659
|
return this;
|
|
2659
2660
|
}
|
|
2660
2661
|
/**
|
|
2661
|
-
*
|
|
2662
|
+
* Unhides one or more consecutive rows starting at the given zero-based index.
|
|
2662
2663
|
* @param {number} rowIndex - The starting index of the rows
|
|
2663
|
-
* @param {number} numRows - The number of rows
|
|
2664
|
+
* @param {number} [numRows] - The number of rows
|
|
2664
2665
|
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2665
2666
|
* @example
|
|
2666
2667
|
* ```typescript
|
|
@@ -2710,7 +2711,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2710
2711
|
/**
|
|
2711
2712
|
* Make certain row wrap and auto height.
|
|
2712
2713
|
* @param {number} rowPosition - The row position to change.
|
|
2713
|
-
* @param {BooleanNumber} auto - Whether to auto fit the row height.
|
|
2714
|
+
* @param {BooleanNumber} [auto] - Whether to auto fit the row height.
|
|
2714
2715
|
* @returns {FWorksheet} This worksheet instance for chaining
|
|
2715
2716
|
* @example
|
|
2716
2717
|
* ```ts
|
|
@@ -2953,7 +2954,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
2953
2954
|
/**
|
|
2954
2955
|
* Inserts one or more consecutive blank columns in a sheet starting at the specified location.
|
|
2955
2956
|
* @param {number} columnIndex - The index indicating where to insert a column, starting at 0 for the first column
|
|
2956
|
-
* @param {number} numColumns - The number of columns to insert
|
|
2957
|
+
* @param {number} [numColumns] - The number of columns to insert
|
|
2957
2958
|
* @returns {FWorksheet} This sheet, for chaining
|
|
2958
2959
|
* @example
|
|
2959
2960
|
* ```typescript
|
|
@@ -3175,7 +3176,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3175
3176
|
/**
|
|
3176
3177
|
* Hides one or more consecutive columns starting at the given index. Use 0-index for this method
|
|
3177
3178
|
* @param {number} columnIndex - The starting index of the columns to hide
|
|
3178
|
-
* @param {number} numColumn - The number of columns to hide
|
|
3179
|
+
* @param {number} [numColumn] - The number of columns to hide
|
|
3179
3180
|
* @returns {FWorksheet} This sheet, for chaining
|
|
3180
3181
|
* @example
|
|
3181
3182
|
* ```typescript
|
|
@@ -3234,7 +3235,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3234
3235
|
/**
|
|
3235
3236
|
* Show one or more consecutive columns starting at the given index. Use 0-index for this method
|
|
3236
3237
|
* @param {number} columnIndex - The starting index of the columns to unhide
|
|
3237
|
-
* @param {number} numColumns - The number of columns to unhide
|
|
3238
|
+
* @param {number} [numColumns] - The number of columns to unhide
|
|
3238
3239
|
* @returns {FWorksheet} This sheet, for chaining
|
|
3239
3240
|
* @example
|
|
3240
3241
|
* ```typescript
|
|
@@ -3325,7 +3326,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3325
3326
|
* fRange.setValue('Whenever it is a damp, drizzly November in my soul...');
|
|
3326
3327
|
*
|
|
3327
3328
|
* // Set the column A to a width which fits the text
|
|
3328
|
-
* fWorksheet.
|
|
3329
|
+
* fWorksheet.autoResizeColumns(0);
|
|
3329
3330
|
*
|
|
3330
3331
|
* // Get the width of the column A
|
|
3331
3332
|
* console.log(fWorksheet.getColumnWidth(0));
|
|
@@ -3711,7 +3712,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3711
3712
|
}
|
|
3712
3713
|
/**
|
|
3713
3714
|
* Sets the sheet tab color.
|
|
3714
|
-
* @param {string
|
|
3715
|
+
* @param {string} color - A color in CSS notation, such as '#ffffff' or 'white'.
|
|
3715
3716
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
3716
3717
|
* @example
|
|
3717
3718
|
* ```ts
|
|
@@ -3732,8 +3733,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3732
3733
|
}
|
|
3733
3734
|
/**
|
|
3734
3735
|
* Get the tab color of the sheet.
|
|
3735
|
-
* @returns {string} The tab color
|
|
3736
|
-
* The default color is css style property 'unset'.
|
|
3736
|
+
* @returns {string | undefined} The tab color, or `undefined` when no color is set.
|
|
3737
3737
|
* @example
|
|
3738
3738
|
* ```ts
|
|
3739
3739
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -3759,13 +3759,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3759
3759
|
* ```
|
|
3760
3760
|
*/
|
|
3761
3761
|
hideSheet() {
|
|
3762
|
-
|
|
3763
|
-
if (this._workbook.getSheets().filter((sheet) => sheet.isSheetHidden() !== _univerjs_core.BooleanNumber.TRUE).length <= 1) throw new Error("Cannot hide the only visible sheet");
|
|
3764
|
-
commandService.syncExecuteCommand(_univerjs_sheets.SetWorksheetHideCommand.id, {
|
|
3765
|
-
unitId: this._workbook.getUnitId(),
|
|
3766
|
-
subUnitId: this._worksheet.getSheetId()
|
|
3767
|
-
});
|
|
3768
|
-
return this;
|
|
3762
|
+
return this.isSheetHidden() ? this : this.setHiddenState(_univerjs_core.WorksheetHiddenState.HIDDEN);
|
|
3769
3763
|
}
|
|
3770
3764
|
/**
|
|
3771
3765
|
* Shows this sheet. Has no effect if the sheet is already visible.
|
|
@@ -3786,7 +3780,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3786
3780
|
return this;
|
|
3787
3781
|
}
|
|
3788
3782
|
/**
|
|
3789
|
-
* Returns true
|
|
3783
|
+
* Returns true for both HIDDEN and VERY_HIDDEN sheets.
|
|
3790
3784
|
* @returns {boolean} True if the sheet is hidden; otherwise, false.
|
|
3791
3785
|
* @example
|
|
3792
3786
|
* ```ts
|
|
@@ -3800,6 +3794,33 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3800
3794
|
return Boolean(this._worksheet.isSheetHidden() === _univerjs_core.BooleanNumber.TRUE);
|
|
3801
3795
|
}
|
|
3802
3796
|
/**
|
|
3797
|
+
* Returns 0 (visible), 1 (hidden), or 2 (very hidden).
|
|
3798
|
+
* @example fWorksheet.getHiddenState() === univerAPI.Enum.WorksheetHiddenState.VERY_HIDDEN
|
|
3799
|
+
*/
|
|
3800
|
+
getHiddenState() {
|
|
3801
|
+
return this._worksheet.getHiddenState();
|
|
3802
|
+
}
|
|
3803
|
+
/**
|
|
3804
|
+
* Changes the persisted hiding state through an undoable command.
|
|
3805
|
+
* VERY_HIDDEN removes the sheet from Unhide UI; showSheet() can reveal it through the API.
|
|
3806
|
+
* The last visible sheet cannot be hidden. Existing isSheetHidden() stays a boolean predicate.
|
|
3807
|
+
* @example fWorksheet.setHiddenState(univerAPI.Enum.WorksheetHiddenState.VERY_HIDDEN)
|
|
3808
|
+
*/
|
|
3809
|
+
setHiddenState(hidden) {
|
|
3810
|
+
if (hidden === _univerjs_core.WorksheetHiddenState.VISIBLE) return this.showSheet();
|
|
3811
|
+
if (hidden !== _univerjs_core.WorksheetHiddenState.HIDDEN && hidden !== _univerjs_core.WorksheetHiddenState.VERY_HIDDEN) throw new RangeError(`Unsupported worksheet hidden state: ${String(hidden)}`);
|
|
3812
|
+
if (this._worksheet.getHiddenState() === hidden) return this;
|
|
3813
|
+
if (this._worksheet.getHiddenState() === _univerjs_core.WorksheetHiddenState.VISIBLE) {
|
|
3814
|
+
if (this._workbook.getSheets().filter((sheet) => !sheet.isSheetHidden()).length <= 1) throw new Error("Cannot hide the only visible sheet");
|
|
3815
|
+
}
|
|
3816
|
+
this._injector.get(_univerjs_core.ICommandService).syncExecuteCommand(_univerjs_sheets.SetWorksheetHideCommand.id, {
|
|
3817
|
+
unitId: this._workbook.getUnitId(),
|
|
3818
|
+
subUnitId: this._worksheet.getSheetId(),
|
|
3819
|
+
hidden
|
|
3820
|
+
});
|
|
3821
|
+
return this;
|
|
3822
|
+
}
|
|
3823
|
+
/**
|
|
3803
3824
|
* Sets the sheet name.
|
|
3804
3825
|
* @param {string} name - The new name for the sheet.
|
|
3805
3826
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
@@ -3852,10 +3873,11 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3852
3873
|
return this._workbook.getSheetIndex(this._worksheet);
|
|
3853
3874
|
}
|
|
3854
3875
|
/**
|
|
3855
|
-
* Clears the sheet
|
|
3876
|
+
* Clears the sheet content and formatting, or only one of them as specified by the options.
|
|
3877
|
+
* Both content and formatting are cleared when both flags are true or both are false.
|
|
3856
3878
|
* @param {IFacadeClearOptions} [options] - Options for clearing the sheet. If not provided, the contents and formatting are cleared both.
|
|
3857
|
-
* @param {boolean} [options.contentsOnly] - If true, the contents of the sheet are cleared.
|
|
3858
|
-
* @param {boolean} [options.formatOnly] -
|
|
3879
|
+
* @param {boolean} [options.contentsOnly] - If true, the contents of the sheet are cleared. Effective only when `formatOnly` is false. Defaults to false.
|
|
3880
|
+
* @param {boolean} [options.formatOnly] - Clears only formatting when true and `contentsOnly` is false. Defaults to false.
|
|
3859
3881
|
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
3860
3882
|
* @example
|
|
3861
3883
|
* ```ts
|
|
@@ -3966,8 +3988,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3966
3988
|
return this.getRange(startRow, startColumn, endRow - startRow + 1, endColumn - startColumn + 1);
|
|
3967
3989
|
}
|
|
3968
3990
|
/**
|
|
3969
|
-
* Returns the
|
|
3970
|
-
* @returns {number}
|
|
3991
|
+
* Returns the zero-based index of the last column with stored cell data, including formatting-only cells.
|
|
3992
|
+
* @returns {number} The last stored column index, or 0 for an empty sheet.
|
|
3971
3993
|
* @example
|
|
3972
3994
|
* ```ts
|
|
3973
3995
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -3983,8 +4005,8 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
|
|
|
3983
4005
|
return this._worksheet.getLastColumnWithContent();
|
|
3984
4006
|
}
|
|
3985
4007
|
/**
|
|
3986
|
-
* Returns the
|
|
3987
|
-
* @returns {number}
|
|
4008
|
+
* Returns the zero-based index of the last row with stored cell data, including formatting-only cells.
|
|
4009
|
+
* @returns {number} The last stored row index, or 0 for an empty sheet.
|
|
3988
4010
|
* @example
|
|
3989
4011
|
* ```ts
|
|
3990
4012
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -4302,7 +4324,7 @@ let FRangePermission = class FRangePermission extends _univerjs_core_facade.FBas
|
|
|
4302
4324
|
}
|
|
4303
4325
|
/**
|
|
4304
4326
|
* Protect the current range.
|
|
4305
|
-
* @param {IRangeProtectionOptions} options Protection options.
|
|
4327
|
+
* @param {IRangeProtectionOptions} [options] Protection options.
|
|
4306
4328
|
* @returns {Promise<FRangeProtectionRule>} The created protection rule.
|
|
4307
4329
|
* @example
|
|
4308
4330
|
* ```ts
|
|
@@ -4567,8 +4589,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4567
4589
|
return this._range.endColumn;
|
|
4568
4590
|
}
|
|
4569
4591
|
/**
|
|
4570
|
-
*
|
|
4571
|
-
* @returns {number} The
|
|
4592
|
+
* Returns the number of columns in this range.
|
|
4593
|
+
* @returns {number} The column count, not a size in pixels.
|
|
4572
4594
|
* @example
|
|
4573
4595
|
* ```ts
|
|
4574
4596
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -4582,8 +4604,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4582
4604
|
return this._range.endColumn - this._range.startColumn + 1;
|
|
4583
4605
|
}
|
|
4584
4606
|
/**
|
|
4585
|
-
*
|
|
4586
|
-
* @returns {number} The
|
|
4607
|
+
* Returns the number of rows in this range.
|
|
4608
|
+
* @returns {number} The row count, not a size in pixels.
|
|
4587
4609
|
* @example
|
|
4588
4610
|
* ```ts
|
|
4589
4611
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -4597,8 +4619,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4597
4619
|
return this._range.endRow - this._range.startRow + 1;
|
|
4598
4620
|
}
|
|
4599
4621
|
/**
|
|
4600
|
-
*
|
|
4601
|
-
* @returns {boolean}
|
|
4622
|
+
* Checks whether this range exactly matches a merged cell range.
|
|
4623
|
+
* @returns {boolean} `true` only for an exact merged range match. Use `isPartOfMerge()` to check overlap.
|
|
4602
4624
|
* @example
|
|
4603
4625
|
* ```ts
|
|
4604
4626
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -4619,7 +4641,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4619
4641
|
* Return first cell style data in this range. Please note that if there are row styles, col styles and (or)
|
|
4620
4642
|
* worksheet style, they will be merged into the cell style. You can use `type` to specify the type of the style to get.
|
|
4621
4643
|
*
|
|
4622
|
-
* @param {GetStyleType} type - The type of the style to get. 'row' means get the composed style of row, col and
|
|
4644
|
+
* @param {GetStyleType} [type] - The type of the style to get. 'row' means get the composed style of row, col and
|
|
4623
4645
|
* default worksheet style. 'col' means get the composed style of col, row and default worksheet style.
|
|
4624
4646
|
* 'cell' means get the style of cell without merging row style, col style and default worksheet style.
|
|
4625
4647
|
* Default is 'row'.
|
|
@@ -4641,7 +4663,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4641
4663
|
/**
|
|
4642
4664
|
* Get the font family of the cell.
|
|
4643
4665
|
*
|
|
4644
|
-
* @param {GetStyleType} type - The type of the style to get. 'row' means get the composed style of row, col and
|
|
4666
|
+
* @param {GetStyleType} [type] - The type of the style to get. 'row' means get the composed style of row, col and
|
|
4645
4667
|
* default worksheet style. 'col' means get the composed style of col, row and default worksheet style.
|
|
4646
4668
|
* 'cell' means get the style of cell without merging row style, col style and default worksheet style.
|
|
4647
4669
|
* Default is 'row'.
|
|
@@ -4663,7 +4685,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4663
4685
|
/**
|
|
4664
4686
|
* Get the font size of the cell.
|
|
4665
4687
|
*
|
|
4666
|
-
* @param {GetStyleType} type - The type of the style to get. 'row' means get the composed style of row, col and
|
|
4688
|
+
* @param {GetStyleType} [type] - The type of the style to get. 'row' means get the composed style of row, col and
|
|
4667
4689
|
* default worksheet style. 'col' means get the composed style of col, row and default worksheet style.
|
|
4668
4690
|
* 'cell' means get the style of cell without merging row style, col style and default worksheet style.
|
|
4669
4691
|
* Default is 'row'.
|
|
@@ -4685,7 +4707,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4685
4707
|
/**
|
|
4686
4708
|
* Return first cell style in this range.
|
|
4687
4709
|
*
|
|
4688
|
-
* @param {GetStyleType} type - The type of the style to get. 'row' means get the composed style of row, col and
|
|
4710
|
+
* @param {GetStyleType} [type] - The type of the style to get. 'row' means get the composed style of row, col and
|
|
4689
4711
|
* default worksheet style. 'col' means get the composed style of col, row and default worksheet style.
|
|
4690
4712
|
* 'cell' means get the style of cell without merging row style, col style and default worksheet style.
|
|
4691
4713
|
* Default is 'row'.
|
|
@@ -4707,7 +4729,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4707
4729
|
/**
|
|
4708
4730
|
* Returns the cell styles for the cells in the range.
|
|
4709
4731
|
*
|
|
4710
|
-
* @param {GetStyleType} type - The type of the style to get. 'row' means get the composed style of row, col and
|
|
4732
|
+
* @param {GetStyleType} [type] - The type of the style to get. 'row' means get the composed style of row, col and
|
|
4711
4733
|
* default worksheet style. 'col' means get the composed style of col, row and default worksheet style.
|
|
4712
4734
|
* 'cell' means get the style of cell without merging row style, col style and default worksheet style.
|
|
4713
4735
|
* Default is 'row'.
|
|
@@ -4755,7 +4777,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4755
4777
|
* ```
|
|
4756
4778
|
*/
|
|
4757
4779
|
getRawValue() {
|
|
4758
|
-
|
|
4780
|
+
const cell = this._worksheet.getCellMatrix().getValue(this._range.startRow, this._range.startColumn);
|
|
4781
|
+
return (0, _univerjs_core.getOriginCellValue)(cell);
|
|
4759
4782
|
}
|
|
4760
4783
|
/**
|
|
4761
4784
|
* Returns the displayed value of the top-left cell in the range. The value is a String. Empty cells return an empty string.
|
|
@@ -4778,7 +4801,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4778
4801
|
* ```
|
|
4779
4802
|
*/
|
|
4780
4803
|
getDisplayValue() {
|
|
4781
|
-
|
|
4804
|
+
const cell = this._worksheet.getCell(this._range.startRow, this._range.startColumn);
|
|
4805
|
+
return (0, _univerjs_core.getDisplayValueFromCell)(cell);
|
|
4782
4806
|
}
|
|
4783
4807
|
getValues(includeRichText) {
|
|
4784
4808
|
if (includeRichText) return this.getValueAndRichTextValues();
|
|
@@ -4844,7 +4868,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4844
4868
|
for (let r = startRow; r <= endRow; r++) {
|
|
4845
4869
|
const row = [];
|
|
4846
4870
|
for (let c = startColumn; c <= endColumn; c++) {
|
|
4847
|
-
const
|
|
4871
|
+
const cell = cellMatrix.getValue(r, c);
|
|
4872
|
+
const rawValue = (0, _univerjs_core.getOriginCellValue)(cell);
|
|
4848
4873
|
row.push(rawValue);
|
|
4849
4874
|
}
|
|
4850
4875
|
values.push(row);
|
|
@@ -4900,7 +4925,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
4900
4925
|
for (let r = startRow; r <= endRow; r++) {
|
|
4901
4926
|
const row = [];
|
|
4902
4927
|
for (let c = startColumn; c <= endColumn; c++) {
|
|
4903
|
-
const
|
|
4928
|
+
const cell = this._worksheet.getCell(r, c);
|
|
4929
|
+
const displayValue = (0, _univerjs_core.getDisplayValueFromCell)(cell);
|
|
4904
4930
|
row.push(displayValue);
|
|
4905
4931
|
}
|
|
4906
4932
|
values.push(row);
|
|
@@ -5085,7 +5111,10 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5085
5111
|
getWrap() {
|
|
5086
5112
|
return this._worksheet.getRange(this._range).getWrap() === _univerjs_core.BooleanNumber.TRUE;
|
|
5087
5113
|
}
|
|
5088
|
-
/**
|
|
5114
|
+
/**
|
|
5115
|
+
* Gets whether the top-left cell shrinks its font size to fit the cell width.
|
|
5116
|
+
* @returns {boolean} Whether shrink-to-fit is enabled for the top-left cell.
|
|
5117
|
+
*/
|
|
5089
5118
|
getShrinkToFit() {
|
|
5090
5119
|
var _this$_worksheet$getC3;
|
|
5091
5120
|
const { startRow, startColumn } = this._range;
|
|
@@ -5101,6 +5130,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5101
5130
|
* if (!fWorksheet) return;
|
|
5102
5131
|
* const fRange = fWorksheet.getRange('A1:B2');
|
|
5103
5132
|
* console.log(fRange.getWraps());
|
|
5133
|
+
* ```
|
|
5104
5134
|
*/
|
|
5105
5135
|
getWraps() {
|
|
5106
5136
|
const cells = this.getCellDatas();
|
|
@@ -5126,7 +5156,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5126
5156
|
return this._worksheet.getRange(this._range).getWrapStrategy();
|
|
5127
5157
|
}
|
|
5128
5158
|
/**
|
|
5129
|
-
* Returns the horizontal alignment of the
|
|
5159
|
+
* Returns the horizontal alignment of the top-left cell as `left`, `center`, or `normal` (right alignment).
|
|
5160
|
+
* Default and other core alignment values return `general`, which is not accepted by `setHorizontalAlignment()`.
|
|
5130
5161
|
* @returns {string} The horizontal alignment of the text in the cell.
|
|
5131
5162
|
* @example
|
|
5132
5163
|
* ```ts
|
|
@@ -5138,10 +5169,12 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5138
5169
|
* ```
|
|
5139
5170
|
*/
|
|
5140
5171
|
getHorizontalAlignment() {
|
|
5141
|
-
|
|
5172
|
+
const coreHorizontalAlignment = this._worksheet.getRange(this._range).getHorizontalAlignment();
|
|
5173
|
+
return transformCoreHorizontalAlignment(coreHorizontalAlignment);
|
|
5142
5174
|
}
|
|
5143
5175
|
/**
|
|
5144
|
-
* Returns
|
|
5176
|
+
* Returns a two-dimensional array of horizontal alignments: `left`, `center`, or `normal` (right alignment).
|
|
5177
|
+
* Default and other core alignment values return `general`, which is not accepted by `setHorizontalAlignment()`.
|
|
5145
5178
|
* @returns {string[][]} A two-dimensional array of horizontal alignments of text associated with cells in the range.
|
|
5146
5179
|
* @example
|
|
5147
5180
|
* ```ts
|
|
@@ -5156,7 +5189,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5156
5189
|
return this._worksheet.getRange(this._range).getHorizontalAlignments().map((row) => row.map((alignment) => transformCoreHorizontalAlignment(alignment)));
|
|
5157
5190
|
}
|
|
5158
5191
|
/**
|
|
5159
|
-
* Returns
|
|
5192
|
+
* Returns `top`, `middle`, or `bottom` for the top-left cell; unspecified alignment returns `general`.
|
|
5193
|
+
* `general` is a getter result and is not accepted by `setVerticalAlignment()`.
|
|
5160
5194
|
* @returns {string} The vertical alignment of the text in the cell.
|
|
5161
5195
|
* @example
|
|
5162
5196
|
* ```ts
|
|
@@ -5171,7 +5205,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5171
5205
|
return transformCoreVerticalAlignment(this._worksheet.getRange(this._range).getVerticalAlignment());
|
|
5172
5206
|
}
|
|
5173
5207
|
/**
|
|
5174
|
-
* Returns
|
|
5208
|
+
* Returns a two-dimensional array of `top`, `middle`, or `bottom` values; unspecified alignment returns `general`.
|
|
5209
|
+
* `general` is a getter result and is not accepted by `setVerticalAlignment()`.
|
|
5175
5210
|
* @returns {string[][]} A two-dimensional array of vertical alignments of text associated with cells in the range.
|
|
5176
5211
|
* @example
|
|
5177
5212
|
* ```ts
|
|
@@ -5189,6 +5224,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5189
5224
|
* Set custom meta data for first cell in current range.
|
|
5190
5225
|
* @param {CustomData} data The custom meta data
|
|
5191
5226
|
* @returns {FRange} This range, for chaining
|
|
5227
|
+
* @example
|
|
5192
5228
|
* ```ts
|
|
5193
5229
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
5194
5230
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
@@ -5213,6 +5249,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5213
5249
|
* Set custom meta data for current range.
|
|
5214
5250
|
* @param {CustomData[][]} datas The custom meta data
|
|
5215
5251
|
* @returns {FRange} This range, for chaining
|
|
5252
|
+
* @example
|
|
5216
5253
|
* ```ts
|
|
5217
5254
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
5218
5255
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
@@ -5240,7 +5277,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5240
5277
|
* Returns the custom meta data for the cell at the start of this range.
|
|
5241
5278
|
* @returns {CustomData | null} The custom meta data
|
|
5242
5279
|
* @example
|
|
5243
|
-
* ```
|
|
5280
|
+
* ```ts
|
|
5244
5281
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
5245
5282
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
5246
5283
|
* if (!fWorksheet) return;
|
|
@@ -5255,9 +5292,9 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5255
5292
|
}
|
|
5256
5293
|
/**
|
|
5257
5294
|
* Returns the custom meta data for the cells in the range.
|
|
5258
|
-
* @returns {CustomData[][]} A two-dimensional array of custom
|
|
5295
|
+
* @returns {Nullable<CustomData>[][]} A two-dimensional array of custom metadata, with `null` for cells without metadata.
|
|
5259
5296
|
* @example
|
|
5260
|
-
* ```
|
|
5297
|
+
* ```ts
|
|
5261
5298
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
5262
5299
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
5263
5300
|
* if (!fWorksheet) return;
|
|
@@ -5397,18 +5434,55 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5397
5434
|
return this;
|
|
5398
5435
|
}
|
|
5399
5436
|
/**
|
|
5400
|
-
* Sets the value
|
|
5401
|
-
*
|
|
5437
|
+
* Sets the value or specified cell properties for every cell in this range.
|
|
5438
|
+
*
|
|
5439
|
+
* There are two input modes:
|
|
5440
|
+
*
|
|
5441
|
+
* - `CellValue` (`number`, `string`, or `boolean`): replaces the cell content. A string starting
|
|
5442
|
+
* with `=` and containing at least one more character is written as a formula (`f`), clearing
|
|
5443
|
+
* the previous value (`v`) and rich text (`p`). Other values clear the previous formula and
|
|
5444
|
+
* rich text. Strings recognized as formatted numbers (for example, percentages, dates, or
|
|
5445
|
+
* currencies) are converted to numeric values and apply the parsed number format. Existing
|
|
5446
|
+
* formatting is otherwise preserved.
|
|
5447
|
+
* - `ICellData`: updates cell-data fields directly, for explicit control over `v` (value),
|
|
5448
|
+
* `f` (formula), `p` (rich text), `t` (value type), and `s` (style). The object bypasses the
|
|
5449
|
+
* formula and formatted-number parsing above: `{ v: '=SUM(A1:A2)' }` does not set a formula;
|
|
5450
|
+
* use `{ f: '=SUM(A1:A2)', v: null, p: null }` instead. Omitted content fields are not
|
|
5451
|
+
* automatically cleared, so use `f: null` and `p: null` when replacing a formula or rich text
|
|
5452
|
+
* with `v`. Use `v: null` to clear the stored value. Supplied style properties are merged into
|
|
5453
|
+
* the existing style; `s: null` clears the style.
|
|
5454
|
+
*
|
|
5455
|
+
* In both modes, the stored value is converted according to its cell type. Unless an `ICellData`
|
|
5456
|
+
* input supplies `t`, the type is inferred from the value, number format, and existing cell type.
|
|
5457
|
+
* Consequently, passing `{ v: '00123' }` alone does not guarantee that the value stays a string;
|
|
5458
|
+
* supply `t: CellValueType.STRING` to store it as text.
|
|
5459
|
+
*
|
|
5460
|
+
* @param {CellValue | ICellData} value The scalar content or cell-data update to apply throughout the range.
|
|
5402
5461
|
* @returns {FRange} This range, for chaining
|
|
5462
|
+
* @example
|
|
5403
5463
|
* ```ts
|
|
5404
5464
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
5405
5465
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
5406
5466
|
* if (!fWorksheet) return;
|
|
5407
|
-
* const fRange = fWorksheet.getRange('B2');
|
|
5467
|
+
* const fRange = fWorksheet.getRange('B2:B3');
|
|
5468
|
+
*
|
|
5469
|
+
* // Replace the content of both cells, preserving their formatting.
|
|
5408
5470
|
* fRange.setValue(123);
|
|
5409
5471
|
*
|
|
5410
|
-
* //
|
|
5411
|
-
* fRange.setValue(
|
|
5472
|
+
* // Parse a percentage and apply its number format to both cells.
|
|
5473
|
+
* fRange.setValue('25%');
|
|
5474
|
+
*
|
|
5475
|
+
* // Write the same formula to both cells.
|
|
5476
|
+
* fRange.setValue('=SUM(A1:A2)');
|
|
5477
|
+
*
|
|
5478
|
+
* // Explicitly replace content and update the background color.
|
|
5479
|
+
* fRange.setValue({ v: 234, f: null, p: null, s: { bg: { rgb: '#ff0000' } } });
|
|
5480
|
+
*
|
|
5481
|
+
* // Store numeric-looking text (CellValueType is imported from '@univerjs/core').
|
|
5482
|
+
* fRange.setValue({ v: '00123', t: CellValueType.STRING, f: null, p: null });
|
|
5483
|
+
*
|
|
5484
|
+
* // Clear value, formula, and rich text while preserving formatting.
|
|
5485
|
+
* fRange.setValue({ v: null, f: null, p: null });
|
|
5412
5486
|
* ```
|
|
5413
5487
|
*/
|
|
5414
5488
|
setValue(value) {
|
|
@@ -5423,9 +5497,11 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5423
5497
|
return this;
|
|
5424
5498
|
}
|
|
5425
5499
|
/**
|
|
5426
|
-
*
|
|
5427
|
-
*
|
|
5500
|
+
* Sets the value or specified cell properties of the top-left cell in this range.
|
|
5501
|
+
* Uses the same scalar parsing and cell-data update rules as {@link FRange.setValue}.
|
|
5502
|
+
* @param {CellValue | ICellData} value The scalar content or cell-data update to apply to the top-left cell only.
|
|
5428
5503
|
* @returns {FRange} This range, for chaining
|
|
5504
|
+
* @example
|
|
5429
5505
|
* ```ts
|
|
5430
5506
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
5431
5507
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
@@ -5458,7 +5534,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5458
5534
|
* @param {RichTextValue | IDocumentData} value The rich text value
|
|
5459
5535
|
* @returns {FRange} The range
|
|
5460
5536
|
* @example
|
|
5461
|
-
* ```
|
|
5537
|
+
* ```ts
|
|
5462
5538
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
5463
5539
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
5464
5540
|
* if (!fWorksheet) return;
|
|
@@ -5492,7 +5568,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5492
5568
|
}
|
|
5493
5569
|
/**
|
|
5494
5570
|
* Set the rich text value for the cells in the range.
|
|
5495
|
-
* @param {RichTextValue[][]} values
|
|
5571
|
+
* @param {(RichTextValue | IDocumentData)[][]} values A two-dimensional array of rich-text values or document data matching this range's dimensions.
|
|
5496
5572
|
* @returns {FRange} The range
|
|
5497
5573
|
* @example
|
|
5498
5574
|
* ```ts
|
|
@@ -5509,13 +5585,14 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5509
5585
|
* .setStyle(6, 7, { bl: 1, cl: { rgb: '#c81e1e' } });
|
|
5510
5586
|
* fRange.setRichTextValues([
|
|
5511
5587
|
* [richText, richText],
|
|
5512
|
-
* [
|
|
5588
|
+
* [richText, richText]
|
|
5513
5589
|
* ]);
|
|
5514
5590
|
* console.log(fRange.getValue(true).toPlainText()); // Hello World
|
|
5515
5591
|
* ```
|
|
5516
5592
|
*/
|
|
5517
5593
|
setRichTextValues(values) {
|
|
5518
|
-
const
|
|
5594
|
+
const cellDatas = values.map((row) => row.map((item) => item && { p: item instanceof _univerjs_core.RichTextValue ? item.getData() : item }));
|
|
5595
|
+
const realValue = (0, _univerjs_core.covertCellValues)(cellDatas, this._range);
|
|
5519
5596
|
const params = {
|
|
5520
5597
|
unitId: this._workbook.getUnitId(),
|
|
5521
5598
|
subUnitId: this._worksheet.getSheetId(),
|
|
@@ -5527,7 +5604,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5527
5604
|
}
|
|
5528
5605
|
/**
|
|
5529
5606
|
* Set the cell wrap of the given range.
|
|
5530
|
-
*
|
|
5607
|
+
* Pass `true` to set `WrapStrategy.WRAP`, or `false` to reset to `WrapStrategy.UNSPECIFIED`.
|
|
5608
|
+
* Use `setWrapStrategy()` to explicitly select clipping or overflow behavior.
|
|
5531
5609
|
* @param {boolean} isWrapEnabled Whether to enable wrap
|
|
5532
5610
|
* @returns {FRange} this range, for chaining
|
|
5533
5611
|
* @example
|
|
@@ -5549,7 +5627,15 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5549
5627
|
});
|
|
5550
5628
|
return this;
|
|
5551
5629
|
}
|
|
5552
|
-
/**
|
|
5630
|
+
/**
|
|
5631
|
+
* Sets whether cells shrink their font size to fit the cell width.
|
|
5632
|
+
* @param {boolean} enabled Whether to enable shrink-to-fit for this range.
|
|
5633
|
+
* @returns {FRange} This range, for chaining.
|
|
5634
|
+
* @example
|
|
5635
|
+
* ```ts
|
|
5636
|
+
* univerAPI.getActiveWorkbook()?.getActiveSheet().getRange('A1:B2').setShrinkToFit(true);
|
|
5637
|
+
* ```
|
|
5638
|
+
*/
|
|
5553
5639
|
setShrinkToFit(enabled) {
|
|
5554
5640
|
this._commandService.syncExecuteCommand(_univerjs_sheets.SetShrinkToFitCommand.id, {
|
|
5555
5641
|
unitId: this._workbook.getUnitId(),
|
|
@@ -5584,7 +5670,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5584
5670
|
}
|
|
5585
5671
|
/**
|
|
5586
5672
|
* Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
|
|
5587
|
-
* @param {
|
|
5673
|
+
* @param {FVerticalAlignment} alignment The vertical alignment
|
|
5588
5674
|
* @returns {FRange} this range, for chaining
|
|
5589
5675
|
* @example
|
|
5590
5676
|
* ```ts
|
|
@@ -5605,8 +5691,9 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5605
5691
|
return this;
|
|
5606
5692
|
}
|
|
5607
5693
|
/**
|
|
5608
|
-
*
|
|
5609
|
-
*
|
|
5694
|
+
* Sets the horizontal alignment for the range using `left`, `center`, or `normal`.
|
|
5695
|
+
* These parameter names follow Google Apps Script. In Univer, `normal` means right alignment; `right` is not accepted.
|
|
5696
|
+
* @param {FHorizontalAlignment} alignment The horizontal alignment: `left`, `center`, or `normal` (right alignment).
|
|
5610
5697
|
* @returns {FRange} this range, for chaining
|
|
5611
5698
|
* @example
|
|
5612
5699
|
* ```ts
|
|
@@ -5614,7 +5701,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5614
5701
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
5615
5702
|
* if (!fWorksheet) return;
|
|
5616
5703
|
* const fRange = fWorksheet.getRange('A1:B2');
|
|
5617
|
-
* fRange.setHorizontalAlignment('
|
|
5704
|
+
* fRange.setHorizontalAlignment('normal'); // Align right
|
|
5618
5705
|
* ```
|
|
5619
5706
|
*/
|
|
5620
5707
|
setHorizontalAlignment(alignment) {
|
|
@@ -5627,8 +5714,13 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5627
5714
|
return this;
|
|
5628
5715
|
}
|
|
5629
5716
|
/**
|
|
5630
|
-
* Sets
|
|
5631
|
-
*
|
|
5717
|
+
* Sets cell values or specified cell properties using an array or a sparse matrix.
|
|
5718
|
+
* Each entry follows the scalar parsing and cell-data update rules of {@link FRange.setValue}.
|
|
5719
|
+
*
|
|
5720
|
+
* A two-dimensional array is relative to this range's top-left cell and must match its dimensions.
|
|
5721
|
+
* A sparse matrix uses absolute, zero-based worksheet row and column keys. Only supplied entries
|
|
5722
|
+
* are updated; matrix coordinates are not offset by or clipped to this range.
|
|
5723
|
+
* @param {CellValue[][] | IObjectMatrixPrimitiveType<CellValue> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>} value An array relative to this range, or a sparse matrix using absolute worksheet coordinates.
|
|
5632
5724
|
* @returns {FRange} This range, for chaining
|
|
5633
5725
|
* @example
|
|
5634
5726
|
* ```ts
|
|
@@ -5640,6 +5732,12 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
5640
5732
|
* [1, { v: 2, s: { bg: { rgb: '#ff0000' } } }],
|
|
5641
5733
|
* [3, 4]
|
|
5642
5734
|
* ]);
|
|
5735
|
+
*
|
|
5736
|
+
* // Update only B2 and C3 using absolute worksheet coordinates.
|
|
5737
|
+
* fWorksheet.getRange('B2:C3').setValues({
|
|
5738
|
+
* 1: { 1: 'B2' },
|
|
5739
|
+
* 2: { 2: { v: 10, f: null, p: null } },
|
|
5740
|
+
* });
|
|
5643
5741
|
* ```
|
|
5644
5742
|
*/
|
|
5645
5743
|
setValues(value) {
|
|
@@ -6011,6 +6109,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
6011
6109
|
* @param {number} callback.row the row number of the cell
|
|
6012
6110
|
* @param {number} callback.col the column number of the cell
|
|
6013
6111
|
* @param {ICellData} callback.cell the cell data
|
|
6112
|
+
* @example
|
|
6014
6113
|
* ```ts
|
|
6015
6114
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
6016
6115
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
@@ -6033,6 +6132,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
6033
6132
|
* @param {AbsoluteRefType} [startAbsoluteRefType] - The absolute reference type for the start cell.
|
|
6034
6133
|
* @param {AbsoluteRefType} [endAbsoluteRefType] - The absolute reference type for the end cell.
|
|
6035
6134
|
* @returns {string} The A1 notation of the range.
|
|
6135
|
+
* @example
|
|
6036
6136
|
* ```ts
|
|
6037
6137
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
6038
6138
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
@@ -6248,11 +6348,12 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
6248
6348
|
});
|
|
6249
6349
|
}
|
|
6250
6350
|
/**
|
|
6251
|
-
* Clears content and formatting
|
|
6351
|
+
* Clears the range content and formatting, or only one of them as specified by the options.
|
|
6352
|
+
* Both content and formatting are cleared when both flags are true or both are false.
|
|
6252
6353
|
* @param {IFacadeClearOptions} [options] - Options for clearing the range. If not provided, the contents and formatting are cleared both.
|
|
6253
|
-
* @param {boolean} [options.contentsOnly] - If true, the contents of the range are cleared.
|
|
6254
|
-
* @param {boolean} [options.formatOnly] -
|
|
6255
|
-
* @returns {
|
|
6354
|
+
* @param {boolean} [options.contentsOnly] - If true, the contents of the range are cleared. Effective only when `formatOnly` is false. Defaults to false.
|
|
6355
|
+
* @param {boolean} [options.formatOnly] - Clears only formatting when true and `contentsOnly` is false. Defaults to false.
|
|
6356
|
+
* @returns {FRange} This range, for chaining.
|
|
6256
6357
|
* @example
|
|
6257
6358
|
* ```ts
|
|
6258
6359
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -6280,7 +6381,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
6280
6381
|
}
|
|
6281
6382
|
/**
|
|
6282
6383
|
* Clears content of the range, while preserving formatting information.
|
|
6283
|
-
* @returns {
|
|
6384
|
+
* @returns {FRange} This range, for chaining.
|
|
6284
6385
|
* @example
|
|
6285
6386
|
* ```typescript
|
|
6286
6387
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -6302,7 +6403,7 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
6302
6403
|
}
|
|
6303
6404
|
/**
|
|
6304
6405
|
* Clears formatting information of the range, while preserving contents.
|
|
6305
|
-
* @returns {
|
|
6406
|
+
* @returns {FRange} This range, for chaining.
|
|
6306
6407
|
* @example
|
|
6307
6408
|
* ```typescript
|
|
6308
6409
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -6550,8 +6651,8 @@ let FRange = _FRange = class FRange extends _univerjs_core_facade.FBaseInitialab
|
|
|
6550
6651
|
* Returns a new range that is relative to the current range, whose upper left point is offset from the current range by the given rows and columns, and with the given height and width in cells.
|
|
6551
6652
|
* @param {number} rowOffset - The number of rows down from the range's top-left cell; negative values represent rows up from the range's top-left cell.
|
|
6552
6653
|
* @param {number} columnOffset - The number of columns right from the range's top-left cell; negative values represent columns left from the range's top-left cell.
|
|
6553
|
-
* @param {number} numRows - The height in rows of the new range.
|
|
6554
|
-
* @param {number} numColumns - The width in columns of the new range.
|
|
6654
|
+
* @param {number} [numRows] - The height in rows of the new range.
|
|
6655
|
+
* @param {number} [numColumns] - The width in columns of the new range.
|
|
6555
6656
|
* @returns {FRange} The new range.
|
|
6556
6657
|
* @example
|
|
6557
6658
|
* ```ts
|
|
@@ -6782,7 +6883,6 @@ let FWorkbookPermission = class FWorkbookPermission extends _univerjs_core_facad
|
|
|
6782
6883
|
pointsToSet["WorkbookView"] = true;
|
|
6783
6884
|
pointsToSet["WorkbookComment"] = true;
|
|
6784
6885
|
pointsToSet["WorkbookPrint"] = true;
|
|
6785
|
-
break;
|
|
6786
6886
|
}
|
|
6787
6887
|
return pointsToSet;
|
|
6788
6888
|
}
|
|
@@ -6897,7 +6997,7 @@ let FWorkbookPermission = class FWorkbookPermission extends _univerjs_core_facad
|
|
|
6897
6997
|
}
|
|
6898
6998
|
/**
|
|
6899
6999
|
* Set multiple collaborators at once (replaces existing collaborators).
|
|
6900
|
-
* @param {Array<{ user:
|
|
7000
|
+
* @param {Array<{ user: ICollaboratorUser; role: UnitRole }>} collaborators Array of collaborators with user information and role.
|
|
6901
7001
|
* @returns {Promise<void>} A promise that resolves when the collaborators are set.
|
|
6902
7002
|
* @example
|
|
6903
7003
|
* ```ts
|
|
@@ -6929,7 +7029,7 @@ let FWorkbookPermission = class FWorkbookPermission extends _univerjs_core_facad
|
|
|
6929
7029
|
}
|
|
6930
7030
|
/**
|
|
6931
7031
|
* Add a single collaborator.
|
|
6932
|
-
* @param {
|
|
7032
|
+
* @param {ICollaboratorUser} user The user information (userID, name, avatar).
|
|
6933
7033
|
* @param {UnitRole} role The role to assign.
|
|
6934
7034
|
* @returns {Promise<void>} A promise that resolves when the collaborator is added.
|
|
6935
7035
|
* @example
|
|
@@ -6955,7 +7055,7 @@ let FWorkbookPermission = class FWorkbookPermission extends _univerjs_core_facad
|
|
|
6955
7055
|
}
|
|
6956
7056
|
/**
|
|
6957
7057
|
* Update an existing collaborator's role and information.
|
|
6958
|
-
* @param {
|
|
7058
|
+
* @param {ICollaboratorUser} user The updated user information (userID, name, avatar).
|
|
6959
7059
|
* @param {UnitRole} role The new role to assign.
|
|
6960
7060
|
* @returns {Promise<void>} A promise that resolves when the collaborator is updated.
|
|
6961
7061
|
* @example
|
|
@@ -7076,6 +7176,7 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
7076
7176
|
getWorkbook() {
|
|
7077
7177
|
return this._workbook;
|
|
7078
7178
|
}
|
|
7179
|
+
/** Releases this facade's resources. Use `univerAPI.disposeUnit()` to unload the owning unit. */
|
|
7079
7180
|
dispose() {
|
|
7080
7181
|
super.dispose();
|
|
7081
7182
|
this._workbook = null;
|
|
@@ -7366,7 +7467,7 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
7366
7467
|
}
|
|
7367
7468
|
/**
|
|
7368
7469
|
* Undo the last action.
|
|
7369
|
-
* @returns {FWorkbook}
|
|
7470
|
+
* @returns {FWorkbook} This workbook, for chaining.
|
|
7370
7471
|
* @example
|
|
7371
7472
|
* ```ts
|
|
7372
7473
|
* // The code below undoes the last action
|
|
@@ -7381,7 +7482,7 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
7381
7482
|
}
|
|
7382
7483
|
/**
|
|
7383
7484
|
* Redo the last undone action.
|
|
7384
|
-
* @returns {FWorkbook}
|
|
7485
|
+
* @returns {FWorkbook} This workbook, for chaining.
|
|
7385
7486
|
* @example
|
|
7386
7487
|
* ```ts
|
|
7387
7488
|
* // The code below redoes the last undone action
|
|
@@ -7745,7 +7846,7 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
7745
7846
|
* const definedNameParam = fWorkbook.newDefinedNameBuilder()
|
|
7746
7847
|
* .setRef('Sheet1!$A$1')
|
|
7747
7848
|
* .setName('MyDefinedName')
|
|
7748
|
-
* .setComment('This is a comment')
|
|
7849
|
+
* .setComment('This is a comment')
|
|
7749
7850
|
* .build();
|
|
7750
7851
|
* console.log(definedNameParam);
|
|
7751
7852
|
* fWorkbook.insertDefinedNameBuilder(definedNameParam);
|
|
@@ -7885,7 +7986,7 @@ let FWorkbook = class FWorkbook extends _univerjs_core_facade.FBaseInitialable {
|
|
|
7885
7986
|
/**
|
|
7886
7987
|
* Create a range theme style.
|
|
7887
7988
|
* @param {string} themeName - The name of the theme to register
|
|
7888
|
-
* @param {Omit<IRangeThemeStyleJSON, 'name'>} themeStyleJson - The theme style json to register
|
|
7989
|
+
* @param {Omit<IRangeThemeStyleJSON, 'name'>} [themeStyleJson] - The theme style json to register
|
|
7889
7990
|
* @returns {RangeThemeStyle} - The created range theme style
|
|
7890
7991
|
* @example
|
|
7891
7992
|
* ```ts
|