php - 如何在 Laravel 中使用选择列表导出 Excel
问题描述
任何人都可以告诉我如何使用此图像的选择列表导出 Excel 文件
我的要求与这些照片相同,我只想在 excel 文件中提供角色选择下拉菜单。
为此,我正在使用 Laravel 的 Maatwebsite 插件。
这是我的示例代码...
<?php
namespace App\Exports;
use App\Models\User;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
class UserRoles implements FromCollection, WithHeadings
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return User::with(['roles'])->get();
}
public function headings(): array
{
return ['id','name','email','role'];
}
}
如果有人可以帮助我,谢谢。
解决方案
推荐阅读
- azure - 使用 API 获取 Azure 服务主体应用程序级别权限
- android - LiveData 的竞争条件
- javascript - 在 next/react 组件中实现页面 javascript
- javascript - 如何通过替换原始数组来替换另一个数组中的唯一值
- html - NGINX html 格式错误
- javascript - Node.js | 将端点转换为通用路径以在 YAML 文件中匹配
- python - cv2.imread 无法识别路径
- python - 修改后如何在原始输入订单上打印列表
- python - 如何在不重复代码的情况下在 Django Rest Framework 中实现密码更改(DRY 原理)
- python - 当只有一组时,pandas groupby-apply 会给出奇怪的结果