Represents a column in a table.
Property | Type | Description |
---|---|---|
id | int | Returns a unique key that identifies the column within the table. Read-only. |
index | int | Returns the index number of the column within the columns collection of the table. Zero-indexed. Read-only. |
name | string | Returns the name of the table column. Read-only. |
values | object[][] | Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cell that contain an error will return the error string. |
None
Method | Return Type | Description |
---|---|---|
delete() | void | Deletes the column from the table. |
getDataBodyRange() | Range | Gets the range object associated with the data body of the column. |
getHeaderRowRange() | Range | Gets the range object associated with the header row of the column. |
getRange() | Range | Gets the range object associated with the entire column. |
getTotalRowRange() | Range | Gets the range object associated with the totals row of the column. |
load(param: object) | void | Fills the proxy object created in JavaScript layer with property and object values specified in the parameter. |
Deletes the column from the table.
tableColumnObject.delete();
None
void
var tableName = 'Table1';
var ctx = new Excel.RequestContext();
var column = ctx.workbook.tables.getItem(tableName).tableColumns.getItemAt(2);
column.delete();
ctx.executeAsync();
Gets the range object associated with the data body of the column.
tableColumnObject.getDataBodyRange();
None
var tableName = 'Table1';
var ctx = new Excel.RequestContext();
var column = ctx.workbook.tables.getItem(tableName).tableColumns.getItemAt(0);
var dataBodyRange = column.getDataBodyRange();
ctx.load(dataBodyRange);
ctx.executeAsync().then(function () {
Console.log(dataBodyRange.address);
});
Gets the range object associated with the header row of the column.
tableColumnObject.getHeaderRowRange();
None
var tableName = 'Table1';
var ctx = new Excel.RequestContext();
var columns = ctx.workbook.tables.getItem(tableName).tableColumns.getItemAt(0);
var headerRowRange = columns.getHeaderRowRange();
ctx.load(headerRowRange);
ctx.executeAsync().then(function () {
Console.log(headerRowRange.address);
});
Gets the range object associated with the entire column.
tableColumnObject.getRange();
None
var tableName = 'Table1';
var ctx = new Excel.RequestContext();
var columns = ctx.workbook.tables.getItem(tableName).tableColumns.getItemAt(0);
var columnRange = columns.getRange();
ctx.load(range);
ctx.executeAsync().then(function () {
Console.log(range.columnRange);
});
Gets the range object associated with the totals row of the column.
tableColumnObject.getTotalRowRange();
None
var tableName = 'Table1';
var ctx = new Excel.RequestContext();
var columns = ctx.workbook.tables.getItem(tableName).tableColumns.getItemAt(0);
var totalRowRange = columns.getTotalRowRange();
ctx.load(totalRowRange);
ctx.executeAsync().then(function () {
Console.log(totalRowRange.address);
});
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 tableName = 'Table1';
var ctx = new Excel.RequestContext();
var column = ctx.workbook.tables.getItem(tableName).tableColumns.getItem(0);
ctx.load(column);
ctx.executeAsync().then(function () {
Console.log(column.index);
});
var ctx = new Excel.RequestContext();
var tables = ctx.workbook.tables;
var newValues = [["New"], ["Values"], ["For"], ["New"], ["Column"]];
var column = ctx.workbook.tables.getItem(tableName).tableColumns.getItemAt(2);
column.values = newValues;
ctx.load(column);
ctx.executeAsync().then(function () {
Console.log(column.values);
});