Laravel 导出到 excel 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49399796/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel export to excel file
提问by Lucentyr
What's the best library for laravel to use when it comes to exporting data to an excel file ? something that uses a template would be much better.
在将数据导出到 excel 文件时,laravel 使用的最佳库是什么?使用模板的东西会好得多。
采纳答案by Rahman Qaiser
Laravel Excelif you need to add dropdown in your excel sheet PhpSpreadsheetwould a good choice over Laravel Excel
Laravel Excel如果你需要在你的 Excel 表格中添加下拉菜单PhpSpreadsheet比Laravel Excel是一个不错的选择
For Laravel Excel you can simply
对于 Laravel Excel,您可以简单地
Excel::loadView('folder.file', $data)
->setTitle('FileName')
->sheet('SheetName')
->mergeCells('A2:B2')
->export('xls');
回答by Pooja Yengandul
Use maatwebsite to Create and import Excel, CSV and PDF files
使用 maatwebsite 创建和导入 Excel、CSV 和 PDF 文件
Add this lines to your composer.json:
将此行添加到您的 composer.json 中:
"require": {
"maatwebsite/excel": "~2.1.0"
}
After updating composer, add the ServiceProvider to the providers array in config/app.php
更新 Composer 后,将 ServiceProvider 添加到 config/app.php 中的 providers 数组
Maatwebsite\Excel\ExcelServiceProvider::class,
You can use the facade for shorter code. Add this to your aliasses:
您可以将外观用于更短的代码。将此添加到您的别名中:
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
To publish the config settings in Laravel 5 use:
要在 Laravel 5 中发布配置设置,请使用:
php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider"
回答by Komal
Best library for excel Maatwebsite
excel Maatwebsite 的最佳库
Easy to importing and exporting Excel and CSV in Laravel
在 Laravel 中轻松导入和导出 Excel 和 CSV