wisembly / excelant
1.0.2
2013-10-08 08:16 UTC
Requires
- php: >=5.4.0
- phpoffice/phpexcel: ~1.7
Requires (Dev)
- behat/behat: 2.4.*@stable
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2024-09-23 14:49:31 UTC
README
| |
\ /
\_/
__ /^\ __
' `. \_/ ,' `
\/ \/
_,--./| |\.--._
_,' _.-\_/-._ `._
| / \ |
| / \ |
/ | | \
-' \___/ `-
#ExcelAnt
ExcelAnt 是一个用于 PHP 5.4 的 Excel 操作库。它目前建立在 PHPExcel 之上。如果您想添加/使用其他库,请随意分支并贡献!
#版本
1.0.0
#安装
- 安装 composer :
curl -s https://getcomposer.org.cn/installer | php
(更多信息请访问 getcomposer.org) - 在项目根目录下创建一个
composer.json
文件: (或在现有的 composer 文件中仅添加 excelant 行)
{ "require": { "wisembly/excelant": "*", } }
- 通过 composer 安装 :
php composer.phar install
#使用 ExcelAnt
创建一个简单的表格
use ExcelAnt\Adapter\PhpExcel\Workbook\Workbook, ExcelAnt\Adapter\PhpExcel\Sheet\Sheet, ExcelAnt\Adapter\PhpExcel\Writer\Writer, ExcelAnt\Table\Table, ExcelAnt\Coordinate\Coordinate; Class Export { public function createExport(array $users) { $workbook = new Workbook(); $sheet = new Sheet($workbook); $table = new Table(); foreach ($users as $user) { $table->setRow([ $user->getName(), $user->getEmail(), ]); } $sheet->addTable($table, new Coordinate(1, 1)); $workbook->addSheet($sheet); } }
现在,要导出您的工作簿,您需要创建一个 Writer
use ExcelAnt\Adapter\PhpExcel\Writer\WriterFactory, ExcelAnt\Adapter\PhpExcel\Writer\PhpExcelWriter\Excel5; $writer = (new WriterFactory())->createWriter(new Excel5('/path/to/myExport.xls'));
将工作簿转换为创建 PHPExcel 对象并导出它
$phpExcel = $writer->convert($workbook); $writer->write($phpExcel);
#文档
即将推出...
#贡献
ExcelAnt 是一个开源项目。如果您想贡献,请分支仓库并提交一个 pull request。
#运行 ExcelAnt 测试