解决phpExcel卡顿问题,php导出CSV,10万数据性能不是问题
public function put_csv($title, $list){ $file_name="用户列表CSV".date("mdHis",time()).".csv"; header ( 'Content-Type: application/vnd.ms-excel' ); header ( 'Content-Disposition: attachment;filename='.$file_name ); header ( 'Cache-Control: max-age=0' ); $file = fopen('php://output',"a"); $limit=1000; $calc=0; foreach ($title as $v){ $tit[]=iconv('UTF-8', 'GB2312//IGNORE',$v); } fputcsv($file,$tit); foreach ($list as $v){ $calc++; if($limit==$calc){ ob_flush(); flush(); $calc=0; } foreach ($v as $t){ $tarr[]=iconv('UTF-8', 'GB2312//IGNORE',$t); } fputcsv($file,$tarr); unset($tarr); } unset($list); fclose($file); exit(); }
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。