php导出excel表格
2015-04-18 02:24
120 查看
<?php header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment; filename=demo.xls'); header('Pragma: no-cache'); header('Expires: 0'); $title = array('编号', '姓名', '性别', '年龄', '身高', '体重'); $data = array( array(1, '张三', '男', '22', 183, 72), array(2, '李四', '女', '18', 170, 50), array(3, '王五', '男', '14', 178, 68), array(4, '赵六', '女', '34', 163, 48) ); echo iconv('utf-8', 'gbk', implode("\t", $title)), "\n"; foreach ($data as $value) { echo iconv('utf-8', 'gbk', implode("\t", $value)), "\n"; } ?> |
[php] header(“Content-type:application/vnd.ms-excel”);
header(“Content-Disposition:attachment; filename=用户信息表.xls”);
require_once(‘./class.db.php’);
$db = new DB(‘localhost’, ‘app_vmovies’, ‘root’, ‘123456’);
$sql = ‘select * from `user` order by `id` desc';
$ret = $db->get_results($sql);
// 输出内容如下:
echo “ID”.”\t”;
echo “昵称”.”\t”;
echo “性别”.”\t”;
echo “OpenId”.”\t”;
echo “平台”.”\t”;
echo “注册日期”.”\t”;
echo “\n”;
$len = count($ret);
for ( $i = 0; $i < $len; $i++ ) {
echo $ret[$i][“id”].”\t”;
echo $ret[$i][“nickname”].”\t”;
echo $ret[$i][“gender”].”\t”;
echo $ret[$i][“openid”].”\t”;
echo $ret[$i][“pf”].”\t”;
echo $ret[$i][“regdate”].”\t”;
echo “\n”;
}
[/php]
相关文章推荐
- php导出excel表格
- php导出excel表格
- phpExcel 实现excel表格和mysql数据库的导入导出
- [php] thinkphp使用csv导出excel表格
- PHP简单导出Excel表格
- PHP导出excel表格
- php导出EXCEL表格
- PHPExcel-1.8.1导入、导出Excel表格
- 通过phpexcel导入和导出excel表格
- php导出excel表格部分代码
- php导出excel表格
- 用php将数据库中数据导出成excel表格
- [PHP][使用PHPCxcel制作excel表格并导出文件的用法及成功实例[已验证][原创]
- tp5 phpexcel 导入,导出 excel表格
- PHP批量导出数据为excel表格
- php导出excel表格
- 【PHP】Excel表格导入导出
- PHP导出大量数据到excel表格
- php导入导出excel表格
- php导出EXCEL表格