dev-master
9999999-dev https://github.com/kartik-v/yii2-reportA Yii2 component to generate beautiful formatted reports using MS Word Templates in PDF/DOC/DOCX format
BSD-3-Clause
template extension yii2 pdf report doc docx
Wallogit.com
2017 © Pedro Peláez
A Yii2 component to generate beautiful formatted reports using MS Word Templates in PDF/DOC/DOCX format
A Yii2 component to generate beautiful formatted reports using Microsoft Word Document Templates in PDF/DOC/DOCX format. The component uses the PHP reports library API to generate reports. PHP-Reports is a cloud based, interactive report engine which helps in generating well formatted PDF reports from Word / DOCX templates., (*2)
Refer this git workflow for contributors., (*3)
The preferred way to install this extension is through composer., (*4)
Note: Check the composer.json for this extension's requirements and dependencies. You must set the
minimum-stabilitytodevin the composer.json file in your application root folder before installation of this extension OR if yourminimum-stabilityis set to any other value other thandev, then set the following in the require section of your composer.json file, (*5)
kartik-v/yii2-report: "@dev"
Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json., (*6)
Either run, (*7)
$ php composer.phar require kartik-v/yii2-report "@dev"
or add, (*8)
"kartik-v/yii2-report": "@dev"
to the require section of your composer.json file., (*9)
Create free account at https://www.php-reports.com and get your free API Key., (*10)
To accelerate the process of creating your reports and applications, PHP Reports takes advantage of Microsoft Word's design capabilites. Simply create a Microsoft Word file and design your report., (*11)
You can use template variables in your Microsoft Word template. Template variables take their name from the contents of their double curly braces and they can later be replaced with a concrete value., (*12)
All template variable names within a template string must be unique. Template variable names are case-insensitive., (*13)
, (*14)
Save and upload your template at "Template Manager" section in https://www.php-reports.com. Remember the template identifier (templateId)., (*15)
yii2-report global componentSetup the following component in the components section of your Yii2 application configuration file., (*16)
use kartik\report\Report;
// ...
'components' => [
// setup Krajee Yii2 Report component
'report' => [
'class' => Report::classname(),
'apiKey' => 'YOUR_PHP_REPORTS_API_KEY',
// the following variables can be set to globally default your settings
'templateId' => 1, // optional: the numeric identifier for your default global template
'outputAction' => Report::ACTION_FORCE_DOWNLOAD, // or Report::ACTION_GET_DOWNLOAD_URL
'outputFileType' => Report::OUTPUT_PDF, // or Report::OUTPUT_DOCX
'outputFileName' => 'KrajeeReport.pdf', // a default file name if
'defaultTemplateVariables' => [ // any default data you desire to always default
'companyName' => 'Krajee.com'
]
]
]
use kartik\report\Report;
$report = Yii::$app->report;
// set your template identifier (override global defaults)
$report->templateId = 2;
// If you want to override the output file name, uncomment line below
// $report->outputFileName = 'My_Generated_Report.pdf';
// If you want to override the output file type, uncomment line below
// $report->outputFileType = Report::OUTPUT_DOCX;
// If you want to override the output file action, uncomment line below
// $report->outputFileAction = Report::ACTION_GET_DOWNLOAD_URL;
// Configure your report data. Each of the keys must match the template
// variables set in your MS Word template and each value will be the
// evaluated to replace the Word template variable. If the value is an
// array, it will treated as tabular data.
$report->templateVariables = [
'client_name' => 'Murat Cileli',
'address' => 'Kadikoy, Istanbul / Turkey',
'date' => '10-Apr-2018',
'phone' => '+1-800-3399622',
'email' => 'admin@gmail.com',
'notes' => 'Thank you for your purchase.',
'quantities' => ['6', '3', '4'],
'products' => ['Apple iPhone 5S', 'Samsung Galaxy S5', 'Office 365 License'],
'prices' => ['490 USD', '399 USD', '199 USD'],
];
// lastly in your controller action download the generated report
return $report->generateReport();
Your output should look something like below:, (*17)
, (*18)
yii2-report is released under the BSD-3-Clause License. See the bundled LICENSE.md for details., (*19)
A Yii2 component to generate beautiful formatted reports using MS Word Templates in PDF/DOC/DOCX format
BSD-3-Clause
template extension yii2 pdf report doc docx