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.
liamxin 48800c0e99
添加说明
3 months ago
.gitignore add 4 months ago
data.json 添加说明 3 months ago
main.py 添加说明 3 months ago
readme.md 添加说明 3 months ago
requirements.txt add remdme 4 months ago
rust.jpg init 4 months ago
template.docx init 4 months ago

readme.md

读取模板生成报表

打包

  1. 打包
    pyinstaller -F main.py -n doc_generate.exe
    
  2. 使用

    在 dist目录下找到可执行文件, 使用命令行调用

    ./doc_generate.exe [模板文件] [生成文件] [数据文件]
    
  3. 使用示例
    • 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;
      

注意

  1. 模板文件 使用相对位置,即相对doc_generate可执行文件的位置
  2. 生成文件 生成的文件都在doc_generate所在位置
  3. 数据文件 使用相对位置,即相对doc_generate可执行文件的位置
  4. 数据文件中若有图片路径,则图片路径也应是相对位置,即图片相对doc_generate可执行文件的位置

返回值说明

说明
0 正常
1 数据内容不正确
2 模板文件不正确