Skip to content

Latest commit

 

History

History
222 lines (166 loc) · 4.99 KB

tablecolumn.md

File metadata and controls

222 lines (166 loc) · 4.99 KB

TableColumn

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.

Relationships

None

Methods

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.

API Specification

delete()

Deletes the column from the table.

Syntax

tableColumnObject.delete();

Parameters

None

Returns

void

Examples

var tableName = 'Table1';
var ctx = new Excel.RequestContext();
var column = ctx.workbook.tables.getItem(tableName).tableColumns.getItemAt(2);
column.delete();
ctx.executeAsync();

Back

getDataBodyRange()

Gets the range object associated with the data body of the column.

Syntax

tableColumnObject.getDataBodyRange();

Parameters

None

Returns

Range

Examples

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

Back

getHeaderRowRange()

Gets the range object associated with the header row of the column.

Syntax

tableColumnObject.getHeaderRowRange();

Parameters

None

Returns

Range

Examples

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

Back

getRange()

Gets the range object associated with the entire column.

Syntax

tableColumnObject.getRange();

Parameters

None

Returns

Range

Examples

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

Back

getTotalRowRange()

Gets the range object associated with the totals row of the column.

Syntax

tableColumnObject.getTotalRowRange();

Parameters

None

Returns

Range

Examples

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

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 and Setter Examples

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

Back