ptrnov/yii2-postman4excel Excel on view or console cronjobs

extensionexcelptrnovpostman4excelpostmanpostman4

Postman Excel for Yii 2

Base On scotthuangzl (ptrnov update)

Postman Excel Export for view or console cronjobs, mail postman

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist ptrnov/yii2-postman4excel "*"

or add

"ptrnov/yii2-postman4excel": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

    use ptrnov\postman4excel\Postman4ExcelBehavior;
    public function behaviors(){
            'export4excel' => [
                'class' => Postman4ExcelBehavior::className(),
                'downloadPath'=>'your path'     //defult "/vendor/ptrnov/yii2-postman4excel/tmp/", Ecample Windows path "d:/folder/"
                'widgetType'=>'download'        //download web browser, delete before download, tmp_download
                //'widgetType'=>'cronjob'       //console method, folder tmp_cronjob
                //'widgetType'=>'mail'          //posman mail, folder tmp_mail
                //'widgetType'=>''              //Empty same download, file  stay on folder "tmp_mix"
                //'prefixStr' => yii::$app->user->identity->username,
                //'suffixStr' => date('Ymd-His'),

            ],
    }
    // localhost/yourController/test-export
    public function actionTestExport()
    {
        //get data from database
        $sqlDataProvider= new ArrayDataProvider([
            'allModels'=>\Yii::$app->db->createCommand("    
                SELECT id, username FROM user
            ")->queryAll(), 
        ]); 
        $arySqlDataProvider=$sqlDataProvider->allModels;    

        /*Array Model Data*/
        $excel_dataAll = Postman4ExcelBehavior::excelDataFormat($arySqlDataProvider);   (not used for columnGroup just put 'ceils' => $arySqlDataProvider)
        $excel_ceilsAll = $excel_dataAll['excel_ceils'];
        $excel_title1 = $excel_dataAll['excel_title'];
        $excel_title2 = ['ID','USERNAME'];

        //Tite Header From Table Name
        //$excel_title = $excel_dataAll['excel_title'];

        //Tite Header From Modify byself
        //$excel_title = ['ID','USERNAME']

        //Note 'sheet_title'
        //old version : 'sheet_title' => $excel_title,
        //new Version : 'sheet_title' => [$excel_title1,$excel_title2,$excel_title3, dst],

        $excel_content = [
            [
                'sheet_name' => 'TEST EXPORT 1 old version',
                'sheet_title' => $excel_title1,                     //old version               
                'ceils' => $excel_ceilsAll,// atau langsung $arySqlDataProvider;
                    //for use column Group.
                    //noted: 'ceils' => "Array Source", not need difinition "Postman4ExcelBehavior::excelDataFormat($array source);"
                    //'columnGroup'=>Name of Field//column group difinition.
                'columnGroup'=>['ID'],//column for grouping.
                'autoSize'=>true,   //true/false.
                //'freezePane' => 'A2',
                'headerColor' => Postman4ExcelBehavior::getCssClass("header"),  //All Header Color font and Backgroud
                'headerColumnCssClass' => [                         //old version
                      [
                        'id' => Postman4ExcelBehavior::getCssClass('yellow'),
                        'username' => Postman4ExcelBehavior::getCssClass('green'),
                     ],
                     [
                         'ID' => Postman4ExcelBehavior::getCssClass('red'),  
                         'USERNAME' => Postman4ExcelBehavior::getCssClass('green'),                          
                     ]             

                ],
               'oddCssClass' => Postman4ExcelBehavior::getCssClass("odd"),
               'evenCssClass' => Postman4ExcelBehavior::getCssClass("even"),
            ],
            [
                'sheet_name' => 'TEST EXPORT 2 new version ',
                //'sheet_title' => [$excel_title1],                 //new version | one Header
                'sheet_title' => [                                  //new version | two or more Header
                    $excel_title1,
                    $excel_title2
                ],  //new version               
                'ceils' => $excel_ceilsAll,
                //'freezePane' => 'E2',
                'headerColor' => Postman4ExcelBehavior::getCssClass("header"),  //old Version | All Header Color font and Backgroud            
                /* --------------------------------------------------------
                 * customize Header properties
                 * Color Ref: http://dmcritchie.mvps.org/excel/colors.htm
                 * columnAutoSize=false, width is Active
                 * 'merge'=>'col,row'
                 * Content properties, validate on use last column title
                 * --------------------------------------------------------
                 */
                'headerStyle' => [                                  //new version
                    [   //the first Header                      
                        'id' => ['align'=>'CENTER','color-font'=>'0000FF','color-background'=>'FFCCCC','merge'=>'0,2','width'=>'2,0'],
                        'username' => ['align'=>'left','color-font'=>'FF0000','color-background'=>'CCFF99','merge'=>'2,1','width'=>'32.29','valign'=>'center','wrap'=>true], 
                    ],
                    [   //The second Header
                         'ID' =>  ['align'=>'right','color-font'=>'0000FF','color-background'=>'CCFFCC'],
                         'USERNAME' =>  ['align'=>'right','color-font'=>'000000','color-background'=>'FFFF99'],              
                    ]                              
                ],  
                'contentStyle' => [                                 //new version
                    [//the first Content
                        //'id' => ['align'=>'left'],
                        //'username' => ['align'=>'right'],
                    ],
                    [//The second Content
                        'ID' =>  ['align'=>'center','color-font'=>'0000FF'],
                        'USERNAME' =>  ['align'=>'center','color-font'=>'0000FF'],               
                    ],                              
                ],  
               'oddCssClass' => Postman4ExcelBehavior::getCssClass("odd"),
               'evenCssClass' => Postman4ExcelBehavior::getCssClass("even"),
            ],

        ];

        $excelFile = "TestExport";
        $this->export4excel($excel_content, $excelFile);    
    }

Changelog

Change Log: `yii2-postman4excel`
===================================

## Version 2.4.6, 
**Date:** 2017-02-08
1. (chg): font-size.
2. (enh): ColumnGrouping (Grouping Rows).
3. (enh): OutlineLevel (level1 dan level2).
4. (enh): Active Column.['outline1','outline2']
5. (chg): Postman4ExcelBehavior::excelDataFormat. (can used/not).
6. (chg): autoSize. (Autosize per-sheet content),

## Version 2.4.5, 
**Date:** 2017-02-06
1. (chg): columnAutoSize.
2. (chg): headerStyle width (columnAutoSize==false)
3. (enh): valign
4. (enh): Text Wrap

## Version 2.4.4, 
**Date:** 2016-10-06
1. (bug): path custimize

## Version 2.4.3, 
**Date:** 2016-08-18
1. (bug): containStyle

## Version 2.4.2, 
**Date:** 2016-08-14
1. (bug): excelDataFormat, validate array
2. (bug): headerStyle merge

## Version 2.4.1, 
**Date:** 2016-08-14
1. (bug): containStyle.

## Version 2.4.0, 
**Date:** 2016-08-14
1. (bug): headerStyle merge (mergeCells). merge(col,row)
2. (enh): columnAutoSize
3. (enh): headerStyle width (columnAutoSize==false)
4. (enh): containStyle color-font

## Version 2.2.0
**Date:** 2016-08-11
1. (enh): containStyle (customize  contain property column align).. 

## Version 2.1.1
**Date:** 2016-08-11
1. (rem): ceils_start_rows  = remove. 
2. (rem): ceils_start_rows = change on sheet_title.
3. (chg): sheet_title = [array1,array2,array3, etc..].
4. (enh): headerColumnCssClass =[[array1],[array1],[array3],[etc..]].
5. (enh) : headerStyle (customize  property colum header align,color-font,color-background).

## Version 2.0.1
**Date:** 2016-08-10
1. (rem) : remove DownloadAction. 
2. (enh):downloadPath : customize add.
3. (enh): widgetType [download,cronjob,mail] = add.
4. (enh): ceils_start_rows (header row1 and header row2).

## Version 2.0.0
**Date:** 2016-08-09
1. (dev):Export Excel default by scotthuangzl/yii2-export2excel.

## Version 1.0.0
1. Test dev.

**Date:** 24-Juli-2016
- Initial release 
- Refrensi version MAJOR.MINOR.PATCH [1.0.0] (http://semver.org)
- Sub repo split from [yii2-postman4excel](https://github.com/ptrnov/yii2-postman4excel)

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



2.4.7 is the latest of 12 releases



BSD-3-Clause license
Stats
2 github stars & 0 github forks
0 downloads in the last day
2 downloads in the last 30 days
84 total downloads