2026b

# add_row


向表格添加一行

函数库: TyReportGenerator

# 语法

add_row(table)

# 说明

add_row(table) 在 table 对象上添加一行。示例

# 示例

向表格添加一行

在 Word 文档中创建 4*3 的表格并设置单元格的值,在表格中增加一个默认空行。

using TyReportGenerator

doc = create_document()
pkg_dir = pkgdir(TyReportGenerator)
add_heading1(doc, "表格")
table = create_table(4, 3; style=Style(Table))
add_table(doc, table)  
# 设置单元格的值
for i in 1:size(table.children)[1]
    for j in 1:size(table.children)[2]
        tt = create_text(string(i * 10 + j))
        cc = create_cell([tt])
        table.children[i, j] = cc
    end
end

# 表格添加一行
add_row(table)
doc_file = joinpath(tempdir(), "Add Row.docx");
generate_report(doc, doc_file)
rptview(doc_file)

# 输入参数

table — table对象
table对象

文档中的 table 对象,存储表格的行列数、合并范围、表格格式等信息。