How to get Microsoft office files downloaded properly through Drupal
I recently came across a situation where the .ppsx files were displayed as some weird characters instead of getting downloaded. For those who aren't aware of the .ppsx file extension, it is nothing but the extension for files created through Microsoft PowerPoint. You can find more information about the Powerpoint file formats here.
Let me elaborate on the issue I faced with .ppsx files in Drupal. We had a content type with a file field and used to upload .pdf, .ppsx, .doc, etc. We didn't have any problem while downloading .pdf files, but in the case of .ppsx files, some weird characters were shown.
The solution to the problem is to add some information about the MIME types in the .htaccess file. Here are the lines that need to be added to the .htaccess file:
AddType application/vnd.ms-word.document.macroEnabled.12 docm
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
AddType application/vnd.ms-powerpoint.template.macroEnabled.12 potm
AddType application/vnd.openxmlformats-officedocument.presentationml.template potx
AddType application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
AddType application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
AddType application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
AddType application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
AddType application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
AddType application/vnd.ms-excel.addin.macroEnabled.12 xlam
AddType application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
AddType application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
AddType application/vnd.ms-excel.template.macroEnabled.12 xltm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
This would address the issue for most of the Microsoft office files.