Comment类
Comment类
封装代表单元格注释的对象。
Comment 类型公开以下成员:
属性
属性 | 描述 |
---|---|
author | 获取并设置原始注意事项作者的名称 |
comment_shape | 获取表示附加到指定注意事项的形状的 Shape 对象。 |
row | 获取注意事项的行索引。 |
column | 获取注意事项的列索引。 |
is_threaded_comment | 指示此注意事项是否为线索注意事项。 |
threaded_comments | 获取主题注意事项列表; |
note | 代表注意事项的内容。 |
html_note | 获取并设置该注意事项中包含数据和一些格式的html字符串。 |
font | 获取注意事项的字体。 |
is_visible | 表示注意事项是否可见。 |
text_orientation_type | 获取并设置注意事项的文本方向类型。 |
text_horizontal_alignment | 获取和设置注意事项的文本水平对齐类型。 |
text_vertical_alignment | 获取和设置注意事项的文本垂直对齐类型。 |
auto_size | 指示注意事项的大小是否根据其内容自动调整。 注意:在某些特殊情况下(例如 Mac 环境),此设置可能不会生效。如果此设置不生效,请将其替换为 FitToTextSize()。 |
height_cm | 表示注意事项的高度,单位为厘米。 |
width_cm | 表示注意事项的宽度,单位为厘米。 |
width | 表示注意事项的宽度,以像素为单位。 |
height | 表示注意事项的高度,以像素为单位。 |
width_inch | 表示注释的宽度,单位为英寸。 |
height_inch | 表示注意事项的高度,以英寸为单位。 |
方法
方法 | 描述 |
---|---|
format_characters(self, start_index, length, font, flag) | 使用字体设置来格式化一些字符。 |
characters(self, start_index, length) | 返回一个 Characters 对象,该对象代表注释文本内的字符范围。 |
get_characters(self) | 返回所有 Characters 对象 代表注释文本内的字符范围。 |
get_rich_formattings(self) | 返回所有 Characters 对象 代表注释文本内的字符范围。 |
例子
from aspose.cells import Workbook
workbook = Workbook()
comments = workbook.worksheets[0].comments
# Add comment to cell A1
commentIndex1 = comments.add(0, 0)
comment1 = comments[commentIndex1]
comment1.note = "First note."
comment1.font.name = "Times New Roman"
# Add comment to cell B2
comments.add("B2")
comment2 = comments.get("B2")
comment2.note = "Second note."
# do your business
# Save the excel file.
workbook.save("exmaple.xlsx")