本篇内容介绍了“php如何不使用插件导出excel”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
复制代码 代码如下:
$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
))))
“php如何不使用插件导出excel”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。