data33 / phpexcel-wrapper
一个快速简便的包装器,使Excel导出更简单
dev-master
2015-08-05 07:18 UTC
Requires
- php: >=5.3.0
- phpoffice/phpexcel: >= 1.8.0
This package is auto-updated.
Last update: 2024-09-23 18:07:57 UTC
README
一个快速简便的包装器,使Excel导出更简单
示例用法
$excel = new Data33\ExcelWrapper\ExcelWrapper(); $excel->setTitle('My first excel file') ->addRow(['Country', 'Capital'], 'header') ->addRow(['Sweden', 'Stockholm']) ->addRow(['Norway', 'Oslo']) ->save('countries.xlsx');
为了样式特定的单元格
$excel->setTitle('My first excel file') ->addRow(['Country', 'Capital'], 'header') ->addRow([['Europe', 'header']]) ->addRow(['Sweden', 'Stockholm']) ->addRow([['Africa', 'header']]) ->addRow(['Tunisia', 'Tunis']) ->save('countries.xlsx');
为了添加自定义样式,我们可以向包装器提供PHPExcel样式数组
Data33\ExcelWrapper\ExcelStyle::setStyle('red', [ 'font' => [ 'size' => 10, 'name' => 'Arial', 'color' => [ 'rgb' => 'ff0000' ] ] ]); $excel->setTitle('My first excel file') ->addRow(['Country', 'Capital'], 'header') ->addRow(['Sweden', ['Stockholm', 'red']]) ->addRow(['Norway', ['Oslo', 'red']]) ->save('countries.xlsx');
为了直接输出到浏览器以供下载
$excel->setTitle('My first excel file') ->addRow(['Country', 'Capital'], 'header') ->addRow(['Sweden', 'Stockholm']) ->addRow(['Norway', 'Oslo']) ->outputToBrowser('countries.xlsx');