Export (0) Print
Expand All

TableData.headers property (JavaScript API for Office)

apps for Office

Gets or sets the headers of the table.

Last modified: March 02, 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".

Hosts:

Excel, Word

Available in Requirement set

TableBindings

Last changed in

1.0

See all support details

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

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

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

Office for Windows desktop

Office for Windows RT

Office Online
(in browser)

Excel

Word

Available in requirement sets

Minimum permission level

Restricted

App types

Content, task pane

Library

Office.js

Namespace

Office

Version

Changes

1.0

Introduced

Show:
© 2015 Microsoft