require_once
ROOT_PATH . '/includes/phpexcel/Classes/PHPExcel.php';
$objPHPExcel
=
new
PHPExcel();
$objPHPExcel
->setActiveSheetIndex(0);
$objPHPExcel
->getActiveSheet()->setTitle('xx列表');
$objPHPExcel
->getActiveSheet()->getColumnDimension('A')->setWidth(10);
$objPHPExcel
->getActiveSheet()->getColumnDimension('B')->setWidth(20);
$objPHPExcel
->getActiveSheet()->getColumnDimension('C')->setWidth(15);
$objPHPExcel
->getActiveSheet()->getColumnDimension('D')->setWidth(50);
$objPHPExcel
->getActiveSheet()->getColumnDimension('E')->setWidth(20);
$objPHPExcel
->getActiveSheet()->getColumnDimension('F')->setWidth(5);
$objPHPExcel
->getActiveSheet()->getColumnDimension('G')->setWidth(20);
$objPHPExcel
->getActiveSheet()->getStyle('A1:J1')->getFont()->setBold(true);
$objPHPExcel
->getActiveSheet()->getStyle('A1:J1')->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel
->getActiveSheet()->setCellValue('A1', '编号');
$objPHPExcel
->getActiveSheet()->setCellValue('B1', '姓名');
$objPHPExcel
->getActiveSheet()->setCellValue('C1', '电话');
$objPHPExcel
->getActiveSheet()->setCellValue('D1', '擅长');
$objPHPExcel
->getActiveSheet()->setCellValue('E1', '创建日期');
$objPHPExcel
->getActiveSheet()->setCellValue('F1', '审核');
$objPHPExcel
->getActiveSheet()->setCellValue('G1', '审核时间');
$row_num
= 2;
foreach
(
$res
as
$value
)
{
$objPHPExcel
->getActiveSheet()->getStyle('A' .
$row_num
. ':' . 'J' .
$row_num
)->getAlignment()
->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel
->getActiveSheet()->getStyle('D' .
$row_num
)->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00);
$objPHPExcel
->getActiveSheet()->getStyle('E' .
$row_num
. ':' . 'H' .
$row_num
)->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel
->getActiveSheet()->setCellValue('A' .
$row_num
,
$value
['id']);
$objPHPExcel
->getActiveSheet()->setCellValue('B' .
$row_num
,
$value
['teacher_name']);
$objPHPExcel
->getActiveSheet()->setCellValue('C' .
$row_num
,
$value
['teacher_mobile']);
$objPHPExcel
->getActiveSheet()->setCellValue('D' .
$row_num
,
$value
['teacher_desc']);
$objPHPExcel
->getActiveSheet()->setCellValue('E' .
$row_num
,
date
('Y-m-d h:i:s',
$value
['createtime']));
$objPHPExcel
->getActiveSheet()->setCellValue('F' .
$row_num
,
$value
['state'] ? '√' : '×');
$objPHPExcel
->getActiveSheet()->setCellValue('G' .
$row_num
,
date
('Y-m-d h:i:s',
$value
['statetime']));
$row_num
++;
}
$outputFileName
= 'teacher_' . time() . '.xls';
$xlsWriter
=
new
PHPExcel_Writer_Excel5(
$objPHPExcel
);
header(
"Content-Type: application/force-download"
);
header(
"Content-Type: application/octet-stream"
);
header(
"Content-Type: application/download"
);
header('Content-Disposition:inline;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"
);
$xlsWriter
->save(
"php://output"
);
echo
file_get_contents
(
$outputFileName
);