此情形在在本机没发现,服务器上报错。解决方式很简单
ob_end_clean();//清除缓冲区,避免乱码(增加此行即可) 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='.$file_name.'.xls'); header("Content-Transfer-Encoding:binary"); $write->save('php://output');