@univerjs/sheets 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +3 -3
- package/lib/es/facade.js +1490 -683
- package/lib/es/index.js +2325 -2222
- package/lib/types/basics/interfaces/selection-config.d.ts +4 -0
- package/lib/types/basics/utils.d.ts +4 -1
- package/lib/types/commands/commands/append-row.command.d.ts +17 -0
- package/lib/types/commands/commands/set-style.command.d.ts +1 -1
- package/lib/types/commands/operations/selection.operation.d.ts +10 -1
- package/lib/types/facade/f-range.d.ts +547 -15
- package/lib/types/facade/f-workbook.d.ts +10 -0
- package/lib/types/facade/f-worksheet.d.ts +84 -7
- package/lib/types/facade/utils.d.ts +36 -27
- package/lib/types/index.d.ts +3 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +3 -3
- package/package.json +8 -8
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { BorderStyleTypes, BorderType, CellValue, CustomData, ICellData, IDocumentData, IObjectMatrixPrimitiveType, IRange, IStyleData, Nullable, Workbook, Worksheet, ICommandService, Injector, RichTextValue, TextStyleValue, WrapStrategy } from '@univerjs/core';
|
|
1
|
+
import { BorderStyleTypes, BorderType, CellValue, CustomData, ICellData, IDocumentData, IObjectMatrixPrimitiveType, IRange, IStyleData, Nullable, Workbook, Worksheet, Dimension, ICommandService, Injector, RichTextValue, TextStyleValue, WrapStrategy } from '@univerjs/core';
|
|
2
2
|
import { SplitDelimiterEnum } from '@univerjs/sheets';
|
|
3
|
+
import { IFacadeClearOptions } from './f-worksheet';
|
|
3
4
|
import { FHorizontalAlignment, FVerticalAlignment } from './utils';
|
|
4
5
|
import { FBaseInitialable } from '@univerjs/core/facade';
|
|
5
6
|
import { FormulaDataModel } from '@univerjs/engine-formula';
|
|
@@ -71,29 +72,53 @@ export declare class FRange extends FBaseInitialable {
|
|
|
71
72
|
*/
|
|
72
73
|
getRange(): IRange;
|
|
73
74
|
/**
|
|
74
|
-
* Gets the starting row
|
|
75
|
-
* @returns {number} The starting row
|
|
75
|
+
* Gets the starting row index of the range. index starts at 0.
|
|
76
|
+
* @returns {number} The starting row index of the range.
|
|
76
77
|
* @example
|
|
77
78
|
* ```ts
|
|
78
79
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
79
80
|
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
80
81
|
* const fRange = fWorksheet.getRange('A1:B2');
|
|
81
|
-
* console.log(fRange.getRow());
|
|
82
|
+
* console.log(fRange.getRow()); // 0
|
|
82
83
|
* ```
|
|
83
84
|
*/
|
|
84
85
|
getRow(): number;
|
|
85
86
|
/**
|
|
86
|
-
* Gets the
|
|
87
|
-
* @returns {number} The
|
|
87
|
+
* Gets the ending row index of the range. index starts at 0.
|
|
88
|
+
* @returns {number} The ending row index of the range.
|
|
88
89
|
* @example
|
|
89
90
|
* ```ts
|
|
90
91
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
91
92
|
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
92
93
|
* const fRange = fWorksheet.getRange('A1:B2');
|
|
93
|
-
* console.log(fRange.
|
|
94
|
+
* console.log(fRange.getLastRow()); // 1
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
getLastRow(): number;
|
|
98
|
+
/**
|
|
99
|
+
* Gets the starting column index of the range. index starts at 0.
|
|
100
|
+
* @returns {number} The starting column index of the range.
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
104
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
105
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
106
|
+
* console.log(fRange.getColumn()); // 0
|
|
94
107
|
* ```
|
|
95
108
|
*/
|
|
96
109
|
getColumn(): number;
|
|
110
|
+
/**
|
|
111
|
+
* Gets the ending column index of the range. index starts at 0.
|
|
112
|
+
* @returns {number} The ending column index of the range.
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
116
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
117
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
118
|
+
* console.log(fRange.getLastColumn()); // 1
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
getLastColumn(): number;
|
|
97
122
|
/**
|
|
98
123
|
* Gets the width of the applied area
|
|
99
124
|
* @returns {number} The width of the area
|
|
@@ -205,6 +230,46 @@ export declare class FRange extends FBaseInitialable {
|
|
|
205
230
|
* ```
|
|
206
231
|
*/
|
|
207
232
|
getValue(includeRichText: true): Nullable<CellValue | RichTextValue>;
|
|
233
|
+
/**
|
|
234
|
+
* Returns the raw value of the top-left cell in the range. Empty cells return `null`.
|
|
235
|
+
* @returns {Nullable<CellValue>} The raw value of the cell. Returns `null` if the cell is empty.
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
239
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
240
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
241
|
+
* fRange.setValueForCell({
|
|
242
|
+
* v: 0.2,
|
|
243
|
+
* s: {
|
|
244
|
+
* n: {
|
|
245
|
+
* pattern: '0%',
|
|
246
|
+
* },
|
|
247
|
+
* },
|
|
248
|
+
* });
|
|
249
|
+
* console.log(fRange.getRawValue()); // 0.2
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
getRawValue(): Nullable<CellValue>;
|
|
253
|
+
/**
|
|
254
|
+
* Returns the displayed value of the top-left cell in the range. The value is a String. Empty cells return an empty string.
|
|
255
|
+
* @returns {string} The displayed value of the cell. Returns an empty string if the cell is empty.
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
259
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
260
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
261
|
+
* fRange.setValueForCell({
|
|
262
|
+
* v: 0.2,
|
|
263
|
+
* s: {
|
|
264
|
+
* n: {
|
|
265
|
+
* pattern: '0%',
|
|
266
|
+
* },
|
|
267
|
+
* },
|
|
268
|
+
* });
|
|
269
|
+
* console.log(fRange.getDisplayValue()); // 20%
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
getDisplayValue(): string;
|
|
208
273
|
/**
|
|
209
274
|
* Returns the cell values for the cells in the range.
|
|
210
275
|
* @returns {Nullable<CellValue>[][]} A two-dimensional array of cell values.
|
|
@@ -232,6 +297,92 @@ export declare class FRange extends FBaseInitialable {
|
|
|
232
297
|
* ```
|
|
233
298
|
*/
|
|
234
299
|
getValues(includeRichText: true): (Nullable<RichTextValue | CellValue>)[][];
|
|
300
|
+
/**
|
|
301
|
+
* Returns a two-dimensional array of the range raw values. Empty cells return `null`.
|
|
302
|
+
* @returns {Array<Array<Nullable<CellValue>>>} The raw value of the cell. Returns `null` if the cell is empty.
|
|
303
|
+
* @example
|
|
304
|
+
* ```ts
|
|
305
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
306
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
307
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
308
|
+
* fRange.setValues([
|
|
309
|
+
* [
|
|
310
|
+
* {
|
|
311
|
+
* v: 0.2,
|
|
312
|
+
* s: {
|
|
313
|
+
* n: {
|
|
314
|
+
* pattern: '0%',
|
|
315
|
+
* },
|
|
316
|
+
* },
|
|
317
|
+
* },
|
|
318
|
+
* {
|
|
319
|
+
* v: 45658,
|
|
320
|
+
* s: {
|
|
321
|
+
* n: {
|
|
322
|
+
* pattern: 'yyyy-mm-dd',
|
|
323
|
+
* },
|
|
324
|
+
* },
|
|
325
|
+
* }
|
|
326
|
+
* ],
|
|
327
|
+
* [
|
|
328
|
+
* {
|
|
329
|
+
* v: 1234.567,
|
|
330
|
+
* s: {
|
|
331
|
+
* n: {
|
|
332
|
+
* pattern: '#,##0.00',
|
|
333
|
+
* }
|
|
334
|
+
* }
|
|
335
|
+
* },
|
|
336
|
+
* null,
|
|
337
|
+
* ],
|
|
338
|
+
* ]);
|
|
339
|
+
* console.log(fRange.getRawValues()); // [[0.2, 45658], [1234.567, null]]
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
getRawValues(): Array<Array<Nullable<CellValue>>>;
|
|
343
|
+
/**
|
|
344
|
+
* Returns a two-dimensional array of the range displayed values. Empty cells return an empty string.
|
|
345
|
+
* @returns {string[][]} A two-dimensional array of values.
|
|
346
|
+
* @example
|
|
347
|
+
* ```ts
|
|
348
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
349
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
350
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
351
|
+
* fRange.setValues([
|
|
352
|
+
* [
|
|
353
|
+
* {
|
|
354
|
+
* v: 0.2,
|
|
355
|
+
* s: {
|
|
356
|
+
* n: {
|
|
357
|
+
* pattern: '0%',
|
|
358
|
+
* },
|
|
359
|
+
* },
|
|
360
|
+
* },
|
|
361
|
+
* {
|
|
362
|
+
* v: 45658,
|
|
363
|
+
* s: {
|
|
364
|
+
* n: {
|
|
365
|
+
* pattern: 'yyyy-mm-dd',
|
|
366
|
+
* },
|
|
367
|
+
* },
|
|
368
|
+
* }
|
|
369
|
+
* ],
|
|
370
|
+
* [
|
|
371
|
+
* {
|
|
372
|
+
* v: 1234.567,
|
|
373
|
+
* s: {
|
|
374
|
+
* n: {
|
|
375
|
+
* pattern: '#,##0.00',
|
|
376
|
+
* }
|
|
377
|
+
* }
|
|
378
|
+
* },
|
|
379
|
+
* null,
|
|
380
|
+
* ],
|
|
381
|
+
* ]);
|
|
382
|
+
* console.log(fRange.getDisplayValues()); // [['20%', '2025-01-01'], ['1,234.57', '']]
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
getDisplayValues(): string[][];
|
|
235
386
|
/**
|
|
236
387
|
* Return first cell model data in this range
|
|
237
388
|
* @returns {ICellData | null} The cell model data
|
|
@@ -322,6 +473,18 @@ export declare class FRange extends FBaseInitialable {
|
|
|
322
473
|
* ```
|
|
323
474
|
*/
|
|
324
475
|
getValueAndRichTextValues(): Nullable<CellValue | RichTextValue>[][];
|
|
476
|
+
/**
|
|
477
|
+
* Returns the formula (A1 notation) of the top-left cell in the range, or an empty string if the cell is empty or doesn't contain a formula.
|
|
478
|
+
* @returns {string} The formula for the cell.
|
|
479
|
+
* @example
|
|
480
|
+
* ```ts
|
|
481
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
482
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
483
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
484
|
+
* console.log(fRange.getFormula());
|
|
485
|
+
* ```
|
|
486
|
+
*/
|
|
487
|
+
getFormula(): string;
|
|
325
488
|
/**
|
|
326
489
|
* Returns the formulas (A1 notation) for the cells in the range. Entries in the 2D array are empty strings for cells with no formula.
|
|
327
490
|
* @returns {string[][]} A two-dimensional array of formulas in string format.
|
|
@@ -335,8 +498,8 @@ export declare class FRange extends FBaseInitialable {
|
|
|
335
498
|
*/
|
|
336
499
|
getFormulas(): string[][];
|
|
337
500
|
/**
|
|
338
|
-
*
|
|
339
|
-
* @returns {boolean}
|
|
501
|
+
* Gets whether text wrapping is enabled for top-left cell in the range.
|
|
502
|
+
* @returns {boolean} whether text wrapping is enabled for the cell.
|
|
340
503
|
* @example
|
|
341
504
|
* ```ts
|
|
342
505
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -346,6 +509,17 @@ export declare class FRange extends FBaseInitialable {
|
|
|
346
509
|
* ```
|
|
347
510
|
*/
|
|
348
511
|
getWrap(): boolean;
|
|
512
|
+
/**
|
|
513
|
+
* Gets whether text wrapping is enabled for cells in the range.
|
|
514
|
+
* @returns {boolean[][]} A two-dimensional array of whether text wrapping is enabled for each cell in the range.
|
|
515
|
+
* @example
|
|
516
|
+
* ```ts
|
|
517
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
518
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
519
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
520
|
+
* console.log(fRange.getWraps());
|
|
521
|
+
*/
|
|
522
|
+
getWraps(): boolean[][];
|
|
349
523
|
/**
|
|
350
524
|
* Returns the text wrapping strategy for the top left cell of the range.
|
|
351
525
|
* @returns {WrapStrategy} The text wrapping strategy
|
|
@@ -359,8 +533,8 @@ export declare class FRange extends FBaseInitialable {
|
|
|
359
533
|
*/
|
|
360
534
|
getWrapStrategy(): WrapStrategy;
|
|
361
535
|
/**
|
|
362
|
-
* Returns the horizontal alignment
|
|
363
|
-
* @returns {string} The horizontal alignment
|
|
536
|
+
* Returns the horizontal alignment of the text (left/center/right) of the top-left cell in the range.
|
|
537
|
+
* @returns {string} The horizontal alignment of the text in the cell.
|
|
364
538
|
* @example
|
|
365
539
|
* ```ts
|
|
366
540
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -371,8 +545,20 @@ export declare class FRange extends FBaseInitialable {
|
|
|
371
545
|
*/
|
|
372
546
|
getHorizontalAlignment(): string;
|
|
373
547
|
/**
|
|
374
|
-
* Returns the
|
|
375
|
-
* @returns {string}
|
|
548
|
+
* Returns the horizontal alignments of the cells in the range.
|
|
549
|
+
* @returns {string[][]} A two-dimensional array of horizontal alignments of text associated with cells in the range.
|
|
550
|
+
* @example
|
|
551
|
+
* ```ts
|
|
552
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
553
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
554
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
555
|
+
* console.log(fRange.getHorizontalAlignments());
|
|
556
|
+
* ```
|
|
557
|
+
*/
|
|
558
|
+
getHorizontalAlignments(): string[][];
|
|
559
|
+
/**
|
|
560
|
+
* Returns the vertical alignment (top/middle/bottom) of the top-left cell in the range.
|
|
561
|
+
* @returns {string} The vertical alignment of the text in the cell.
|
|
376
562
|
* @example
|
|
377
563
|
* ```ts
|
|
378
564
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -382,6 +568,18 @@ export declare class FRange extends FBaseInitialable {
|
|
|
382
568
|
* ```
|
|
383
569
|
*/
|
|
384
570
|
getVerticalAlignment(): string;
|
|
571
|
+
/**
|
|
572
|
+
* Returns the vertical alignments of the cells in the range.
|
|
573
|
+
* @returns {string[][]} A two-dimensional array of vertical alignments of text associated with cells in the range.
|
|
574
|
+
* @example
|
|
575
|
+
* ```ts
|
|
576
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
577
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
578
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
579
|
+
* console.log(fRange.getVerticalAlignments());
|
|
580
|
+
* ```
|
|
581
|
+
*/
|
|
582
|
+
getVerticalAlignments(): string[][];
|
|
385
583
|
/**
|
|
386
584
|
* Set custom meta data for first cell in current range.
|
|
387
585
|
* @param {CustomData} data The custom meta data
|
|
@@ -450,6 +648,30 @@ export declare class FRange extends FBaseInitialable {
|
|
|
450
648
|
* ```
|
|
451
649
|
*/
|
|
452
650
|
setBorder(type: BorderType, style: BorderStyleTypes, color?: string): FRange;
|
|
651
|
+
/**
|
|
652
|
+
* Returns the background color of the top-left cell in the range.
|
|
653
|
+
* @returns {string} The color code of the background.
|
|
654
|
+
* @example
|
|
655
|
+
* ```ts
|
|
656
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
657
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
658
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
659
|
+
* console.log(fRange.getBackground());
|
|
660
|
+
* ```
|
|
661
|
+
*/
|
|
662
|
+
getBackground(): string;
|
|
663
|
+
/**
|
|
664
|
+
* Returns the background colors of the cells in the range.
|
|
665
|
+
* @returns {string[][]} A two-dimensional array of color codes of the backgrounds.
|
|
666
|
+
* @example
|
|
667
|
+
* ```ts
|
|
668
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
669
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
670
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
671
|
+
* console.log(fRange.getBackgrounds());
|
|
672
|
+
* ```
|
|
673
|
+
*/
|
|
674
|
+
getBackgrounds(): string[][];
|
|
453
675
|
/**
|
|
454
676
|
* Set background color for current range.
|
|
455
677
|
* @param {string} color The background color
|
|
@@ -476,6 +698,19 @@ export declare class FRange extends FBaseInitialable {
|
|
|
476
698
|
* ```
|
|
477
699
|
*/
|
|
478
700
|
setBackground(color: string): FRange;
|
|
701
|
+
/**
|
|
702
|
+
* Set rotation for text in current range.
|
|
703
|
+
* @param {number} rotation - The rotation angle in degrees
|
|
704
|
+
* @returns This range, for chaining
|
|
705
|
+
* @example
|
|
706
|
+
* ```typescript
|
|
707
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
708
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
709
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
710
|
+
* fRange.setTextRotation(45);
|
|
711
|
+
* ```
|
|
712
|
+
*/
|
|
713
|
+
setTextRotation(rotation: number): FRange;
|
|
479
714
|
/**
|
|
480
715
|
* Sets the value of the range.
|
|
481
716
|
* @param {CellValue | ICellData} value The value can be a number, string, boolean, or standard cell format. If it begins with `=`, it is interpreted as a formula. The value is tiled to all cells in the range.
|
|
@@ -842,11 +1077,26 @@ export declare class FRange extends FBaseInitialable {
|
|
|
842
1077
|
* ```ts
|
|
843
1078
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
844
1079
|
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1080
|
+
*
|
|
1081
|
+
* // Set the range A1:B2 as the active range, default active cell is A1
|
|
845
1082
|
* const fRange = fWorksheet.getRange('A1:B2');
|
|
846
1083
|
* fRange.activate();
|
|
1084
|
+
* console.log(fWorksheet.getActiveRange().getA1Notation()); // A1:B2
|
|
1085
|
+
* console.log(fWorksheet.getActiveCell().getA1Notation()); // A1
|
|
1086
|
+
*
|
|
1087
|
+
* // Set the cell B2 as the active cell
|
|
1088
|
+
* // Because B2 is in the active range A1:B2, the active range will not change, and the active cell will be changed to B2
|
|
847
1089
|
* const cell = fWorksheet.getRange('B2');
|
|
848
|
-
* cell.activateAsCurrentCell();
|
|
849
|
-
* console.log(fWorksheet.getActiveRange().getA1Notation()); // B2
|
|
1090
|
+
* cell.activateAsCurrentCell();
|
|
1091
|
+
* console.log(fWorksheet.getActiveRange().getA1Notation()); // A1:B2
|
|
1092
|
+
* console.log(fWorksheet.getActiveCell().getA1Notation()); // B2
|
|
1093
|
+
*
|
|
1094
|
+
* // Set the cell C3 as the active cell
|
|
1095
|
+
* // Because C3 is not in the active range A1:B2, a new active range C3:C3 will be created, and the active cell will be changed to C3
|
|
1096
|
+
* const cell2 = fWorksheet.getRange('C3');
|
|
1097
|
+
* cell2.activateAsCurrentCell();
|
|
1098
|
+
* console.log(fWorksheet.getActiveRange().getA1Notation()); // C3:C3
|
|
1099
|
+
* console.log(fWorksheet.getActiveCell().getA1Notation()); // C3
|
|
850
1100
|
* ```
|
|
851
1101
|
*/
|
|
852
1102
|
activateAsCurrentCell(): FRange;
|
|
@@ -955,4 +1205,286 @@ export declare class FRange extends FBaseInitialable {
|
|
|
955
1205
|
* ```
|
|
956
1206
|
*/
|
|
957
1207
|
getUsedThemeStyle(): string | undefined;
|
|
1208
|
+
/**
|
|
1209
|
+
* Clears content and formatting information of the range. Or Optionally clears only the contents or only the formatting.
|
|
1210
|
+
* @param {IFacadeClearOptions} [options] - Options for clearing the range. If not provided, the contents and formatting are cleared both.
|
|
1211
|
+
* @param {boolean} [options.contentsOnly] - If true, the contents of the range are cleared. If false, the contents and formatting are cleared. Default is false.
|
|
1212
|
+
* @param {boolean} [options.formatOnly] - If true, the formatting of the range is cleared. If false, the contents and formatting are cleared. Default is false.
|
|
1213
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
1214
|
+
* @example
|
|
1215
|
+
* ```ts
|
|
1216
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1217
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
1218
|
+
* const fRange = fWorkSheet.getRange('A1:D10');
|
|
1219
|
+
*
|
|
1220
|
+
* // clear the content and format of the range A1:D10
|
|
1221
|
+
* fRange.clear();
|
|
1222
|
+
*
|
|
1223
|
+
* // clear the content only of the range A1:D10
|
|
1224
|
+
* fRange.clear({ contentsOnly: true });
|
|
1225
|
+
* ```
|
|
1226
|
+
*/
|
|
1227
|
+
clear(options?: IFacadeClearOptions): FRange;
|
|
1228
|
+
/**
|
|
1229
|
+
* Clears content of the range, while preserving formatting information.
|
|
1230
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
1231
|
+
* @example
|
|
1232
|
+
* ```typescript
|
|
1233
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1234
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
1235
|
+
* const fRange = fWorkSheet.getRange('A1:D10');
|
|
1236
|
+
*
|
|
1237
|
+
* // clear the content only of the range A1:D10
|
|
1238
|
+
* fRange.clearContent();
|
|
1239
|
+
* ```
|
|
1240
|
+
*/
|
|
1241
|
+
clearContent(): FRange;
|
|
1242
|
+
/**
|
|
1243
|
+
* Clears formatting information of the range, while preserving contents.
|
|
1244
|
+
* @returns {FWorksheet} Returns the current worksheet instance for method chaining
|
|
1245
|
+
* @example
|
|
1246
|
+
* ```typescript
|
|
1247
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1248
|
+
* const fWorkSheet = fWorkbook.getActiveSheet();
|
|
1249
|
+
* const fRange = fWorkSheet.getRange('A1:D10');
|
|
1250
|
+
* // clear the format only of the range A1:D10
|
|
1251
|
+
* fRange.clearFormat();
|
|
1252
|
+
* ```
|
|
1253
|
+
*/
|
|
1254
|
+
clearFormat(): FRange;
|
|
1255
|
+
/**
|
|
1256
|
+
* Inserts empty cells into this range. Existing data in the sheet along the provided dimension is shifted away from the inserted range.
|
|
1257
|
+
* @param {Dimension} shiftDimension - The dimension along which to shift existing data.
|
|
1258
|
+
* @example
|
|
1259
|
+
* ```ts
|
|
1260
|
+
* // Assume the active sheet empty sheet.
|
|
1261
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1262
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1263
|
+
* const values = [
|
|
1264
|
+
* [1, 2, 3, 4],
|
|
1265
|
+
* [2, 3, 4, 5],
|
|
1266
|
+
* [3, 4, 5, 6],
|
|
1267
|
+
* [4, 5, 6, 7],
|
|
1268
|
+
* [5, 6, 7, 8],
|
|
1269
|
+
* ];
|
|
1270
|
+
*
|
|
1271
|
+
* // Set the range A1:D5 with some values, the range A1:D5 will be:
|
|
1272
|
+
* // 1 | 2 | 3 | 4
|
|
1273
|
+
* // 2 | 3 | 4 | 5
|
|
1274
|
+
* // 3 | 4 | 5 | 6
|
|
1275
|
+
* // 4 | 5 | 6 | 7
|
|
1276
|
+
* // 5 | 6 | 7 | 8
|
|
1277
|
+
* const fRange = fWorksheet.getRange('A1:D5');
|
|
1278
|
+
* fRange.setValues(values);
|
|
1279
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]
|
|
1280
|
+
*
|
|
1281
|
+
* // Insert the empty cells into the range A1:B2 along the columns dimension, the range A1:D5 will be:
|
|
1282
|
+
* // | | 1 | 2
|
|
1283
|
+
* // | | 2 | 3
|
|
1284
|
+
* // 3 | 4 | 5 | 6
|
|
1285
|
+
* // 4 | 5 | 6 | 7
|
|
1286
|
+
* // 5 | 6 | 7 | 8
|
|
1287
|
+
* const fRange2 = fWorksheet.getRange('A1:B2');
|
|
1288
|
+
* fRange2.insertCells(univerAPI.Enum.Dimension.COLUMNS);
|
|
1289
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[null, null, 1, 2], [null, null, 2, 3], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]
|
|
1290
|
+
*
|
|
1291
|
+
* // Set the range A1:D5 values again, the range A1:D5 will be:
|
|
1292
|
+
* // 1 | 2 | 3 | 4
|
|
1293
|
+
* // 2 | 3 | 4 | 5
|
|
1294
|
+
* // 3 | 4 | 5 | 6
|
|
1295
|
+
* // 4 | 5 | 6 | 7
|
|
1296
|
+
* // 5 | 6 | 7 | 8
|
|
1297
|
+
* fRange.setValues(values);
|
|
1298
|
+
*
|
|
1299
|
+
* // Insert the empty cells into the range A1:B2 along the rows dimension, the range A1:D5 will be:
|
|
1300
|
+
* // | | 3 | 4
|
|
1301
|
+
* // | | 4 | 5
|
|
1302
|
+
* // 1 | 2 | 5 | 6
|
|
1303
|
+
* // 2 | 3 | 6 | 7
|
|
1304
|
+
* // 3 | 4 | 7 | 8
|
|
1305
|
+
* const fRange3 = fWorksheet.getRange('A1:B2');
|
|
1306
|
+
* fRange3.insertCells(univerAPI.Enum.Dimension.ROWS);
|
|
1307
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[null, null, 3, 4], [null, null, 4, 5], [1, 2, 5, 6], [2, 3, 6, 7], [3, 4, 7, 8]]
|
|
1308
|
+
* ```
|
|
1309
|
+
*/
|
|
1310
|
+
insertCells(shiftDimension: Dimension): void;
|
|
1311
|
+
/**
|
|
1312
|
+
* Deletes this range of cells. Existing data in the sheet along the provided dimension is shifted towards the deleted range.
|
|
1313
|
+
* @param {Dimension} shiftDimension - The dimension along which to shift existing data.
|
|
1314
|
+
* @example
|
|
1315
|
+
* ```ts
|
|
1316
|
+
* // Assume the active sheet empty sheet.
|
|
1317
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1318
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1319
|
+
* const values = [
|
|
1320
|
+
* [1, 2, 3, 4],
|
|
1321
|
+
* [2, 3, 4, 5],
|
|
1322
|
+
* [3, 4, 5, 6],
|
|
1323
|
+
* [4, 5, 6, 7],
|
|
1324
|
+
* [5, 6, 7, 8],
|
|
1325
|
+
* ];
|
|
1326
|
+
*
|
|
1327
|
+
* // Set the range A1:D5 with some values, the range A1:D5 will be:
|
|
1328
|
+
* // 1 | 2 | 3 | 4
|
|
1329
|
+
* // 2 | 3 | 4 | 5
|
|
1330
|
+
* // 3 | 4 | 5 | 6
|
|
1331
|
+
* // 4 | 5 | 6 | 7
|
|
1332
|
+
* // 5 | 6 | 7 | 8
|
|
1333
|
+
* const fRange = fWorksheet.getRange('A1:D5');
|
|
1334
|
+
* fRange.setValues(values);
|
|
1335
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]
|
|
1336
|
+
*
|
|
1337
|
+
* // Delete the range A1:B2 along the columns dimension, the range A1:D5 will be:
|
|
1338
|
+
* // 3 | 4 | |
|
|
1339
|
+
* // 4 | 5 | |
|
|
1340
|
+
* // 3 | 4 | 5 | 6
|
|
1341
|
+
* // 4 | 5 | 6 | 7
|
|
1342
|
+
* // 5 | 6 | 7 | 8
|
|
1343
|
+
* const fRange2 = fWorksheet.getRange('A1:B2');
|
|
1344
|
+
* fRange2.deleteCells(univerAPI.Enum.Dimension.COLUMNS);
|
|
1345
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[3, 4, null, null], [4, 5, null, null], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]
|
|
1346
|
+
*
|
|
1347
|
+
* // Set the range A1:D5 values again, the range A1:D5 will be:
|
|
1348
|
+
* // 1 | 2 | 3 | 4
|
|
1349
|
+
* // 2 | 3 | 4 | 5
|
|
1350
|
+
* // 3 | 4 | 5 | 6
|
|
1351
|
+
* // 4 | 5 | 6 | 7
|
|
1352
|
+
* // 5 | 6 | 7 | 8
|
|
1353
|
+
* fRange.setValues(values);
|
|
1354
|
+
*
|
|
1355
|
+
* // Delete the range A1:B2 along the rows dimension, the range A1:D5 will be:
|
|
1356
|
+
* // 3 | 4 | 3 | 4
|
|
1357
|
+
* // 4 | 5 | 4 | 5
|
|
1358
|
+
* // 5 | 6 | 5 | 6
|
|
1359
|
+
* // | | 6 | 7
|
|
1360
|
+
* // | | 7 | 8
|
|
1361
|
+
* const fRange3 = fWorksheet.getRange('A1:B2');
|
|
1362
|
+
* fRange3.deleteCells(univerAPI.Enum.Dimension.ROWS);
|
|
1363
|
+
* console.log(fWorksheet.getRange('A1:D5').getValues()); // [[3, 4, 3, 4], [4, 5, 4, 5], [5, 6, 5, 6], [null, null, 6, 7], [null, null, 7, 8]]
|
|
1364
|
+
* ```
|
|
1365
|
+
*/
|
|
1366
|
+
deleteCells(shiftDimension: Dimension): void;
|
|
1367
|
+
/**
|
|
1368
|
+
* Returns a copy of the range expanded `Direction.UP` and `Direction.DOWN` if the specified dimension is `Dimension.ROWS`, or `Direction.NEXT` and `Direction.PREVIOUS` if the dimension is `Dimension.COLUMNS`.
|
|
1369
|
+
* The expansion of the range is based on detecting data next to the range that is organized like a table.
|
|
1370
|
+
* The expanded range covers all adjacent cells with data in them along the specified dimension including the table boundaries.
|
|
1371
|
+
* If the original range is surrounded by empty cells along the specified dimension, the range itself is returned.
|
|
1372
|
+
* @param {Dimension} [dimension] - The dimension along which to expand the range. If not provided, the range will be expanded in both dimensions.
|
|
1373
|
+
* @returns {FRange} The range's data region or a range covering each column or each row spanned by the original range.
|
|
1374
|
+
* @example
|
|
1375
|
+
* ```ts
|
|
1376
|
+
* // Assume the active sheet is a new sheet with no data.
|
|
1377
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1378
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1379
|
+
*
|
|
1380
|
+
* // Set the range A1:D4 with some values, the range A1:D4 will be:
|
|
1381
|
+
* // | | |
|
|
1382
|
+
* // | | 100 |
|
|
1383
|
+
* // | 100 | | 100
|
|
1384
|
+
* // | | 100 |
|
|
1385
|
+
* fWorksheet.getRange('C2').setValue(100);
|
|
1386
|
+
* fWorksheet.getRange('B3').setValue(100);
|
|
1387
|
+
* fWorksheet.getRange('D3').setValue(100);
|
|
1388
|
+
* fWorksheet.getRange('C4').setValue(100);
|
|
1389
|
+
*
|
|
1390
|
+
* // Get C3 data region along the rows dimension, the range will be C2:D4
|
|
1391
|
+
* const range = fWorksheet.getRange('C3').getDataRegion(univerAPI.Enum.Dimension.ROWS);
|
|
1392
|
+
* console.log(range.getA1Notation()); // C2:C4
|
|
1393
|
+
*
|
|
1394
|
+
* // Get C3 data region along the columns dimension, the range will be B3:D3
|
|
1395
|
+
* const range2 = fWorksheet.getRange('C3').getDataRegion(univerAPI.Enum.Dimension.COLUMNS);
|
|
1396
|
+
* console.log(range2.getA1Notation()); // B3:D3
|
|
1397
|
+
*
|
|
1398
|
+
* // Get C3 data region along the both dimension, the range will be B2:D4
|
|
1399
|
+
* const range3 = fWorksheet.getRange('C3').getDataRegion();
|
|
1400
|
+
* console.log(range3.getA1Notation()); // B2:D4
|
|
1401
|
+
* ```
|
|
1402
|
+
*/
|
|
1403
|
+
getDataRegion(dimension?: Dimension): FRange;
|
|
1404
|
+
/**
|
|
1405
|
+
* Returns true if the range is totally blank.
|
|
1406
|
+
* @returns {boolean} true if the range is blank; false otherwise.
|
|
1407
|
+
* @example
|
|
1408
|
+
* ```ts
|
|
1409
|
+
* // Assume the active sheet is a new sheet with no data.
|
|
1410
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1411
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1412
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1413
|
+
* console.log(fRange.isBlank()); // true
|
|
1414
|
+
*
|
|
1415
|
+
* // Set the range A1:B2 with some values
|
|
1416
|
+
* fRange.setValueForCell(123);
|
|
1417
|
+
* console.log(fRange.isBlank()); // false
|
|
1418
|
+
* ```
|
|
1419
|
+
*/
|
|
1420
|
+
isBlank(): boolean;
|
|
1421
|
+
/**
|
|
1422
|
+
* Returns a new range that is offset from this range by the given number of rows and columns (which can be negative).
|
|
1423
|
+
* The new range is the same size as the original range.
|
|
1424
|
+
* @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.
|
|
1425
|
+
* @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.
|
|
1426
|
+
* @returns {FRange} The new range.
|
|
1427
|
+
* @example
|
|
1428
|
+
* ```ts
|
|
1429
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1430
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1431
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1432
|
+
* console.log(fRange.getA1Notation()); // A1:B2
|
|
1433
|
+
*
|
|
1434
|
+
* // Offset the range by 1 row and 1 column
|
|
1435
|
+
* const newRange = fRange.offset(1, 1);
|
|
1436
|
+
* console.log(newRange.getA1Notation()); // B2:C3
|
|
1437
|
+
* ```
|
|
1438
|
+
*/
|
|
1439
|
+
offset(rowOffset: number, columnOffset: number): FRange;
|
|
1440
|
+
/**
|
|
1441
|
+
* 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 in cells.
|
|
1442
|
+
* @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.
|
|
1443
|
+
* @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.
|
|
1444
|
+
* @param {number} numRows - The height in rows of the new range.
|
|
1445
|
+
* @returns {FRange} The new range.
|
|
1446
|
+
* @example
|
|
1447
|
+
* ```ts
|
|
1448
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1449
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1450
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1451
|
+
* console.log(fRange.getA1Notation()); // A1:B2
|
|
1452
|
+
*
|
|
1453
|
+
* // Offset the range by 1 row and 1 column, and set the height of the new range to 3
|
|
1454
|
+
* const newRange = fRange.offset(1, 1, 3);
|
|
1455
|
+
* console.log(newRange.getA1Notation()); // B2:C4
|
|
1456
|
+
* ```
|
|
1457
|
+
*/
|
|
1458
|
+
offset(rowOffset: number, columnOffset: number, numRows: number): FRange;
|
|
1459
|
+
/**
|
|
1460
|
+
* Updates the formula for this range. The given formula must be in A1 notation.
|
|
1461
|
+
* @param {string} formula - A string representing the formula to set for the cell.
|
|
1462
|
+
* @returns {FRange} This range instance for chaining.
|
|
1463
|
+
* @example
|
|
1464
|
+
* ```ts
|
|
1465
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1466
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1467
|
+
* const fRange = fWorksheet.getRange('A1');
|
|
1468
|
+
* fRange.setFormula('=SUM(A2:A5)');
|
|
1469
|
+
* console.log(fRange.getFormula()); // '=SUM(A2:A5)'
|
|
1470
|
+
* ```
|
|
1471
|
+
*/
|
|
1472
|
+
setFormula(formula: string): FRange;
|
|
1473
|
+
/**
|
|
1474
|
+
* Sets a rectangular grid of formulas (must match dimensions of this range). The given formulas must be in A1 notation.
|
|
1475
|
+
* @param {string[][]} formulas - A two-dimensional string array of formulas.
|
|
1476
|
+
* @returns {FRange} This range instance for chaining.
|
|
1477
|
+
* @example
|
|
1478
|
+
* ```ts
|
|
1479
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
1480
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
1481
|
+
* const fRange = fWorksheet.getRange('A1:B2');
|
|
1482
|
+
* fRange.setFormulas([
|
|
1483
|
+
* ['=SUM(A2:A5)', '=SUM(B2:B5)'],
|
|
1484
|
+
* ['=SUM(A6:A9)', '=SUM(B6:B9)'],
|
|
1485
|
+
* ]);
|
|
1486
|
+
* console.log(fRange.getFormulas()); // [['=SUM(A2:A5)', '=SUM(B2:B5)'], ['=SUM(A6:A9)', '=SUM(B6:B9)']]
|
|
1487
|
+
* ```
|
|
1488
|
+
*/
|
|
1489
|
+
setFormulas(formulas: string[][]): FRange;
|
|
958
1490
|
}
|
|
@@ -316,6 +316,16 @@ export declare class FWorkbook extends FBaseInitialable {
|
|
|
316
316
|
* ```
|
|
317
317
|
*/
|
|
318
318
|
getActiveRange(): FRange | null;
|
|
319
|
+
/**
|
|
320
|
+
* Returns the active cell in this spreadsheet.
|
|
321
|
+
* @returns {FRange | null} The active cell
|
|
322
|
+
* @example
|
|
323
|
+
* ```ts
|
|
324
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
325
|
+
* console.log(fWorkbook.getActiveCell().getA1Notation());
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
getActiveCell(): FRange | null;
|
|
319
329
|
/**
|
|
320
330
|
* Deletes the currently active sheet.
|
|
321
331
|
* @returns {boolean} true if the sheet was deleted, false otherwise
|