php_fun_获得记录的的 xls文件
时间:2006-11-09 来源:tystok
/*
*$res format as Array(array("user_name"=>"tystok","scope"=>...)...);
*$fn 文件名
*/
function getxls($res,$fn="")
{
if($fn=="") $fn = time().".xls";
if((!is_array($res))|| count($res)==0) return false;
$file_type = "vnd.ms-excel";
header("Content-Type: application/$file_type");
header("Content-Disposition: attachment; filename=$fn");
header("Pragma: no-cache");
header("Expires: 0");
$title = "";
foreach($res[0] as $key => $val){
$title .= $key." \t ";
}
echo $title."\n";
for($i=0;$i<count($res);$i++){
foreach($res[$i] as $val){
echo iconv('UTF8','gbk',$val); //必须转为GBK的
echo "\t";
}
echo "\n";
}
相关阅读 更多 +
排行榜 更多 +