![]() |
幸福的水煮肉 · 如何获取某个进程的主窗口以及创建进程的程序名 ...· 5 天前 · |
![]() |
胡子拉碴的大葱 · prometheus-nginxlog-ex ...· 2 周前 · |
![]() |
含蓄的镜子 · AttributeError: ...· 1 年前 · |
![]() |
睿智的打火机 · 离开老家前,为你父母的智能手机/电视设置成E ...· 1 年前 · |
我正在尝试使用这个组件,我已经将它从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');