A
A
Alexander Arbuzov2013-07-23 11:09:47
PHP
Alexander Arbuzov, 2013-07-23 11:09:47

Problem when downloading the generated Excel file

For formation I use phpExcel. The file is generated and when downloaded from the server via ftp or via a direct link, the file is opened. And if you send it to the client via header(), then the file does not open. Writes "the actual format of the file being opened differs from the file name indicated by its extension." And the file thus has zero size.
Send code:

    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment;filename="orders.xls"');
    header('Cache-Control: max-age=0');
    header("Content-Length: " . filesize($_SERVER['DOCUMENT_ROOT'].'/files/orders.xls'));

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Arbuzov, 2013-07-23
@arbuzzz

What always surprises me on Habré:
You go to the section created for questions . You create a question after trying to solve it yourself. You write and comment on everything.
All the same, the question is minus, and even they manage to slap a minus into karma ...

U
Urvin, 2013-07-23
@Urvin

You forgot to display the contents of the file.
habrahabr.ru/post/151795/

A
Alexander Arbuzov, 2013-07-23
@arbuzzz

Yes, I understand, blunted at first.
The result is the same - zero size and "the actual format of the file being opened differs from the specified one."
I set the rights to the file before uploading to 777.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question