What is correct content-type for excel files?

ExcelMime Types

Excel Problem Overview


I want excel files on a website to open in Excel when clicked, not get saved on desktop, or get opened embedded in a browser etc. Now obviously it all depends on how everything is configured for each user, but what's the best Content-Type and other settings to achieve just that most of the time?

Excel Solutions


Solution 1 - Excel

For BIFF .xls files

application/vnd.ms-excel

For Excel2007 and above .xlsx files

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

Solution 2 - Excel

application/vnd.ms-excel

Solution 3 - Excel

Do keep in mind that the file.getContentType could also output application/octet-stream instead of the required application/vnd.openxmlformats-officedocument.spreadsheetml.sheet when you try to upload the file that is already open.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontawView Question on Stackoverflow
Solution 1 - ExcelMark BakerView Answer on Stackoverflow
Solution 2 - ExcelmikuView Answer on Stackoverflow
Solution 3 - ExcelDiTapView Answer on Stackoverflow