use App\Models\User; use Illuminate\Support\Facades\Log; use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\FromQuery; use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithMapping;
class UsersExport implements FromQuery,WithHeadings,WithMapping {
有吗
3.1不能这么用,我也找了好久,问了同事才知道它自带一个query函数,模型::query 就是分块查询了,在官方文档的From Query位置
<?php
namespace App\Exports;
use App\Models\User;
use Illuminate\Support\Facades\Log;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
class UsersExport implements FromQuery,WithHeadings,WithMapping
{
}
贴上实例,控制器里面调用还是一样的 return Excel::download(new UsersExport($data), ‘invoices.xlsx’);
通过查询导出这种,如果查询出来的块数据,需要继续处理(比如再返回一个需要计算的属性:某某数量),该怎么写 :neutral_face: