campo/docxfindandreplace

在DOCX模板中查找和替换变量。

1.0.0 2016-09-20 05:34 UTC

This package is auto-updated.

Last update: 2024-09-24 03:54:30 UTC


README

Latest Version on Packagist Software License Latest Version on Packagist Build Status

这是一个简单的DOCX文件查找和替换实用程序。简单地将DOCX模板与一些变量映射,并保存一个新的副本。

安装

通过Composer

$ composer require campo/docxfindandreplace

用法

在你的DOCX模板中,你需要将任何要替换的变量用大括号括起来(例如 {FIRSTNAME}。请确保在模板中使用全部 大写 的变量,因为Microsoft Word的拼写检查可能会创建问题。

\Campo\DocxFindAndReplace\Docx::create(__DIR__ . "/template.docx")->replace(
    [
        'FIRSTNAME' => 'Joe',
        'LASTNAME' => 'Campo',
    ]
)->save(__DIR__ . '/newfile.docx');

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件