PHP代碼:
header("Content-type:application/vnd.ms-Excel");
header("Content-Disposition:attachment;filename=users.xls" );
echo "公司名稱"."\t";
echo "用戶名"."\t";
echo "密碼"."\t";
echo "二級域名"."\t";
echo "\n";
foreach($result['result'] as $val){
echo "$val->ComName"."\t";
echo "$val->UserName"."\t";
echo "$val->UserTruePw"."\t";
echo emptyempty($val->DoMainName)?'':('http://'.$val->DoMainName.'.jiaomai.com')."\t";
echo "\n";
}
?>
注意編碼問題,因為表格一般輸出是utf-8 編碼。我用表格形式(table+tr+td)輸出的時候就出現了亂碼。。。。因為我頁面編碼是GB2312,可用iconv轉也行,為了防止亂碼自己又搞不定,最好用上面方法輸出.