Worksheet类

Worksheet类

封装表示单个工作表的对象。

Worksheet 类型公开了以下成员:

特性

属性 描述
protection 表示可用于工作表的各种类型的保护选项。支持ExcelXP及以上版本的高级保护选项。
unique_id 获取和设置唯一标识,与{15DB5C3C-A5A1-48AF-8F25-3D86AC232D4F}相同。
workbook 获取包含此工作表的工作簿对象。
cells 获取 Worksheet.cells 集合。
query_tables 在工作表中获取 QueryTableCollection
pivot_tables 获取此工作表中的所有数据透视表。
type 表示工作表类型。
name 获取或设置工作表的名称。
show_formulas 指示是否显示公式或其结果。
is_gridlines_visible 获取或设置一个值,该值指示网格线是否可见。默认为 true。
is_row_column_headers_visible 获取或设置一个值,该值指示工作表是否显示行标题和列标题。
默认为真。
pane_state 指示窗格是否具有水平或垂直拆分,以及这些拆分是否已冻结。
display_zeros 如果显示零值则为真。
display_right_to_left 指示指定的工作表是否从右到左而不是从左到右显示。
默认为假。
is_outline_shown 指示是否显示轮廓。
is_selected 指示打开工作簿时是否选择了此工作表。
list_objects 获取此工作表中的所有 ListObject。
tab_id 指定工作表的内部标识符。
horizontal_page_breaks 获取 HorizontalPageBreakCollection 集合。
vertical_page_breaks 获取 VerticalPageBreakCollection 集合。
hyperlinks 获取 HyperlinkCollection 集合。
page_setup 表示此工作表中的页面设置说明。
auto_filter 表示指定工作表的自动筛选器。
has_autofilter 指示此工作表是否具有自动筛选器。
transition_evaluation 指示是否启用转换公式评估(Lotus 兼容性)选项。
transition_entry 指示是否启用转换公式条目(Lotus 兼容性)选项。
visibility_type 指示此工作表的可见状态。
is_visible 表示工作表是否可见。
sparkline_group_collection 获取工作表中的迷你图组集合。
sparkline_groups 获取工作表中的迷你图组。
charts 获取 Chart 集合
comments 获取 Comment 集合。
pictures 获取 Picture 集合。
text_boxes 获取 TextBox 集合。
check_boxes 获取 CheckBox 集合。
ole_objects 表示工作表中 OleObject 的集合。
shapes 返回此工作表中的所有绘图形状。
slicers 在工作表中获取 Slicer 集合
timelines 获取工作表中的Timeline集合
index 获取工作表集合中工作表的索引。
is_protected 指示工作表是否受保护。
validations 获取工作表中的数据验证设置集合。
allow_edit_ranges 获取工作表中的允许编辑范围集合。
error_check_options 获取应用于特定范围的错误检查设置。
outline 获取此工作表上的大纲。
first_visible_row 表示第一个可见行索引。
first_visible_column 表示第一个可见列索引。
zoom 表示以百分比表示的比例因子。它应该在 10 到 400 之间。
view_type 获取和设置视图类型。
is_page_break_preview 指示指定的工作表是否显示在普通视图或分页预览中。
is_ruler_visible 指示标尺是否可见。此属性仅适用于分页预览。
tab_color 代表工作表标签颜色。
code_name 获取工作表代号。
background_image 获取和设置工作表背景图像。
conditional_formattings 获取工作表中的 ConditionalFormattings。
active_cell 获取或设置工作表中的活动单元格。
custom_properties 获取表示的对象
与工作表关联的标识符信息。
smart_tag_setting 获取工作表的所有 SmartTagCollection 对象。
scenarios 获取 Scenario 的集合。
cell_watches 获取正在“监视窗口”中监视的此工作表上的单元格集合。

方法

方法 描述
freeze_panes(row, column, freezed_rows, freezed_columns) 冻结工作表中指定单元格的窗格。
freeze_panes(cell_name, freezed_rows, freezed_columns) 冻结工作表中指定单元格的窗格。
copy(source_sheet) 从另一个工作表复制内容和格式。
copy(source_sheet, copy_options) 从另一个工作表复制内容和格式。
auto_fit_column(column_index, first_row, last_row) 自动调整列宽。
auto_fit_column(column_index) 自动调整列宽。
auto_fit_columns() 自动调整此工作表中的所有列。
auto_fit_columns(options) 自动调整此工作表中的所有列。
auto_fit_columns(first_column, last_column) 自动调整列宽。
auto_fit_columns(first_column, last_column, options) 自动调整列宽。
auto_fit_columns(first_row, first_column, last_row, last_column) 自动调整列宽。
auto_fit_columns(first_row, first_column, last_row, last_column, options) 自动调整列宽。
auto_fit_row(row_index, first_column, last_column) 自动调整行高。
auto_fit_row(row_index, first_column, last_column, options) 自动调整行高。
auto_fit_row(start_row, end_row, start_column, end_column) 自动调整矩形范围内的行高。
auto_fit_row(row_index) 自动调整行高。
auto_fit_rows() 自动调整此工作表中的所有行。
auto_fit_rows(only_auto) 自动调整此工作表中的所有行。
auto_fit_rows(options) 自动调整此工作表中的所有行。
auto_fit_rows(start_row, end_row) 自动调整范围内的行高。
auto_fit_rows(start_row, end_row, options) 自动调整范围内的行高。
protect(type) 保护工作表。
protect(type, password, old_password) 保护工作表。
unprotect() 取消保护工作表。
unprotect(password) 取消保护工作表。
calculate_formula(formula) 计算一个公式。
calculate_formula(formula, opts) 计算一个公式。
calculate_formula(recursive, ignore_error, custom_function) 计算此工作表中的所有公式。
calculate_formula(options, recursive) 计算此工作表中的所有公式。
get_panes() 获取窗格。
get_freezed_panes(row, column, freezed_rows, freezed_columns) 获取冻结窗格。
split() 拆分窗口。
un_freeze_panes() 解冻工作表中的窗格。
remove_split() 删除拆分窗口。
add_page_breaks(cell_name) 添加分页符。
advanced_filter(is_filter, list_range, criteria_range, copy_to, unique_record_only) 使用复杂的标准过滤数据。
remove_auto_filter() 删除工作表的自动筛选器。
set_visible(is_visible, ignore_error) 设置可见选项。
select_range(start_row, start_column, total_rows, total_columns, remove_others) 选择一个范围。
remove_all_drawing_objects() 删除此工作表中的所有绘图对象。
clear_comments() 清除设计器电子表格中的所有评论。
move_to(index) 将工作表移动到电子表格中的另一个位置。
replace(old_string, new_string) 用新字符串替换所有单元格的文本。
get_selected_ranges() 获取设计器电子表格中选定的单元格范围。
set_background(picture_data) 设置工作表背景图像。
get_printing_page_breaks(options) 获取自动分页符。
start_access_cache(opts) 启动使用缓存访问此工作表中数据的会话。
close_access_cache(opts) 关闭使用缓存访问此工作表中数据的会话。
xml_map_query(path, xml_map) 查询映射/链接到 xml 映射特定路径的单元格区域。
refresh_pivot_tables() 刷新此工作表中的所有数据透视表。

例子

from aspose.cells import Workbook

workbook = Workbook()
sheet = workbook.worksheets[0]
# Freeze panes at "AS40" with 10 rows and 10 columns
sheet.freeze_panes("AS40", 10, 10)
# Add a hyperlink in Cell A1
sheet.hyperlinks.add("A1", 1, 1, "http://www.aspose.com")

也可以看看