PHP替换Word文档中的变量

发布于 2024-09-27 05:59:20 字数 272 浏览 0 评论 0原文

我有一个包含某些变量的Word文档(例如字符串$$title$$)。现在我想在 PHP 中打开这个 word 文档,并将字符串 $$title$$ 替换为我从数据库中读取的字符串。最后一步是保存此 Word 文档并将其提供给用户下载。

替换字符串并开始下载就没有问题了。但我不知道如何将单词内容放入 php 中的变量中,使用该变量,然后将其保存到新的单词文档中。

你们中有人知道一个很好的 PHP 类,它提供了对编辑 Word 文档内容的支持吗? (如果必须的话,我可以接受 OpenXML 格式)

I have a word document that contains certain variables (for example the string $$title$$). Now I want to open this word document in PHP and replace the string $$title$$ with a string I read out of the database. Final step would be to save this word document and give it to the user for download.

Replacing the string and start the download is no problem. But I don't know how I can get the word content into a variable in php, work with that variable and then save it to a new word document.

Does any one of you know a good PHP class that provides support for editing the contents of a word document? (I'm fine with OpenXML formats if it has to be)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半山落雨半山空 2024-10-04 05:59:20

您尝试过 PHPWord 吗?我一直在同一站点使用 PHPExcel,它是一个很棒的库。

Have you tried PHPWord? I've been using PHPExcel from the same site and it is great library.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文