direct808 / docxerator
简单的 MS Word DOCX 模板处理器
0.1.4
2018-11-06 15:00 UTC
Requires
- ext-mbstring: *
- ext-simplexml: *
- ext-zip: *
Requires (Dev)
- phpunit/phpunit: ^6.3
This package is not auto-updated.
Last update: 2024-09-21 17:45:12 UTC
README
Docxerator 是一个简单的 MS Word DOCX 模板处理器
特性
- 自定义标签模板
- 处理碎片化标签
要求
- PHP 版本 5.6 或更高
- XML 扩展
- MBString 扩展
使用 Composer 安装
要使用 Composer 安装,只需要求此包的最新版本。
composer require direct808/docxerator
确保已加载 Composer 的自动加载文件。
// somewhere early in your project's loading, require the Composer autoloader // see: https://getcomposer.org.cn/doc/00-intro.md require 'vendor/autoload.php';
用法
Docxerator 非常易于使用
// reference the Docxerator namespace use Direct808\Docxerator\Docxerator; // instantiate and use the Docxerator class $docxerator = new Docxerator(); // open docx template file (contains the label #MARK#) $docxerator->open('./you_docx_document.docx'); // Replace the label $docxerator->replace('MARK', 'Your replaced content'); // Save the processing document $processingDocumentPath = $docxerator->save();
自定义标签格式
$docxerator = new Docxerator(); // Docxerator will processing labels of the format {MARK} $docxerator->setMarkPattern('/\{(\w+)\}/i'); $docxerator->open('./you_docx_document.docx'); $processingDocumentPath = $docxerator->save();