- 论坛徽章:
- 0
|
/*
*$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";
}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/14250/showart_197855.html |
|