export in excel

Questionsexport in excel
anavarro asked 10 years ago

I successfully added the export to excel option in a grid. But, here comes the issue:

When I click the export in excel option, testing on localhost, it works great. It shows the download dialog and the file is downloaded; but, when I upload the php file to the web server and click on the export option, the download dialog is not shown and the data to be exported appears on a different tab on the browser.

Am I missing something? Is there anything else I should do to make it work on the web server?

3 Answers
Abu Ghufran answered 10 years ago


You might need to force download excel type either by setting htaccess

1) This links forces pdf files to get downloaded. Change it to xls or xlsx for your case.
Force a PDF or MP3 to download (without loading in memory)

Ananda Theerthan answered 9 years ago

I exactly have same issue, even tried adding this to .htaccess in my folder.

<FilesMatch ".(?i:csv)$">
ForceType application/octet-stream
Header set Content-Disposition attachment

The content just outputs to new tab instead of downloading.

Abu Ghufran answered 9 years ago

Another reason for this issue could be

1) blank space character at start of file
2) invisible BOM character at start of file

In case #1 will give header already sent error. #2 will push all data as html text.

White spaces can be removed by checking top and end of all included files.
To remove invisible BOM character, i would recommend Notepad++ -> Open file -> Encoding menu -> Encode UTF without BOM

Your Answer

8 + 5 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?