时间:2021-05-26
复制代码 代码如下:
$filename=date("Y年m月d日")."数据信息统计结果.xls"; //文件名
$ua = $_SERVER["HTTP_USER_AGENT"]; //中文文件名不乱码
if (preg_match("/MSIE/", $ua)) {
$filename=urlencode($filename);
} else if (preg_match("/Firefox/", $ua)) {
$filename=$filename;
} else {
$filename=urlencode($filename);
}
header("Content-type:application/vnd.ms-excel"); //输出excel头
header("Content-Disposition:filename=".$filename);
$n = iconv('utf-8', 'gbk', '11'); //设置excel表格列
$t = iconv('utf-8', 'gbk', '22');
$k = iconv('utf-8', 'gbk', '33');
$s = iconv('utf-8', 'gbk', '44');
$r= iconv('utf-8', 'gbk', '55');
$a= iconv('utf-8', 'gbk', '66');
echo "{$n}\t";
echo "{$t}\t";
echo "{$k}\t";
echo "{$s}\t";
echo "{$r}\t";
echo "{$a}\t\n";
foreach($a as $kk=>$pp){ //对每列些数据
foreach($pp['child'] as $k=>$p){
echo iconv("utf-8", "gbk//IGNORE", $pp['u']."\t");
echo iconv("utf-8", "gbk//IGNORE", $p['u']."\t");
echo iconv("utf-8", "gbk//IGNORE", $p['s']."\t");
echo iconv("utf-8", "gbk//IGNORE", $p['t']."\t");
echo iconv("utf-8", "gbk//IGNORE", $p['c']."\t");
echo iconv("utf-8", "gbk//IGNORE", $p['t']."\t\n");
}
}
数组格式为
复制代码 代码如下:
Array
(
[0] => Array
(
[unitid] => 1234
[u] => aaa
[fid] => 1000
[shengid] => 1000
[shiid] => 0
[xianid] => 0
[rid] => 2
[orders] => 50
[sys_createuid] => 1
[sys_createtime] => 1383556976
[sys_updateuid] => 1
[sys_updatetime] => 1389853763
[child] => Array
(
[0] => Array
(
[unitid] => 1035
[u] => bbb
[fid] => 1000
[shengid] => 1000
[shiid] => 0
[xianid] => 0
[rid] => 2
[orders] => 50
[sys_createuid] => 1
[sys_createtime] => 1383556976
[sys_updateuid] => 1
[sys_updatetime] => 1389853763
[funitname] =>
[s] => 6
[t] => 1
[c] => 1
[t] => 2
)
[4] => Array
(
[u] => 合计
[s] => 8
[t] => 1
[c] => 3
[t] => 3
))))
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了jquery+php实现导出datatables插件数据到excel的方法。分享给大家供大家参考。具体如下:DataTables是一个jQuery
本文实例讲述了Yii框架使用PHPExcel导出Excel文件的方法。分享给大家供大家参考,具体如下:最近在研究PHP的Yii框架,很喜欢,碰到导出Excel的
因为前几天写了篇文章,用php-excel-reader类导入excel内容,顺便说些excel导出问题,我用的是simpleexcel,一个很简单的导出xls
本文实例讲述了PHP将Excel导入数据库及数据库数据导出至Excel的方法。分享给大家供大家参考。具体实现方法如下:一.导入导入需要使用能读取Excel的组件
最近在研究PHP的Yii框架,很喜欢,碰到导出Excel的问题,研究了一下,就有了下面的方法:最简单的利用composer安装composerr