webman里面直接输出phpspeadsheet导出的文件到php://output

roczyl
$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;
1109 1 11
1个评论

软饭工程师

搞了半天的excel 导出,只有你这个能正常跳转到浏览器下载,非常nice
下面这个也不能使用
https://www.workerman.net/a/1394

  • 暂无评论

roczyl

-120
积分
0
获赞数
0
粉丝数
2022-08-03 加入
🔝