可以到处为CVS格式或者用html的<table>形式然后加上上面所说的header就可以了header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera header("Content-type: application/x-msexcel"); // This should work for the rest header('Content-Disposition: attachment; filename="'.basename($export_file).'"');
$export_file = "test.xls";
ob_end_clean();
ini_set('zlib.output_compression','Off');header('Pragma: public');
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header ("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: none');
header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera
header("Content-type: application/x-msexcel"); // This should work for the rest
header('Content-Disposition: attachment; filename="'.basename($export_file).'"'); echo "test1" . "\t";
echo "test2" . "\t";
echo "test3" . "\n";
<?php
header("<meta http-equiv=\"content-type\" content=\"text/html;charset=uft-8\">");
header("Content-Type: application/vnd.ms-excel");
header("content-disposition: attachment;filename=test.xls");
$arr = array(
'0'=>array('name'=>'zhangshan','age'=>'22'),
'1'=>array('name'=>'zhangshan','age'=>'22'),
'2'=>array('name'=>'zhangshan','age'=>'22'),
'3'=>array('name'=>'zhangshan','age'=>'22'),
);
echo "name" . "\t";
echo "age" . "\t";
echo "\n";
foreach($arr as $value) {
echo $value['name'] . "\t";
echo $value['age'] . "\t";
echo "\n";
}
?>
header("Content-type: application/x-msexcel"); // This should work for the rest
header('Content-Disposition: attachment; filename="'.basename($export_file).'"');
<?
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=信息.xls");
require('../include/config.inc');
$link_id=mysql_connect($dbhost,$dbuser,$dbpassword);
mysql_select_db($dbname,$link_id);
set_time_limit(0);
$province=$_POST['province'];
$city=$_POST['city'];
$area=$_POST['area'];
echo "id\t";
echo "classname\t";
echo "area\t";
echo "userbh\t";
echo "userkh\t";
echo "addtime\t";
echo "isjrfs\t";
echo "issrfs\t";
echo "zhiwu\t";
echo "danwei\t";
echo "beizhu\t";
echo "username\t";
echo "password\t";
echo "pname\t";
echo "psex\t";
echo "dtime\t";
echo "address\t";
echo "province\t";
echo "city\t";
echo "area\t";
echo "code\t";
echo "tel\t";
echo "phone\t";
echo "bbname\t";
echo "bbsex\t";
echo "bbdtime\t";
echo "bbparent\t";
echo "email\t";
echo "point\t\n";
$str="select * from member where area='$area'";
$result=mysql_query($str,$link_id);
while($rs=mysql_fetch_array($result)){
echo $rs['id']."\t";
echo $rs['classname']."\t";
echo $rs['area']."\t";
echo $rs['userbh']."\t";
echo $rs['userkh']."\t";
echo $rs['addtime']."\t";
echo $rs['isjrfs']."\t";
echo $rs['issrfs']."\t";
echo $rs['zhiwu']."\t";
echo $rs['danwei']."\t";
echo $rs['beizhu']."\t";
echo $rs['username']."\t";
echo $rs['password']."\t";
echo $rs['pname']."\t";
echo $rs['psex']."\t";
echo $rs['dtime']."\t";
echo $rs['address']."\t";
echo $rs['province']."\t";
echo $rs['city']."\t";
echo $rs['area']."\t";
echo $rs['code']."\t";
echo $rs['tel']."\t";
echo $rs['phone']."\t";
echo $rs['bbname']."\t";
echo $rs['bbsex']."\t";
echo $rs['bbdtime']."\t";
echo $rs['bbparent']."\t";
echo $rs['email']."\t";
echo $rs['point']."\t\n";
}
mysql_close($link_id);
?> 记得上一页要把变量传递过来哦~