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.getWorksheets().get(0);
//Add new Style to Workbook
var style = workbook.createStyle();
//Setting the background color to Blue
style.setBackgroundColor(new Color(0, 0, 0xff));
//Setting the foreground color to Red
style.setForegroundColor(new Color(0xff, 0, 0));
//setting Background Pattern
style.setPattern(BackgroundType.DiagonalStripe);
//New Style Flag
var styleFlag = new StyleFlag();
//Set All Styles
styleFlag.setAll(true);
//Get first Column
var column = worksheet.getCells().getColumns().get(0);
//Apply Style to first Column
column.applyStyle(style, styleFlag);
//Saving the Excel file
workbook.save("output/Column.xls");
Methods
Method | Description |
---|---|
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. |
isNull() | Checks whether the implementation object is null. |
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:
Parameter | Type | Description |
---|---|---|
value | number | The 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:
Parameter | Type | Description |
---|---|---|
value | number | The 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:
Parameter | Type | Description |
---|---|---|
value | boolean | The 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:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
applyStyle(Style, StyleFlag)
Applies formats for a whole column.
applyStyle(style: Style, flag: StyleFlag) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
style | Style | The style object which will be applied. |
flag | StyleFlag | Flags which indicates applied formatting properties. |
getStyle()
Gets the style of this column.
getStyle() : Style;
Returns
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:
Parameter | Type | Description |
---|---|---|
style | Style | the 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;