Represents an Office.js binding that is defined in the workbook.
Property | Type | Description |
---|---|---|
id | string | Represents binding identifier. Read-only. |
type | string | Returns the type of the binding. Read-only. Possible values are: Range, Table, Text. |
None
Method | Return Type | Description |
---|---|---|
getRange() | Range | Returns the range represented by the binding. Will throw an error if binding is not of the correct type. |
getTable() | Table | Returns the table represented by the binding. Will throw an error if binding is not of the correct type. |
getText() | string | Returns the text represented by the binding. Will throw an error if binding is not of the correct type. |
load(param: object) | void | Fills the proxy object created in JavaScript layer with property and object values specified in the parameter. |
Returns the range represented by the binding. Will throw an error if binding is not of the correct type.
bindingObject.getRange();
None
Below example uses binding object to get the associated range.
var ctx = new Excel.RequestContext();
var binding = ctx.workbook.bindings.getItemAt(0);
var range = binding.getRange();
ctx.load(range);
ctx.executeAsync().then(function() {
Console.log(range.cellCount);
});
Returns the table represented by the binding. Will throw an error if binding is not of the correct type.
bindingObject.getTable();
None
var ctx = new Excel.RequestContext();
var binding = ctx.workbook.bindings.getItemAt(0);
var table = binding.getTable();
ctx.load(table);
ctx.executeAsync().then(function () {
Console.log(table.name);
});
Returns the text represented by the binding. Will throw an error if binding is not of the correct type.
bindingObject.getText();
None
string
var ctx = new Excel.RequestContext();
var binding = ctx.workbook.bindings.getItemAt(0);
var text = binding.getText();
ctx.load(text);
ctx.executeAsync().then(function() {
Console.log(text);
});
Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.
object.load(param);
Parameter | Type | Description |
---|---|---|
param | object | Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object. |
void
var ctx = new Excel.RequestContext();
var binding = ctx.workbook.bindings.getItemAt(0);
ctx.load(binding);
ctx.executeAsync().then(function() {
Console.log(binding.type);
});