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.
|
|
1 month ago | |
|---|---|---|
| .gitignore | 1 month ago | |
| data.json | 1 month ago | |
| data_1.json | 4 months ago | |
| main.py | 1 month ago | |
| readme.md | 8 months ago | |
| requirements.txt | 9 months ago | |
| rust.jpg | 9 months ago | |
| schema.json | 4 months ago | |
| template.docx | 1 month ago | |
| test.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 | 模板文件不正确 |