[TYPO3-english] Headers to export to Excel

Richard Davies richard at ocular.co.nz
Tue Sep 11 01:24:50 CEST 2012


Hi there,

I believe typo3 only throws out its headers right at the end, so if you
call your headers, echo out the data then exit, it should work.
spreadsheet_excel_writer works well for me. Can you confirm you call send
at the start of your write? It should go something like
->construct
->send(file)
//add/write data
->close
exit;

Richard


On 11 September 2012 10:38, Guillermo R. Oramas J. <oramas.g at gmail.com>wrote:

> 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!
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
>


More information about the TYPO3-english mailing list