-
Notifications
You must be signed in to change notification settings - Fork 63
/
excel.workbook.yml
1034 lines (925 loc) · 38.5 KB
/
excel.workbook.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.Workbook
uid: 'excel!Excel.Workbook:class'
package: excel!
fullName: Excel.Workbook
summary: >-
Workbook is the top level object which contains related workbook objects such as worksheets, tables, and ranges. To
learn more about the workbook object model, read [Work with workbooks using the Excel JavaScript
API](https://learn.microsoft.com/office/dev/add-ins/excel/excel-add-ins-workbooks)<!-- -->.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
type: class
properties:
- name: application
uid: 'excel!Excel.Workbook#application:member'
package: excel!
fullName: application
summary: Represents the Excel application instance that contains this workbook.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly application: Excel.Application;'
return:
type: '<xref uid="excel!Excel.Application:class" />'
- name: autoSave
uid: 'excel!Excel.Workbook#autoSave:member'
package: excel!
fullName: autoSave
summary: Specifies if the workbook is in AutoSave mode.
remarks: '\[ [API set: ExcelApi 1.9](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly autoSave: boolean;'
return:
type: boolean
- name: bindings
uid: 'excel!Excel.Workbook#bindings:member'
package: excel!
fullName: bindings
summary: Represents a collection of bindings that are part of the workbook.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly bindings: Excel.BindingCollection;'
return:
type: '<xref uid="excel!Excel.BindingCollection:class" />'
- name: calculationEngineVersion
uid: 'excel!Excel.Workbook#calculationEngineVersion:member'
package: excel!
fullName: calculationEngineVersion
summary: Returns a number about the version of Excel Calculation Engine.
remarks: '\[ [API set: ExcelApi 1.9](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly calculationEngineVersion: number;'
return:
type: number
- name: chartDataPointTrack
uid: 'excel!Excel.Workbook#chartDataPointTrack:member'
package: excel!
fullName: chartDataPointTrack
summary: >-
True if all charts in the workbook are tracking the actual data points to which they are attached. False if the
charts track the index of the data points.
remarks: '\[ [API set: ExcelApi 1.9](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'chartDataPointTrack: boolean;'
return:
type: boolean
- name: comments
uid: 'excel!Excel.Workbook#comments:member'
package: excel!
fullName: comments
summary: Represents a collection of comments associated with the workbook.
remarks: '\[ [API set: ExcelApi 1.10](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly comments: Excel.CommentCollection;'
return:
type: '<xref uid="excel!Excel.CommentCollection:class" />'
- name: context
uid: 'excel!Excel.Workbook#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: customXmlParts
uid: 'excel!Excel.Workbook#customXmlParts:member'
package: excel!
fullName: customXmlParts
summary: Represents the collection of custom XML parts contained by this workbook.
remarks: '\[ [API set: ExcelApi 1.5](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly customXmlParts: Excel.CustomXmlPartCollection;'
return:
type: '<xref uid="excel!Excel.CustomXmlPartCollection:class" />'
- name: dataConnections
uid: 'excel!Excel.Workbook#dataConnections:member'
package: excel!
fullName: dataConnections
summary: Represents all data connections in the workbook.
remarks: '\[ [API set: ExcelApi 1.7](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly dataConnections: Excel.DataConnectionCollection;'
return:
type: '<xref uid="excel!Excel.DataConnectionCollection:class" />'
- name: functions
uid: 'excel!Excel.Workbook#functions:member'
package: excel!
fullName: functions
summary: Represents a collection of worksheet functions that can be used for computation.
remarks: '\[ [API set: ExcelApi 1.2](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly functions: Excel.Functions;'
return:
type: '<xref uid="excel!Excel.Functions:class" />'
- name: isDirty
uid: 'excel!Excel.Workbook#isDirty:member'
package: excel!
fullName: isDirty
summary: >-
Specifies if changes have been made since the workbook was last saved. You can set this property to `true` if you
want to close a modified workbook without either saving it or being prompted to save it.
remarks: '\[ [API set: ExcelApi 1.9](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'isDirty: boolean;'
return:
type: boolean
- name: name
uid: 'excel!Excel.Workbook#name:member'
package: excel!
fullName: name
summary: Gets the workbook name.
remarks: '\[ [API set: ExcelApi 1.7](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly name: string;'
return:
type: string
- name: names
uid: 'excel!Excel.Workbook#names:member'
package: excel!
fullName: names
summary: Represents a collection of workbook-scoped named items (named ranges and constants).
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly names: Excel.NamedItemCollection;'
return:
type: '<xref uid="excel!Excel.NamedItemCollection:class" />'
- name: pivotTables
uid: 'excel!Excel.Workbook#pivotTables:member'
package: excel!
fullName: pivotTables
summary: Represents a collection of PivotTables associated with the workbook.
remarks: >-
\[ [API set: ExcelApi 1.3](/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/38-pivottable/pivottable-get-pivottables.yaml
await Excel.run(async (context) => {
// Get the names of all the PivotTables in the workbook.
const pivotTables = context.workbook.pivotTables;
pivotTables.load("name");
await context.sync();
// Display the names in the console.
console.log("PivotTables in the workbook:")
pivotTables.items.forEach((pivotTable) => {
console.log(`\t${pivotTable.name}`);
});
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly pivotTables: Excel.PivotTableCollection;'
return:
type: '<xref uid="excel!Excel.PivotTableCollection:class" />'
- name: pivotTableStyles
uid: 'excel!Excel.Workbook#pivotTableStyles:member'
package: excel!
fullName: pivotTableStyles
summary: Represents a collection of PivotTableStyles associated with the workbook.
remarks: '\[ [API set: ExcelApi 1.10](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly pivotTableStyles: Excel.PivotTableStyleCollection;'
return:
type: '<xref uid="excel!Excel.PivotTableStyleCollection:class" />'
- name: previouslySaved
uid: 'excel!Excel.Workbook#previouslySaved:member'
package: excel!
fullName: previouslySaved
summary: Specifies if the workbook has ever been saved locally or online.
remarks: '\[ [API set: ExcelApi 1.9](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly previouslySaved: boolean;'
return:
type: boolean
- name: properties
uid: 'excel!Excel.Workbook#properties:member'
package: excel!
fullName: properties
summary: Gets the workbook properties.
remarks: >-
\[ [API set: ExcelApi 1.7](/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/26-document/properties.yaml
await Excel.run(async (context) => {
let titleValue = "Excel document properties API";
let subjectValue = "Set and get document properties";
let keywordsValue = "Set and get operations";
let commentsValue = "This is an Excel document properties API code sample";
let categoryValue = "Office Add-ins";
let managerValue = "John";
let companyValue = "Microsoft";
let docProperties = context.workbook.properties;
// Set the writeable document properties.
docProperties.title = titleValue;
docProperties.subject = subjectValue;
docProperties.keywords = keywordsValue;
docProperties.comments = commentsValue;
docProperties.category = categoryValue;
docProperties.manager = managerValue;
docProperties.company = companyValue;
await context.sync();
console.log("Set the following document properties: title, subject, keywords, comments, category, manager, company.");
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly properties: Excel.DocumentProperties;'
return:
type: '<xref uid="excel!Excel.DocumentProperties:class" />'
- name: protection
uid: 'excel!Excel.Workbook#protection:member'
package: excel!
fullName: protection
summary: Returns the protection object for a workbook.
remarks: '\[ [API set: ExcelApi 1.7](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly protection: Excel.WorkbookProtection;'
return:
type: '<xref uid="excel!Excel.WorkbookProtection:class" />'
- name: queries
uid: 'excel!Excel.Workbook#queries:member'
package: excel!
fullName: queries
summary: Returns a collection of Power Query queries that are part of the workbook.
remarks: '\[ [API set: ExcelApi 1.14](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly queries: Excel.QueryCollection;'
return:
type: '<xref uid="excel!Excel.QueryCollection:class" />'
- name: readOnly
uid: 'excel!Excel.Workbook#readOnly:member'
package: excel!
fullName: readOnly
summary: Returns `true` if the workbook is open in read-only mode.
remarks: '\[ [API set: ExcelApi 1.8](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly readOnly: boolean;'
return:
type: boolean
- name: settings
uid: 'excel!Excel.Workbook#settings:member'
package: excel!
fullName: settings
summary: Represents a collection of settings associated with the workbook.
remarks: '\[ [API set: ExcelApi 1.4](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly settings: Excel.SettingCollection;'
return:
type: '<xref uid="excel!Excel.SettingCollection:class" />'
- name: slicers
uid: 'excel!Excel.Workbook#slicers:member'
package: excel!
fullName: slicers
summary: Represents a collection of slicers associated with the workbook.
remarks: '\[ [API set: ExcelApi 1.10](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly slicers: Excel.SlicerCollection;'
return:
type: '<xref uid="excel!Excel.SlicerCollection:class" />'
- name: slicerStyles
uid: 'excel!Excel.Workbook#slicerStyles:member'
package: excel!
fullName: slicerStyles
summary: Represents a collection of SlicerStyles associated with the workbook.
remarks: '\[ [API set: ExcelApi 1.10](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly slicerStyles: Excel.SlicerStyleCollection;'
return:
type: '<xref uid="excel!Excel.SlicerStyleCollection:class" />'
- name: styles
uid: 'excel!Excel.Workbook#styles:member'
package: excel!
fullName: styles
summary: Represents a collection of styles associated with the workbook.
remarks: >-
\[ [API set: ExcelApi 1.7](/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/style.yaml
await Excel.run(async (context) => {
let styles = context.workbook.styles;
// Add a new style to the style collection.
// Styles is in the Home tab ribbon.
styles.add("Diagonal Orientation Style");
let newStyle = styles.getItem("Diagonal Orientation Style");
// The "Diagonal Orientation Style" properties.
newStyle.textOrientation = 38;
newStyle.autoIndent = true;
newStyle.includeProtection = true;
newStyle.shrinkToFit = true;
newStyle.locked = false;
await context.sync();
console.log("Successfully added a new style with diagonal orientation to the Home tab ribbon.");
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'readonly styles: Excel.StyleCollection;'
return:
type: '<xref uid="excel!Excel.StyleCollection:class" />'
- name: tables
uid: 'excel!Excel.Workbook#tables:member'
package: excel!
fullName: tables
summary: Represents a collection of tables associated with the workbook.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly tables: Excel.TableCollection;'
return:
type: '<xref uid="excel!Excel.TableCollection:class" />'
- name: tableStyles
uid: 'excel!Excel.Workbook#tableStyles:member'
package: excel!
fullName: tableStyles
summary: Represents a collection of TableStyles associated with the workbook.
remarks: '\[ [API set: ExcelApi 1.10](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly tableStyles: Excel.TableStyleCollection;'
return:
type: '<xref uid="excel!Excel.TableStyleCollection:class" />'
- name: timelineStyles
uid: 'excel!Excel.Workbook#timelineStyles:member'
package: excel!
fullName: timelineStyles
summary: Represents a collection of TimelineStyles associated with the workbook.
remarks: '\[ [API set: ExcelApi 1.10](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly timelineStyles: Excel.TimelineStyleCollection;'
return:
type: '<xref uid="excel!Excel.TimelineStyleCollection:class" />'
- name: usePrecisionAsDisplayed
uid: 'excel!Excel.Workbook#usePrecisionAsDisplayed:member'
package: excel!
fullName: usePrecisionAsDisplayed
summary: >-
True if calculations in this workbook will be done using only the precision of the numbers as they're displayed.
Data will permanently lose accuracy when switching this property from `false` to `true`<!-- -->.
remarks: '\[ [API set: ExcelApi 1.9](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'usePrecisionAsDisplayed: boolean;'
return:
type: boolean
- name: worksheets
uid: 'excel!Excel.Workbook#worksheets:member'
package: excel!
fullName: worksheets
summary: Represents a collection of worksheets associated with the workbook.
remarks: '\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'readonly worksheets: Excel.WorksheetCollection;'
return:
type: '<xref uid="excel!Excel.WorksheetCollection:class" />'
methods:
- name: close(closeBehavior)
uid: 'excel!Excel.Workbook#close:member(1)'
package: excel!
fullName: close(closeBehavior)
summary: Close current workbook.
remarks: >-
\[ [API set: ExcelApi 1.11](/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/50-workbook/workbook-save-and-close.yaml
await Excel.run(async (context) => {
context.workbook.close(Excel.CloseBehavior.save);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'close(closeBehavior?: Excel.CloseBehavior): void;'
parameters:
- id: closeBehavior
description: workbook close behavior.
type: '<xref uid="excel!Excel.CloseBehavior:enum" />'
return:
type: void
description: ''
- name: close(closeBehaviorString)
uid: 'excel!Excel.Workbook#close:member(2)'
package: excel!
fullName: close(closeBehaviorString)
summary: Close current workbook.
remarks: '\[ [API set: ExcelApi 1.11](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'close(closeBehaviorString?: "Save" | "SkipSave"): void;'
parameters:
- id: closeBehaviorString
description: workbook close behavior.
type: '"Save" | "SkipSave"'
return:
type: void
description: ''
- name: getActiveCell()
uid: 'excel!Excel.Workbook#getActiveCell:member(1)'
package: excel!
fullName: getActiveCell()
summary: Gets the currently active cell from the workbook.
remarks: >-
\[ [API set: ExcelApi 1.7](/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/50-workbook/workbook-get-active-cell.yaml
await Excel.run(async (context) => {
let myWorkbook = context.workbook;
let activeCell = myWorkbook.getActiveCell();
activeCell.load("address");
await context.sync();
console.log("The active cell is " + activeCell.address);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getActiveCell(): Excel.Range;'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getActiveChart()
uid: 'excel!Excel.Workbook#getActiveChart:member(1)'
package: excel!
fullName: getActiveChart()
summary: >-
Gets the currently active chart in the workbook. If there is no active chart, an `ItemNotFound` exception is
thrown.
remarks: '\[ [API set: ExcelApi 1.9](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getActiveChart(): Excel.Chart;'
return:
type: '<xref uid="excel!Excel.Chart:class" />'
description: ''
- name: getActiveChartOrNullObject()
uid: 'excel!Excel.Workbook#getActiveChartOrNullObject:member(1)'
package: excel!
fullName: getActiveChartOrNullObject()
summary: >-
Gets the currently active chart in the workbook. If there is no active chart, 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.9](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getActiveChartOrNullObject(): Excel.Chart;'
return:
type: '<xref uid="excel!Excel.Chart:class" />'
description: ''
- name: getActiveSlicer()
uid: 'excel!Excel.Workbook#getActiveSlicer:member(1)'
package: excel!
fullName: getActiveSlicer()
summary: >-
Gets the currently active slicer in the workbook. If there is no active slicer, an `ItemNotFound` exception is
thrown.
remarks: '\[ [API set: ExcelApi 1.10](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getActiveSlicer(): Excel.Slicer;'
return:
type: '<xref uid="excel!Excel.Slicer:class" />'
description: ''
- name: getActiveSlicerOrNullObject()
uid: 'excel!Excel.Workbook#getActiveSlicerOrNullObject:member(1)'
package: excel!
fullName: getActiveSlicerOrNullObject()
summary: >-
Gets the currently active slicer in the workbook. If there is no active slicer, 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.10](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getActiveSlicerOrNullObject(): Excel.Slicer;'
return:
type: '<xref uid="excel!Excel.Slicer:class" />'
description: ''
- name: getIsActiveCollabSession()
uid: 'excel!Excel.Workbook#getIsActiveCollabSession:member(1)'
package: excel!
fullName: getIsActiveCollabSession()
summary: >-
Returns `true` if the workbook is being edited by multiple users (through co-authoring). Please be aware there
might be some delay between when the workbook status changes and when the changes are reflected on the result of
the method.
remarks: '\[ [API set: ExcelApi 1.9](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'getIsActiveCollabSession(): OfficeExtension.ClientResult<boolean>;'
return:
type: '<xref uid="office!OfficeExtension.ClientResult:class" /><boolean>'
description: ''
- name: getSelectedRange()
uid: 'excel!Excel.Workbook#getSelectedRange:member(1)'
package: excel!
fullName: getSelectedRange()
summary: >-
Gets the currently selected single range from the workbook. If there are multiple ranges selected, this method
will throw an error.
remarks: |-
\[ [API set: ExcelApi 1.1](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]
#### Examples
```TypeScript
await Excel.run(async (context) => {
const selectedRange = context.workbook.getSelectedRange();
selectedRange.load('address');
await context.sync();
console.log(selectedRange.address);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'getSelectedRange(): Excel.Range;'
return:
type: '<xref uid="excel!Excel.Range:class" />'
description: ''
- name: getSelectedRanges()
uid: 'excel!Excel.Workbook#getSelectedRanges:member(1)'
package: excel!
fullName: getSelectedRanges()
summary: >-
Gets the currently selected one or more ranges from the workbook. Unlike `getSelectedRange()`<!-- -->, this method
returns a `RangeAreas` object that represents all the selected ranges.
remarks: >-
\[ [API set: ExcelApi 1.9](/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-areas.yaml
await Excel.run(async (context) => {
const selectedRanges = context.workbook.getSelectedRanges();
selectedRanges.format.fill.color = "lightblue";
await context.sync();
})
```
isPreview: false
isDeprecated: false
syntax:
content: 'getSelectedRanges(): Excel.RangeAreas;'
return:
type: '<xref uid="excel!Excel.RangeAreas:class" />'
description: ''
- name: 'insertWorksheetsFromBase64(base64File, options)'
uid: 'excel!Excel.Workbook#insertWorksheetsFromBase64:member(1)'
package: excel!
fullName: 'insertWorksheetsFromBase64(base64File, options)'
summary: |-
Inserts the specified worksheets from a source workbook into the current workbook.
*Note**: This API is currently only supported for Office on Windows, Mac, and the web.
remarks: >-
\[ [API set: ExcelApi 1.13](/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/50-workbook/workbook-insert-external-worksheets.yaml
// Retrieve the file and set up an HTML FileReader element.
const myFile = <HTMLInputElement>document.getElementById("file");
const reader = new FileReader();
reader.onload = (event) => {
// Remove the metadata before the Base64-encoded string.
const startIndex = reader.result.toString().indexOf("base64,");
externalWorkbook = reader.result.toString().substr(startIndex + 7);
};
// Read the file as a data URL so that we can parse the Base64-encoded string.
reader.readAsDataURL(myFile.files[0]);
...
await Excel.run(async (context) => {
// Retrieve the source workbook.
const workbook = context.workbook;
// Set up the insert options.
const options = {
sheetNamesToInsert: [], // Insert all the worksheets from the source workbook.
positionType: Excel.WorksheetPositionType.after, // Insert after the `relativeTo` sheet.
relativeTo: "Sheet1" // The sheet relative to which the other worksheets will be inserted. Used with `positionType`.
};
// Insert the new worksheets.
workbook.insertWorksheetsFromBase64(externalWorkbook, options);
await context.sync();
});
```
isPreview: false
isDeprecated: false
syntax:
content: >-
insertWorksheetsFromBase64(base64File: string, options?: Excel.InsertWorksheetOptions):
OfficeExtension.ClientResult<string[]>;
parameters:
- id: base64File
description: Required. The base64-encoded string representing the source workbook file.
type: string
- id: options
description: >-
Optional. The options that define which worksheets to insert and where in the workbook the new worksheets
will be inserted. By default, all the worksheets from the source workbook are inserted at the end of the
current workbook.
type: '<xref uid="excel!Excel.InsertWorksheetOptions:interface" />'
return:
type: '<xref uid="office!OfficeExtension.ClientResult:class" /><string[]>'
description: An array of IDs corresponding to each newly inserted worksheet.
- name: load(options)
uid: 'excel!Excel.Workbook#load:member(1)'
package: excel!
fullName: load(options)
summary: >-
Queues up a command to load the specified properties of the object. You must call `context.sync()` before reading
the properties.
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'load(options?: Excel.Interfaces.WorkbookLoadOptions): Excel.Workbook;'
parameters:
- id: options
description: Provides options for which properties of the object to load.
type: '<xref uid="excel!Excel.Interfaces.WorkbookLoadOptions:interface" />'
return:
type: '<xref uid="excel!Excel.Workbook:class" />'
description: ''
- name: load(propertyNames)
uid: 'excel!Excel.Workbook#load:member(2)'
package: excel!
fullName: load(propertyNames)
summary: >-
Queues up a command to load the specified properties of the object. You must call `context.sync()` before reading
the properties.
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'load(propertyNames?: string | string[]): Excel.Workbook;'
parameters:
- id: propertyNames
description: A comma-delimited string or an array of strings that specify the properties to load.
type: 'string | string[]'
return:
type: '<xref uid="excel!Excel.Workbook:class" />'
description: ''
- name: load(propertyNamesAndPaths)
uid: 'excel!Excel.Workbook#load:member(3)'
package: excel!
fullName: load(propertyNamesAndPaths)
summary: >-
Queues up a command to load the specified properties of the object. You must call `context.sync()` before reading
the properties.
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: |-
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Excel.Workbook;
parameters:
- id: propertyNamesAndPaths
description: >-
`propertyNamesAndPaths.select` is a comma-delimited string that specifies the properties to load, and
`propertyNamesAndPaths.expand` is a comma-delimited string that specifies the navigation properties to load.
type: |-
{
select?: string;
expand?: string;
}
return:
type: '<xref uid="excel!Excel.Workbook:class" />'
description: ''
- name: save(saveBehavior)
uid: 'excel!Excel.Workbook#save:member(1)'
package: excel!
fullName: save(saveBehavior)
summary: Save current workbook.
remarks: >-
\[ [API set: ExcelApi 1.11](/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/50-workbook/workbook-save-and-close.yaml
await Excel.run(async (context) => {
context.workbook.save(Excel.SaveBehavior.save);
});
```
isPreview: false
isDeprecated: false
syntax:
content: 'save(saveBehavior?: Excel.SaveBehavior): void;'
parameters:
- id: saveBehavior
description: The save behavior must be "Save" or "Prompt". Default value is "Save".
type: '<xref uid="excel!Excel.SaveBehavior:enum" />'
return:
type: void
description: ''
- name: save(saveBehaviorString)
uid: 'excel!Excel.Workbook#save:member(2)'
package: excel!
fullName: save(saveBehaviorString)
summary: Save current workbook.
remarks: '\[ [API set: ExcelApi 1.11](/javascript/api/requirement-sets/excel/excel-api-requirement-sets) \]'
isPreview: false
isDeprecated: false
syntax:
content: 'save(saveBehaviorString?: "Save" | "Prompt"): void;'
parameters:
- id: saveBehaviorString
description: The save behavior must be "Save" or "Prompt". Default value is "Save".
type: '"Save" | "Prompt"'
return:
type: void
description: ''
- name: 'set(properties, options)'
uid: 'excel!Excel.Workbook#set:member(1)'
package: excel!
fullName: 'set(properties, options)'
summary: >-
Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate
properties, or another API object of the same type.
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'set(properties: Interfaces.WorkbookUpdateData, options?: OfficeExtension.UpdateOptions): void;'
parameters:
- id: properties
description: >-
A JavaScript object with properties that are structured isomorphically to the properties of the object on
which the method is called.
type: '<xref uid="excel!Excel.Interfaces.WorkbookUpdateData:interface" />'
- id: options
description: Provides an option to suppress errors if the properties object tries to set any read-only properties.
type: '<xref uid="office!OfficeExtension.UpdateOptions:interface" />'
return:
type: void
description: ''
- name: set(properties)
uid: 'excel!Excel.Workbook#set:member(2)'
package: excel!
fullName: set(properties)
summary: 'Sets multiple properties on the object at the same time, based on an existing loaded object.'
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'set(properties: Excel.Workbook): void;'
parameters:
- id: properties
description: ''
type: '<xref uid="excel!Excel.Workbook:class" />'
return:
type: void
description: ''
- name: toJSON()
uid: 'excel!Excel.Workbook#toJSON:member(1)'
package: excel!
fullName: toJSON()
summary: >-
Overrides the JavaScript `toJSON()` method in order to provide more useful output when an API object is passed to
`JSON.stringify()`<!-- -->. (`JSON.stringify`<!-- -->, in turn, calls the `toJSON` method of the object that is
passed to it.) Whereas the original Excel.Workbook object is an API object, the `toJSON` method returns a plain
JavaScript object (typed as `Excel.Interfaces.WorkbookData`<!-- -->) that contains shallow copies of any loaded
child properties from the original object.
remarks: ''
isPreview: false
isDeprecated: false
syntax:
content: 'toJSON(): Excel.Interfaces.WorkbookData;'
return:
type: '<xref uid="excel!Excel.Interfaces.WorkbookData:interface" />'
description: ''
events:
- name: onActivated
uid: 'excel!Excel.Workbook#onActivated:member'
package: excel!
fullName: onActivated
summary: 'Occurs when the workbook is activated. Note: This event will not fire when the workbook is opened.'
remarks: >-
\[ [API set: ExcelApi 1.13](/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/events-workbook-activated.yaml
async function workbookActivated(event: Excel.WorkbookActivatedEventArgs) {
await Excel.run(async (context) => {
// Callback function for when the workbook is activated.
console.log("The workbook was activated.");
});
}
...
await Excel.run(async (context) => {
const workbook = context.workbook;
// Register the workbook activated event handler.
workbook.onActivated.add(workbookActivated);
await context.sync();
console.log("Added event handler for workbook activated.");
});
```
isPreview: false
isDeprecated: false
syntax: