Column class

Column class

Represents a single column in a worksheet.

The Column type exposes the following members:

Properties

PropertyDescription
indexGets the index of this column.
widthGets and sets the column width in unit of characters.
group_levelGets the group level of the column.
is_hiddenIndicates whether the column is hidden.
has_custom_styleIndicates whether this column has custom style settings(different from the default one inherited from workbook).
styleGets the style of this column.
is_collapsedwhether the column is collapsed

Methods

MethodDescription
apply_styleApplies formats for a whole column.
get_styleGets the style of this column.
set_styleSets the style of this column.

Example

from aspose.cells import BackgroundType, StyleFlag, Workbook
from aspose.pydrawing import Color

# Instantiating a Workbook object
workbook = Workbook()
# Obtaining the reference of the first worksheet
worksheet = workbook.worksheets[0]
style = workbook.create_style()
# Setting the background color to Blue
style.background_color = Color.blue
# Setting the foreground color to Red
style.foreground_color = Color.red
# setting Background Pattern
style.pattern = BackgroundType.DIAGONAL_STRIPE
# New Style Flag
styleFlag = StyleFlag()
# Set All Styles
styleFlag.all = True
# Get first Column
column = worksheet.cells.columns[0]
# Apply Style to first Column
column.apply_style(style, styleFlag)
# Saving the Excel file
workbook.save("book1.xls")

See Also