当前位置:网站首页>Laravel8 export excel file
Laravel8 export excel file
2022-07-05 03:58:00 【s_ Canned ice cubes】
1. Reference resources Excle Official website .
2. Use composer Command to deploy Excle.
composer require maatwebsite/excel3. Use composer Command to create Excle The export model .
php artisan make:export UsersExport --model=User4. Click to enter the newly created Excle controller .

5. The contents of the document are modified

notes : If we export excle Header words , We need to inherit our header file .


Just write our exported method in our control :

Finally, call our method through the route :

Attach complete code :
Excle Content of model file :
<?php
namespace App\Exports;
use App\Models\AddlistModel;
use App\Models\User;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;// export excle Header
class UsersExport implements FromCollection, WithHeadings
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
// Here we call the model we need to export data
return AddlistModel::all();
}
// Add the specified header
public function headings(): array
{
return [
'ID',
' title ',
' Text ',
' Creation time ',
' Modification time '
];
}
}
Controller code content :
// Export us Excl file
public function export()
{
return Excel::download(new UsersExport, 'excle.xlsx');
}边栏推荐
- BDF application - topology sequence
- Analysis of dagger2 principle
- laravel8 导出Excle文件
- 在线SQL转Excel(xls/xlsx)工具
- 企业级:Spire.Office for .NET:Platinum|7.7.x
- Pyqt pyside custom telescopic menu bar sharing (including tutorial)
- 测试开发是什么?为什么现在那么多公司都要招聘测试开发?
- Blue Bridge Cup single chip microcomputer -- PWM pulse width modulation
- Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘
- [untitled]
猜你喜欢

Learning notes of raspberry pie 4B - IO communication (I2C)

【软件逆向-基础知识】分析方法、汇编指令体系结构

Clickhouse物化视图

在线文本行固定长度填充工具

laravel8 导出Excle文件

10种寻址方式之间的区别

A brief introduction to the behavior tree of unity AI

PlasticSCM 企业版Crack

Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery

Redis source code analysis: redis cluster
随机推荐
Difference between MotionEvent. getRawX and MotionEvent. getX
灵魂三问:什么是接口测试,接口测试怎么玩,接口自动化测试怎么玩?
Redis6-01nosql database
JWT vulnerability recurrence
【做题打卡】集成每日5题分享(第三期)
Containerd series - detailed explanation of plugins
Binary heap implementation (priority queue implementation)
线程基础知识
PlasticSCM 企业版Crack
汇编-入门
C语言课设:影院售票管理系统
Google Chrome CSS will not update unless the cache is cleared - Google Chrome CSS doesn't update unless clear cache
[wp][introduction] brush weak type questions
Interview byte, pass the exam and directly work on three sides. As a result, I found an architect to hang me?
Thread Basics
25K 入职腾讯的那天,我特么哭了
ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
Clickhouse materialized view
Excuse me, my request is a condition update, but it is blocked in the buffer. In this case, can I only flush the cache every time?
provide/inject
https://laravel-excel.com/