Yii 2.0: yii2-excelview

Excel View allows the export of data from a yii2-gridview to various formats (csv, html, xls, xlsx)
6 followers

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

Total 10 comments

#19632 report it
_ker_ at 2015/10/20 09:32am
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

#19405 report it
Mubeen at 2015/06/22 02:45am
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.

#18444 report it
Artur Oliveira at 2014/10/29 06:19pm
Scott several issues

Scott

Sorry for the delay Could you please create issues in the issue tracker with the description of your problems

Thanks

#18388 report it
Scott_Huang at 2014/10/22 10:41pm
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.

#18387 report it
Scott_Huang at 2014/10/22 10:31pm
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}&nbsp</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.

#18385 report it
Scott_Huang at 2014/10/22 10:08pm
issue: cannot ignore or direct export Action column

Getting unknown property: yii\grid\ActionColumn::attribute

#18382 report it
Artur Oliveira at 2014/10/22 02:22pm
Pay attention: Need add gridview in modules

Good point

Added to the instructions

Thanks

#18380 report it
Scott_Huang at 2014/10/22 10:49am
Pay attention: Need add gridview in modules

'modules' => [ ... 'gridview' => [ 'class' => '\kartik\grid\Module' ] ...

#18355 report it
Scott_Huang at 2014/10/19 10:26pm
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

#18349 report it
Scott_Huang at 2014/10/19 09:46am
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.

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet