2017 © Pedro Peláez
 

yii2-extension yii2-phpexcel

Exporting PHP to Excel

image

yantze/yii2-phpexcel

Exporting PHP to Excel

  • Monday, November 16, 2015
  • by yantze
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 13 % Grown

The README.md

PHPExcel

Feature

  • Run Limit Time 300s
  • Simple
  • Flexible
  • High Performance

Installation

The preferred way to install this extension is through composer., (*1)

Either run, (*2)

composer require yantze/yii2-phpexcel

or add below line to the require section of your application's composer.json file., (*3)

"yantze/yii2-phpexcel" : "*"

Usage

$head = [
    'fhead' => [
        [
            'colspan' => 2,
            'name' => '',
        ],[
            'colspan' => 2,
            'name' => 'second',
        ],
    ],
    'head' => [
        [
            'sort' => 'tb_col_name1',
            'name' => 'col1',
        ],[
            'sort' => 'tb_col_name2',
            'name' => 'col2',
        ],[
            'sort' => 'tb_col_name3',
            'name' => 'col3',
        ],[
            'sort' => 'tb_col_name4',
            'name' => 'col4',
        ],
    ]
];

$arrayData = [
    [NULL, 2010, 2011, 2012],
    ['Q1',   12,   15,   21],
    ['Q2',   56,   73,   86],
    ['Q3',   52,   61,   69],
    ['Q4',   30,   32,    0],
];

$name = 'filename';

$excel = new \yantze\helper\Excel();
$curRow = 1;

if (count($head['fhead']) > 1 || $head['fhead'][0]['name'] != '') {
    $excel->addAdvancedMenu($head['fhead'], $curRow++);
}

$head1 = ArrayHelper::getColumn($head['head'], 'name');
$excel->addHead($head1, $curRow++);

$excel->setData($arrayData, $curRow);
$excel->output("xlsx", $name);

Useful PHPExcel Articles

PHPExcel Offical Accessing Cells, (*4)

License

MIT, (*5)

The Versions

16/11 2015

dev-master

9999999-dev

Exporting PHP to Excel

  Sources   Download

MIT

The Requires

 

by zhi yang

extension yii2 excel xls export xlsx