账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    使用phpword进行文档合并
    • 2020-01-01 00:00
    • 10
    9
    0

    问题描述

    我这里有一个很复杂精细的word,需要替换其中用户的个人数据后导出。但是如果使用phpword的template替换,每个用户就会生成一个word。这样似乎很不方便打印?这里有几百上千个用户,他们都使用同样的导出模板,有什么办法可以只生成一个word吗?

    我的尝试

    昨天才开始接触phpword,实在不熟悉。想要提取word的页面数据、样式出来然后写入新的word,结果以失败告终。(好像不能读取?)
    想要生成多个word后再合并word也失败了……

    求各位大神出手!

    0
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 10 元积分
        全部回答
    • 0
    • AI智能解答 超级管理员 2023-04-06 12:021楼
      \`\`\`php loadTemplate('document1.docx'); $document2 = $phpWord->loadTemplate('document2.docx'); $document1->setValue('value1', 'Document 1'); $document2->setValue('value2', 'Document 2'); $document1->saveAs('mergedDocument.docx'); $document2->saveAs('mergedDocument.docx', \PhpOffice\PhpWord\Writer\Word2007\Part\WriterPart::WRITE_FILE_APPEND); ?> \`\`\`
    • AI智能解答 超级管理员 2023-04-06 12:022楼
      \`\`\`php loadTemplate('document1.docx'); $document2 = $phpWord->loadTemplate('document2.docx'); $document1->setValue('value1', 'Document 1'); $document2->setValue('value2', 'Document 2'); $document1->saveAs('mergedDocument.docx'); $document2->saveAs('mergedDocument.docx', \PhpOffice\PhpWord\Writer\Word2007\Part\WriterPart::WRITE_FILE_APPEND); ?> \`\`\`
    • AI智能解答 超级管理员 2023-04-06 11:583楼
      \`\`\`php loadTemplate('document1.docx'); $document2 = $phpWord->loadTemplate('document2.docx'); $document1->setValue('value1', 'Document 1'); $document2->setValue('value2', 'Document 2'); $document1->saveAs('mergedDocument.docx'); $document2->saveAs('mergedDocument.docx', \PhpOffice\PhpWord\Writer\Word2007\Part\WriterPart::WRITE_FILE_APPEND); ?> \`\`\`
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部