This article mainly introduces a simple way for PHP to export Excel without using Plug-ins, first get an array of the data that needs to be exported, and the format of the array is below. Then you define the file name and the style of Excel you want to export, and the last is the loop array, which outputs the data
Code as follows: $filename =date ("Y-year m-month D-Day"). " Data information statistics results. xls "; //filename $ua = $_server["Http_user_agent"]; //Chinese filename is not garbled if (Preg_match ("/msie/", $ua)) { $filename =urlencode ($filename);} else if (Preg_mat CH ("/firefox/", $ua)) { $filename = $filename;} else { $filename =urlencode ($filen AME); Header ("Content-type:application/vnd.ms-excel"); Outputs an Excel header header ("Content-disposition:filename=". $filename); $n = Iconv (' utf-8 ', ' GBK ', ' 11 '); Set Excel table Column $t = iconv (' utf-8 ', ' gbk ', ' 22 '); $k = Iconv (' utf-8 ', ' GBK ', ') '; $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}tn"; foreach ($a as $kk => $pp) {//For each column of data foreach ($pp [' child '] as $k => $p) {echo iconv ("Utf-8", "gbk// IGNORE ", $pp [' U ']." T "); Echo iconv ("Utf-8", "Gbk//ignore", $p [' U ']. " T "); EchoIconv ("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 ']. " TN "); } array format code is as follows: Array ( [0] => Array ([uni TID] => 1234 [u] => AAA [FID] => 1000 [shengid] => 1000 [shiid] => 0 [Xianid] => 0 [RID] => 2 [Orders ] => [Sys_createuid] => 1 [sys_createtime] => 1383556976 [Sys_updateuid] => 1 [sys_updatetime] => 138985 3763 [child] => Array ([0] => Array ( [Unitid] => 1035 [u] => bbb [ FID] => 1000 [Shengid] => 1000 [shiid] => 0 [Xianid] => 0 &NB Sp [RID] => 2 [orders] => [Sys_createuid] => 1 [sys_createtime] => 1 383556976 [Sys_updateuid] => 1 [Sys_updatETime] => 1389853763 [funitname] => [s] => 6 [T] => 1 & nbsp [C] => 1 [T] => 2)  [4] => Array ( [u] => Total [s] => 8 [T] => 1 [C] => 3 [T] => 3))