Excel.TableColumn class

Represents a column in a table.

[ API set: ExcelApi 1.1 ]

Extends
OfficeExtension.ClientObject

Properties

filter

Retrieve the filter applied to the column. Read-only.

[ API set: ExcelApi 1.2 ]

id

Returns a unique key that identifies the column within the table. Read-only.

[ API set: ExcelApi 1.1 ]

index

Returns the index number of the column within the columns collection of the table. Zero-indexed. Read-only.

[ API set: ExcelApi 1.1 ]

name

Represents the name of the table column.

[ API set: ExcelApi 1.1 for getting the name; 1.4 for setting it. ]

values

Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string.

[ API set: ExcelApi 1.1 ]

Methods

delete()

Deletes the column from the table.

[ API set: ExcelApi 1.1 ]

getDataBodyRange()

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

[ API set: ExcelApi 1.1 ]

getHeaderRowRange()

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

[ API set: ExcelApi 1.1 ]

getRange()

Gets the range object associated with the entire column.

[ API set: ExcelApi 1.1 ]

getTotalRowRange()

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

[ API set: ExcelApi 1.1 ]

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

toJSON()

Property Details

filter

Retrieve the filter applied to the column. Read-only.

[ API set: ExcelApi 1.2 ]

readonly filter: Excel.Filter;
Property Value

id

Returns a unique key that identifies the column within the table. Read-only.

[ API set: ExcelApi 1.1 ]

readonly id: number;
Property Value
number

index

Returns the index number of the column within the columns collection of the table. Zero-indexed. Read-only.

[ API set: ExcelApi 1.1 ]

readonly index: number;
Property Value
number

name

Represents the name of the table column.

[ API set: ExcelApi 1.1 for getting the name; 1.4 for setting it. ]

name: string;
Property Value
string

values

Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string.

[ API set: ExcelApi 1.1 ]

values: any[][];
Property Value
any[][]

Method Details

delete()

Deletes the column from the table.

[ API set: ExcelApi 1.1 ]

delete(): void;
Returns
void

Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var column = ctx.workbook.tables.getItem(tableName).columns.getItemAt(2);
    column.delete();
    return ctx.sync(); 
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

getDataBodyRange()

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

[ API set: ExcelApi 1.1 ]

getDataBodyRange(): Excel.Range;
Returns

Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var column = ctx.workbook.tables.getItem(tableName).columns.getItemAt(0);
    var dataBodyRange = column.getDataBodyRange();
    dataBodyRange.load('address');
    return ctx.sync().then(function() {
        console.log(dataBodyRange.address);
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

getHeaderRowRange()

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

[ API set: ExcelApi 1.1 ]

getHeaderRowRange(): Excel.Range;
Returns

Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var columns = ctx.workbook.tables.getItem(tableName).columns.getItemAt(0);
    var headerRowRange = columns.getHeaderRowRange();
    headerRowRange.load('address');
    return ctx.sync().then(function() {
        console.log(headerRowRange.address);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

getRange()

Gets the range object associated with the entire column.

[ API set: ExcelApi 1.1 ]

getRange(): Excel.Range;
Returns

Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var columns = ctx.workbook.tables.getItem(tableName).columns.getItemAt(0);
    var columnRange = columns.getRange();
    columnRange.load('address');
    return ctx.sync().then(function() {
        console.log(columnRange.address);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

getTotalRowRange()

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

[ API set: ExcelApi 1.1 ]

getTotalRowRange(): Excel.Range;
Returns

Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var columns = ctx.workbook.tables.getItem(tableName).columns.getItemAt(0);
    var totalRowRange = columns.getTotalRowRange();
    totalRowRange.load('address');
    return ctx.sync().then(function() {
        console.log(totalRowRange.address);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

load(option?: string | string[]): Excel.TableColumn;
Parameters
option
string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns
Remarks

In addition to this signature, this method has the following signatures:

load(option?: { select?: string; expand?: string; }): Excel.TableColumn - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load.

load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.TableColumn - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items.

Examples

Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var column = ctx.workbook.tables.getItem(tableName).columns.getItem(0);
    column.load('index');
    return ctx.sync().then(function() {
        console.log(column.index);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});
Excel.run(function (ctx) { 
    var tableName = 'Table1';
    var tables = ctx.workbook.tables;
    var newValues = [["New"], ["Values"], ["For"], ["New"], ["Column"]];
    var column = ctx.workbook.tables.getItem(tableName).columns.getItemAt(2);
    column.values = newValues;
    column.load('values');
    return ctx.sync().then(function() {
        console.log(column.values);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

toJSON()

toJSON(): Excel.Interfaces.TableColumnData;
Returns