kartik-v/yii2-word-report

Make reports in Yii2 with Microsoft Word Templates.

Installs: 1 146

Dependents: 0

Suggesters: 0

Security: 0

Stars: 9

Watchers: 6

Forks: 3

Open Issues: 1

Type:yii2-extension

dev-main 2021-02-24 16:56 UTC

This package is auto-updated.

Last update: 2024-11-25 02:04:43 UTC


README

Krajee Logo
yii2-word-report Donate

Stable Version Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

A Yii2 library to generate Word / PDF reports using Microsoft Word Templates.

Refer detailed documentation and/or a complete demo.

Documentation and Demo

You can see detailed documentation and demonstration on usage of the extension.

Installation

The preferred way to install this extension is through composer.

Pre-requisites

Note: Check the composer.json for this extension's requirements and dependencies. You must set the minimum-stability to dev in the composer.json file in your application root folder before installation of this extension OR if your minimum-stability is set to any other value other than dev, 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.

Install

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.

Usage

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();

License

yii2-word-report is released under the BSD-3-Clause License. See the bundled LICENSE.md for details.