el-gitto-junior / docx-merge
用于将多个 MS Word ".docx" 文件合并为一个文件的简单库
v1.0.2
2018-07-13 15:33 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 4.8.*
This package is auto-updated.
Last update: 2024-09-06 23:31:18 UTC
README
用于将多个 MS Word ".docx" 文件合并为一个文件的简单库
特性
- 为 MS Office 2007 及以上版本创建有效的 docx 文件
详细信息
- 对于处理 docx 的 ZIP,我使用 TbsZip
安装
php composer.phar require krustnic/docx-merge
合并示例
require "vendor/autoload.php";
use DocxMerge\DocxMerge;
$dm = new DocxMerge();
$dm->merge( [
"templates/TplPage1.docx",
"templates/TplPage2.docx"
], "/tmp/result.docx" );
setValues 示例
# Use "${NAME}" in docx file to create placeholders
require "vendor/autoload.php";
use DocxMerge\DocxMerge;
$dm = new DocxMerge();
$dm->setValues( "templates/template.docx",
"templates/result.docx",
array( "NAME" => "Sterling", "SURNAME" => "Archer" ) );
或者使用样式("粗体"、"斜体"、"下划线")
$dm->setValues( "templates/template.docx",
"templates/result.docx",
[
"NAME" => [
[
"value" => "Sterling",
"decoration" => [ "bold", "italic" ]
],
[
"value" => "Archer",
"decoration" => [ "bold", "underline" ]
]
]
]);