Skip to content

Latest commit

 

History

History
147 lines (107 loc) · 3.17 KB

binding.md

File metadata and controls

147 lines (107 loc) · 3.17 KB

Binding

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.

Relationships

None

Methods

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.

API Specification

getRange()

Returns the range represented by the binding. Will throw an error if binding is not of the correct type.

Syntax

bindingObject.getRange();

Parameters

None

Returns

Range

Examples

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);
});

Back

getTable()

Returns the table represented by the binding. Will throw an error if binding is not of the correct type.

Syntax

bindingObject.getTable();

Parameters

None

Returns

Table

Examples

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);
});

Back

getText()

Returns the text represented by the binding. Will throw an error if binding is not of the correct type.

Syntax

bindingObject.getText();

Parameters

None

Returns

string

Examples

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);
});

Back

load(param: object)

Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.

Syntax

object.load(param);

Parameters

Parameter Type Description
param object Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object.

Returns

void

Examples

Back

Getter Examples

var ctx = new Excel.RequestContext();
var binding = ctx.workbook.bindings.getItemAt(0);
ctx.load(binding);
ctx.executeAsync().then(function() {
	Console.log(binding.type);
});

Back