Skip to content

Latest commit

 

History

History
123 lines (93 loc) · 3.13 KB

tablerowcollection.md

File metadata and controls

123 lines (93 loc) · 3.13 KB

TableRowCollection

Represents a collection of all the rows that are part of the table.

Property Type Description
count int Returns the number of rows in the table. Read-only.
items TableRow[] A collection of tableRow objects. Read-only.

Relationships

None

Methods

Method Return Type Description
add(index: number, values: object[][]) TableRow Adds a new row to the table.
getItemAt(index: number) TableRow Gets a row based on its position in the collection.
load(param: object) void Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.

API Specification

add(index: number, values: object[][])

Adds a new row to the table.

Syntax

tableRowCollectionObject.add(index, values);

Parameters

Parameter Type Description
index number Optional. Specifies the relative position of the new row. If null, the addition happens at the end. Any rows below the inserted row are shifted downwards. Zero-indexed.
values object[][] Optional. A 2-dimensional array of unformatted values of the table row.

Returns

TableRow

Examples

var ctx = new Excel.RequestContext();
var tables = ctx.workbook.tables;
var values = [["Sample", "Values", "For", "New", "Row"]];
var row = tables.getItem("Table1").rows.add(null, values);
ctx.load(row);
ctx.executeAsync().then(function () {
	Console.log(row.index);
});

Back

getItemAt(index: number)

Gets a row based on its position in the collection.

Syntax

tableRowCollectionObject.getItemAt(index);

Parameters

Parameter Type Description
index number Index value of the object to be retrieved. Zero-indexed.

Returns

TableRow

Examples

var ctx = new Excel.RequestContext();
var tablerow = ctx.workbook.tables.getItem('Table1').rows.getItemAt(0);
ctx.load(tablerow);
ctx.executeAsync().then(function () {
		Console.log(tablerow.name);
});

Back

load(param: object)

Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.

Syntax

object.load(param);

Parameters

Parameter Type Description
param object Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object.

Returns

void

Examples

Back

Getter Examples

var ctx = new Excel.RequestContext();
var tablerows = ctx.workbook.tables.getItem('Table1').rows;
ctx.load(tablerows);
ctx.executeAsync().then(function () {
	Console.log("tablerows Count: " + tablerows.count);
	for (var i = 0; i < tablerows.items.length; i++)
	{
		Console.log(tablerows.items[i].index);
	}
});

Back