一个高效,快速的xlsx文件导出扩展
可用于在Excel 2007及以上版本XLSX文件中写入多个工作表的文本,数字,公式和超链接
[https://pecl.php.net/package/xlswriter](https://pecl.php.net/package/xlswriter)
[文档地址](https://xlswriter-docs.viest.me/zh-cn/kuai-su-shang-shou/chuang-jian-wen-jian)
### **为什么使用xlswriter**
请参考下方对比图;由于内存原因,PHPExcel数据量`相对较大`的情况下无法正常工作,虽然可以通过`修改memory_limit`配置来解决内存问题,但完成工作的时间可能会更长;
(PHPExcel是一个处理Excel,CVS文件的开源框架,可以使用它来读取、写入不同格式的电子表格,这也是PHP至今最通用的Excel处理工具,但是它有一个非常致命的缺点: 特别占内存;但不幸的是PHPExcel官方已不再维护了这个项目了,官方团队在github上又起了一个新项目,叫PhpSpreadsheet)
* [Predefined Constants](https://www.php.net/manual/en/xlswriter.constants.php)
* [Vtiful\Kernel\Excel](https://www.php.net/manual/en/class.vtiful-kernel-excel.php)— The Vtiful\Kernel\Excel 类
* [Vtiful\Kernel\Excel::addSheet](https://www.php.net/manual/en/vtiful-kernel-excel.addSheet.php)— addSheet
* [Vtiful\Kernel\Excel::autoFilter](https://www.php.net/manual/en/vtiful-kernel-excel.autoFilter.php)— autoFilter
* [Vtiful\Kernel\Excel::constMemory](https://www.php.net/manual/en/vtiful-kernel-excel.constMemory.php)— constMemory
* [Vtiful\Kernel\Excel::\_\_construct](https://www.php.net/manual/en/vtiful-kernel-excel.construct.php)— constructor
* [Vtiful\Kernel\Excel::data](https://www.php.net/manual/en/vtiful-kernel-excel.data.php)— data
* [Vtiful\Kernel\Excel::fileName](https://www.php.net/manual/en/vtiful-kernel-excel.filename.php)— fileName
* [Vtiful\Kernel\Excel::getHandle](https://www.php.net/manual/en/vtiful-kernel-excel.getHandle.php)— getHandle
* [Vtiful\Kernel\Excel::header](https://www.php.net/manual/en/vtiful-kernel-excel.header.php)— header
* [Vtiful\Kernel\Excel::insertFormula](https://www.php.net/manual/en/vtiful-kernel-excel.insertFormula.php)— insertFormula
* [Vtiful\Kernel\Excel::insertImage](https://www.php.net/manual/en/vtiful-kernel-excel.insertImage.php)— insertImage
* [Vtiful\Kernel\Excel::insertText](https://www.php.net/manual/en/vtiful-kernel-excel.insertText.php)— insertText
* [Vtiful\Kernel\Excel::mergeCells](https://www.php.net/manual/en/vtiful-kernel-excel.mergeCells.php)— mergeCells
* [Vtiful\Kernel\Excel::output](https://www.php.net/manual/en/vtiful-kernel-excel.output.php)— output
* [Vtiful\Kernel\Excel::setColumn](https://www.php.net/manual/en/vtiful-kernel-excel.setColumn.php)— setColumn
* [Vtiful\Kernel\Excel::setRow](https://www.php.net/manual/en/vtiful-kernel-excel.setRow.php)— setRow
*****
* [Vtiful\Kernel\Format](https://www.php.net/manual/en/class.vtiful-kernel-format.php)— The Vtiful\Kernel\Format 类
* [Vtiful\Kernel\Format::align](https://www.php.net/manual/en/vtiful-kernel-format.align.php)— align
* [Vtiful\Kernel\Format::bold](https://www.php.net/manual/en/vtiful-kernel-format.bold.php)— bold
* [Vtiful\Kernel\Format::italic](https://www.php.net/manual/en/vtiful-kernel-format.italic.php)— italic
* [Vtiful\Kernel\Format::underline](https://www.php.net/manual/en/vtiful-kernel-format.underline.php)— underline
例子:
# 导出文件
```
$config = ['path' => '/home/viest'];//如果路径下有相同命名的文件,新文件会覆盖老文件
$excel = new \Vtiful\Kernel\Excel($config);
// fileName 会自动创建一个工作表,你可以自定义该工作表名称,工作表名称为可选参数
$filePath = $excel->fileName('tutorial01.xlsx', 'sheet1')
->header(['Item', 'Cost'])
->data([
['Rent', 1000],
['Gas', 100],
['Food', 300],
['Gym', 50],
])
->output();
```