, (*1)
The main purpose of this library is not replace kartik-v/yii2-export. Kartik's one has a lot of features not implemented on this one., (*2)
This is a new yii2-export widget wrote from the scratch to improve performance., (*3)
The idea of this one appeared when PHPExcel doesn't fit to generate large excel files in a fast way. The first feature was dispatch reports to be generated in queues., (*4)
Not enough, another feature was replace PHPExcel with spout, successfully reducing the time consuming., (*5)
Installation
The preferred way to install this extension is through composer., (*6)
Either run, (*7)
$ composer require ericmaicon/yii2-export:*
or add, (*8)
"ericmaicon/yii2-export": "*"
to the require
section of your composer.json
file., (*9)
Usage
Using with the Grid:, (*10)
<?= \Da\export\GridView::widget([
'dataProvider' => $dataProvider,
]); ?>
To use Kartik's grid you will need to override renderExport method:, (*11)
<?php
use Da\export\ExportMenu;
class GridView extends \kartik\grid\GridView
{
public function renderExport()
{
return ExportMenu::widget([
'dataProvider' => $this->dataProvider,
'columns' => $this->columns,
]);
}
}
Stand-alone use:, (*12)
Another configurations:, (*13)
Queue, (*14)
[
'target' => \Da\export\ExportMenu::TARGET_QUEUE,
'queueConfig' => [
'queueName' => \common\models\ReportModel::REPORT_TUBE,
'queueAdapter' => \Da\export\queue\rabbitmq\RabbitMqQueueStoreAdapter::className(),
'queueMessage' => function () {
}
]
]
Target, (*15)
[
'target' => \Da\export\ExportMenu::TARGET_SELF,
]
Filename, (*16)
[
'filename' => 'test',
]
Export Footer, (*17)
[
'exportFooter' => true,
]
Options, (*18)
[
'class' => 'btn-group',
]
Dropdown Options, (*19)
[
'class' => 'btn btn-default',
'label' => 'Export',
'menuOptions' => [
'class' => 'dropdown-menu dropdown-menu-right'
]
]
Dropdown Items, (*20)
[
ExportMenu::FORMAT_CSV => [
'label' => 'CSV',
'options' => [
'title' => 'Comma Separated Values',
'data-id' => ExportMenu::FORMAT_CSV,
],
'url' => 'javascript:;',
'className' => CsvOption::className(),
]
]
Selected Option, (*21)
[
'selectedOption' => ExportMenu::FORMAT_CSV,
]
Testing
$ ./vendor/bin/phpunit
What is missing?
- PDF, HTML and TXT export options
- Confirm Alert
- Column selectors
- Store file
- Events
- Internationalization