在header() 前面加上ob_end_clean() 函数, 清除缓冲区, 这样就不会乱码了! ob_end_clean();//清除缓冲区,避免乱码 header('Content-Type: application/vnd.ms-excel');