@univerjs/sheets 1.0.0-rc.0 → 1.0.0
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-sheet-hooks.d.ts +24 -0
- 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/model/range-protection-render.model.d.ts +33 -0
- package/lib/types/model/range-protection-rule.model.d.ts +75 -0
- package/lib/types/model/range-protection.cache.d.ts +55 -0
- package/lib/types/model/range-theme-model.d.ts +102 -0
- package/lib/types/model/range-theme-util.d.ts +113 -0
- package/lib/types/model/range-themes/build-in-theme.factory.d.ts +20 -0
- package/lib/types/model/range-themes/default.d.ts +18 -0
- package/lib/types/model/zebra-crossing-cache.d.ts +57 -0
- 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
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { ICommand } from '@univerjs/core';
|
|
17
|
+
import { WorksheetHiddenState } from '@univerjs/core';
|
|
17
18
|
export interface ISetWorksheetHiddenCommandParams {
|
|
19
|
+
unitId?: string;
|
|
18
20
|
subUnitId?: string;
|
|
21
|
+
/** Defaults to ordinary hiding; VERY_HIDDEN is available to API callers. */
|
|
22
|
+
hidden?: WorksheetHiddenState;
|
|
19
23
|
}
|
|
20
24
|
export declare const SetWorksheetHideCommand: ICommand;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { IAccessor, ICellData, IMutation, IMutationCommonParams, IObjectMatrixPrimitiveType, IRange, Nullable } from '@univerjs/core';
|
|
16
|
+
import type { IAccessor, ICellData, IMutation, IMutationCommonParams, IObjectMatrixPrimitiveType, IRange, IStyleData, Nullable } from '@univerjs/core';
|
|
17
|
+
import { ObjectMatrix, Styles } from '@univerjs/core';
|
|
17
18
|
/** Params of `SetRangeValuesMutation` */
|
|
18
19
|
export interface ISetRangeValuesMutationParams extends IMutationCommonParams {
|
|
19
20
|
subUnitId: string;
|
|
@@ -31,6 +32,16 @@ export interface ISetRangeValuesMutationParams extends IMutationCommonParams {
|
|
|
31
32
|
export interface ISetRangeValuesRangeMutationParams extends ISetRangeValuesMutationParams {
|
|
32
33
|
range: IRange[];
|
|
33
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Read-only native value preparation for caller-owned atomic model staging. The resulting style IDs
|
|
37
|
+
* must travel with the prepared cells; replay installs them and must not allocate replacement IDs.
|
|
38
|
+
* This does not execute handlers, publish notifications, or own style garbage collection.
|
|
39
|
+
*/
|
|
40
|
+
export declare function prepareSetRangeValuesMutation(cells: ObjectMatrix<Nullable<ICellData>>, styles: Styles, params: Pick<ISetRangeValuesMutationParams, 'cellValue' | 'isOverrideStyle'>): {
|
|
41
|
+
before: IObjectMatrixPrimitiveType<Nullable<ICellData>>;
|
|
42
|
+
after: IObjectMatrixPrimitiveType<Nullable<ICellData>>;
|
|
43
|
+
styles: Record<string, IStyleData>;
|
|
44
|
+
};
|
|
34
45
|
/**
|
|
35
46
|
* Generate undo mutation of a `SetRangeValuesMutation`
|
|
36
47
|
*
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { BooleanNumber, IAccessor, IMutation } from '@univerjs/core';
|
|
17
|
+
import { WorksheetHiddenState } from '@univerjs/core';
|
|
17
18
|
export interface ISetWorksheetHideMutationParams {
|
|
18
|
-
hidden: BooleanNumber;
|
|
19
|
+
hidden: WorksheetHiddenState | BooleanNumber;
|
|
19
20
|
unitId: string;
|
|
20
21
|
subUnitId: string;
|
|
21
22
|
}
|
|
@@ -44,7 +44,7 @@ export declare class FDefinedNameBuilder {
|
|
|
44
44
|
setName(name: string): FDefinedNameBuilder;
|
|
45
45
|
/**
|
|
46
46
|
* Sets the formula of the defined name builder.
|
|
47
|
-
* @param {string
|
|
47
|
+
* @param {string} formula The formula without the leading `=`; this method prepends it.
|
|
48
48
|
* @returns {FDefinedNameBuilder} The instance of `FDefinedNameBuilder` for method chaining.
|
|
49
49
|
* @example
|
|
50
50
|
* ```ts
|
|
@@ -232,7 +232,7 @@ export declare class FDefinedName extends FBase {
|
|
|
232
232
|
setName(name: string): void;
|
|
233
233
|
/**
|
|
234
234
|
* Sets the formula of the defined name.
|
|
235
|
-
* @param {string} formula The formula
|
|
235
|
+
* @param {string} formula The formula without the leading `=`; this method prepends it.
|
|
236
236
|
* @example
|
|
237
237
|
* ```ts
|
|
238
238
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -154,8 +154,8 @@ export declare class FRange extends FBaseInitialable {
|
|
|
154
154
|
*/
|
|
155
155
|
getLastColumn(): number;
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
158
|
-
* @returns {number} The
|
|
157
|
+
* Returns the number of columns in this range.
|
|
158
|
+
* @returns {number} The column count, not a size in pixels.
|
|
159
159
|
* @example
|
|
160
160
|
* ```ts
|
|
161
161
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -167,8 +167,8 @@ export declare class FRange extends FBaseInitialable {
|
|
|
167
167
|
*/
|
|
168
168
|
getWidth(): number;
|
|
169
169
|
/**
|
|
170
|
-
*
|
|
171
|
-
* @returns {number} The
|
|
170
|
+
* Returns the number of rows in this range.
|
|
171
|
+
* @returns {number} The row count, not a size in pixels.
|
|
172
172
|
* @example
|
|
173
173
|
* ```ts
|
|
174
174
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -180,8 +180,8 @@ export declare class FRange extends FBaseInitialable {
|
|
|
180
180
|
*/
|
|
181
181
|
getHeight(): number;
|
|
182
182
|
/**
|
|
183
|
-
*
|
|
184
|
-
* @returns {boolean}
|
|
183
|
+
* Checks whether this range exactly matches a merged cell range.
|
|
184
|
+
* @returns {boolean} `true` only for an exact merged range match. Use `isPartOfMerge()` to check overlap.
|
|
185
185
|
* @example
|
|
186
186
|
* ```ts
|
|
187
187
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -199,7 +199,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
199
199
|
* Return first cell style data in this range. Please note that if there are row styles, col styles and (or)
|
|
200
200
|
* worksheet style, they will be merged into the cell style. You can use `type` to specify the type of the style to get.
|
|
201
201
|
*
|
|
202
|
-
* @param {GetStyleType} type - The type of the style to get. 'row' means get the composed style of row, col and
|
|
202
|
+
* @param {GetStyleType} [type] - The type of the style to get. 'row' means get the composed style of row, col and
|
|
203
203
|
* default worksheet style. 'col' means get the composed style of col, row and default worksheet style.
|
|
204
204
|
* 'cell' means get the style of cell without merging row style, col style and default worksheet style.
|
|
205
205
|
* Default is 'row'.
|
|
@@ -218,7 +218,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
218
218
|
/**
|
|
219
219
|
* Get the font family of the cell.
|
|
220
220
|
*
|
|
221
|
-
* @param {GetStyleType} type - The type of the style to get. 'row' means get the composed style of row, col and
|
|
221
|
+
* @param {GetStyleType} [type] - The type of the style to get. 'row' means get the composed style of row, col and
|
|
222
222
|
* default worksheet style. 'col' means get the composed style of col, row and default worksheet style.
|
|
223
223
|
* 'cell' means get the style of cell without merging row style, col style and default worksheet style.
|
|
224
224
|
* Default is 'row'.
|
|
@@ -237,7 +237,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
237
237
|
/**
|
|
238
238
|
* Get the font size of the cell.
|
|
239
239
|
*
|
|
240
|
-
* @param {GetStyleType} type - The type of the style to get. 'row' means get the composed style of row, col and
|
|
240
|
+
* @param {GetStyleType} [type] - The type of the style to get. 'row' means get the composed style of row, col and
|
|
241
241
|
* default worksheet style. 'col' means get the composed style of col, row and default worksheet style.
|
|
242
242
|
* 'cell' means get the style of cell without merging row style, col style and default worksheet style.
|
|
243
243
|
* Default is 'row'.
|
|
@@ -256,7 +256,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
256
256
|
/**
|
|
257
257
|
* Return first cell style in this range.
|
|
258
258
|
*
|
|
259
|
-
* @param {GetStyleType} type - The type of the style to get. 'row' means get the composed style of row, col and
|
|
259
|
+
* @param {GetStyleType} [type] - The type of the style to get. 'row' means get the composed style of row, col and
|
|
260
260
|
* default worksheet style. 'col' means get the composed style of col, row and default worksheet style.
|
|
261
261
|
* 'cell' means get the style of cell without merging row style, col style and default worksheet style.
|
|
262
262
|
* Default is 'row'.
|
|
@@ -275,7 +275,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
275
275
|
/**
|
|
276
276
|
* Returns the cell styles for the cells in the range.
|
|
277
277
|
*
|
|
278
|
-
* @param {GetStyleType} type - The type of the style to get. 'row' means get the composed style of row, col and
|
|
278
|
+
* @param {GetStyleType} [type] - The type of the style to get. 'row' means get the composed style of row, col and
|
|
279
279
|
* default worksheet style. 'col' means get the composed style of col, row and default worksheet style.
|
|
280
280
|
* 'cell' means get the style of cell without merging row style, col style and default worksheet style.
|
|
281
281
|
* Default is 'row'.
|
|
@@ -310,7 +310,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
310
310
|
getValue(): CellValue | null;
|
|
311
311
|
/**
|
|
312
312
|
* Return first cell value in this range
|
|
313
|
-
* @param {
|
|
313
|
+
* @param {true} includeRichText Pass `true` to return a `RichTextValue` for rich-text content instead of plain text.
|
|
314
314
|
* @returns {CellValue | RichTextValue | null} The cell value
|
|
315
315
|
* @example
|
|
316
316
|
* ```ts
|
|
@@ -388,7 +388,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
388
388
|
getValues(): Nullable<CellValue>[][];
|
|
389
389
|
/**
|
|
390
390
|
* Returns the cell values for the cells in the range.
|
|
391
|
-
* @param {
|
|
391
|
+
* @param {true} includeRichText Pass `true` to return `RichTextValue` entries for rich-text content instead of plain text.
|
|
392
392
|
* @returns {Nullable<RichTextValue | CellValue>[][]} A two-dimensional array of cell values.
|
|
393
393
|
* @example
|
|
394
394
|
* ```ts
|
|
@@ -580,7 +580,10 @@ export declare class FRange extends FBaseInitialable {
|
|
|
580
580
|
* ```
|
|
581
581
|
*/
|
|
582
582
|
getWrap(): boolean;
|
|
583
|
-
/**
|
|
583
|
+
/**
|
|
584
|
+
* Gets whether the top-left cell shrinks its font size to fit the cell width.
|
|
585
|
+
* @returns {boolean} Whether shrink-to-fit is enabled for the top-left cell.
|
|
586
|
+
*/
|
|
584
587
|
getShrinkToFit(): boolean;
|
|
585
588
|
/**
|
|
586
589
|
* Gets whether text wrapping is enabled for cells in the range.
|
|
@@ -592,6 +595,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
592
595
|
* if (!fWorksheet) return;
|
|
593
596
|
* const fRange = fWorksheet.getRange('A1:B2');
|
|
594
597
|
* console.log(fRange.getWraps());
|
|
598
|
+
* ```
|
|
595
599
|
*/
|
|
596
600
|
getWraps(): boolean[][];
|
|
597
601
|
/**
|
|
@@ -608,7 +612,8 @@ export declare class FRange extends FBaseInitialable {
|
|
|
608
612
|
*/
|
|
609
613
|
getWrapStrategy(): WrapStrategy;
|
|
610
614
|
/**
|
|
611
|
-
* Returns the horizontal alignment of the
|
|
615
|
+
* Returns the horizontal alignment of the top-left cell as `left`, `center`, or `normal` (right alignment).
|
|
616
|
+
* Default and other core alignment values return `general`, which is not accepted by `setHorizontalAlignment()`.
|
|
612
617
|
* @returns {string} The horizontal alignment of the text in the cell.
|
|
613
618
|
* @example
|
|
614
619
|
* ```ts
|
|
@@ -621,7 +626,8 @@ export declare class FRange extends FBaseInitialable {
|
|
|
621
626
|
*/
|
|
622
627
|
getHorizontalAlignment(): string;
|
|
623
628
|
/**
|
|
624
|
-
* Returns
|
|
629
|
+
* Returns a two-dimensional array of horizontal alignments: `left`, `center`, or `normal` (right alignment).
|
|
630
|
+
* Default and other core alignment values return `general`, which is not accepted by `setHorizontalAlignment()`.
|
|
625
631
|
* @returns {string[][]} A two-dimensional array of horizontal alignments of text associated with cells in the range.
|
|
626
632
|
* @example
|
|
627
633
|
* ```ts
|
|
@@ -634,7 +640,8 @@ export declare class FRange extends FBaseInitialable {
|
|
|
634
640
|
*/
|
|
635
641
|
getHorizontalAlignments(): string[][];
|
|
636
642
|
/**
|
|
637
|
-
* Returns
|
|
643
|
+
* Returns `top`, `middle`, or `bottom` for the top-left cell; unspecified alignment returns `general`.
|
|
644
|
+
* `general` is a getter result and is not accepted by `setVerticalAlignment()`.
|
|
638
645
|
* @returns {string} The vertical alignment of the text in the cell.
|
|
639
646
|
* @example
|
|
640
647
|
* ```ts
|
|
@@ -647,7 +654,8 @@ export declare class FRange extends FBaseInitialable {
|
|
|
647
654
|
*/
|
|
648
655
|
getVerticalAlignment(): string;
|
|
649
656
|
/**
|
|
650
|
-
* Returns
|
|
657
|
+
* Returns a two-dimensional array of `top`, `middle`, or `bottom` values; unspecified alignment returns `general`.
|
|
658
|
+
* `general` is a getter result and is not accepted by `setVerticalAlignment()`.
|
|
651
659
|
* @returns {string[][]} A two-dimensional array of vertical alignments of text associated with cells in the range.
|
|
652
660
|
* @example
|
|
653
661
|
* ```ts
|
|
@@ -663,6 +671,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
663
671
|
* Set custom meta data for first cell in current range.
|
|
664
672
|
* @param {CustomData} data The custom meta data
|
|
665
673
|
* @returns {FRange} This range, for chaining
|
|
674
|
+
* @example
|
|
666
675
|
* ```ts
|
|
667
676
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
668
677
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
@@ -677,6 +686,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
677
686
|
* Set custom meta data for current range.
|
|
678
687
|
* @param {CustomData[][]} datas The custom meta data
|
|
679
688
|
* @returns {FRange} This range, for chaining
|
|
689
|
+
* @example
|
|
680
690
|
* ```ts
|
|
681
691
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
682
692
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
@@ -694,7 +704,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
694
704
|
* Returns the custom meta data for the cell at the start of this range.
|
|
695
705
|
* @returns {CustomData | null} The custom meta data
|
|
696
706
|
* @example
|
|
697
|
-
* ```
|
|
707
|
+
* ```ts
|
|
698
708
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
699
709
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
700
710
|
* if (!fWorksheet) return;
|
|
@@ -705,9 +715,9 @@ export declare class FRange extends FBaseInitialable {
|
|
|
705
715
|
getCustomMetaData(): CustomData | null;
|
|
706
716
|
/**
|
|
707
717
|
* Returns the custom meta data for the cells in the range.
|
|
708
|
-
* @returns {CustomData[][]} A two-dimensional array of custom
|
|
718
|
+
* @returns {Nullable<CustomData>[][]} A two-dimensional array of custom metadata, with `null` for cells without metadata.
|
|
709
719
|
* @example
|
|
710
|
-
* ```
|
|
720
|
+
* ```ts
|
|
711
721
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
712
722
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
713
723
|
* if (!fWorksheet) return;
|
|
@@ -801,25 +811,64 @@ export declare class FRange extends FBaseInitialable {
|
|
|
801
811
|
*/
|
|
802
812
|
setTextRotation(rotation: number): FRange;
|
|
803
813
|
/**
|
|
804
|
-
* Sets the value
|
|
805
|
-
*
|
|
814
|
+
* Sets the value or specified cell properties for every cell in this range.
|
|
815
|
+
*
|
|
816
|
+
* There are two input modes:
|
|
817
|
+
*
|
|
818
|
+
* - `CellValue` (`number`, `string`, or `boolean`): replaces the cell content. A string starting
|
|
819
|
+
* with `=` and containing at least one more character is written as a formula (`f`), clearing
|
|
820
|
+
* the previous value (`v`) and rich text (`p`). Other values clear the previous formula and
|
|
821
|
+
* rich text. Strings recognized as formatted numbers (for example, percentages, dates, or
|
|
822
|
+
* currencies) are converted to numeric values and apply the parsed number format. Existing
|
|
823
|
+
* formatting is otherwise preserved.
|
|
824
|
+
* - `ICellData`: updates cell-data fields directly, for explicit control over `v` (value),
|
|
825
|
+
* `f` (formula), `p` (rich text), `t` (value type), and `s` (style). The object bypasses the
|
|
826
|
+
* formula and formatted-number parsing above: `{ v: '=SUM(A1:A2)' }` does not set a formula;
|
|
827
|
+
* use `{ f: '=SUM(A1:A2)', v: null, p: null }` instead. Omitted content fields are not
|
|
828
|
+
* automatically cleared, so use `f: null` and `p: null` when replacing a formula or rich text
|
|
829
|
+
* with `v`. Use `v: null` to clear the stored value. Supplied style properties are merged into
|
|
830
|
+
* the existing style; `s: null` clears the style.
|
|
831
|
+
*
|
|
832
|
+
* In both modes, the stored value is converted according to its cell type. Unless an `ICellData`
|
|
833
|
+
* input supplies `t`, the type is inferred from the value, number format, and existing cell type.
|
|
834
|
+
* Consequently, passing `{ v: '00123' }` alone does not guarantee that the value stays a string;
|
|
835
|
+
* supply `t: CellValueType.STRING` to store it as text.
|
|
836
|
+
*
|
|
837
|
+
* @param {CellValue | ICellData} value The scalar content or cell-data update to apply throughout the range.
|
|
806
838
|
* @returns {FRange} This range, for chaining
|
|
839
|
+
* @example
|
|
807
840
|
* ```ts
|
|
808
841
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
809
842
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
810
843
|
* if (!fWorksheet) return;
|
|
811
|
-
* const fRange = fWorksheet.getRange('B2');
|
|
844
|
+
* const fRange = fWorksheet.getRange('B2:B3');
|
|
845
|
+
*
|
|
846
|
+
* // Replace the content of both cells, preserving their formatting.
|
|
812
847
|
* fRange.setValue(123);
|
|
813
848
|
*
|
|
814
|
-
* //
|
|
815
|
-
* fRange.setValue(
|
|
849
|
+
* // Parse a percentage and apply its number format to both cells.
|
|
850
|
+
* fRange.setValue('25%');
|
|
851
|
+
*
|
|
852
|
+
* // Write the same formula to both cells.
|
|
853
|
+
* fRange.setValue('=SUM(A1:A2)');
|
|
854
|
+
*
|
|
855
|
+
* // Explicitly replace content and update the background color.
|
|
856
|
+
* fRange.setValue({ v: 234, f: null, p: null, s: { bg: { rgb: '#ff0000' } } });
|
|
857
|
+
*
|
|
858
|
+
* // Store numeric-looking text (CellValueType is imported from '@univerjs/core').
|
|
859
|
+
* fRange.setValue({ v: '00123', t: CellValueType.STRING, f: null, p: null });
|
|
860
|
+
*
|
|
861
|
+
* // Clear value, formula, and rich text while preserving formatting.
|
|
862
|
+
* fRange.setValue({ v: null, f: null, p: null });
|
|
816
863
|
* ```
|
|
817
864
|
*/
|
|
818
865
|
setValue(value: CellValue | ICellData): FRange;
|
|
819
866
|
/**
|
|
820
|
-
*
|
|
821
|
-
*
|
|
867
|
+
* Sets the value or specified cell properties of the top-left cell in this range.
|
|
868
|
+
* Uses the same scalar parsing and cell-data update rules as {@link FRange.setValue}.
|
|
869
|
+
* @param {CellValue | ICellData} value The scalar content or cell-data update to apply to the top-left cell only.
|
|
822
870
|
* @returns {FRange} This range, for chaining
|
|
871
|
+
* @example
|
|
823
872
|
* ```ts
|
|
824
873
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
825
874
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
@@ -837,7 +886,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
837
886
|
* @param {RichTextValue | IDocumentData} value The rich text value
|
|
838
887
|
* @returns {FRange} The range
|
|
839
888
|
* @example
|
|
840
|
-
* ```
|
|
889
|
+
* ```ts
|
|
841
890
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
842
891
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
843
892
|
* if (!fWorksheet) return;
|
|
@@ -856,7 +905,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
856
905
|
setRichTextValueForCell(value: RichTextValue | IDocumentData): FRange;
|
|
857
906
|
/**
|
|
858
907
|
* Set the rich text value for the cells in the range.
|
|
859
|
-
* @param {RichTextValue[][]} values
|
|
908
|
+
* @param {(RichTextValue | IDocumentData)[][]} values A two-dimensional array of rich-text values or document data matching this range's dimensions.
|
|
860
909
|
* @returns {FRange} The range
|
|
861
910
|
* @example
|
|
862
911
|
* ```ts
|
|
@@ -873,7 +922,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
873
922
|
* .setStyle(6, 7, { bl: 1, cl: { rgb: '#c81e1e' } });
|
|
874
923
|
* fRange.setRichTextValues([
|
|
875
924
|
* [richText, richText],
|
|
876
|
-
* [
|
|
925
|
+
* [richText, richText]
|
|
877
926
|
* ]);
|
|
878
927
|
* console.log(fRange.getValue(true).toPlainText()); // Hello World
|
|
879
928
|
* ```
|
|
@@ -881,7 +930,8 @@ export declare class FRange extends FBaseInitialable {
|
|
|
881
930
|
setRichTextValues(values: (RichTextValue | IDocumentData)[][]): FRange;
|
|
882
931
|
/**
|
|
883
932
|
* Set the cell wrap of the given range.
|
|
884
|
-
*
|
|
933
|
+
* Pass `true` to set `WrapStrategy.WRAP`, or `false` to reset to `WrapStrategy.UNSPECIFIED`.
|
|
934
|
+
* Use `setWrapStrategy()` to explicitly select clipping or overflow behavior.
|
|
885
935
|
* @param {boolean} isWrapEnabled Whether to enable wrap
|
|
886
936
|
* @returns {FRange} this range, for chaining
|
|
887
937
|
* @example
|
|
@@ -895,7 +945,15 @@ export declare class FRange extends FBaseInitialable {
|
|
|
895
945
|
* ```
|
|
896
946
|
*/
|
|
897
947
|
setWrap(isWrapEnabled: boolean): FRange;
|
|
898
|
-
/**
|
|
948
|
+
/**
|
|
949
|
+
* Sets whether cells shrink their font size to fit the cell width.
|
|
950
|
+
* @param {boolean} enabled Whether to enable shrink-to-fit for this range.
|
|
951
|
+
* @returns {FRange} This range, for chaining.
|
|
952
|
+
* @example
|
|
953
|
+
* ```ts
|
|
954
|
+
* univerAPI.getActiveWorkbook()?.getActiveSheet().getRange('A1:B2').setShrinkToFit(true);
|
|
955
|
+
* ```
|
|
956
|
+
*/
|
|
899
957
|
setShrinkToFit(enabled: boolean): FRange;
|
|
900
958
|
/**
|
|
901
959
|
* Sets the text wrapping strategy for the cells in the range.
|
|
@@ -914,7 +972,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
914
972
|
setWrapStrategy(strategy: WrapStrategy): FRange;
|
|
915
973
|
/**
|
|
916
974
|
* Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
|
|
917
|
-
* @param {
|
|
975
|
+
* @param {FVerticalAlignment} alignment The vertical alignment
|
|
918
976
|
* @returns {FRange} this range, for chaining
|
|
919
977
|
* @example
|
|
920
978
|
* ```ts
|
|
@@ -927,8 +985,9 @@ export declare class FRange extends FBaseInitialable {
|
|
|
927
985
|
*/
|
|
928
986
|
setVerticalAlignment(alignment: FVerticalAlignment): FRange;
|
|
929
987
|
/**
|
|
930
|
-
*
|
|
931
|
-
*
|
|
988
|
+
* Sets the horizontal alignment for the range using `left`, `center`, or `normal`.
|
|
989
|
+
* These parameter names follow Google Apps Script. In Univer, `normal` means right alignment; `right` is not accepted.
|
|
990
|
+
* @param {FHorizontalAlignment} alignment The horizontal alignment: `left`, `center`, or `normal` (right alignment).
|
|
932
991
|
* @returns {FRange} this range, for chaining
|
|
933
992
|
* @example
|
|
934
993
|
* ```ts
|
|
@@ -936,13 +995,18 @@ export declare class FRange extends FBaseInitialable {
|
|
|
936
995
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
937
996
|
* if (!fWorksheet) return;
|
|
938
997
|
* const fRange = fWorksheet.getRange('A1:B2');
|
|
939
|
-
* fRange.setHorizontalAlignment('
|
|
998
|
+
* fRange.setHorizontalAlignment('normal'); // Align right
|
|
940
999
|
* ```
|
|
941
1000
|
*/
|
|
942
1001
|
setHorizontalAlignment(alignment: FHorizontalAlignment): FRange;
|
|
943
1002
|
/**
|
|
944
|
-
* Sets
|
|
945
|
-
*
|
|
1003
|
+
* Sets cell values or specified cell properties using an array or a sparse matrix.
|
|
1004
|
+
* Each entry follows the scalar parsing and cell-data update rules of {@link FRange.setValue}.
|
|
1005
|
+
*
|
|
1006
|
+
* A two-dimensional array is relative to this range's top-left cell and must match its dimensions.
|
|
1007
|
+
* A sparse matrix uses absolute, zero-based worksheet row and column keys. Only supplied entries
|
|
1008
|
+
* are updated; matrix coordinates are not offset by or clipped to this range.
|
|
1009
|
+
* @param {CellValue[][] | IObjectMatrixPrimitiveType<CellValue> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>} value An array relative to this range, or a sparse matrix using absolute worksheet coordinates.
|
|
946
1010
|
* @returns {FRange} This range, for chaining
|
|
947
1011
|
* @example
|
|
948
1012
|
* ```ts
|
|
@@ -954,6 +1018,12 @@ export declare class FRange extends FBaseInitialable {
|
|
|
954
1018
|
* [1, { v: 2, s: { bg: { rgb: '#ff0000' } } }],
|
|
955
1019
|
* [3, 4]
|
|
956
1020
|
* ]);
|
|
1021
|
+
*
|
|
1022
|
+
* // Update only B2 and C3 using absolute worksheet coordinates.
|
|
1023
|
+
* fWorksheet.getRange('B2:C3').setValues({
|
|
1024
|
+
* 1: { 1: 'B2' },
|
|
1025
|
+
* 2: { 2: { v: 10, f: null, p: null } },
|
|
1026
|
+
* });
|
|
957
1027
|
* ```
|
|
958
1028
|
*/
|
|
959
1029
|
setValues(value: CellValue[][] | IObjectMatrixPrimitiveType<CellValue> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>): FRange;
|
|
@@ -1179,6 +1249,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
1179
1249
|
* @param {number} callback.row the row number of the cell
|
|
1180
1250
|
* @param {number} callback.col the column number of the cell
|
|
1181
1251
|
* @param {ICellData} callback.cell the cell data
|
|
1252
|
+
* @example
|
|
1182
1253
|
* ```ts
|
|
1183
1254
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1184
1255
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
@@ -1196,6 +1267,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
1196
1267
|
* @param {AbsoluteRefType} [startAbsoluteRefType] - The absolute reference type for the start cell.
|
|
1197
1268
|
* @param {AbsoluteRefType} [endAbsoluteRefType] - The absolute reference type for the end cell.
|
|
1198
1269
|
* @returns {string} The A1 notation of the range.
|
|
1270
|
+
* @example
|
|
1199
1271
|
* ```ts
|
|
1200
1272
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1201
1273
|
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
@@ -1382,11 +1454,12 @@ export declare class FRange extends FBaseInitialable {
|
|
|
1382
1454
|
*/
|
|
1383
1455
|
getUsedThemeStyle(): string | undefined;
|
|
1384
1456
|
/**
|
|
1385
|
-
* Clears content and formatting
|
|
1457
|
+
* Clears the range content and formatting, or only one of them as specified by the options.
|
|
1458
|
+
* Both content and formatting are cleared when both flags are true or both are false.
|
|
1386
1459
|
* @param {IFacadeClearOptions} [options] - Options for clearing the range. If not provided, the contents and formatting are cleared both.
|
|
1387
|
-
* @param {boolean} [options.contentsOnly] - If true, the contents of the range are cleared.
|
|
1388
|
-
* @param {boolean} [options.formatOnly] -
|
|
1389
|
-
* @returns {
|
|
1460
|
+
* @param {boolean} [options.contentsOnly] - If true, the contents of the range are cleared. Effective only when `formatOnly` is false. Defaults to false.
|
|
1461
|
+
* @param {boolean} [options.formatOnly] - Clears only formatting when true and `contentsOnly` is false. Defaults to false.
|
|
1462
|
+
* @returns {FRange} This range, for chaining.
|
|
1390
1463
|
* @example
|
|
1391
1464
|
* ```ts
|
|
1392
1465
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1404,7 +1477,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
1404
1477
|
clear(options?: IFacadeClearOptions): FRange;
|
|
1405
1478
|
/**
|
|
1406
1479
|
* Clears content of the range, while preserving formatting information.
|
|
1407
|
-
* @returns {
|
|
1480
|
+
* @returns {FRange} This range, for chaining.
|
|
1408
1481
|
* @example
|
|
1409
1482
|
* ```typescript
|
|
1410
1483
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -1419,7 +1492,7 @@ export declare class FRange extends FBaseInitialable {
|
|
|
1419
1492
|
clearContent(): FRange;
|
|
1420
1493
|
/**
|
|
1421
1494
|
* Clears formatting information of the range, while preserving contents.
|
|
1422
|
-
* @returns {
|
|
1495
|
+
* @returns {FRange} This range, for chaining.
|
|
1423
1496
|
* @example
|
|
1424
1497
|
* ```typescript
|
|
1425
1498
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -71,7 +71,7 @@ export declare class FSelection {
|
|
|
71
71
|
getActiveRangeList(): FRange[];
|
|
72
72
|
/**
|
|
73
73
|
* Represents the current select cell in the sheet.
|
|
74
|
-
* @returns {ISelectionCell} The
|
|
74
|
+
* @returns {Nullable<ISelectionCell>} The primary cell of the current selection, or `null` when none exists.
|
|
75
75
|
* @example
|
|
76
76
|
* ```ts
|
|
77
77
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Injector } from '@univerjs/core';
|
|
17
|
+
import { FBase } from '@univerjs/core/facade';
|
|
18
|
+
/**
|
|
19
|
+
* @hideconstructor
|
|
20
|
+
*/
|
|
21
|
+
export declare class FSheetHooks extends FBase {
|
|
22
|
+
protected readonly _injector: Injector;
|
|
23
|
+
constructor(_injector: Injector);
|
|
24
|
+
}
|
|
@@ -24,7 +24,7 @@ export interface IFUniverSheetsMixin {
|
|
|
24
24
|
/**
|
|
25
25
|
* Create a new spreadsheet and get the API handler of that spreadsheet.
|
|
26
26
|
* @param {Partial<IWorkbookData>} data The snapshot of the spreadsheet.
|
|
27
|
-
* @param {ICreateUnitOptions} options The options of creating the spreadsheet.
|
|
27
|
+
* @param {ICreateUnitOptions} [options] The options of creating the spreadsheet.
|
|
28
28
|
* @returns {FWorkbook} The spreadsheet API instance.
|
|
29
29
|
* @example
|
|
30
30
|
* ```ts
|
|
@@ -63,13 +63,12 @@ export interface IFUniverSheetsMixin {
|
|
|
63
63
|
getWorkbook(id: string): FWorkbook | null;
|
|
64
64
|
/**
|
|
65
65
|
* Get the target of the sheet.
|
|
66
|
-
* @param {
|
|
67
|
-
* @returns {
|
|
66
|
+
* @param {{ unitId?: string; subUnitId?: string; sheetId?: string }} [params] Target IDs from the command parameters. Omitted IDs use the current workbook and active sheet.
|
|
67
|
+
* @returns {{ workbook: FWorkbook; worksheet: FWorksheet; unitId: string; subUnitId: string } | null} The resolved workbook, worksheet, and their IDs, or `null` if the target cannot be resolved.
|
|
68
68
|
* @example
|
|
69
69
|
* ```ts
|
|
70
70
|
* univerAPI.addEvent(univerAPI.Event.CommandExecuted, (event) => {
|
|
71
|
-
* const
|
|
72
|
-
* const target = univerAPI.getSheetCommandTarget(commandInfo.params);
|
|
71
|
+
* const target = univerAPI.getSheetCommandTarget(event.params);
|
|
73
72
|
* if (!target) return;
|
|
74
73
|
* const { workbook, worksheet } = target;
|
|
75
74
|
* console.log(workbook, worksheet);
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
import type { CommandListener, CustomData, IDisposable, IRange, IStyleData, IWorkbookData, IWorksheetData, Workbook } from '@univerjs/core';
|
|
17
17
|
import type { ISetDefinedNameMutationParam } from '@univerjs/engine-formula';
|
|
18
18
|
import type { IRangeThemeStyleJSON } from '@univerjs/sheets';
|
|
19
|
-
import type { FontLine as _FontLine } from './f-range';
|
|
20
19
|
import { ICommandService, ILogService, Injector, IPermissionService, IResourceLoaderService, IUniverInstanceService } from '@univerjs/core';
|
|
21
20
|
import { FBaseInitialable } from '@univerjs/core/facade';
|
|
22
21
|
import { IDefinedNamesService } from '@univerjs/engine-formula';
|
|
@@ -39,6 +38,9 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
39
38
|
protected readonly _permissionService: IPermissionService;
|
|
40
39
|
protected readonly _logService: ILogService;
|
|
41
40
|
protected readonly _definedNamesService: IDefinedNamesService;
|
|
41
|
+
/**
|
|
42
|
+
* The workbook unit id used to identify this workbook in commands and snapshots.
|
|
43
|
+
*/
|
|
42
44
|
readonly id: string;
|
|
43
45
|
constructor(_workbook: Workbook, _injector: Injector, _resourceLoaderService: IResourceLoaderService, _selectionManagerService: SheetsSelectionsService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _permissionService: IPermissionService, _logService: ILogService, _definedNamesService: IDefinedNamesService);
|
|
44
46
|
/**
|
|
@@ -53,6 +55,7 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
53
55
|
* ```
|
|
54
56
|
*/
|
|
55
57
|
getWorkbook(): Workbook;
|
|
58
|
+
/** Releases this facade's resources. Use `univerAPI.disposeUnit()` to unload the owning unit. */
|
|
56
59
|
dispose(): void;
|
|
57
60
|
/**
|
|
58
61
|
* Get the id of the workbook.
|
|
@@ -267,7 +270,7 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
267
270
|
deleteSheet(sheet: FWorksheet | string): boolean;
|
|
268
271
|
/**
|
|
269
272
|
* Undo the last action.
|
|
270
|
-
* @returns {FWorkbook}
|
|
273
|
+
* @returns {FWorkbook} This workbook, for chaining.
|
|
271
274
|
* @example
|
|
272
275
|
* ```ts
|
|
273
276
|
* // The code below undoes the last action
|
|
@@ -278,7 +281,7 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
278
281
|
undo(): FWorkbook;
|
|
279
282
|
/**
|
|
280
283
|
* Redo the last undone action.
|
|
281
|
-
* @returns {FWorkbook}
|
|
284
|
+
* @returns {FWorkbook} This workbook, for chaining.
|
|
282
285
|
* @example
|
|
283
286
|
* ```ts
|
|
284
287
|
* // The code below redoes the last undone action
|
|
@@ -537,7 +540,7 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
537
540
|
* const definedNameParam = fWorkbook.newDefinedNameBuilder()
|
|
538
541
|
* .setRef('Sheet1!$A$1')
|
|
539
542
|
* .setName('MyDefinedName')
|
|
540
|
-
* .setComment('This is a comment')
|
|
543
|
+
* .setComment('This is a comment')
|
|
541
544
|
* .build();
|
|
542
545
|
* console.log(definedNameParam);
|
|
543
546
|
* fWorkbook.insertDefinedNameBuilder(definedNameParam);
|
|
@@ -648,7 +651,7 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
648
651
|
/**
|
|
649
652
|
* Create a range theme style.
|
|
650
653
|
* @param {string} themeName - The name of the theme to register
|
|
651
|
-
* @param {Omit<IRangeThemeStyleJSON, 'name'>} themeStyleJson - The theme style json to register
|
|
654
|
+
* @param {Omit<IRangeThemeStyleJSON, 'name'>} [themeStyleJson] - The theme style json to register
|
|
652
655
|
* @returns {RangeThemeStyle} - The created range theme style
|
|
653
656
|
* @example
|
|
654
657
|
* ```ts
|
|
@@ -761,11 +764,3 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
761
764
|
*/
|
|
762
765
|
removeStyles(styleKeys: string[]): void;
|
|
763
766
|
}
|
|
764
|
-
/**
|
|
765
|
-
* @ignore
|
|
766
|
-
*/
|
|
767
|
-
export declare namespace FWorkbook {
|
|
768
|
-
type FontLine = _FontLine;
|
|
769
|
-
type FontStyle = _FontLine;
|
|
770
|
-
type FontWeight = _FontLine;
|
|
771
|
-
}
|