目录

  • 数据格式

  • 引入文件

  • 导出

数据格式

Array
(
    [0] => Array
        (
            [id] => 4
            [qrcord_id] => 1
            [openid] => oXtOes8lfAzW4cIhnB4C5ORQZFOs
            [type] => 1
            [name] => 测试
            [scene_str] => 
            [scene_id] => 10001
            [append] => 1508398903
            [fans] => Array
                (
                    [openid] => oXtOes8lfAzW4cIhnB4C5ORQZFOs
                    [nickname] => 简言
                )

        )

    [1] => Array
        (
            [id] => 3
            [qrcord_id] => 1
            [openid] => oXtOes8lfAzW4cIhnB4C5ORQZFOs
            [type] => 2
            [name] => 测试
            [scene_str] => 
            [scene_id] => 10001
            [append] => 1508398886
            [fans] => Array
                (
                    [openid] => oXtOes8lfAzW4cIhnB4C5ORQZFOs
                    [nickname] => 简言
                )

        )

)

引入文件

use common\helpers\ExcelHelper;

导出

        $header = [
            ['field' => 'id', 'name' =>  'ID', 'type' => 'text'],
            ['field' => 'name', 'name' =>  '场景名称', 'type' => 'text'],
            ['field' => 'fans.openid', 'name' =>  'openid', 'type' => 'text'],//表示获取二维数组的字段以.隔开
            ['field' => 'fans.nickname', 'name' =>  '昵称', 'type' => 'text'],
            ['field' => 'scene_str', 'name' =>  '场景值', 'type' => 'text'],
            ['field' => 'scene_id', 'name' =>  '场景ID', 'type' => 'text'],
            ['field' => 'type', 'name' =>  '关注扫描', 'type' => 'selectd', 'rule' => ['' => '全部','1' => '关注','2' => '扫描']],
            ['field' => 'append', 'name' => '创建日期', 'type' => 'date', 'rule' => 'Y-m-d H:i:s'],
        ];

        //导出Excel $dataList为查询出来的数据
        ExcelHelper::exportExcelData($dataList,$header);
        //导出csv表格
        //ExcelHelper::exportCSVData($dataList,$header);

上次更新:2018-08-14