>  기사  >  백엔드 개발  >  PHP导出excil报表

PHP导出excil报表

WBOY
WBOY원래의
2016-06-13 12:23:09996검색

PHP导出excil表格

PHP导出Excel格式文件(xls),只需给PHP文件加一个文件头,filename 就是导出的xls文件名,当你点击这个文件的URL时,就会提示你下载xls文件了

header("Content-Type: application/vnd.ms-execl");
header("Content-Disposition: attachment; filename=info.xls");
header("Pragma: no-cache");
header("Expires:0"); 

例子:

header("Content-Type: application/vnd.ms-execl");

header("Content-Disposition: attachment; filename=info.xls");

header("Pragma: no-cache");

header("Expires:0");

require_once(dirname(__FILE__)."/../include/config_base.php");

require_once(dirname(__FILE__)."/../dede/config.php");

require_once(dirname(__FILE__)."/../include/pub_datalist.php");

$dsql = new DedeSql(false); 

echo "订阅日期"."\t";

echo "订阅内容"."\t";

echo "姓名"."\t"; 

$dsql->SetQuery("Select * from `TableName` order by `id` desc");

$dsql->Execute();

$i = 1;

while($row = $dsql->GetArray()){     

    echo $row['uTime']."\t";   

    echo $row['uCont']."\t";   

    echo $row['uName']."\t";       

    $i++;

}?>

 

2014-04-04

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.