Word文档报告自动生成工具,从模板到成品一站式搞定。
python3 scripts/docx_ops.py fill-template template.docx --data data.json -o report.docx
python3 scripts/docx_ops.py create-report --title "月度销售报告" --config report_config.json -o report.docx
python3 scripts/docx_ops.py mail-merge template.docx --data recipients.csv -o output/
python3 scripts/docx_ops.py add-toc report.docx -o report_with_toc.docx
python3 scripts/docx_ops.py to-pdf report.docx -o report.pdf
模板中使用 {{变量名}} 作为占位符,支持:
{{公司名称}} - 简单文本替换{{#表格}}...{{/表格}} - 循环生成行{{日期:format=YYYY-MM-DD}} - 格式化日期详见 references/template-syntax.md
pip install python-docx jinja2 pandas
# 导出PDF需要: sudo apt install libreoffice
创建报告的配置JSON格式见 references/report-config.md
共 1 个版本