时间:2021-07-01 10:21:17 帮助过:14人阅读
下载
更新composer
或者直接在命令行中
composer require maatwebsite/excel
2配置
app/config/app.php
providers数组中添加
Maatwebsite\Excel\ExcelServiceProvider::class,
aliasses数组中添加:
‘Excel’ => Maatwebsite\Excel\Facades\Excel::class,
3、使用
namespaceApp\Http\Controllers;
useIlluminate\Http\Request;
useApp\Http\Requests;
useApp\Http\Controllers\Controller;
useMaatwebsite\Excel\Facades\Excel;
classDemoControllerextendsController
{publicfunctiongetDemo(){return view("demo.demo");
}
publicfunctiongetExcel(){// $excel = App::make('excel');
Excel::create('Laravel Excel', function($excel) {$excel->sheet('Excel sheet', function($sheet) {$sheet->setOrientation('landscape');
});
})->export('xls');
}
}
导出excel api地址
http://www.maatwebsite.nl/laravel-excel/docs/export
导入excel api地址
http://www.maatwebsite.nl/laravel-excel/docs/import
以上就介绍了laravel5 中使用excel,包括了require方面的内容,希望对PHP教程有兴趣的朋友有所帮助。