早些时候,php 5.6文件已保存。 更新到php 7和os到ubuntu 16.04之后。 它无法正常工作
$objPHPExcel->getActiveSheet()->setTitle('KYC Report');
$objPHPExcel->setActiveSheetIndex(0);
//print_r($objPHPExcel);die;
// Redirect output to a client’s web browser (Excel5)
header('Content-type: application/vnd.ms-excel');
// It will be called file.xls
//header('Content-Disposition: attachment; filename="sectionlist.xlsx"');
if (Yii::app()->user->checkAccess('Magicbus-admin') || Yii::app()->user->checkAccess('Magicbus-accountant')) {
header('Content-Disposition: attachment;filename=Transaction Report"' . date('ymdhis', time()) . '.xlsx');
} else {
header('Content-Disposition: attachment;filename=KYCReport-"' . date('ymdhis', time()) . '.xls');
}
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
ob_start();
$objWriter->save('php://output');
Yii::app()->end();
我在yii上使用PHPExcel 1.8。在服务器上启用了php版本即。 5和7。