header("Pragma: public"); header("Expires: 0"); header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); header("Content-Type:application/force-download"); header("Content-Type:application/vnd.ms-execl"); header("Content-Type:application/octet-stream"); header("Content-Type:application/download");; header('Content-Disposition:attachment;filename='.$fileName.''); header("Content-Transfer-Encoding:binary");//输出 $writer = IOFactory::createWriter($spreadsheet,'Xlsx'); $writer->save('php://output');
但是如果
$writer->save('文件名');
就可以直接保存在根目录,但是不能下载
代码以及错误信息, 截图发出来