Office.TableData class

Represents the data in a table or an Office.TableBinding.

Constructors

(constructor)(rows, headers)

Constructs a new instance of the TableData class

(constructor)()

Constructs a new instance of the TableData class

Properties

headers

Gets or sets the headers of the table.

rows

Gets or sets the rows in the table. Returns an array of arrays that contains the data in the table. Returns an empty array if there are no rows.

Constructor Details

(constructor)(rows, headers)

Constructs a new instance of the TableData class

constructor(rows: any[][], headers: any[]);

Parameters

rows
any[][]
headers
any[]

(constructor)()

Constructs a new instance of the TableData class

constructor();

Property Details

headers

Gets or sets the headers of the table.

headers: any[];

Property Value

any[]

Remarks

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.

Examples

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

rows

Gets or sets the rows in the table. Returns an array of arrays that contains the data in the table. Returns an empty array if there are no rows.

rows: any[][];

Property Value

any[][]

Remarks

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 rows 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.

Examples

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