[php]代码库
<?
define("DB_HOST","localhost");
define("DB_USER","root");
define("DB_PASS","root");
define("DB_DATABASE","cowaw");
mysql_connect(DB_HOST,DB_USER,DB_PASS) or die('can not connect mysql database!');
mysql_select_db(DB_DATABASE) or die('can not select database!');
mysql_query('set names utf8');
header("Content-type:application/vnd.ms-excel"); //excel文件头
header("Content-Disposition:filename=xlstest.xls"); //excel文件头
$query = mysql_query("select name,sex,city,job from xlstest ");
while ($result=mysql_fetch_array($query)){
echo $result['name']."\t".$result['sex']."\t".$result['city']."\t".$result['job']."\t\n";
}
?>