-
Notifications
You must be signed in to change notification settings - Fork 61
/
excel.range.yml
1568 lines (1436 loc) · 58.6 KB
/
excel.range.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
### YamlMime:TSType
name: Excel.Range
uid: 'excel!Excel.Range:class'
package: excel!
fullName: Excel.Range
summary: >-
Range represents a set of one or more contiguous cells such as a cell, a row, a column, or a block of cells. To learn
more about how ranges are used throughout the API, start with [Ranges in the Excel JavaScript
API](https://learn.microsoft.com/office/dev/add-ins/excel/excel-add-ins-core-concepts#ranges)<!-- -->.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
type: class
properties:
- name: address
uid: 'excel!Excel.Range#address:member'
package: excel!
fullName: address
summary: 'Specifies the range reference in A1-style. Address value contains the sheet reference (e.g., "Sheet1!A1:B4").'
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly address: string;'
return:
type: string
- name: addressLocal
uid: 'excel!Excel.Range#addressLocal:member'
package: excel!
fullName: addressLocal
summary: Represents the range reference for the specified range in the language of the user.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly addressLocal: string;'
return:
type: string
- name: cellCount
uid: 'excel!Excel.Range#cellCount:member'
package: excel!
fullName: cellCount
summary: >-
Specifies the number of cells in the range. This API will return -1 if the cell count exceeds 2^31-1
(2,147,483,647).
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly cellCount: number;'
return:
type: number
- name: columnCount
uid: 'excel!Excel.Range#columnCount:member'
package: excel!
fullName: columnCount
summary: Specifies the total number of columns in the range.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly columnCount: number;'
return:
type: number
- name: columnHidden
uid: 'excel!Excel.Range#columnHidden:member'
package: excel!
fullName: columnHidden
summary: >-
Represents if all columns in the current range are hidden. Value is `true` when all columns in a range are hidden.
Value is `false` when no columns in the range are hidden. Value is `null` when some columns in a range are hidden
and other columns in the same range are not hidden.
remarks: '\[ [API set: ExcelApi 1.2](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'columnHidden: boolean;'
return:
type: boolean
- name: columnIndex
uid: 'excel!Excel.Range#columnIndex:member'
package: excel!
fullName: columnIndex
summary: Specifies the column number of the first cell in the range. Zero-indexed.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly columnIndex: number;'
return:
type: number
- name: context
uid: 'excel!Excel.Range#context:member'
package: excel!
fullName: context
summary: >-
The request context associated with the object. This connects the add-in's process to the Office host
application's process.
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'context: RequestContext;'
return:
type: '<xref uid="excel!Excel.RequestContext:class" />'
- name: format
uid: 'excel!Excel.Range#format:member'
package: excel!
fullName: format
summary: 'Returns a format object, encapsulating the range''s font, fill, borders, alignment, and other properties.'
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly format: Excel.RangeFormat;'
return:
type: '<xref uid="excel!Excel.RangeFormat:class" />'
- name: formulas
uid: 'excel!Excel.Range#formulas:member'
package: excel!
fullName: formulas
summary: 'Represents the formula in A1-style notation. If a cell has no formula, its value is returned instead.'
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'formulas: any[][];'
return:
type: 'any[][]'
- name: formulasLocal
uid: 'excel!Excel.Range#formulasLocal:member'
package: excel!
fullName: formulasLocal
summary: >-
Represents the formula in A1-style notation, in the user's language and number-formatting locale. For example, the
English "=SUM(A1, 1.5)" formula would become "=SUMME(A1; 1,5)" in German. If a cell has no formula, its value is
returned instead.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'formulasLocal: any[][];'
return:
type: 'any[][]'
- name: formulasR1C1
uid: 'excel!Excel.Range#formulasR1C1:member'
package: excel!
fullName: formulasR1C1
summary: 'Represents the formula in R1C1-style notation. If a cell has no formula, its value is returned instead.'
remarks: '\[ [API set: ExcelApi 1.2](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'formulasR1C1: any[][];'
return:
type: 'any[][]'
- name: hidden
uid: 'excel!Excel.Range#hidden:member'
package: excel!
fullName: hidden
summary: >-
Represents if all cells in the current range are hidden. Value is `true` when all cells in a range are hidden.
Value is `false` when no cells in the range are hidden. Value is `null` when some cells in a range are hidden and
other cells in the same range are not hidden.
remarks: '\[ [API set: ExcelApi 1.2](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly hidden: boolean;'
return:
type: boolean
- name: numberFormat
uid: 'excel!Excel.Range#numberFormat:member'
package: excel!
fullName: numberFormat
summary: >-
Represents Excel's number format code for the given range. For more information about Excel number formatting, see
[Number format
codes](https://support.microsoft.com/office/number-format-codes-5026bbd6-04bc-48cd-bf33-80f18b4eae68)<!-- -->.
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Set the text of the chart title to "My Chart" and display it as an overlay on the chart.
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "F5:G7";
const numberFormat = [[null, "d-mmm"], [null, "d-mmm"], [null, null]]
const values = [["Today", 42147], ["Tomorrow", "5/24"], ["Difference in days", null]];
const formulas = [[null,null], [null,null], [null,"=G6-G5"]];
const range = context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress);
range.numberFormat = numberFormat;
range.values = values;
range.formulas= formulas;
range.load('text');
await context.sync();
console.log(range.text);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'numberFormat: any[][];'
return:
type: 'any[][]'
- name: rowCount
uid: 'excel!Excel.Range#rowCount:member'
package: excel!
fullName: rowCount
summary: Returns the total number of rows in the range.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly rowCount: number;'
return:
type: number
- name: rowHidden
uid: 'excel!Excel.Range#rowHidden:member'
package: excel!
fullName: rowHidden
summary: >-
Represents if all rows in the current range are hidden. Value is `true` when all rows in a range are hidden. Value
is `false` when no rows in the range are hidden. Value is `null` when some rows in a range are hidden and other
rows in the same range are not hidden.
remarks: '\[ [API set: ExcelApi 1.2](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'rowHidden: boolean;'
return:
type: boolean
- name: rowIndex
uid: 'excel!Excel.Range#rowIndex:member'
package: excel!
fullName: rowIndex
summary: Returns the row number of the first cell in the range. Zero-indexed.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly rowIndex: number;'
return:
type: number
- name: sort
uid: 'excel!Excel.Range#sort:member'
package: excel!
fullName: sort
summary: Represents the range sort of the current range.
remarks: >-
\[ [API set: ExcelApi 1.2](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/30-events/event-column-and-row-sort.yaml
async function sortTopToBottom(criteria: string) {
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getActiveWorksheet();
const range = sheet.getRange("A1:E5");
// Find the column header that provides the sort criteria.
const header = range.find(criteria, {});
header.load("columnIndex");
await context.sync();
range.sort.apply(
[
{
key: header.columnIndex,
sortOn: Excel.SortOn.value
}
],
false /*matchCase*/,
true /*hasHeaders*/,
Excel.SortOrientation.rows
);
await context.sync();
});
}
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly sort: Excel.RangeSort;'
return:
type: '<xref uid="excel!Excel.RangeSort:class" />'
- name: text
uid: 'excel!Excel.Range#text:member'
package: excel!
fullName: text
summary: >-
Text values of the specified range. The text value will not depend on the cell width. The number sign (\#)
substitution that happens in the Excel UI will not affect the text value returned by the API.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly text: string[][];'
return:
type: 'string[][]'
- name: values
uid: 'excel!Excel.Range#values:member'
package: excel!
fullName: values
summary: >-
Represents the raw values of the specified range. The data returned could be a string, number, or boolean. Cells
that contain an error will return the error string. If the returned value starts with a plus ("+"), minus ("-"),
or equal sign ("="), Excel interprets this value as a formula.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'values: any[][];'
return:
type: 'any[][]'
- name: valueTypes
uid: 'excel!Excel.Range#valueTypes:member'
package: excel!
fullName: valueTypes
summary: Specifies the type of data in each cell.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly valueTypes: Excel.RangeValueType[][];'
return:
type: '<xref uid="excel!Excel.RangeValueType:enum" />[][]'
- name: worksheet
uid: 'excel!Excel.Range#worksheet:member'
package: excel!
fullName: worksheet
summary: The worksheet containing the current range.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly worksheet: Excel.Worksheet;'
return:
type: '<xref uid="excel!Excel.Worksheet:class" />'
methods:
- name: clear(applyTo)
uid: 'excel!Excel.Range#clear:member(1)'
package: excel!
fullName: clear(applyTo)
summary: 'Clear range values, format, fill, border, etc.'
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Clear the format and contents of the range.
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "D:F";
const range = context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress);
range.clear();
await context.sync();
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'clear(applyTo?: Excel.ClearApplyTo): void;'
parameters:
- id: applyTo
description: Optional. Determines the type of clear action. See `Excel.ClearApplyTo` for details.
type: '<xref uid="excel!Excel.ClearApplyTo:enum" />'
return:
type: void
description: ''
- name: clear(applyToString)
uid: 'excel!Excel.Range#clear:member(2)'
package: excel!
fullName: clear(applyToString)
summary: 'Clear range values, format, fill, border, etc.'
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'clear(applyToString?: "All" | "Formats" | "Contents" | "Hyperlinks" | "RemoveHyperlinks"): void;'
parameters:
- id: applyToString
description: Optional. Determines the type of clear action. See `Excel.ClearApplyTo` for details.
type: '"All" | "Formats" | "Contents" | "Hyperlinks" | "RemoveHyperlinks"'
return:
type: void
description: ''
- name: delete(shift)
uid: 'excel!Excel.Range#delete:member(1)'
package: excel!
fullName: delete(shift)
summary: Deletes the cells associated with the range.
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "D:F";
const range = context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress);
range.delete("Left");
await context.sync();
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'delete(shift: Excel.DeleteShiftDirection): void;'
parameters:
- id: shift
description: Specifies which way to shift the cells. See `Excel.DeleteShiftDirection` for details.
type: '<xref uid="excel!Excel.DeleteShiftDirection:enum" />'
return:
type: void
description: ''
- name: delete(shiftString)
uid: 'excel!Excel.Range#delete:member(2)'
package: excel!
fullName: delete(shiftString)
summary: Deletes the cells associated with the range.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'delete(shiftString: "Up" | "Left"): void;'
parameters:
- id: shiftString
description: Specifies which way to shift the cells. See `Excel.DeleteShiftDirection` for details.
type: '"Up" | "Left"'
return:
type: void
description: ''
- name: getBoundingRect(anotherRange)
uid: 'excel!Excel.Range#getBoundingRect:member(1)'
package: excel!
fullName: getBoundingRect(anotherRange)
summary: >-
Gets the smallest range object that encompasses the given ranges. For example, the `GetBoundingRect` of "B2:C5"
and "D10:E15" is "B2:E15".
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "D4:G6";
let range = context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress);
range = range.getBoundingRect("G4:H8");
range.load('address');
await context.sync();
console.log(range.address); // Prints Sheet1!D4:H8
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getBoundingRect(anotherRange: Range | string): Excel.Range;'
parameters:
- id: anotherRange
description: 'The range object, address, or range name.'
type: '<xref uid="excel!Excel.Range:class" /> | string'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: 'getCell(row, column)'
uid: 'excel!Excel.Range#getCell:member(1)'
package: excel!
fullName: 'getCell(row, column)'
summary: >-
Gets the range object containing the single cell based on row and column numbers. The cell can be outside the
bounds of its parent range, so long as it stays within the worksheet grid. The returned cell is located relative
to the top left cell of the range.
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "A1:F8";
const worksheet = context.workbook.worksheets.getItem(sheetName);
const range = worksheet.getRange(rangeAddress);
const cell = range.getCell(0,0);
cell.load('address');
await context.sync();
console.log(cell.address);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getCell(row: number, column: number): Excel.Range;'
parameters:
- id: row
description: Row number of the cell to be retrieved. Zero-indexed.
type: number
- id: column
description: Column number of the cell to be retrieved. Zero-indexed.
type: number
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getColumn(column)
uid: 'excel!Excel.Range#getColumn:member(1)'
package: excel!
fullName: getColumn(column)
summary: Gets a column contained in the range.
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
await Excel.run(async (context) => {
const sheetName = "Sheet19";
const rangeAddress = "A1:F8";
const range = context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress).getColumn(1);
range.load('address');
await context.sync();
console.log(range.address); // prints Sheet1!B1:B8
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getColumn(column: number): Excel.Range;'
parameters:
- id: column
description: Column number of the range to be retrieved. Zero-indexed.
type: number
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getColumnsAfter(count)
uid: 'excel!Excel.Range#getColumnsAfter:member(1)'
package: excel!
fullName: getColumnsAfter(count)
summary: Gets a certain number of columns to the right of the current `Range` object.
remarks: '\[ [API set: ExcelApi 1.2](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getColumnsAfter(count?: number): Excel.Range;'
parameters:
- id: count
description: >-
Optional. The number of columns to include in the resulting range. In general, use a positive number to
create a range outside the current range. You can also use a negative number to create a range within the
current range. The default value is 1.
type: number
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getColumnsBefore(count)
uid: 'excel!Excel.Range#getColumnsBefore:member(1)'
package: excel!
fullName: getColumnsBefore(count)
summary: Gets a certain number of columns to the left of the current `Range` object.
remarks: '\[ [API set: ExcelApi 1.2](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getColumnsBefore(count?: number): Excel.Range;'
parameters:
- id: count
description: >-
Optional. The number of columns to include in the resulting range. In general, use a positive number to
create a range outside the current range. You can also use a negative number to create a range within the
current range. The default value is 1.
type: number
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getEntireColumn()
uid: 'excel!Excel.Range#getEntireColumn:member(1)'
package: excel!
fullName: getEntireColumn()
summary: >-
Gets an object that represents the entire column of the range (for example, if the current range represents cells
"B4:E11", its `getEntireColumn` is a range that represents columns "B:E").
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Note: the grid properties of the Range (values, numberFormat, formulas)
// contains null since the Range in question is unbounded.
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "D:F";
const range = context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress);
const rangeEC = range.getEntireColumn();
rangeEC.load('address');
await context.sync();
console.log(rangeEC.address);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getEntireColumn(): Excel.Range;'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getEntireRow()
uid: 'excel!Excel.Range#getEntireRow:member(1)'
package: excel!
fullName: getEntireRow()
summary: >-
Gets an object that represents the entire row of the range (for example, if the current range represents cells
"B4:E11", its `GetEntireRow` is a range that represents rows "4:11").
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Gets an object that represents the entire row of the range
// (for example, if the current range represents cells "B4:E11",
// its GetEntireRow is a range that represents rows "4:11").
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "D:F";
const range = context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress);
const rangeER = range.getEntireRow();
rangeER.load('address');
await context.sync();
console.log(rangeER.address);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getEntireRow(): Excel.Range;'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getIntersection(anotherRange)
uid: 'excel!Excel.Range#getIntersection:member(1)'
package: excel!
fullName: getIntersection(anotherRange)
summary: Gets the range object that represents the rectangular intersection of the given ranges.
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "A1:F8";
const range =
context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress).getIntersection("D4:G6");
range.load('address');
await context.sync();
console.log(range.address); // prints Sheet1!D4:F6
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getIntersection(anotherRange: Range | string): Excel.Range;'
parameters:
- id: anotherRange
description: The range object or range address that will be used to determine the intersection of ranges.
type: '<xref uid="excel!Excel.Range:class" /> | string'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getIntersectionOrNullObject(anotherRange)
uid: 'excel!Excel.Range#getIntersectionOrNullObject:member(1)'
package: excel!
fullName: getIntersectionOrNullObject(anotherRange)
summary: >-
Gets the range object that represents the rectangular intersection of the given ranges. If no intersection is
found, then this method returns an object with its `isNullObject` property set to `true`<!-- -->. For further
information, see [*OrNullObject methods and
properties](https://learn.microsoft.com/office/dev/add-ins/develop/application-specific-api-model#ornullobject-methods-and-properties)<!--
-->.
remarks: >-
\[ [API set: ExcelApi 1.4](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
// Link to full sample:
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-relationships.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
const salesTable = sheet.tables.getItem("SalesTable");
const dataRange = salesTable.getDataBodyRange();
// We want the most recent quarter that has data, so
// exclude quarters without data and get the last of
// the remaining columns.
const usedDataRange = dataRange.getUsedRange(true /* valuesOnly */);
const currentQuarterRange = usedDataRange.getLastColumn();
// Asian and European teams have separate contests.
const asianSalesRange = sheet.getRange("A2:E4");
const europeanSalesRange = sheet.getRange("A5:E7");
// The data for each chart is the intersection of the
// current quarter column and the rows for the continent.
const asianContestRange = asianSalesRange.getIntersectionOrNullObject(currentQuarterRange);
const europeanContestRange = europeanSalesRange.getIntersectionOrNullObject(currentQuarterRange);
// Must sync before you can test the output of *OrNullObject
// method/property.
await context.sync();
if (asianContestRange.isNullObject) {
// See the declaration of this function for how to
// test this code path.
reportMissingData("Asian");
} else {
createContinentChart(
sheet,
"Asian",
asianContestRange,
"A9",
"F24"
);
}
if (europeanContestRange.isNullObject) {
// See the declaration of this function for how to
// test this code path.
reportMissingData("European");
} else {
createContinentChart(
sheet,
"European",
europeanContestRange,
"A25",
"F40"
);
}
await context.sync();
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getIntersectionOrNullObject(anotherRange: Range | string): Excel.Range;'
parameters:
- id: anotherRange
description: The range object or range address that will be used to determine the intersection of ranges.
type: '<xref uid="excel!Excel.Range:class" /> | string'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getLastCell()
uid: 'excel!Excel.Range#getLastCell:member(1)'
package: excel!
fullName: getLastCell()
summary: 'Gets the last cell within the range. For example, the last cell of "B2:D5" is "D5".'
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "A1:F8";
const range = context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress).getLastCell();
range.load('address');
await context.sync();
console.log(range.address); // prints Sheet1!F8
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getLastCell(): Excel.Range;'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getLastColumn()
uid: 'excel!Excel.Range#getLastColumn:member(1)'
package: excel!
fullName: getLastColumn()
summary: 'Gets the last column within the range. For example, the last column of "B2:D5" is "D2:D5".'
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "A1:F8";
const range = context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress).getLastColumn();
range.load('address');
await context.sync();
console.log(range.address); // prints Sheet1!F1:F8
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getLastColumn(): Excel.Range;'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getLastRow()
uid: 'excel!Excel.Range#getLastRow:member(1)'
package: excel!
fullName: getLastRow()
summary: 'Gets the last row within the range. For example, the last row of "B2:D5" is "B5:D5".'
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "A1:F8";
const range = context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress).getLastRow();
range.load('address');
await context.sync();
console.log(range.address); // prints Sheet1!A8:F8
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getLastRow(): Excel.Range;'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: 'getOffsetRange(rowOffset, columnOffset)'
uid: 'excel!Excel.Range#getOffsetRange:member(1)'
package: excel!
fullName: 'getOffsetRange(rowOffset, columnOffset)'
summary: >-
Gets an object which represents a range that's offset from the specified range. The dimension of the returned
range will match this range. If the resulting range is forced outside the bounds of the worksheet grid, an error
will be thrown.
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "D4:F6";
const range =
context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress).getOffsetRange(-1,4);
range.load('address');
await context.sync();
console.log(range.address); // prints Sheet1!H3:J5
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getOffsetRange(rowOffset: number, columnOffset: number): Excel.Range;'
parameters:
- id: rowOffset
description: >-
The number of rows (positive, negative, or 0) by which the range is to be offset. Positive values are offset
downward, and negative values are offset upward.
type: number
- id: columnOffset
description: >-
The number of columns (positive, negative, or 0) by which the range is to be offset. Positive values are
offset to the right, and negative values are offset to the left.
type: number
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: 'getResizedRange(deltaRows, deltaColumns)'
uid: 'excel!Excel.Range#getResizedRange:member(1)'
package: excel!
fullName: 'getResizedRange(deltaRows, deltaColumns)'
summary: >-
Gets a `Range` object similar to the current `Range` object, but with its bottom-right corner expanded (or
contracted) by some number of rows and columns.
remarks: '\[ [API set: ExcelApi 1.2](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getResizedRange(deltaRows: number, deltaColumns: number): Excel.Range;'
parameters:
- id: deltaRows
description: >-
The number of rows by which to expand the bottom-right corner, relative to the current range. Use a positive
number to expand the range, or a negative number to decrease it.
type: number
- id: deltaColumns
description: >-
The number of columns by which to expand the bottom-right corner, relative to the current range. Use a
positive number to expand the range, or a negative number to decrease it.
type: number
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getRow(row)
uid: 'excel!Excel.Range#getRow:member(1)'
package: excel!
fullName: getRow(row)
summary: Gets a row contained in the range.
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
await Excel.run(async (context) => {
const sheetName = "Sheet1";
const rangeAddress = "A1:F8";
const range = context.workbook.worksheets.getItem(sheetName).getRange(rangeAddress).getRow(1);
range.load('address');
await context.sync();
console.log(range.address); // prints Sheet1!A2:F2
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getRow(row: number): Excel.Range;'
parameters:
- id: row
description: Row number of the range to be retrieved. Zero-indexed.
type: number
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getRowsAbove(count)
uid: 'excel!Excel.Range#getRowsAbove:member(1)'
package: excel!
fullName: getRowsAbove(count)
summary: Gets a certain number of rows above the current `Range` object.
remarks: '\[ [API set: ExcelApi 1.2](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getRowsAbove(count?: number): Excel.Range;'
parameters:
- id: count
description: >-
Optional. The number of rows to include in the resulting range. In general, use a positive number to create
a range outside the current range. You can also use a negative number to create a range within the current
range. The default value is 1.
type: number
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getRowsBelow(count)
uid: 'excel!Excel.Range#getRowsBelow:member(1)'
package: excel!
fullName: getRowsBelow(count)
summary: Gets a certain number of rows below the current `Range` object.
remarks: '\[ [API set: ExcelApi 1.2](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getRowsBelow(count?: number): Excel.Range;'
parameters:
- id: count