Office.Binding interface

ドキュメントのセクションへのバインドを表します。

Binding オブジェクトは、型に関係なく、すべてのバインドによって所有されている機能を公開します。

Binding オブジェクトが直接呼び出されることはありません。 これは、各種類のバインドを表すオブジェクトの抽象親クラスです。 Office.MatrixBindingOffice.TableBinding、または Office.TextBinding です。 これらの 3 つのオブジェクトはすべて、バインド内のデータとの対話を可能にする Binding オブジェクトから getDataAsync メソッドと setDataAsync メソッドを継承します。 また、これらのプロパティ値を照会するための ID プロパティと型プロパティも継承します。 さらに、MatrixBinding および TableBinding オブジェクトは、行数と列数をカウントする機能など、マトリックスおよびテーブル固有の機能も公開します。

注釈

アプリケーション: Word、Excel (非推奨、代わりに Excel.Binding を使用)

要件セット:

プロパティ

document

バインドに関連付けられている Document オブジェクトを取得します。

id

同じ Office.Document オブジェクト内のバインド間でこのバインドを一意に識別する文字列。

type

バインドの種類を取得します。

メソッド

addHandlerAsync(eventType, handler, options, callback)

指定した Office.EventType のオブジェクトにイベント ハンドラーを追加します。 サポートされている EventType は Office.EventType.BindingDataChangedOffice.EventType.BindingSelectionChangedです。

addHandlerAsync(eventType, handler, callback)

指定した Office.EventType のオブジェクトにイベント ハンドラーを追加します。 サポートされている EventType は Office.EventType.BindingDataChangedOffice.EventType.BindingSelectionChangedです。

getDataAsync(options, callback)

バインド内に含まれるデータを返します。

getDataAsync(callback)

バインド内に含まれるデータを返します。

removeHandlerAsync(eventType, options, callback)

指定されたイベントの種類のバインドから、指定されたハンドラーを削除します。

removeHandlerAsync(eventType, callback)

指定されたイベントの種類のバインドから、指定されたハンドラーを削除します。

setDataAsync(data, options, callback)

指定されたバインド オブジェクトで表されるドキュメントのバインド セクションにデータを書き込みます。

setDataAsync(data, callback)

指定されたバインド オブジェクトで表されるドキュメントのバインド セクションにデータを書き込みます。

プロパティの詳細

document

バインドに関連付けられている Document オブジェクトを取得します。

document: Office.Document;

プロパティ値

Office.context.document.bindings.getByIdAsync("myBinding", function (asyncResult) {
    write(asyncResult.value.document.url);
});

// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

id

同じ Office.Document オブジェクト内のバインド間でこのバインドを一意に識別する文字列。

id: string;

プロパティ値

string

Office.context.document.bindings.getByIdAsync("myBinding", function (asyncResult) {
    write(asyncResult.value.id);
});

// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

type

バインドの種類を取得します。

type: Office.BindingType;

プロパティ値

Office.context.document.bindings.getByIdAsync("MyBinding", function (asyncResult) { 
    write(asyncResult.value.type); 
}) 

// Function that writes to a div with id='message' on the page. 
function write(message){ 
    document.getElementById('message').innerText += message;  
}

メソッドの詳細

addHandlerAsync(eventType, handler, options, callback)

指定した Office.EventType のオブジェクトにイベント ハンドラーを追加します。 サポートされている EventType は Office.EventType.BindingDataChangedOffice.EventType.BindingSelectionChangedです。

addHandlerAsync(eventType: Office.EventType, handler: any, options?: Office.AsyncContextOptions, callback?: (result: Office.AsyncResult<void>) => void): void;

パラメーター

eventType
Office.EventType

イベントの種類。 バインドの場合は、 または を指定Office.EventType.BindingDataChangedOffice.EventType.BindingSelectionChangedできます。

handler

any

追加するイベント ハンドラー関数。パラメーターは Office.BindingDataChangedEventArgs または Office.BindingSelectionChangedEventArgs 型のみです。

options
Office.AsyncContextOptions

コールバックで使用するために、任意の型のコンテキスト データを変更せずに保持するためのオプションを提供します。

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット: BindingEvents

各イベント ハンドラー関数の名前が一意である限り、指定した eventType に対して複数のイベント ハンドラーを追加できます。

addHandlerAsync(eventType, handler, callback)

指定した Office.EventType のオブジェクトにイベント ハンドラーを追加します。 サポートされている EventType は Office.EventType.BindingDataChangedOffice.EventType.BindingSelectionChangedです。

addHandlerAsync(eventType: Office.EventType, handler: any, callback?: (result: Office.AsyncResult<void>) => void): void;

パラメーター

eventType
Office.EventType

イベントの種類。 バインドの場合は、 または を指定Office.EventType.BindingDataChangedOffice.EventType.BindingSelectionChangedできます。

handler

any

追加するイベント ハンドラー関数。パラメーターは Office.BindingDataChangedEventArgs または Office.BindingSelectionChangedEventArgs 型のみです。

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット: BindingEvents

各イベント ハンドラー関数の名前が一意である限り、指定した eventType に対して複数のイベント ハンドラーを追加できます。

// The following code sample calls the select function of the Office object to access the binding
// with ID "MyBinding", and then calls the addHandlerAsync method to add a handler function 
// for the bindingDataChanged event of that binding.
function addEventHandlerToBinding() {
    Office.select("bindings#MyBinding").addHandlerAsync(
        Office.EventType.BindingDataChanged, onBindingDataChanged);
}

function onBindingDataChanged(eventArgs) {
    write("Data has changed in binding: " + eventArgs.binding.id);
}

// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}
// To add an event handler for the BindingSelectionChanged event of a binding, 
// use the addHandlerAsync method of the Binding object.
// The event handler receives an argument of type BindingSelectionChangedEventArgs.
function addEventHandlerToBinding() {
    Office.select("bindings#MyBinding").addHandlerAsync(
        Office.EventType.BindingSelectionChanged, onBindingSelectionChanged);
}

function onBindingSelectionChanged(eventArgs) {
    write(eventArgs.binding.id + " has been selected.");
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

getDataAsync(options, callback)

バインド内に含まれるデータを返します。

getDataAsync<T>(options?: GetBindingDataOptions, callback?: (result: AsyncResult<T>) => void): void;

パラメーター

options
Office.GetBindingDataOptions

バインド内のデータを取得する方法のオプションを提供します。

callback

(result: Office.AsyncResult<T>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。 結果のプロパティは value 、指定したバインド内の値です。 パラメーターが coercionType 指定され、呼び出しが成功した場合、データは CoercionType 列挙トピックで説明されている形式で返されます。

戻り値

void

注釈

要件セット:

MatrixBinding または TableBinding から呼び出されると、getDataAsync メソッドは、オプションの startRow、startColumn、rowCount、columnCount パラメーターが指定されている場合 (および連続した有効な範囲を指定する) 場合、バインドされた値のサブセットを返します。

getDataAsync(callback)

バインド内に含まれるデータを返します。

getDataAsync<T>(callback?: (result: AsyncResult<T>) => void): void;

パラメーター

callback

(result: Office.AsyncResult<T>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。 結果のプロパティは value 、指定したバインド内の値です。 パラメーターが coercionType 指定され、呼び出しが成功した場合、データは CoercionType 列挙トピックで説明されている形式で返されます。

戻り値

void

注釈

要件セット:

MatrixBinding または TableBinding から呼び出されると、getDataAsync メソッドは、オプションの startRow、startColumn、rowCount、columnCount パラメーターが指定されている場合 (および連続した有効な範囲を指定する) 場合、バインドされた値のサブセットを返します。

function showBindingData() {
    Office.select("bindings#MyBinding").getDataAsync(function (asyncResult) {
        write(asyncResult.value)
    });
}

// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

// There is an important difference in behavior between using the "table" and "matrix" coercionType with the
// Binding.getDataAsync method, with respect to data formatted with header rows, as shown in the following
// two examples. These code examples show event handler functions for the Binding.SelectionChanged event.

// If you specify the "table" coercionType, the TableData.rows property ( result.value.rows in the following
// code example) returns an array that contains only the body rows of the table. So, its 0th row will be the
// first non-header row in the table.
function selectionChanged(evtArgs) { 
    Office.select("bindings#TableTranslate").getDataAsync(
        { coercionType: 'table', 
          startRow: evtArgs.startRow, 
          startCol: 0, 
          rowCount: 1, 
          columnCount: 1 },  
        function (result) { 
            if (result.status == 'succeeded') { 
                write("Image to find: " + result.value.rows[0][0]); 
            } 
            else 
                write(result.error.message); 
    }); 
}     
// Function that writes to a div with id='message' on the page. 
function write(message){ 
    document.getElementById('message').innerText += message; 
}

// However, if you specify the "matrix" coercionType, result.value in the following code example returns an array
// that contains the table header in the 0th row. If the table header contains multiple rows, then these are all
// included in the result.value matrix as separate rows before the table body rows are included.
function selectionChanged(evtArgs) { 
    Office.select("bindings#TableTranslate").getDataAsync(
        { coercionType: 'matrix', 
          startRow: evtArgs.startRow, 
          startCol: 0, 
          rowCount: 1, 
          columnCount: 1 },  
        function (result) { 
            if (result.status == 'succeeded') { 
                write("Image to find: " + result.value[1][0]); 
            } 
            else 
                write(result.error.message); 
    }); 
}     
// Function that writes to a div with id='message' on the page. 
function write(message){ 
    document.getElementById('message').innerText += message; 
}

removeHandlerAsync(eventType, options, callback)

指定されたイベントの種類のバインドから、指定されたハンドラーを削除します。

removeHandlerAsync(eventType: Office.EventType, options?: RemoveHandlerOptions, callback?: (result: AsyncResult<void>) => void): void;

パラメーター

eventType
Office.EventType

イベントの種類。 バインドの場合は、 または を指定Office.EventType.BindingDataChangedOffice.EventType.BindingSelectionChangedできます。

options
Office.RemoveHandlerOptions

削除されるイベント ハンドラーまたはハンドラーを決定するオプションを提供します。

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット: BindingEvents

removeHandlerAsync(eventType, callback)

指定されたイベントの種類のバインドから、指定されたハンドラーを削除します。

removeHandlerAsync(eventType: Office.EventType, callback?: (result: AsyncResult<void>) => void): void;

パラメーター

eventType
Office.EventType

イベントの種類。 バインドの場合は、 または を指定Office.EventType.BindingDataChangedOffice.EventType.BindingSelectionChangedできます。

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット: BindingEvents

function removeEventHandlerFromBinding() {
    Office.select("bindings#MyBinding").removeHandlerAsync(
        Office.EventType.BindingDataChanged, {handler:onBindingDataChanged});
}

setDataAsync(data, options, callback)

指定されたバインド オブジェクトで表されるドキュメントのバインド セクションにデータを書き込みます。

setDataAsync(data: TableData | any, options?: SetBindingDataOptions, callback?: (result: AsyncResult<void>) => void): void;

パラメーター

data

Office.TableData | any

現在の選択範囲に設定するデータ。 Office アプリケーションで使用できるデータ型:

string: Excel on the webと Windows、および Word on the web と Windows のみ

配列の配列: Excel と Word のみ

Office.TableData: Excel と Word のみ

HTML: Word on the web と Windows のみ

Office Open XML: Word のみ

options
Office.SetBindingDataOptions

バインドでデータを設定する方法のオプションを提供します。

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット:

データに渡される値には、バインディングで書き込まれるデータが含まれます。 次の表に示されるように、渡された値の種類により、書き込まれる内容が決まります。

data 書き込まれるデータ
文字列 プレーン テキストまたは文字列に強制できる内容が書き込まれます。
配列の配列 ("matrix") Tabular data without headers will be written. たとえば、3 行 2 列のデータを書き込むには、 \[\["R1C1", "R1C2"\], \["R2C1", "R2C2"\], \["R3C1", "R3C2"\]\] という配列を渡します。 3 行の 1 つの列を書き込むには、次のような配列を渡します。 \[\["R1C1"\], \["R2C1"\], \["R3C1"\]\]
TableDataオブジェクト ヘッダー付きのテーブルが書き込まれます。

また、バインドにデータを書き込むときに、次のアプリケーション固有の処理が適用されます。 Word の場合、指定したデータは次のようにバインドに書き込まれます。

data 書き込まれるデータ
文字列 指定されたテキストが書き込まれます。
配列の配列 ("matrix") または TableData オブジェクト HTML
HTML 指定された HTML が書き込まれます。 書き込む HTML に無効な HTML が含まれている場合も、エラーは発生しません。 HTML はできる限り書き込まれ、無効なデータは省略されます。
Office Open XML ("Open XML") 指定された XML が書き込まれます。

Excel の場合、指定したデータは次のようにバインドに書き込まれます。

data 書き込まれるデータ
文字列 指定されたテキストが最初にバインドされたセルの値として挿入されます。 また、バインドされたセルに追加する有効な数式を指定できます。 たとえば、data を "=SUM(A1:A5)" と設定すると、指定の範囲内の値が集計されます。 ただし、バインドされたセルで数式を設定する場合、その後、バインドされたセルからは追加された数式 (または既存の数式) を読み取ることができません。 バインドされたセルで メソッドを Binding.getDataAsync 呼び出してデータを読み取る場合、メソッドはセルに表示されるデータ (数式の結果) のみを返すことができます。
配列の配列 (「matrix」)、形状が指定されたバインドの形状と完全に一致する場合 The set of rows and columns are written.You can also specify an array of arrays that contain valid formulas to add them to the bound cells. たとえば、データを に \[\["=SUM(A1:A5)","=AVERAGE(A1:A5)"\]\] 設定すると、これらの 2 つの数式が 2 つのセルを含むバインドに追加されます。 1 つのバインドされたセルに数式を設定する場合と同様に、メソッドを使用 Binding.getDataAsync してバインドから追加された数式 (または既存の数式) を読み取ることはできません。バインドされたセルに表示されるデータのみが返されます。
TableDataオブジェクトとテーブルの図形は、バインドされたテーブルと一致します The specified set of rows and/or headers are written, if no other data in surrounding cells will be overwritten. **注**: *data* パラメーターに渡すオブジェクトで TableData 数式を指定した場合、Excel の "計算列" 機能により、列内の数式が自動的に複製されるため、予期した結果が得られない可能性があります。 バインドされたテーブルに数式を含む *data* を書き込む場合にこの問題を回避するには、データを配列の配列 (オブジェクトではなく TableData ) として指定し、*coercionType* を Microsoft.Office.Matrix または "matrix" として指定します。

Excel on the webの場合:

  • データ パラメーターに渡される値のセルの合計数は、このメソッドの 1 回の呼び出しで 20,000 を超えることはできません。

  • cellFormat パラメーターに渡される書式設定グループの数は、100 を超えることはできません。 1 つの書式設定グループは、指定のセル範囲に適用される書式設定のセットから構成されます。

上記以外の場合は、エラーが返されます。

setDataAsync メソッドは、オプションの startRow パラメーターと startColumn パラメーターを指定し、有効な範囲を指定した場合、テーブルまたはマトリックス バインドのサブセットにデータを書き込みます。

setDataAsync メソッドに渡されたコールバック関数で、AsyncResult オブジェクトのプロパティを使用して次の情報を戻せます。

プロパティ 使用
AsyncResult.value 取得する undefined オブジェクトまたはデータがないため、常にが返されます
AsyncResult.status 操作の成功または失敗を判断する
AsyncResult.error 操作が失敗した場合にエラー情報を提供する Error オブジェクトにアクセスする
AsyncResult.asyncContext 変更されずに AsyncResult オブジェクトで返される任意の型の項目を定義する

setDataAsync(data, callback)

指定されたバインド オブジェクトで表されるドキュメントのバインド セクションにデータを書き込みます。

setDataAsync(data: TableData | any, callback?: (result: AsyncResult<void>) => void): void;

パラメーター

data

Office.TableData | any

現在の選択範囲に設定するデータ。 Office アプリケーションで使用できるデータ型:

string: Excel on the webと Windows、および Word on the web と Windows のみ

配列の配列: Excel と Word のみ

TableData: Excel と Word のみ

HTML: Word on the web と Windows のみ

Office Open XML: Word のみ

callback

(result: Office.AsyncResult<void>) => void

オプション。 コールバックから戻るときに呼び出される関数。パラメーターは Office.AsyncResult 型のみです。

戻り値

void

注釈

要件セット:

データに渡される値には、バインディングで書き込まれるデータが含まれます。 次の表に示されるように、渡された値の種類により、書き込まれる内容が決まります。

data 書き込まれるデータ
文字列 プレーン テキストまたは文字列に強制できる内容が書き込まれます。
配列の配列 ("matrix") Tabular data without headers will be written. たとえば、3 行 2 列のデータを書き込むには、 \[\["R1C1", "R1C2"\], \["R2C1", "R2C2"\], \["R3C1", "R3C2"\]\] という配列を渡します。 3 行の 1 つの列を書き込むには、次のような配列を渡します。 \[\["R1C1"\], \["R2C1"\], \["R3C1"\]\]
TableDataオブジェクト ヘッダー付きのテーブルが書き込まれます。

また、バインドにデータを書き込むときに、次のアプリケーション固有の処理が適用されます。 Word の場合、指定したデータは次のようにバインドに書き込まれます。

data 書き込まれるデータ
文字列 指定されたテキストが書き込まれます。
配列の配列 ("matrix") または TableData オブジェクト HTML
HTML 指定された HTML が書き込まれます。 書き込む HTML に無効な HTML が含まれている場合も、エラーは発生しません。 HTML はできる限り書き込まれ、無効なデータは省略されます。
Office Open XML ("Open XML") 指定された XML が書き込まれます。

Excel の場合、指定したデータは次のようにバインドに書き込まれます。

data 書き込まれるデータ
文字列 指定されたテキストが最初にバインドされたセルの値として挿入されます。 また、バインドされたセルに追加する有効な数式を指定できます。 たとえば、data を "=SUM(A1:A5)" と設定すると、指定の範囲内の値が集計されます。 ただし、バインドされたセルで数式を設定する場合、その後、バインドされたセルからは追加された数式 (または既存の数式) を読み取ることができません。 バインドされたセルで メソッドを Binding.getDataAsync 呼び出してデータを読み取る場合、メソッドはセルに表示されるデータ (数式の結果) のみを返すことができます。
配列の配列 (「matrix」)、形状が指定されたバインドの形状と完全に一致する場合 The set of rows and columns are written.You can also specify an array of arrays that contain valid formulas to add them to the bound cells. たとえば、データを に \[\["=SUM(A1:A5)","=AVERAGE(A1:A5)"\]\] 設定すると、これらの 2 つの数式が 2 つのセルを含むバインドに追加されます。 1 つのバインドされたセルに数式を設定する場合と同様に、メソッドを使用 Binding.getDataAsync してバインドから追加された数式 (または既存の数式) を読み取ることはできません。バインドされたセルに表示されるデータのみが返されます。
TableDataオブジェクトとテーブルの図形は、バインドされたテーブルと一致します The specified set of rows and/or headers are written, if no other data in surrounding cells will be overwritten. **注**: *data* パラメーターに渡すオブジェクトで TableData 数式を指定した場合、Excel の "計算列" 機能により、列内の数式が自動的に複製されるため、予期した結果が得られない可能性があります。 バインドされたテーブルに数式を含む *data* を書き込む場合にこの問題を回避するには、データを配列の配列 (オブジェクトではなく TableData ) として指定し、*coercionType* を Microsoft.Office.Matrix または "matrix" として指定します。

Excel on the webの場合:

  • データ パラメーターに渡される値のセルの合計数は、このメソッドの 1 回の呼び出しで 20,000 を超えることはできません。

  • cellFormat パラメーターに渡される書式設定グループの数は、100 を超えることはできません。 1 つの書式設定グループは、指定のセル範囲に適用される書式設定のセットから構成されます。

上記以外の場合は、エラーが返されます。

setDataAsync メソッドは、オプションの startRow パラメーターと startColumn パラメーターを指定し、有効な範囲を指定した場合、テーブルまたはマトリックス バインドのサブセットにデータを書き込みます。

setDataAsync メソッドに渡されたコールバック関数で、AsyncResult オブジェクトのプロパティを使用して次の情報を戻せます。

プロパティ 使用
AsyncResult.value 取得する undefined オブジェクトまたはデータがないため、常にが返されます
AsyncResult.status 操作の成功または失敗を判断する
AsyncResult.error 操作が失敗した場合にエラー情報を提供する Error オブジェクトにアクセスする
AsyncResult.asyncContext 変更されずに AsyncResult オブジェクトで返される任意の型の項目を定義する

function setBindingData() {
    Office.select("bindings#MyBinding").setDataAsync('Hello World!', function (asyncResult) { });
}

// Specifying the optional coercionType parameter lets you specify the kind of data you want to write to a binding.
// For example, in Word if you want to write HTML to a text binding, you can specify the coercionType parameter 
// as "html" as shown in the following example, which uses HTML <b> tags to make "Hello" bold.
function writeHtmlData() {
    Office.select("bindings#myBinding").setDataAsync(
        "<b>Hello</b> World!", {coercionType: "html"}, function (asyncResult) {
        if (asyncResult.status == "failed") {
            write('Error: ' + asyncResult.error.message);
        }
    });
}

// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

// In this example, the call to setDataAsync passes the data parameter as an array of arrays
// (to create a single column of three rows), and specifies the data structure with the 
// coercionType parameter as a "matrix".
function writeBoundDataMatrix() {
    Office.select("bindings#myBinding").setDataAsync(
        [['Berlin'],['Munich'],['Duisburg']],{ coercionType: "matrix" }, function (asyncResult) {
        if (asyncResult.status == "failed") {
            write('Error: ' + asyncResult.error.message);
        } else {
            write('Bound data: ' + asyncResult.value);
        }
    });
}
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 
}

// In the writeBoundDataTable function in this example, the call to setDataAsync passes the data parameter 
// as a TableData object (to write three columns and three rows), and specifies the data structure
// with the coercionType parameter as a "table".

// In the updateTableData function, the call to setDataAsync again passes the data parameter as a TableData object,
// but as a single column with a new header and three rows, to update the values in the last column 
// of the table created with the writeBoundDataTable function. The optional zero-based startColumn parameter 
// is specified as 2 to replace the values in the third column of the table.
function writeBoundDataTable() {
    // Create a TableData object.
    const myTable = new Office.TableData();
    myTable.headers = ['First Name', 'Last Name', 'Grade'];
    myTable.rows = [['Kim', 'Abercrombie', 'A'], ['Junmin','Hao', 'C'],['Toni','Poe','B']];

    // Set myTable in the binding.
    Office.select("bindings#myBinding").setDataAsync(myTable, { coercionType: "table" }, 
        function (asyncResult) {
            if (asyncResult.status == Office.AsyncResultStatus.Failed) {
                write('Error: '+ asyncResult.error.message);
        } else {
            write('Bound data: ' + asyncResult.value);
        }
    });
}

// Replace last column with different data.
function updateTableData() {
    const newTable = new Office.TableData();
    newTable.headers = ["Gender"];
    newTable.rows = [["M"],["M"],["F"]];
    Office.select("bindings#myBinding").setDataAsync(newTable, { coercionType: "table", startColumn:2 }, 
        function (asyncResult) {
            if (asyncResult.status == Office.AsyncResultStatus.Failed) {
                write('Error: '+ asyncResult.error.message);
        } else {
            write('Bound data: ' + asyncResult.value);
        }     
    });   
}

// In this example, the following call passes two formatting groups to cellFormat.
Office.select("bindings#myBinding").setDataAsync([['Berlin'],['Munich'],['Duisburg']],
  {cellFormat:[{cells: {row: 1}, format: {fontColor: "yellow"}}, 
      {cells: {row: 3, column: 4}, format: {borderColor: "white", fontStyle: "bold"}}]}, 
  function (asyncResult){});