Skip to content

Instantly share code, notes, and snippets.

@IamSmith
Created April 5, 2011 08:30
Show Gist options
  • Save IamSmith/903248 to your computer and use it in GitHub Desktop.
Save IamSmith/903248 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