eseperio/yii2-exportable-gridview
Composer 安装命令:
composer require eseperio/yii2-exportable-gridview
包简介
Yii2 gridview with full export of data to spreadsheet.
README 文档
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
| Name | Type | default | Description |
|---|---|---|---|
layout |
string | {summary} {items} {export} {pager} | In addition to default layout this gridview has {export} section. This is the place for export button. |
fileName |
string | exported.xls | Name to use on the generated filename. If writerType value is not set then the writer will be guessed from the extension. |
writerType |
string | null | The writer to be used when generating file. See Spreadsheet writer. Accepts Xls, Xlsx, Ods, Csv, Html, Tcpdf, Dompdf, Mpdf |
exportable |
boolean | true | Whether to enable export for this gridview |
exportLinkOptions |
array | ['class'=> 'btn btn-default', 'target'=>'_blank'] |
Options for the export link. It also accepts label and encode |
exportColumns |
array | empty | Property to define a different column combination for export only. If empty default columns of gridview will be used |
Constants available
All writers identifiers are available through constants.
| Constant name | Value |
|---|---|
WRITER_XLS |
Xls |
WRITER_XLSX |
Xlsx |
WRITER_ODS |
Ods |
WRITER_CSV |
Csv |
WRITER_HTML |
Html |
WRITER_TCPDF |
Tcpdf |
WRITER_DOMPDF |
Dompdf |
WRITER_MPDF |
Mpdf |
Known issues
- There is a known issue with codeception functional tests where testing export may break other tests if output buffer is not enabled in php.
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
eseperio/yii2-exportable-gridview 适用场景与选型建议
eseperio/yii2-exportable-gridview 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.6k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2018 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 eseperio/yii2-exportable-gridview 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 eseperio/yii2-exportable-gridview 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.6k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-27