swordfly1979/php-library

There is no license information available for the latest version (v0.0.2) of this package.

一个自定义php工具库

v0.0.2 2020-02-21 14:53 UTC

This package is auto-updated.

Last update: 2025-06-26 19:23:27 UTC


README

安装:composer require swordfly1979/php-library

DataImport

数据导入类,依赖phpoffice/phpspreadsheet。使用前先安装: composer require phpoffice/phpspreadsheet use swordfly1979\DataImport

  • excel() excel导入

    $import = new DataImport()
    $list = $import->excel($param)
    
    $param['url'] 导入的文件咱径(必填)
    $param['isHead'] 是否包含表头 默认:false
    $param['format'] 导入的数据格式替换: 如 ['A'=>'yourKeyName'...]

DataExport

数据导出类依赖 phpoffice/phpspreadsheet use swordfly1979\DataExport

  • excel() 导出excel

    $export = new DataExport()
    $list = $export->excel($param)
    
    $param['list'] array 需要导出的数据 (必填项)
    $param['header'] array 导出的表头及格式 (选填,不填不导出表头),如设置表头,导出的数据列以表头为准
    $param['fileName] string 导出文件名 选填 (选填,不填默认 Y-m-d导出数据
    $param['title'] string 导出的表title (选填)
    数据示例
    $param['list']
    $list = [
        [
            'nickname' => '张三',
            'mobile' => '15000000000',
            'total' => 14
        ],
        [
            'nickname' => '李四',
            'mobile' => '15800000000',
            'total' => 54
        ],
        [
            'nickname' => '王五',
            'mobile' => '15100000000',
            'total' => 554
        ],
        [
            'nickname' => '赵六',
            'mobile' => '13800000000',
            'total' => 74
        ]
    ];
    $param['head']数据示例
    $header = [
        [
            'title' => '手机',  //导出的表列名称(必填)
            'key' => 'mobile', //对应的$param['list']数据键值(必填)
            'type' => 'str',   //数据类型(选填,不填自动判断) str字符串;n数值;b布尔; null空;inlineStr
            ‘value'=>’void‘ //此列固定填充值(选填)
        ],
        [
            'title' => '昵称',
            'key' => 'nickname',
            'type' => 'str',
        ],
        [
            'title' => '昵称2',
            'type' => 'str',
            'value' =>'张三'
        ]
    ]