|
|
睿智的打火机 · 【午夜0时的吻】中字预告片-当片寄凉太遇上桥 ...· 2 年前 · |
|
|
知识渊博的蟠桃 · 上海财经大学2023年高校专项初审通过考生名单公示· 2 年前 · |
|
|
活泼的草稿本 · 我穿成了书中病娇男主的继母 - 抖音· 2 年前 · |
|
|
爱喝酒的牙膏 · 英国办的这场婚礼价值85个亿新郎俩前女友也到 ...· 2 年前 · |
|
|
朝气蓬勃的油条 · 文在寅慰问医院大火受害者家属 ...· 2 年前 · |
我正在尝试使用这个组件,我已经将它从2.1更新到3.1,我的导出现在被破坏了。这个新版本中不存在方法
create
,或者文档中遗漏了一些东西。
Excel::create()
Call to undefined method Maatwebsite\Excel\Excel::create()
发布于 2019-12-22 12:56:31
这里是文档 https://docs.laravel-excel.com/3.1/exports/
你必须在de文件夹中创建一个导出类:
应用程序/导出/
使用以下命令:
用户php artisan make:导出模型-- UsersExport =
将创建文件UsersExport.php
namespace App\Exports;
use App\User;
use Maatwebsite\Excel\Concerns\FromCollection;
class UsersExport implements FromCollection
public function collection()
return User::all();
}
在你的控制器中
namespace App\Http\Controllers;
use App\Exports\UsersExport;
use Maatwebsite\Excel\Facades\Excel;
class UsersController extends Controller
public function export()
return Excel::download(new UsersExport, 'users.xlsx');
}
在你的路线上
Route::get('users/export/', 'UsersController@export');
发布于 2020-07-30 17:49:43
使用laravel插件在excel中导出数据
Excel::create('filename',function($excel) use ($data){
$excel->sheet('filename', function($sheet) use ($data){
$sheet->fromArray($data, null, 'A1', false, false);
$sheet->cell('A1:Z1', function ($cells) {
$cells->setFontWeight('bold');