linyuee / excel
excel导出工具包
1.0.1
2018-03-07 06:34 UTC
Requires
- php: >=5.5
- linyuee/core: 1.0.*
- phpoffice/phpexcel: ^1.8
This package is not auto-updated.
Last update: 2024-11-18 08:19:04 UTC
README
1、安装
composer require linyuee/excel
2、使用
导出数据
//导出的数据
$data = array(
['id'=>1,'username'=>'test1','phone'=>'18881515151'],
['id'=>2,'username'=>'test2','phone'=>'18881515152'],
['id'=>3,'username'=>'test3','phone'=>'18881515153'],
);
//标题
$sheettitle = array(
'id'=>'ID',
'username'=>'答题人',
'phone'=>'联系方式',
);
//导出的数据和标题数组的key要一致
$excel = new \Linyuee\Excel\Export();
$excel->setData($data)
->setFileName('问卷答题情况')
->setTitle($sheettitle)
->setStartIndex('B')
->setFileExt('csv') //目前支持csv,xls,xlsx
->export();
读取文件数据
$excel = new \Linyuee\Excel\Import();
$data = $excel->setPath('/disk2/123.xlsx')->read();
var_dump($data);