PHP生成CSV单元格未在Windows上显示

I am using Cakephp 2.0. I need to generate a Report on daily basics in an excel format. So i written a function to generate a CSV File. Its working fine in Linux machine when i downloads the file in OpenOffice but if I try to open the same file in windows Microsoft then there is no cells, but the data is displaying properly. With this I listed my coding

    $model.= "-".date('d M,Y');
    header ("Expires: Mon, ".date('d M,Y')." GMT");
    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");
    header ("Content-Disposition: attachment; filename=\"$model.xls" );
    header ("Content-Description: Generated Report" );

Any one helps thanx

I think you might doing something wrong here Please check your header. You have mentioned csv in the question and you're writing excel header. That is might be confusing MS Excel

header ("Content-type: application/vnd.ms-excel");
header ("Content-Disposition: attachment; filename=\"$model.xls" );
header ("Content-Description: Generated Report" );

I'm using this kind of header format which is perfectly working for me in windows and as well as in Open office. Please give a try with this.

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-type: octet/stream");
header("Content-Type: application/force-download");
header("Content-Type: application/download");
header("Content-disposition: attachment; filename=" . basename($filename.".csv"));
header("refresh: 0; url= ".$redirect_url);

Excel CSV files should be named SSV files, because the data columns need to be separated by a semicolon instead of a comma. Also the data should be enclosed in quotes and any inner quotes need to be escaped as double quote; e.g. 1;"Some ""string"" with escapes".