Workbook is the top level object which contains related workbook objects such as worksheets, tables, ranges, etc. It can be used to list related references.
None
The Workbook has the following relationships defined:
| Relationship | Type | Description | Notes |
|---|---|---|---|
| application | Application | Returns an object that represents the Excel application managing the workbook. | |
| names | NamedItem collection | Collection of Named Ranges associated with the workbook | Workbook.Names |
| tables | Table collection | Collection of Tables associated with the workbook | Workbook.ListObjects |
| worksheets | Worksheet collection | Collection of Worksheets associated with the workbook | Workbook.Worksheets |
| bindings | Binding collection | A collection of all the Binding objects that are part of the workbook. |
The Worksheet has the following methods defined:
| Method | Return Type | Description | Notes |
|---|---|---|---|
| getActiveWorksheet() | Worksheet object | Get the currently active worksheet in the workbook. | |
| getSelectedRange() | Range object | Get the currently selected Range from the Workbook. |
Get the currently active worksheet in the workbook.
context.workbook.getActiveWorksheet();None
Worksheet object.
var ctx = new Excel.ExcelClientContext();
var activeWorksheet = ctx.workbook.getActiveWorksheet();
ctx.load(activeWorksheet);
ctx.executeAsync().then(function () {
Console.log(activeWorksheet.name);
});Get the currently selected Range from the Workbook.
context.workbook.getSelectedRange();None
Range object.
var ctx = new Excel.ExcelClientContext();
var selectedRange = ctx.workbook.getSelectedRange();
ctx.executeAsync().then(function () {
Console.log(selectedRange.address);
});