目前我用phpspeadsheet导出excel文件,是存为文件然后再respon的。 有没有方法直接输出而不用输出实体文件?
$writer = new Xlsx($spreadsheet);
$response = response();
ob_start();
$writer->save('php://output');
$c = ob_get_contents();
ob_flush();
flush();
$response->withHeaders([
    'Content-Type' => 'application/vnd.ms-excel',
    'Content-Disposition' => 'attachment;filename="xxx.xlsx"',
    'Cache-Control' => 'max-age=0',
])->withBody($c);
return $response;

转自:https://www.workerman.net/q/9070

标签: none

添加新评论