这里写自定义目录标题
phpexcel 导出部分
$fileName = '用户信息';
$date = date("Y-m-d",time());
$fileName .= "_{$date}.xls";
$fileName = iconv("utf-8", "gb2312", $fileName);
$objPHPExcel->setActiveSheetIndex(0);
ob_end_clean();//清除缓冲区,避免乱码
header('Content-Type: application/vnd.ms-excel');
header("Content-Disposition: attachment;filename=\"$fileName\"");
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output'); //文件通过浏览器下载
关键语句
ob_end_clean();//清除缓冲区,避免乱码
问题描述
导出Excel时,文件打不开,显示乱码 …unknown creater 需要清除缓存区