2014-01-20 31 views
1

正如標題所指定的,當下載文件時,我得到一個文件沒有以指定格式錯誤。以下是我的代碼。另外,下載的文件沒有任何單元格。正在下載.xls拋出錯誤 - 文件不是指定格式

$content = ob_end_flush(); 
$filename = trim($filename); 
$filename = str_replace(array(' ', '/', '\\'), '', $title); 
$filename .= "_Export.xls"; 
header('Content-type: application/vnd.ms-excel; charset=utf-8'); 
//header('Content-type: application/ms-excel'); 
header('Content-Disposition: attachment; filename='.$filename); 
echo $content; 

回答

0

地說:

ob_clean(); 
ob_start(); 

header('Content-type: application/vnd.ms-excel; charset=utf-8'); 

,並嘗試...


OR

變化

header('Content-type: application/vnd.ms-excel; charset=utf-8'); 

header('Content-type: application/msexcel; charset=utf-8'); 

header('Content-type: application/octet-stream; charset=utf-8'); 
+0

仍然沒有工作... – user3214555

+1

先生,請再給我一個解決方案.... – user3214555

+0

只看到編輯答案... –