A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.) using the PHPExcel library. The widget allows you to configure the dataProvider, columns just like a yii\grid\GridView. However, it just displays the export actions in form of a ButtonDropdown menu, for embedding into any of your GridView or other components.
In addition, with release v1.2.0, the extension also displays a handy grid columns selector for controlling the columns for export. The features available with the column selector are:
- shows a column picker dropdown list to allow selection of columns for export.
- new
container
property allows you to group the export menu and column selector dropdowns. - allows configuration of column picker dropdown button through
columnSelectorOptions
- auto-generates column labels in the column selector. But you can override displayed column labels for each column key through
columnSelector
property settings. - allows preselected columns through
selectedColumns
(you must set the selected column keys) - allows columns to be disabled in column selector through
disabledColumns
(you must set the disabled column keys) - allows columns to be hidden in column selector through
hiddenColumns
(you must set the hidden column keys) - allows columns to be hidden from both export and column selector through
noExportColumns
(you must set the no export column keys) - toggle display of the column selector through
showColumnSelector
property - column selector is displayed only if
asDropdown
is set totrue
.
The extension offers configurable user interfaces for advanced cases using view templates.
exportFormView
allows you to setup your own custom view file for rendering the export form.exportColumnsView
allows you to setup your own custom view file for rendering the column selector dropdown.
Demo ¶
You can see detailed documentation and demonstration on usage of the extension.
Installation ¶
The preferred way to install this extension is through composer.
Either run:
$ php composer.phar require kartik-v/yii2-export "*"
or add:
"kartik-v/yii2-export": "*"
to the require
section of your composer.json
file.
Usage ¶
use kartik\export\ExportMenu;
$gridColumns = [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
'color',
'publish_date',
'status',
['class' => 'yii\grid\ActionColumn'],
];
// Renders a export dropdown menu
echo ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns
]);
// You can choose to render your own GridView separately
echo \kartik\grid\GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns
]);
Report ¶
- Report any issues on the project page
- Use the forum page for any discussions on this extension
License ¶
yii2-export is released under the BSD 3-Clause License. See the bundled LICENSE.md
for details.
all-krajee.css file not loaded
Everything works fine except the drop-down list. The all-krajee.css file is not present in the widget.
Plz Help
Getting error
Hi Kartik V.
I've used code from Usage and getting error Class 'PHPExcel_Settings' not found.
Tried versions from
"kartik-v/yii2-export": "dev-master" and "kartik-v/yii2-export": "*"
Pls help
exportmenu not collapsing when click
Hi! I successfully setup the export menu and now appearing both button (columns, export option).... but the problem is whenever i click on the buttons the menu wont show up. Did I missed something? I am also using AdminLTE theme, I'm thinking whether something conflicting with the css or js. Please help
How to export the data with header in table structure, not attributes of the model?
for example, I have changed a view column name from typeId to "Type Name" in the model:
Public Function attributeLabels{
return [
'typeId' => Yii::t('app', 'Type Name'),
]
}
How can I export the header as "typeId", not "Type Name"?
Hello, install this complete for export and it works very well for me.
The problem that I am having is with my template, using the original Yii2 template works fine but when I apply the custom styles and execute the exporting action it does not allow me through the POST method, where can I change to do the export through GET?
how to use this with the Phpspreadsheet as this PhpExcel is probably dead
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.