问题描述
谁能告诉我如何导出带有选择列表的 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'];
}
}
如果有人可以帮助我, 谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)