ticketpark / excel-bundle
此包协助使用 HtmlPhpExcel 创建 Excel 文件
0.2
2016-06-23 12:26 UTC
Requires
- php: >=5.3.3
- ticketpark/file-bundle: ~0.2
- ticketpark/htmlphpexcel: ~0.3
This package is not auto-updated.
Last update: 2023-11-22 08:14:33 UTC
README
此 Symfony2 扩展实现了 HtmlPhpExcel,可以将 HTML 表格转换为 Excel 文件。
功能
- ExcelCreator (服务)
- 从 HTML 模板创建 Excel 文件
安装
在 composer.json 中添加 TicketparkExcelBundle
{ "require": { "ticketpark/excel-bundle": "dev-master" } }
现在运行以下命令让 composer 下载扩展包
$ php composer.phar update ticketpark/excel-bundle
在 kernel 中启用扩展包
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Ticketpark\ExcelBundle\TicketparkExcelBundle(), new Ticketpark\FileBundle\TicketparkFileBundle(), ); }
ExcelCreator 的使用
在控制器中使用 Excel 创建服务创建 Excel 文件
$file = $this->get('ticketpark.excel.creator') ->setIdentifier('someIdentifier') // the identifier is used for caching purposes ->setContent('<table><tr><td>foo</td></tr></table>') ->create(); // Output the file (example, this is not connected to the bundle) $headers = array( 'Content-Type' => 'application/vnd.ms-excel', 'Content-Disposition' => 'attachment; filename="filename.xlsx"' ); return new Symfony\Component\HttpFoundation\Response(file_get_contents($file), 200, $headers);
许可协议
此扩展包采用 MIT 许可协议。完整许可协议请参阅扩展包中的许可文件。
Resources/meta/LICENSE