TableData.rows property (JavaScript API for Office)

Office Add-ins

Gets or sets the rows in the table.

Last modified: June 25, 2015

Note Note

The name "apps for Office" is changing to "Office Add-ins". During the transition, the documentation and the UI of some Office host applications and Visual Studio tools might still use the term "apps for Office". For details, see New name for apps for Office and SharePoint.

Hosts:

Excel, Word

Available in Requirement set

TableBindings

Added in

1.1

See all support details

var myRows = tableBindingObj.rows;

Returns an array of arrays that contains the data in the table. Returns an empty array[], if there are no rows.

To specify rows, you must specify an array of arrays that corresponds to the structure of the table. For example, to specify two rows of string values in a two-column table you would set the row property to [['a', 'b'], ['c', 'd']].

If you specify null for the rows property (or leave the property empty when you construct a TableData object), the following results occur when your code executes:

  • If you insert a new table, a blank row will be inserted.

  • If you overwrite or update an existing table, the existing rows are not altered.

The following example creates a single-column table with a header and three rows.

function createTableData() {
    var tableData = new Office.TableData();
    tableData.headers = [['header1']];
    tableData.rows = [['row1'], ['row2'], ['row3']];
    return tableData;
}

A checkmark (√) in the following matrix indicates that this method is supported in the corresponding Office host application. An empty cell indicates that the Office host application doesn't support this method.

For more information about Office host application and server requirements, see Requirements for running apps for Office.

Office for Windows desktop

Office Online
(in browser)

Office for iPad

Excel

Word

Available in requirement sets

TableBindings

Minimum permission level

Restricted

App types

Content, task pane

Library

Office.js

Namespace

Office

Version

Changes

1.1

Added support for Word Online.

1.1

Added support for Excel and Word in Office for iPad

1.0

Introduced

Show:
© 2015 Microsoft