You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
3 months ago | |
---|---|---|
.gitignore | 4 months ago | |
data.json | 3 months ago | |
main.py | 3 months ago | |
readme.md | 3 months ago | |
requirements.txt | 4 months ago | |
rust.jpg | 4 months ago | |
template.docx | 4 months ago |
readme.md
读取模板生成报表
打包
- 打包
pyinstaller -F main.py -n doc_generate.exe
- 使用
在 dist目录下找到可执行文件, 使用命令行调用
./doc_generate.exe [模板文件] [生成文件] [数据文件]
- 使用示例
- Qt
QString templatefile = "template/template.docx"; // 模板文件 QString generatefile = "Test.docx"; // 生成文件 QString datafile = "data/data.json"; // 数据文件 QString cmd = QString("doc_generate %1 %2 %3").arg(templatefile, generatefile, datafile); QProcess process; process.start(cmd); process.waitForFinished(); QString output = process.readAllStandardOutput(); qDebug() << output;
- Qt
注意
- 模板文件 使用相对位置,即相对doc_generate可执行文件的位置
- 生成文件 生成的文件都在doc_generate所在位置
- 数据文件 使用相对位置,即相对doc_generate可执行文件的位置
- 数据文件中若有图片路径,则图片路径也应是相对位置,即图片相对doc_generate可执行文件的位置
返回值说明
值 | 说明 |
---|---|
0 | 正常 |
1 | 数据内容不正确 |
2 | 模板文件不正确 |