Skip to content

Instantly share code, notes, and snippets.

@mtrojanowski
Created March 22, 2013 13:42
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 mtrojanowski/5221364 to your computer and use it in GitHub Desktop.
Save mtrojanowski/5221364 to your computer and use it in GitHub Desktop.
Sf 1.4. send an Excel file to browser
$this->getResponse()->clearHttpHeaders();
$this->getResponse()->setStatusCode(200);
$this->getResponse()->setContentType('application/vnd.ms-excel');
$this->getResponse()->setHttpHeader('Content-Disposition', "attachment; filename=filename.xls");
$this->getResponse()->setHttpHeader('Content-Transfer-Encoding', 'binary');
$this->getResponse()->setHttpHeader('Content-Length', $file_size);
return $this->renderText($file_contents);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment