Reputation: 1
I work on a website, and up until Monday we were able to download a custom excel file sheet and display it. At this point, whenever we try to open it, it launches a blank, grayed-out workbook if Excel is not currently running, and nothing if it is. I have tried editing the content type to no avail. I have tried creating documents with older data that worked at the time and it doesn't work. Nothing has changed on the file system regarding this in a month, and it only just started. Here is the current code used to generate the file:
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename=' . $fname);
ob_clean();
ob_flush();
echo $somecontent;
exit;
Here is what happens when I try to open the created file.
The only way I have found that fixes this currently is to open the file in Notepad++, edit it, and save it, which then allows it to open properly in Excel.
Any help would be appreciated.
EDIT 1: So because the comments below didn't help much, I took a look around and found this video, and upon disabling those three options I could open the files again without having to go through Notepad++ first. I then narrowed down the field that was causing issues to "Protect files originating from the internet" even though before they worked fine.
Upvotes: 0
Views: 164