function exportToExcel($fileName = '', $headArr = [], $data = []){
ini_set('memory_limit','1024M');
ini_set('max_execution_time',0);
ob_end_clean();
ob_start();
header("Content-Type: text/csv");
header("Content-Disposition:filename=".$fileName.'.csv');
$fp=fopen('php://output','w');
fwrite($fp, chr(0xEF).chr(0xBB).chr(0xBF));
fputcsv($fp,$headArr);
$index = 0;
foreach ($data as $item) {
if($index==1000){
$index=0;
ob_flush();
flush();
}
$index++;
fputcsv($fp,$item);
}
ob_flush();
flush();
ob_end_clean();
exit();
}