Skip to content

Instantly share code, notes, and snippets.

@gravitano
Created April 14, 2015 07:54
Show Gist options
  • Save gravitano/edc6579582cc7988e7e6 to your computer and use it in GitHub Desktop.
Save gravitano/edc6579582cc7988e7e6 to your computer and use it in GitHub Desktop.
<?php
if ( ! function_exists('xls'))
{
/**
* XLS Response.
*
* @param string $filename
* @param string $view
* @param array $data
* @param integer $status
* @return \Response
*/
function xls($filename, $view, $data = [], $status = 200)
{
$filename = $filename . date('YmdHis').'.xls';
return response()->view($view, $data, $status, [
"Pragma" => " public",
"Expires" => " 0",
"Cache-Control" => " must-revalidate, post-check=0, pre-check=0",
"Content-Type" => " application/force-download",
"Content-Type" => " application/octet-stream",
"Content-Type" => " application/download",
"Content-Disposition" => " attachment;filename={$filename}",
"Content-Transfer-Encoding" => " binary ",
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment