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.

44 lines
1.4 KiB

4 months ago
# 读取模板生成报表
3 months ago
## 打包
3 months ago
1. 打包
> ```powershell
> pyinstaller -F main.py -n doc_generate.exe
> ```
1. 使用
> 在 dist目录下找到可执行文件, 使用命令行调用
> ```python
> ./doc_generate.exe [模板文件] [生成文件] [数据文件]
> ```
1. 使用示例
- Qt
> ```c++
> 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;
> ```
## 注意
1. 模板文件 使用相对位置,即相对**doc_generate**可执行文件的位置
1. 生成文件 生成的文件都在**doc_generate**所在位置
1. 数据文件 使用相对位置,即相对**doc_generate**可执行文件的位置
2. 数据文件中若有图片路径,则图片路径也应是相对位置,即图片相对**doc_generate**可执行文件的位置
## 返回值说明
| 值 | 说明 |
|:-:|:-------:|
| 0 | 正常 |
| 1 | 数据内容不正确 |
| 2 | 模板文件不正确 |
3 months ago
4 months ago