我的程序导出到Execl全是乱码
<?php
require_once '../data/function.php';
header("Content-Type:text/html;charset=gbk");
if(isset($_POST['time1'])&&($_POST['time1'])!="")
{
$time1=$_POST['time1'];
$time3=strtotime($time1." 00:00:00");
}else{
$time1="2010-12-1";
$time3=strtotime($time1." 00:00:00");
}
if(isset($_POST['time2'])&&($_POST['time2'])!="")
{
$time2=$_POST['time2'];
$time4=strtotime($time2." 23:59:59");
}else{
$time2=date("Y-m-d",time()+8*60*60);
$time4=strtotime($time2." 23:59:59");
}
if(isset($_POST['s3']))
{
$s3=$_POST['s3'];

header("Content-Type: application/vnd.ms-excel;charset=gbk");
header("Content-Disposition: attachment; filename=report.xls");
header("Pragma: no-cache");
header("Expires: 0");
$crlf = "\n";
$sep = "\t";
//取回数据
$aquery=get("select realname,username from pw_members where username!='admin' and realname like '".$s3."%' and realname != ''");
while($rs=mysql_fetch_array($aquery))
{
$realname=$rs['realname'];
$fenshu=get1("select sum(fenshu) from pw_shenhe where author like '".$rs['username']."%' and shenhetime between '".$time3."' and '".$time4."'",'sum(fenshu)');if($fenshu==""){$fenshu='0';}
$ycxtjf=checklogin("select * from pw_shenhe where author='".$rs['username']."' and type='分' and shenhetime between '".$time3."' and '".$time4."'");
//echo $realname.$sep;
echo $realname."\t";  
echo $fenshu.$sep;
echo $ycxtjf.$sep;
echo $crlf;
}
}
?>
功能函数里面也做了 set names gbk的 但是程序导出后中文的部分($realname)就全是乱码 请高手帮忙看看!