[TYPO3-english] Headers to export to Excel
Guillermo R. Oramas J.
oramas.g at gmail.com
Tue Sep 11 00:38:12 CEST 2012
Hello.
I have a frontend plugin where I displayed some tabular data. I developed a
function to export the same data to excel.
To do that I created a link with a parameter "?cmd=excel" that redirects to
the same plugin and trigger the excel function.
When the user clicks the link the browser dialog appears offering to open
or save the file. If the user selects "save", the file is saved and then
opens without problems, but if the user selects "open" then the browser
opens the file in an unreadable format.
I know that is because the headers passed to the browser are html and
nothing is said about excel.
I think I need to put something like:
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="filename.xls"');
header('Cache-Control: max-age=0');
But I suspect that the Spreadsheet_Excel_Writer already do that, so the
problem is how to pass these headers before any other headers?
Thanks for the help. I hope I will learn something new today!
More information about the TYPO3-english
mailing list