工作在我的項目的Excel佈局我添加CakePHP的2.1 XLS頭內容類型沒有在Mac的Safari
<?php
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ("Content-type: application/vnd.ms-excel");/*.pdf,.xls*/
header ("Content-Disposition: attachment; filename=Report.xls");
header ("Content-Description: Generated Report");
?>
<?php echo $content_for_layout ?>
,並在我的控制器
function export_xls($id=null) {
$this->render('export_xls', 'export_xls');
}
和export_xls.ctp保持空白。
在Windows中,它創造的report.xls文件,但MAC OS的Safari瀏覽器下載它作爲report.xls.html 什麼該做,我不understand.i我使用CakePHP 2.1
請幫我解決這個問題.....
您是否試過[Media View](http://book.cakephp.org/2.0/en/views/media-view.html)? – noslone
我使用該媒體視圖,但它不起作用。 –
你需要設置正確的'mimeType'或者離開它。如果CakePHP知道'mimeType',CakePHP會自動填充'mimeType' – noslone