Created
May 2, 2018 15:42
-
-
Save vincentmoulene/bbbdfe2b452a7a4e5cab21a201f9c67c to your computer and use it in GitHub Desktop.
Export xls with symfony
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Symfony\Component\HttpFoundation\Request; | |
/** | |
* Create a zip file with excel contain the list of clubs. | |
* | |
* @param Request $request | |
* @param $the_response_excel_file | |
* @param $the_file_name | |
*/ | |
public function exportAction(Request $request, $the_response_excel_file, $the_file_name) | |
{ | |
// adding headers | |
$dispositionHeader = $response->headers->makeDisposition( | |
ResponseHeaderBag::DISPOSITION_ATTACHMENT, | |
$filename | |
); | |
$response->headers->set('Content-Type', 'text/vnd.ms-excel; charset=utf-8'); | |
$response->headers->set('Pragma', 'public'); | |
$response->headers->set('Cache-Control', 'maxage=1'); | |
$response->headers->set('Content-Disposition', $dispositionHeader); | |
return $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think 'text/vnd.ms-excel' mimetype does not exist. It should be 'application/vnd.ms-excel'.
See https://github.com/apache/tika/blob/main/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml#L1898