function export($log_list_export)
{
require "../include/phpexcel/PHPExcel.php";
require "../include/phpexcel/PHPExcel/Writer/Excel5.php";
//创建一个excel
$objPHPExcel = new PHPExcel();
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
//设置sheet名称
$sheets=$objPHPExcel->getActiveSheet()->setTitle('sheet_name'); //设置sheet列头信息
$objPHPExcel->setActiveSheetIndex()->setCellValue('A1', '记录id')->setCellValue('B1', '活动ID')->setCellValue('C1', '订单号(满天星)')->setCellValue('D1', '活动名称')->setCellValue('E1', '抽奖凭证')->setCellValue('F1', '抽奖手机')->setCellValue('G1', '奖品名称')->setCellValue('H1', '中奖信息')->setCellValue('I1', '记录时间');
$i=;
foreach($log_list_export as $v){
//设置单元格的值
$sheets=$objPHPExcel->getActiveSheet()->setCellValue('A'.$i,$v['log_id']);
$sheets=$objPHPExcel->getActiveSheet()->setCellValue('B'.$i,$v['turntable_id']);
$sheets=$objPHPExcel->getActiveSheet()->setCellValue('C'.$i,$v['OrderNO']);
$sheets=$objPHPExcel->getActiveSheet()->setCellValue('D'.$i,$v['prize_id']);
if($v['lottery_cert']==){
$sheets=$objPHPExcel->getActiveSheet()->setCellValue('E'.$i,'取票码+手机号');
}else{
$lottery_cert = iconv('utf-8','gb2312','');
}
$sheets=$objPHPExcel->getActiveSheet()->setCellValue('F'.$i,$v['mobile']);
$sheets=$objPHPExcel->getActiveSheet()->setCellValue('G'.$i,$v['prize_name']);
$sheets=$objPHPExcel->getActiveSheet()->setCellValue('H'.$i,$v['log_msg']);
$sheets=$objPHPExcel->getActiveSheet()->setCellValue('I'.$i,date("Y-m-d H:i:s",$v['log_time']));
$i++;
} ob_end_clean();//清除缓冲区,避免乱码
// 输出Excel表格到浏览器下载
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="呵呵.xls"'); //excel表格名称
header('Cache-Control: max-age=0');
header('Cache-Control: max-age=1');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header('Pragma: public'); // HTTP/1.0 $objWriter->save('php://output');
exit;
}
//$log_list_export数据源,是个二维数组
export($log_list_export);
特别提示:exit不能省略;设置个是之前加ob_end_clean();//清除缓冲区,避免乱码