# modify_cell


修改Cell对象属性

函数库: TyReportGenerator

# 语法

modify_cell(cell; style)

# 说明

modify_cell(cell; style)修改单元格的属性。 示例

# 示例

修改单元格的属性

创建 Word 文档,添加表格,修改表格第一行单元格的背景色、加粗、水平对齐、字体、段前段后间距。

using TyReportGenerator

doc = create_document()

headerContent = ["Item" "Quantity" "Cost"];
bodyContent = ["Table" 1 55; "Chair" 4 100; "Bookshelf" 2 40]
table = create_table(
    bodyContent;
    style = Style(; style_type = "Table Grid", font_family = "Times New Roman", halign = "center", outer_margin = (0, 0)),
)
add_header(table, headerContent)
add_table(doc, table)

# modify_cell修改第一行单元格的背景色、加粗、水平对齐、字体、段前段后间距
for j in 1:size(table.children)[2]
    modify_cell(
        table.children[1, j];
        style=Style(;
            background_color_cell=(173, 216, 230),
            bold=true,
            halign="center",
            font_family="Times New Roman",
            outer_margin=(0, 0),
        ),
    )
end

doc_file = joinpath(tempdir(), "modifycell.docx");

generate_report(doc, doc_file)
rptview(doc_file)

# 输入参数

cell-cell对象
cell对象

cell对象,存储表格单元格信息。用户可自定义单元格大小。

style-cell格式
document 对象的单元格数组

cell 样式的格式。