yantze / yii2-phpexcel
Exporting PHP to Excel
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
This package is not auto-updated.
Last update: 2024-10-26 18:49:25 UTC
README
Feature
- Run Limit Time 300s
- Simple
- Flexible
- High Performance
Installation
The preferred way to install this extension is through composer.
Either run
composer require yantze/yii2-phpexcel
or add below line to the require section of your application's composer.json file.
"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
License
MIT