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. |
None
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. |
Adds a new row to the table.
tableRowCollectionObject.add(index, values);
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. |
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);
});
Gets a row based on its position in the collection.
tableRowCollectionObject.getItemAt(index);
Parameter | Type | Description |
---|---|---|
index | number | Index value of the object to be retrieved. Zero-indexed. |
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);
});
Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.
object.load(param);
Parameter | Type | Description |
---|---|---|
param | object | Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object. |
void
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);
}
});