2026b

# add_heading1


添加一级标题

函数库: TyReportGenerator

# 语法

add_heading1(obj, text)

# 说明

add_heading1(obj, text)添加一级标题。示例

# 示例

添加一级标题

创建 Word 文档,添加一级标题和二级标题,生成报告并查看。

using TyReportGenerator

doc = create_document()
pkg_dir = pkgdir(TyReportGenerator)

add_heading1(doc, "一级标题")
add_heading2(doc, "二级标题")

doc_file = joinpath(tempdir(), "Add Heading1.docx");
tpl_file = joinpath(pkg_dir, "examples/Resources/文档模板-空.docx");

#生成文档报告
generate_report(doc, doc_file, tpl_file)
rptview(doc_file)

# 输入参数

obj — 文档对象
document 对象

指定为文档对象(document 对象)。

text — 标题文本内容
字符串

文本内容,指定为字符串。