您好,登錄后才能下訂單哦!
本篇內容介紹了“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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。