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?
Hello,
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)
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
</FilesMatch>
The content just outputs to new tab instead of downloading.
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