commit
fb4514e91d
@ -0,0 +1,4 @@
|
||||
/build/
|
||||
/dist/
|
||||
.idea
|
||||
*.spec
|
||||
@ -0,0 +1,100 @@
|
||||
[
|
||||
{
|
||||
"key": "{Title}",
|
||||
"value": "测试标题",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "{文件内容}",
|
||||
"value": "测试内容内容内容",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "{TableTitle}",
|
||||
"value": "这是标题",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "{dateTime}",
|
||||
"value": "2025年11月26日",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "{remark}",
|
||||
"value": "这个是备注备注备注备注",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "{Test1}",
|
||||
"value": "2025年11月26日",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "{Test2}",
|
||||
"value": "2025年11月26日",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "{Test3}",
|
||||
"value": "2025年",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "{Picture}",
|
||||
"value": "rust.jpg",
|
||||
"type": "picture",
|
||||
"width": 1.25
|
||||
},
|
||||
{
|
||||
"key": "{Table}",
|
||||
"type": "table",
|
||||
"value": [
|
||||
{
|
||||
"No": "序号",
|
||||
"Name": "名称",
|
||||
"Col2": "第一列",
|
||||
"Col3": "第二列"
|
||||
},
|
||||
{
|
||||
"No": "1",
|
||||
"Name": "名称测试1",
|
||||
"Col2": "列2",
|
||||
"Col3": "列3"
|
||||
},
|
||||
{
|
||||
"No": "2",
|
||||
"Name": "名称测试2",
|
||||
"Col2": "列2",
|
||||
"Col3": "列3"
|
||||
},
|
||||
{
|
||||
"No": "3",
|
||||
"Name": "名称测试3",
|
||||
"Col2": "列2",
|
||||
"Col3": "列3"
|
||||
},
|
||||
{
|
||||
"No": "4",
|
||||
"Name": "名称测试4",
|
||||
"Col2": "列2",
|
||||
"Col3": "列3"
|
||||
},
|
||||
{
|
||||
"No": "5",
|
||||
"Name": "名称测试5",
|
||||
"Col2": "列2",
|
||||
"Col3": "列3"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "{List}",
|
||||
"type": "list",
|
||||
"value": [
|
||||
"A1队列3的生存性最高,机动时间0s,机动距离0m,综合生存能力为0,隐蔽等级为1,道路性质为0;",
|
||||
"A2队列3的生存性最高,机动时间0s,机动距离0m,综合生存能力为0,隐蔽等级为1,道路性质为0;",
|
||||
"A3队列3的生存性最高,机动时间0s,机动距离0m,综合生存能力为0,隐蔽等级为1,道路性质为0;",
|
||||
"A4队列3的生存性最高,机动时间0s,机动距离0m,综合生存能力为0,隐蔽等级为1,道路性质为0;"
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,43 @@
|
||||
# 读取模板生成报表
|
||||
|
||||
## 打包
|
||||
|
||||
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 | 模板文件不正确 |
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue