natmars/yii2-word
最新稳定版本:1.1
Composer 安装命令:
composer require natmars/yii2-word
包简介
Helper and wrapper class for PHPWord for simple communication
README 文档
README
Helper and wrapper class for PHPWord for simple communication.
Installation
Either run
$ php composer.phar require natmars/yii2-word "@dev"
or add
"natmars/yii2-word": "@dev"
Creating a multi-line file using the word template
1. Creating Your First Template
Create a Microsoft Word file.
Use ${variableName} to set variables. Use ${tableName}, ${itemName} to generate a table (the value of ${tableName} is set to empty, but the values of ${itemName} are set to match a data in an array). Result will look like this:
2. Saving template
Set the file name as $fileName, put the file in the template directory $templatesDir and determine the location to save the finished file $tmpDir
3. Generating the report
use natmars\word\Word; $templateFullPath = $templatesDir . $fileName; $outputFullPath = $tmpDir . $fileName; $phpWord = new Word(); // create a file using a template $phpWord->saveFromMultiLineTemplate($templateFullPath, $outputFullPath, [ 'variableName' => 'variableValue', 'tableName' => [ ['itemName' => 'itemValue1'], ['itemName' => 'itemValue2'], ['itemName' => 'itemValue3'], ], ]); // download file $phpWord->downloadTemplate($outputFullPath);
4. Check your output report document
Your output should look something like below:
Run for example:
\natmars\example\Test::generate();
统计信息
- 总下载量: 109
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2019-11-10

