Skip to content

Instantly share code, notes, and snippets.

@brahimmachkouri
Forked from IamSmith/output.php
Created January 22, 2016 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brahimmachkouri/7e37133bf82ee4a2538d to your computer and use it in GitHub Desktop.
Save brahimmachkouri/7e37133bf82ee4a2538d to your computer and use it in GitHub Desktop.
Output as a download
<?php
$phpExcel = new PHPExcel();
$phpExcel->getActiveSheet()->setTitle("My Sheet");
$phpExcel->setActiveSheetIndex(0);
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"filename.xls\"");
header("Cache-Control: max-age=0");
$objWriter = PHPExcel_IOFactory::createWriter($phpExcel, "Excel5");
$objWriter->save("php://output");
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment