TableData.headers property (JavaScript API for Office v1.1)

JavaScript API for Office v1.1

Gets or sets the headers of the table.

Last modified: June 12, 2014

var hasHeaders = tableBindingObj.headers;

true if the table has headers; otherwise false.

To specify headers, you must specify an array of arrays that corresponds to the structure of the table. For example, to specify headers for a two-column table you would set the header property to [['header1', 'header2']].

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

  • If you insert a new table, the default column headers for the table are created.

  • If you overwrite or update an existing table, the existing headers 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;
}

App types

Content apps, Task pane apps

Supported clients

Excel 2013, Excel Online, Excel 2013 SP1, Excel 2013 RT, Word 2013, Word 2013 SP1, Word 2013 RT

Library

Office.js

Namespace

Office

Show:
© 2014 Microsoft