eseperio / yii2-exportable-gridview
Yii2 gridview with full export of data to spreadsheet.
Requires
- phpoffice/phpspreadsheet: ^1.1
- yiisoft/yii2: ~2.0.12
This package is auto-updated.
Last update: 2024-10-29 00:32:17 UTC
README
Gridview with full data export
This works as normal gridview, but adds a button to export the data loaded into it. It exports all records found on the active record query. Works with the same data as the gridview does. Uses phpspreadsheet to generate export file.
How does it work
Following the same behavior that pjax widget, this widget act as a normal gridview until
a request is made with the url query parameters export-grid
and export-container
.
The latter should contain the id of gridview without the hashtag. When both parameters are received, response
is cleared and then spreadsheet generation begins. This allow to generate a file with absolutely all
records found on the gridview.
This project is currently under development. Any contribution is welcome.
Installation
composer require eseperio/yii2-exportable-gridview @dev
Usage
This widget extends from yii2-gridview but add functionality to export all the rows queried by the DataProvider.
use eseperio\gridview\ExportableGridview as GridView; <?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'id', 'title', 'description', 'author', ], ]); ?>
Additional configuration
Constants available
All writers identifiers are available through constants.
Notes
All html tags are removed when exporting.
Todo
- Add option to exclude certain columns like ActionColumn.
- Add batch data processing.
- Add custom PDF export method.
- Add tests