Chaos' Blog

yii导出Excel

2019-04-16

尝试了一下用yii导出,真的特别方便,所以特地介绍一下
需要用composer

项目根目录下运行

1
composer require --prefer-dist moonlandsoft/yii2-phpexcel

controller下

1
use moonland\phpexccel\Excel;
1
2
3
4
5
6
7
8
9
Excel::export([
'models' => $result,
'fileName'=> 'file',
'columns' => ['id','name'],
'headers'=> [
'id'=> '编号‘,
'name' => '名字',
]
]);
Tags: Yii