php 导出excel

http://blog.csdn.net/zhaoxuejie/article/details/7243129

google 的xml excel

function export_excel($filename,$title,$data){

ob_end_clean(); 
ini_set('zlib.output_compression','Off'); 

header('Pragma: public'); 
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");                   
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT'); 
header('Cache-Control: no-store, no-cache, must-revalidate');    
header('Cache-Control: pre-check=0, post-check=0, max-age=0');    
header ("Pragma: no-cache"); 
header("Expires: 0"); 
header('Content-Transfer-Encoding: none'); 
header('Content-Type: application/vnd.ms-excel;charset=utf-8');                 
header("Content-type: application/x-msexcel;charset=utf-8"); 
header("Content-disposition: attachment; filename="  . iconv('utf-8', "gb2312", $filename) . ".xls");
$s = '';
if (is_array($title)){
    foreach ($title as $key => $value){
        $s .=  $value."\t";
    }
}
$s .=  "\n";
if (is_array($data)){
    foreach ($data as $key => $value){
        foreach ($value as $_key => $_value){
            $s .=  $_value."\t";
        }
        $s .=  "\n";
    }
}

$s = mb_convert_encoding($s, 'gb2312');
//$s = iconv('utf-8', "gb2312", $s);
exit($s);

}

你可能感兴趣的:(php 导出excel)