$writer = new Xlsx($spreadsheet);
$response = response();
ob_start();
$writer->save('php://output');
$c = ob_get_contents();
ob_end_clean();
$response->withHeaders([
'Content-Type' => 'application/vnd.ms-excel',
'Content-Disposition' => 'attachment;filename="xxx.xlsx"',
'Cache-Control' => 'max-age=0',
])->withBody($c);
return $response;
搞了半天的excel 导出,只有你这个能正常跳转到浏览器下载,非常nice
下面这个也不能使用
https://www.workerman.net/a/1394