Column

Column class

Represents a single column in a worksheet.

class Column;

Methods

MethodDescription
getIndex()Gets the index of this column.
getWidth()Gets and sets the column width in unit of characters.
setWidth(number)Gets and sets the column width in unit of characters.
getGroupLevel()Gets the group level of the column.
setGroupLevel(number)Gets the group level of the column.
isHidden()Indicates whether the column is hidden.
setIsHidden(boolean)Indicates whether the column is hidden.
getHasCustomStyle()Indicates whether this column has custom style settings(different from the default one inherited from workbook).
isCollapsed()whether the column is collapsed
setIsCollapsed(boolean)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.

getIndex()

Gets the index of this column.

getIndex() : number;

getWidth()

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)

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()

Gets the group level of the column.

getGroupLevel() : number;

setGroupLevel(number)

Gets the group level of the column.

setGroupLevel(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

isHidden()

Indicates whether the column is hidden.

isHidden() : boolean;

setIsHidden(boolean)

Indicates whether the column is hidden.

setIsHidden(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getHasCustomStyle()

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

getHasCustomStyle() : boolean;

isCollapsed()

whether the column is collapsed

isCollapsed() : boolean;

setIsCollapsed(boolean)

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 [ApplyStyle(Style, StyleFlag)](../applystyle(style, styleflag)/) 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)/)