<?php$data = array (Array (' name ' = ' Tom ', ' age ' =>61, ' date ' = ' 2014-09-24 12:00:00 '), Array (' name ' = ' ' Mark ', ' age ' =>25, ' date ' = ' 2014-09-23 11:00:00 '), Array (' name ' = ' Lucy ', ' age ' = , ' date ' = ' 2014-09-22 10:00:00 '), $title = array (' name ', ' age ', ' time ',); Exportexcel ($data, $ title);d IE ();/** * export excel * @param array $data Datasets * @param array $title Title set * @param string $filename exported Excel file name */ Function exportexcel ($data =array (), $title =array (), $filename = ' report ') {header ("content-type:application/ Vnd.ms-excel "); Header (" Content-disposition:filename= ". $filename.". XLS ");//Export xls start if (!empty ($title)) {foreach ($title as $k => $v) {$title [ $k] = iconv ("UTF-8", "GBK", $v);} $title = implode ("\ t", $title);echo "$title \ n";} if (!empty ($data)) {foreach ($data as $key = $val) {Foreach ($val as $ck => $cv) {$data [$key] [$ck] = iconv ("UTF-8", "GBK", $CV);} $data [$key] = implode ("\ t", $data [$key]);} Echo implode ("\ n", $data);}}
php_excel/output.php