/** * 导出日志 */ public function excel() { setlocale(LC_ALL, 'en_US.UTF-8'); $filename = date('YmdHis') . ".csv"; header("Content-type:text/csv"); header("Content-Disposition:attachment;filename=" . $filename); header('Cache-Control:must-revalidate,post-check=0,pre-check=0'); header('Expires:0'); header('Pragma:public'); $db = Db::name($this->table)->order('id desc'); $excelinfo = parent::_excel($db); $result = "标题,地址,作者,添加时间"."\n"; foreach ($excelinfo as $v_excelinfo){ $result.=replaces_string($v_excelinfo['article_title']).','. replaces_string($v_excelinfo['url']).','. replaces_string($v_excelinfo['article_author']).','. replaces_string($v_excelinfo['article_publish_time'])."\n"; } echo $result;return; }
Atas ialah kandungan terperinci php导出cvs xls xlsx的解决方法. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!