Last active
April 30, 2017 16:07
-
-
Save denkurbatov/0a0b333b900ad63f905fe8456458eda9 to your computer and use it in GitHub Desktop.
excel.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function downloadFileAction($file_name) | |
{ | |
// Redirect output to a client’s web browser (Excel2007) | |
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); | |
header('Content-Disposition: attachment;filename="' . $file_name . '.xlsx' .'"'); | |
header('Cache-Control: max-age=0'); | |
// If you're serving to IE 9, then the following may be needed | |
header('Cache-Control: max-age=1'); | |
// If you're serving to IE over SSL, then the following may be needed | |
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past | |
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified | |
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1 | |
header ('Pragma: public'); // HTTP/1.0 | |
$objPHPExcel = PHPExcel_IOFactory::load($this->config->application->filesDir . $file_name . '.xlsx'); | |
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); | |
$objWriter->save('php://output'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment