CVS文件导出
/** * @param $filename 文件名 */ public function exportCxv($filename) { $filename = @iconv('UTF-8', 'GBK', $filename . '.csv'); header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:attachment;filename=" . $filename); header('Cache-Control:must-revalidate,post-check=0,pre-check=0'); header('Expires:0'); header('Pragma:public'); $title = "标题栏,标题栏"; echo @iconv('UTF-8', 'GBK//IGNORE', $title) . "\r\n"; } /** * [csv 导出数据] * @param [type] $data [数据] * @return [type] [description] */ public function csv($data) { if (!empty($data)) { foreach ($data as $key => $value) { $param = $value['param']; $date = date("Y-m-d H:i:s", $value['$date'] ? $value['$date'] : null); echo '"'.@mb_convert_encoding($param, 'GBK', 'UTF-8').'",'; echo '"'.@mb_convert_encoding($date, 'GBK', 'UTF-8').'",'; echo " \r\n"; } } }