A customer reported a problem with downloading XLS files from one of our servers.
The error messages was a bit cryptic and we knew these did not come from our backend.
It seems that ERROR_MESSAGE_MAIN and ERROR_MESSAGE_REASON are messages from iOS. As always I Googled to find any tips & tricks on how to solve it but without luck.
We could isolate the error down to XLSX files. In PHP we pulled the content type by the following code:
$contentType = $dcx_file->getMimeType(); header("Content-type: ".$contentType);
This gave us “application/vnd.ms-excel” which obviously did not work. But I was sure I’ve seen iOS handle XLS previews before. Something must be wrong with how the headers in our PHP download function worked.
After some trial and error I found out that iOS did not really know how to map “application/vnd.ms-excel” to the preview function. So I tried a couple of different content types and ended up with this: “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”.
Now I’ve added a exception for XLS files like this and it seems to work like a charm.
$contentType = $dcx_file->getMimeType(); if($contentType=="application/vnd.ms-excel") { $contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; } header("Content-type: ".$contentType);