Column

Column class

Represents a single column in a worksheet.

class Column;

Example

const { Workbook, Color, BackgroundType, StyleFlag } = require("aspose.cells.node");

//Instantiating a Workbook object
var workbook = new Workbook();
//Obtaining the reference of the first worksheet
var worksheet = workbook.worksheets.get(0);

//Add new Style to Workbook
var style = workbook.createStyle();
//Setting the background color to Blue
style.backgroundColor = Color.Blue;
//Setting the foreground color to Red
style.foregroundColor = Color.Red;
//setting Background Pattern
style.pattern = BackgroundType.DiagonalStripe;
//New Style Flag
var styleFlag = new StyleFlag();
//Set All Styles
styleFlag.all = true;

//Get first Column
var column = worksheet.cells.columns.get(0);
//Apply Style to first Column
column.applyStyle(style, styleFlag);

//Saving the Excel file
workbook.save("output/Column.xls");

Properties

PropertyTypeDescription
indexnumberReadonly. Gets the index of this column.
widthnumberGets and sets the column width in unit of characters.
groupLevelnumberGets the group level of the column.
isHiddenbooleanIndicates whether the column is hidden.
hasCustomStylebooleanReadonly. Indicates whether this column has custom style settings(different from the default one inherited from workbook).
isCollapsedbooleanwhether the column is collapsed

Methods

MethodDescription
getIndex()@deprecated. Please use the ‘index’ property instead. Gets the index of this column.
getWidth()@deprecated. Please use the ‘width’ property instead. Gets and sets the column width in unit of characters.
setWidth(number)@deprecated. Please use the ‘width’ property instead. Gets and sets the column width in unit of characters.
getGroupLevel()@deprecated. Please use the ‘groupLevel’ property instead. Gets the group level of the column.
setGroupLevel(number)@deprecated. Please use the ‘groupLevel’ property instead. Gets the group level of the column.
isHidden()@deprecated. Please use the ‘isHidden’ property instead. Indicates whether the column is hidden.
setIsHidden(boolean)@deprecated. Please use the ‘isHidden’ property instead. Indicates whether the column is hidden.
getHasCustomStyle()@deprecated. Please use the ‘hasCustomStyle’ property instead. Indicates whether this column has custom style settings(different from the default one inherited from workbook).
isCollapsed()@deprecated. Please use the ‘isCollapsed’ property instead. whether the column is collapsed
setIsCollapsed(boolean)@deprecated. Please use the ‘isCollapsed’ property instead. whether the column is collapsed
applyStyle(Style, StyleFlag)Applies formats for a whole column.
getStyle()Gets the style of this column.
setStyle(Style)Sets the style of this column.
isNull()Checks whether the implementation object is null.

index

Readonly. Gets the index of this column.

index : number;

width

Gets and sets the column width in unit of characters.

width : number;

Remarks

For spreadsheet, column width is measured as the number of characters of the maximum digit width of the numbers 0~9 as rendered in the normal style’s font.

groupLevel

Gets the group level of the column.

groupLevel : number;

isHidden

Indicates whether the column is hidden.

isHidden : boolean;

hasCustomStyle

Readonly. Indicates whether this column has custom style settings(different from the default one inherited from workbook).

hasCustomStyle : boolean;

isCollapsed

whether the column is collapsed

isCollapsed : boolean;

getIndex()

@deprecated. Please use the ‘index’ property instead. Gets the index of this column.

getIndex() : number;

getWidth()

@deprecated. Please use the ‘width’ property instead. Gets and sets the column width in unit of characters.

getWidth() : number;

Remarks

For spreadsheet, column width is measured as the number of characters of the maximum digit width of the numbers 0~9 as rendered in the normal style’s font.

setWidth(number)

@deprecated. Please use the ‘width’ property instead. Gets and sets the column width in unit of characters.

setWidth(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

Remarks

For spreadsheet, column width is measured as the number of characters of the maximum digit width of the numbers 0~9 as rendered in the normal style’s font.

getGroupLevel()

@deprecated. Please use the ‘groupLevel’ property instead. Gets the group level of the column.

getGroupLevel() : number;

setGroupLevel(number)

@deprecated. Please use the ‘groupLevel’ property instead. Gets the group level of the column.

setGroupLevel(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

isHidden()

@deprecated. Please use the ‘isHidden’ property instead. Indicates whether the column is hidden.

isHidden() : boolean;

setIsHidden(boolean)

@deprecated. Please use the ‘isHidden’ property instead. Indicates whether the column is hidden.

setIsHidden(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getHasCustomStyle()

@deprecated. Please use the ‘hasCustomStyle’ property instead. Indicates whether this column has custom style settings(different from the default one inherited from workbook).

getHasCustomStyle() : boolean;

isCollapsed()

@deprecated. Please use the ‘isCollapsed’ property instead. whether the column is collapsed

isCollapsed() : boolean;

setIsCollapsed(boolean)

@deprecated. Please use the ‘isCollapsed’ property instead. whether the column is collapsed

setIsCollapsed(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

applyStyle(Style, StyleFlag)

Applies formats for a whole column.

applyStyle(style: Style, flag: StyleFlag) : void;

Parameters:

ParameterTypeDescription
styleStyleThe style object which will be applied.
flagStyleFlagFlags which indicates applied formatting properties.

getStyle()

Gets the style of this column.

getStyle() : Style;

Returns

Style

Remarks

Modifying the returned style object directly takes no effect for this column or any cells in this column. You have to call [ApplyStyle(Style, StyleFlag)](../applystyle(style, styleflag)/) or SetStyle(Style) method to apply the change to this column.

Column’s style is the style which will be inherited by cells in this column(those cells that have no custom style settings, such as existing cells that have not been set style explicitly, or those that have not been instantiated)

setStyle(Style)

Sets the style of this column.

setStyle(style: Style) : void;

Parameters:

ParameterTypeDescription
styleStylethe style to be used as the default style for cells in this column.

Remarks

This method only sets the given style as the default style for this column, without changing the style settings for existing cells in this column. To update style settings of existing cells to the specified style at the same time, please use [ApplyStyle(Style, StyleFlag)](../applystyle(style, styleflag)/)

isNull()

Checks whether the implementation object is null.

isNull() : boolean;