A Yii2 library to generate Word / PDF reports using Microsoft Word Templates.
Refer detailed documentation and/or a complete demo.
You can see detailed documentation and demonstration on usage of the extension.
The preferred way to install this extension is through composer.
Note: Check the composer.json for this extension's requirements and dependencies. You must set the
minimum-stability
todev
in the composer.json file in your application root folder before installation of this extension OR if yourminimum-stability
is set to any other value other thandev
, then set the following in the require section of your composer.json file
kartik-v/yii2-word-report: "@dev"
Read this web tip /wiki on setting the minimum-stability
settings for your application's composer.json.
Either run
$ php composer.phar require kartik-v/yii2-word-report "@dev"
or add
"kartik-v/yii2-word-report": "@dev"
to the require
section of your composer.json
file.
use kartik\wordreport\TemplateReport;
$report = new TemplateReport([
'format' => TemplateReport::FORMAT_BOTH,
'inputFile' => 'Invoice_Template_01.docx',
'outputFile' => 'Invoice_Report_' . date('Y-m-d'),
'values' => ['invoice_no' => 2001, 'invoice_date' => '2020-02-21'],
'images' => ['company_logo' => '@webroot/images/company.jpg', 'customer_logo' => '@webroot/images/company.jpg'],
'rows' => [
'item' => [
['item' => 1, 'name' => 'Potato', 'price' => '$10.00'],
['item' => 2, 'name' => 'Tomato', 'price' => '$20.00'],
]
],
'blocks' => [
'customer_block' => [
['customer_name' => 'John', 'customer_address' => 'Address for John'],
['customer_name' => 'Bill', 'customer_address' => 'Address for Bill'],
],
]
]);
// Generate the report
$report->generate();
yii2-word-report is released under the BSD-3-Clause License. See the bundled LICENSE.md
for details.