This extension allows exporting of data from a yii2-grid This is a port to Yii2 of an extension already available for Yii1 eexcelview
Requirements ¶
- Tested on Yii 2.0.0
- Requires yii2-grid and phpoffice/phpexcel
Installation ¶
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist arturoliveira/yii2-excelview "*"
or add
"arturoliveira/yii2-excelview": "*"
to the require section of your composer.json
file.
Usage ¶
Once the extension is installed, simply use it in your code by :
<?= \arturoliveira\ExcelView::widget(
); ?>
To include the export buttons just add {fullexport} to your layout
All the yii2-grid options are available please refer to yii2-grid page for instructions
Since this module depends on yii2-grid don't forget to add the following to your config file
'modules' => [
...
'gridview' => [
'class' => '\kartik\grid\Module'
]
...
]
Resources ¶
- Demo Page (Not avaliable yet. Keep posted ....)
- Packagist
- Source
- Bug Tracker
phpoffice/phexcel 1.8.0 => no matching package found.
I try both
php composer.phar require --prefer-dist arturoliveira/yii2-excelview "*"
and
php composer.phar require --prefer-dist arturoliveira/yii2-excelview "dev-master"
Find error:
phpoffice/phexcel 1.8.0 => no matching package found.
Can you advise? thanks.
Successful install extention now.
My original error is phpoffice/phpexcel 1.8.0 => no matching package found.
It can resolve by
remove phpoffice/phpexcel:"dev-master" from my existig composer.json firstly to avoid different version of phpexcel
then add
"arturoliveira/yii2-excelview": "dev-master"
then
composer udpate --prefer-dist
Pay attention: Need add gridview in modules
'modules' => [
...
'gridview' => [
'class' => '\kartik\grid\Module'
]
...
Pay attention: Need add gridview in modules
Good point
Added to the instructions
Thanks
issue: cannot ignore or direct export Action column
Getting unknown property: yii\grid\ActionColumn::attribute
Another Issue: Include additional characters when export excel/csv.
It will normal if I export in control directly with 'export' mode instead of 'grid'mode.
however, if I set layout as
'layout' => '{summary}<div class="pull-right">{fullexport} </div>{items}{pager}',
and try export through the button, the export result will be not correct as below:
CSV:
<div class="country-index"> <h1>Countries</h1> <p> </p> "#" Code Name Population 1 AU Australia 18886000 2 BR Brazil 170115000 3 CA Canada 1147000 4 CN China 1277558000
Excel:
The excel output even cannot open normally, like below
<div class="country-index"> <h1>Countries</h1> <p> </p> ??????;? ? ? !"#$%&'()*+,-./01234567?9:;???????Oh??+'??0?8@Ph t€?SubjectUnknown Creator@€?????@€????? ? ??B?=?%r8X"1??Calibri1? ?Calibri?? ? ?? ? ?? ? ?? ? ; ?0?(????My Application%Data exported on: 2014-10-23 10:32:43#CodeName PopulationAU AustraliaBRBrazilCACanadaCNChinaDEGermanyFRFranceGBUnited KingdomINIndiaRURussiaTSTestUSU.S.A ? ??*+?€????&ffffff??'ffffff??(??)???"dXX333333??333333??U}m}?}?}???
I think it caused by additional character output when generate excel to cause format not correct. Thanks.
Third Issue: Cannot integrate into panel layout.
I can show fullexport in layout, however, it will not work in case I setup pane and define pane layout. Can you help to resolve it? thx.
Scott several issues
Scott
Sorry for the delay
Could you please create issues in the issue tracker with the description of your problems
Thanks
how to export with filtered values
Suppose if the user is wants to export only the selected values using this extension , How to implement?
For Eg, if i want to download a report for filter using datewise given by user in the page.
Column format
I'm trying to add a column with format:
[ 'attribute' => 'datetime', 'format' => ['date', 'php:' . Yii::t('app', 'm-d-Y h:i:s')] ],
but it doesn't work... datetime just is shown using default format Y-m-d h:i:s
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.