Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PHPExcel sample excel output of array ($arr) -
$objPHPExcel = new PHPExcel();
// autosize excel columns
foreach(range('A','Z') as $columnID)
$objPHPExcel->getActiveSheet()->fromArray($arr, NULL, 'A1');
// write excel2007 standard xlsx
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$filename = $this->options["export"]["filename"];
header('Content-Type: application/');
header('Content-Disposition: attachment;filename="'.$filename.'.xlsx"');
// if ssl and IE, remove above cache-control and add following
if ( (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") || $_SERVER["SERVER_PORT"] == "443" )
header('Cache-Control: private');
header('Pragma: token');
header('Cache-Control: max-age=0');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.