This commit is contained in:
dongpd 2020-03-27 15:03:44 +07:00
parent c2e025d1d9
commit ead3361d32

View File

@ -16,9 +16,6 @@ class DashboardController extends Controller {
public function init() { public function init() {
parent::init(); parent::init();
if (Yii::$app->user->isGuest) {
return $this->redirect(['/site/login']);
}
} }
/** /**
@ -80,7 +77,7 @@ class DashboardController extends Controller {
$totals = count($lists) + 2; $totals = count($lists) + 2;
$maxCol = "H"; $maxCol = "H";
$activeSheet = $objPHPExcel->getActiveSheet(); $activeSheet = $objPHPExcel->getActiveSheet();
$activeSheet->setCellValue("A1", "DANH SÁCH CHẤM CÔNG"); $activeSheet->setCellValue("A1", "DỮ LIỆU CHẤM CÔNG");
$activeSheet->mergeCells('A1:' . $maxCol . '1'); $activeSheet->mergeCells('A1:' . $maxCol . '1');
$activeSheet->getRowDimension('1')->setRowHeight(50); $activeSheet->getRowDimension('1')->setRowHeight(50);
$activeSheet->getStyle("A2:" . $maxCol . "2")->getFont()->setBold(true); $activeSheet->getStyle("A2:" . $maxCol . "2")->getFont()->setBold(true);
@ -138,12 +135,13 @@ class DashboardController extends Controller {
] ]
]); ]);
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean(); // ob_end_clean();
header('Content-type: application/vnd.ms-excel'); // header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="du-lieu.xlsx"'); // header('Content-Disposition: attachment; filename="du-lieu.xlsx"');
header('Cache-Control: max-age=0'); // header('Cache-Control: max-age=0');
$objWriter->save('php://output'); // $objWriter->save('php://output');
exit(); $objWriter->save('du-lieu.xlsx');
return $this->redirect(Yii::$app->request->hostInfo . "/BiFace_Server_Lite/web/du-lieu.xlsx");
} }
} }