
PHP导出Excel格式文件(xls)
- 2007-11-26
- 分类:PHP&MySql
- 作者:银子
- 510 次查看
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-Disposition: attachment; filename=info.xls");
header("Pragma: no-cache");
header("Expires: 0");
以下是全部代码:
- <?php
- 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++;
- }
- ?>
NOTE:本博内容大部分为原创,转载请注明出处。
永久链接:http://www.zdyi.com/index.php/php-output-excel-xls/33.html

导出来好做,我现在正找读取的呢!!不好找,呵呵!!