Column class
Column class
Represents a single column in a worksheet.
The Column type exposes the following members:
Properties
Property | Description |
---|---|
index | Gets the index of this column. |
width | Gets and sets the column width in unit of characters. |
group_level | Gets the group level of the column. |
is_hidden | Indicates whether the column is hidden. |
has_custom_style | Indicates whether this column has custom style settings(different from the default one inherited from workbook). |
style | Gets the style of this column. |
is_collapsed | whether the column is collapsed |
Methods
Method | Description |
---|---|
apply_style | Applies formats for a whole column. |
get_style | Gets the style of this column. |
set_style | Sets 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
- module
aspose.cells