set_time_limit(0);
$list = TraceKeyword::select(DB::raw('keyword,sum(pv) as pv,sum(uv) as uv,sum(ip) as ip,sum(reg) as reg'))
->groupBy('keyword')
->orderBy('uv', 'desc')
->get();
$newList[] = [ '关健字', 'PV', 'UV', 'IP', '报名人数', '转换率'];
foreach ($list as $item) {
$newList[] = [
str_replace('=', '', $item->keyword),
$item->pv,
$item->uv,
$item->ip,
$item->reg,
percentageRatio($item->reg, $item->uv)
];
}
\Excel::create('搜索词信息-' . Carbon::now()->toDateString(), function ($excel) use ($newList) {
$excel->sheet('keyword', function ($sheet) use ($newList) {
$sheet->rows($newList);
});
})->download('xlsx');<br></br>
导出约1万条,还是可以。但是超级一万就出错了,有什么优代方案吗?