php导出cvs xls xlsx的解决方法
程序员文章站
2022-03-14 18:14:44
...
/** * 导出日志 */ 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; }
以上就是php导出cvs xls xlsx的解决方法的详细内容,更多请关注其它相关文章!
推荐阅读