$objExcel = new PHPExcel();
$objWriter = new PHPExcel_Writer_Excel5($objExcel);$objProps = $objExcel->getProperties();
$objExcel->setActiveSheetIndex(0);
$objActSheet = $objExcel->getActiveSheet();
$objActSheet->setTitle($title);
$objActSheet->setCellValue('B1', '真实姓名');
for ($i = 2; $i < count($res) + 2; $i++) {
$objActSheet->setCellValue('A' . $i, $res[$i - 2]['name']);
$objActSheet->setCellValue('B' . $i, $res[$i - 2]['realname']);
}
$outputFileName = $title . ".xls";
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition:attachment;filename="' . $outputFileName . '"');
header("Content-Transfer-Encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
$objWriter->save('php://output');