Represents a collection of all the columns that are part of the table.
Property | Type | Description |
---|---|---|
count | int | Returns the number of columns in the table. Read-only. |
items | TableColumn[] | A collection of tableColumn objects. Read-only. |
None
Method | Return Type | Description |
---|---|---|
add(index: number, values: object[][]) | TableColumn | Adds a new column to the table. |
getItem(id: object) | TableColumn | Gets a column object by Name or ID. |
getItemAt(index: number) | TableColumn | Gets a column 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 column to the table.
tableColumnCollectionObject.add(index, values);
Parameter | Type | Description |
---|---|---|
index | number | Specifies the relative position of the new column. The previous column at this position is shifted to the right. The index value should be equal to or less than the last column's index value, so it cannot be used to append a column at the end of the table. Zero-indexed. |
values | object[][] | Optional. A 2-dimensional array of unformatted values of the table column. |
var ctx = new Excel.RequestContext();
var tables = ctx.workbook.tables;
var values = [["Sample"], ["Values"], ["For"], ["New"], ["Column"]];
var column = tables.getItem("Table1").columns.add(null, values);
ctx.load(column);
ctx.executeAsync().then(function () {
Console.log(column.name);
});
Gets a column object by Name or ID.
tableColumnCollectionObject.getItem(id);
Parameter | Type | Description |
---|---|---|
id | object | Column Name or ID. |
var ctx = new Excel.RequestContext();
var tablecolumn = ctx.workbook.tables.getItem['Table1'].columns.getItem(0);
ctx.load(tablecolumn)
ctx.executeAsync().then(function () {
Console.log(tablecolumn.name);
});
Gets a column based on its position in the collection.
tableColumnCollectionObject.getItemAt(index);
Parameter | Type | Description |
---|---|---|
index | number | Index value of the object to be retrieved. Zero-indexed. |
var ctx = new Excel.RequestContext();
var tablecolumn = ctx.workbook.tables.getItem['Table1'].columns.getItemAt(0);
ctx.load(tablecolumn)
ctx.executeAsync().then(function () {
Console.log(tablecolumn.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 tablecolumns = ctx.workbook.tables.getItem['Table1'].columns;
ctx.load(tablecolumns);
ctx.executeAsync().then(function () {
Console.log("tablecolumns Count: " + tablecolumns.count);
for (var i = 0; i < tablecolumns.items.length; i++)
{
Console.log(tablecolumns.items[i].name);
}
});