Header( "Content-type: application/octet-stream ");
Header( "Accept-Ranges: bytes ");
Header( "Content-type:application/vnd.ms-excel ");
Header( "Content-Disposition:attachment;filename=test.xls ");
$con = mysql_connect("localhost","root","123456");
mysql_select_db("db_test");
mysql_query('set names utf8');
$sql = "select id,FirstName,LastName,Age,Hometown,Job from user";
$result = mysql_query($sql,$con);
echo "id\tFirstName\tLastName\tAge\tHometown\tJob";
while ($rs=mysql_fetch_array($result)){
echo "\n";
echo $rs['id']."\t".$rs['FirstName']."\t".$rs['LastName']."\t".$rs['Age']."\t".$rs['Hometown']."\t".$rs['Job'];
}