Column类

Column类

代表工作表中的单个列。

Column 类型公开以下成员:

特性

属性描述
index获取该列的索引。
width获取和设置以字符为单位的列宽。
group_level获取列的组级别。
is_hidden指示该列是否隐藏。
has_custom_style指示该列是否具有自定义样式设置(与从工作簿继承的默认样式不同)。
style获取该列的样式。
is_collapsed列是否折叠

方法

方法描述
apply_style应用整列的格式。
get_style获取该列的样式。
set_style设置该列的样式。

例子

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

也可以看看