Application type for excel

MS Excel has the following observed MIME types:

  • application/vnd.ms-excel (official)
  • application/msexcel
  • application/x-msexcel
  • application/x-ms-excel
  • application/x-excel
  • application/x-dos_ms_excel
  • application/xls
  • application/x-xls
  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (xlsx)

Is there any one type that would work for all versions? If not, do we need to set response.setContentType() with each one of these mime types individually?

Also, we use file streaming in our application to display document (not just excel — any type of document). In doing so, how can we retain the filename if the user opts to save the file — currently, the name of the servlet that renders the file appears as the default name.

Jordy van Eijk's user avatar

asked Jun 10, 2009 at 7:07

Subramanian's user avatar

5

I believe the standard MIME type for Excel files is application/vnd.ms-excel.

Regarding the name of the document, you should set the following header in the response:

header('Content-Disposition: attachment; filename="name_of_excel_file.xls"');

Callum Watkins's user avatar

answered Dec 26, 2009 at 19:44

jbochi's user avatar

jbochijbochi

28.7k16 gold badges73 silver badges90 bronze badges

7

Waking up an old thread here I see, but I felt the urge to add the «new» .xlsx format.

According to http://filext.com/file-extension/XLSX the extension for .xlsx is application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. It might be a good idea to include it when checking for mime types!

Dave Jarvis's user avatar

Dave Jarvis

30.2k39 gold badges178 silver badges312 bronze badges

answered Apr 20, 2012 at 12:39

Karlis Rode's user avatar

Karlis RodeKarlis Rode

3,5932 gold badges16 silver badges16 bronze badges

1

For .xls use the following content-type

application/vnd.ms-excel

For Excel 2007 version and above .xlsx files format

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

answered Apr 6, 2019 at 7:21

Du-Lacoste's user avatar

Du-LacosteDu-Lacoste

11k2 gold badges65 silver badges50 bronze badges

I was setting MIME type from .NET code as below —

File(generatedFileName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")

My application generates excel using OpenXML SDK. This MIME type worked —

vnd.openxmlformats-officedocument.spreadsheetml.sheet

Aleksei Matiushkin's user avatar

answered Jun 21, 2016 at 17:01

Divyans Mahansaria's user avatar

I am using EPPlus to generate .xlsx (OpenXML format based) excel file. For sending this excel file as attachment in email I use the following MIME type and it works fine with EPPlus generated file and opens properly in ms-outlook mail client preview.

string mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
System.Net.Mime.ContentType contentType = null;
if (mimeType?.Length > 0)
{
    contentType = new System.Net.Mime.ContentType(mimeType);
}

answered Nov 1, 2018 at 11:25

Vishwajit G's user avatar

Vishwajit GVishwajit G

5004 silver badges9 bronze badges

For anyone who is still stumbling with this after using all of the possible MIME types listed in the question:

I have found that iMacs tend to also throw a MIME type of «text/xls» for XLS Excel files, hope this helps.

answered May 25, 2016 at 18:58

be_es's user avatar

be_esbe_es

311 bronze badge

This topic lists the most common MIME types with corresponding document types, ordered by their common extensions.

The following two important MIME types are the default types:

  • text/plain is the default value for textual files. A textual file should be human-readable and must not contain binary data.
  • application/octet-stream is the default value for all other cases. An unknown file type should use this type. Browsers are particularly careful when manipulating these files to protect users from software vulnerabilities and possible dangerous behavior.

IANA is the official registry of MIME media types and maintains a list of all the official MIME types. This table lists important MIME types for the Web:

Extension Kind of document MIME Type
.aac AAC audio audio/aac
.abw AbiWord document application/x-abiword
.arc Archive document (multiple files embedded) application/x-freearc
.avif AVIF image image/avif
.avi AVI: Audio Video Interleave video/x-msvideo
.azw Amazon Kindle eBook format application/vnd.amazon.ebook
.bin Any kind of binary data application/octet-stream
.bmp Windows OS/2 Bitmap Graphics image/bmp
.bz BZip archive application/x-bzip
.bz2 BZip2 archive application/x-bzip2
.cda CD audio application/x-cdf
.csh C-Shell script application/x-csh
.css Cascading Style Sheets (CSS) text/css
.csv Comma-separated values (CSV) text/csv
.doc Microsoft Word application/msword
.docx Microsoft Word (OpenXML) application/vnd.openxmlformats-officedocument.wordprocessingml.document
.eot MS Embedded OpenType fonts application/vnd.ms-fontobject
.epub Electronic publication (EPUB) application/epub+zip
.gz GZip Compressed Archive application/gzip
.gif Graphics Interchange Format (GIF) image/gif
.htm, .html HyperText Markup Language (HTML) text/html
.ico Icon format image/vnd.microsoft.icon
.ics iCalendar format text/calendar
.jar Java Archive (JAR) application/java-archive
.jpeg, .jpg JPEG images image/jpeg
.js JavaScript text/javascript (Specifications: HTML and RFC 9239)
.json JSON format application/json
.jsonld JSON-LD format application/ld+json
.mid, .midi Musical Instrument Digital Interface (MIDI) audio/midi, audio/x-midi
.mjs JavaScript module text/javascript
.mp3 MP3 audio audio/mpeg
.mp4 MP4 video video/mp4
.mpeg MPEG Video video/mpeg
.mpkg Apple Installer Package application/vnd.apple.installer+xml
.odp OpenDocument presentation document application/vnd.oasis.opendocument.presentation
.ods OpenDocument spreadsheet document application/vnd.oasis.opendocument.spreadsheet
.odt OpenDocument text document application/vnd.oasis.opendocument.text
.oga OGG audio audio/ogg
.ogv OGG video video/ogg
.ogx OGG application/ogg
.opus Opus audio audio/opus
.otf OpenType font font/otf
.png Portable Network Graphics image/png
.pdf Adobe Portable Document Format (PDF) application/pdf
.php Hypertext Preprocessor (Personal Home Page) application/x-httpd-php
.ppt Microsoft PowerPoint application/vnd.ms-powerpoint
.pptx Microsoft PowerPoint (OpenXML) application/vnd.openxmlformats-officedocument.presentationml.presentation
.rar RAR archive application/vnd.rar
.rtf Rich Text Format (RTF) application/rtf
.sh Bourne shell script application/x-sh
.svg Scalable Vector Graphics (SVG) image/svg+xml
.tar Tape Archive (TAR) application/x-tar
.tif, .tiff Tagged Image File Format (TIFF) image/tiff
.ts MPEG transport stream video/mp2t
.ttf TrueType Font font/ttf
.txt Text, (generally ASCII or ISO 8859-n) text/plain
.vsd Microsoft Visio application/vnd.visio
.wav Waveform Audio Format audio/wav
.weba WEBM audio audio/webm
.webm WEBM video video/webm
.webp WEBP image image/webp
.woff Web Open Font Format (WOFF) font/woff
.woff2 Web Open Font Format (WOFF) font/woff2
.xhtml XHTML application/xhtml+xml
.xls Microsoft Excel application/vnd.ms-excel
.xlsx Microsoft Excel (OpenXML) application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xml XML application/xml is recommended as of RFC 7303 (section 4.1), but text/xml is still used sometimes. You can assign a specific MIME type to a file with .xml extension depending on how its contents are meant to be interpreted. For instance, an Atom feed is application/atom+xml, but application/xml serves as a valid default.
.xul XUL application/vnd.mozilla.xul+xml
.zip ZIP archive application/zip
.3gp 3GPP audio/video container video/3gpp; audio/3gpp if it doesn’t contain video
.3g2 3GPP2 audio/video container video/3gpp2; audio/3gpp2 if it doesn’t contain video
.7z 7-zip archive application/x-7z-compressed

The content type for .xlsx files is:

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

Or use this:

Response.ContentType = "application/vnd.ms-excel";

Response.AppendHeader("content-disposition", "attachment; filename=myfile.xls");

For Excel 2007 and above the MIME type differs

Response.ContentType = "application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

Response.AppendHeader("content-disposition", "attachment; filename=myfile.xlsx");

Or if you are trying to read the file then try this:

DataSet objds = new DataSet();
string ConnStr = "";
if (FileExtension == ".xlsx")
{
    ConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileName + ";Extended Properties="Excel 12.0 Xml;HDR=No;IMEX=1";";
}
else
{
    ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileName + ";Extended Properties="Excel 8.0;HDR=No;IMEX=1";";

}
OleDbCommand selectCommand = new OleDbCommand();
OleDbConnection connection = new OleDbConnection();
OleDbDataAdapter adapter = new OleDbDataAdapter();
connection.ConnectionString = ConnStr;
string strSQL = "SELECT * FROM [Sheet1$]";
if (connection.State != ConnectionState.Open)
    connection.Open();
OleDbCommand cmd = new OleDbCommand(strSQL, connection);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(objds);
connection.Close();

All the best.
—Amit

This article describes MIME Types and the corresponding file extension of the Microsoft Office documents. It will very be useful for document analysis, and you can easily define ContentType for the Microsoft Office associated documents in ASP.NET applications. Also you can use this details to customize MIME types in IIS server configuration.

 For Microsoft Office Excel, you can define content type like this example.
 Aspx page
<%response.ContentType=“application/vnd.ms-excel”%>

 C#
  Response.ContentType = “application/vnd.ms-excel”;

The following table lists the MIME types and file extensions that are associated  with the Microsoft Office documents.

Extension MIME Type
.doc application/msword
.dot application/msword
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
.docm application/vnd.ms-word.document.macroEnabled.12
.dotm application/vnd.ms-word.template.macroEnabled.12
.xls application/vnd.ms-excel
.xlt application/vnd.ms-excel
.xla application/vnd.ms-excel
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
.xlsm application/vnd.ms-excel.sheet.macroEnabled.12
.xltm application/vnd.ms-excel.template.macroEnabled.12
.xlam application/vnd.ms-excel.addin.macroEnabled.12
.xlsb application/vnd.ms-excel.sheet.binary.macroEnabled.12
.ppt application/vnd.ms-powerpoint
.pot application/vnd.ms-powerpoint
.pps application/vnd.ms-powerpoint
.ppa application/vnd.ms-powerpoint
.pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
.potx application/vnd.openxmlformats-officedocument.presentationml.template
.ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow
.ppam application/vnd.ms-powerpoint.addin.macroEnabled.12
.pptm application/vnd.ms-powerpoint.presentation.macroEnabled.12
.potm application/vnd.ms-powerpoint.template.macroEnabled.12
.ppsm application/vnd.ms-powerpoint.slideshow.macroEnabled.12

Thanks,
Morgan
Software Developer

Содержание

  1. Common MIME types
  2. Found a content problem with this page?
  3. What is MIME Type for Excel Document ?
  4. 1 .xls
  5. 2 .xlsx
  6. 3 .xltx
  7. 4 .xlsm
  8. 5 .xlam
  9. 6 .xlsb

Common MIME types

This topic lists the most common MIME types with corresponding document types, ordered by their common extensions.

The following two important MIME types are the default types:

  • text/plain is the default value for textual files. A textual file should be human-readable and must not contain binary data.
  • application/octet-stream is the default value for all other cases. An unknown file type should use this type. Browsers are particularly careful when manipulating these files to protect users from software vulnerabilities and possible dangerous behavior.

IANA is the official registry of MIME media types and maintains a list of all the official MIME types. This table lists important MIME types for the Web:

Extension Kind of document MIME Type
.aac AAC audio audio/aac
.abw AbiWord document application/x-abiword
.arc Archive document (multiple files embedded) application/x-freearc
.avif AVIF image image/avif
.avi AVI: Audio Video Interleave video/x-msvideo
.azw Amazon Kindle eBook format application/vnd.amazon.ebook
.bin Any kind of binary data application/octet-stream
.bmp Windows OS/2 Bitmap Graphics image/bmp
.bz BZip archive application/x-bzip
.bz2 BZip2 archive application/x-bzip2
.cda CD audio application/x-cdf
.csh C-Shell script application/x-csh
.css Cascading Style Sheets (CSS) text/css
.csv Comma-separated values (CSV) text/csv
.doc Microsoft Word application/msword
.docx Microsoft Word (OpenXML) application/vnd.openxmlformats-officedocument.wordprocessingml.document
.eot MS Embedded OpenType fonts application/vnd.ms-fontobject
.epub Electronic publication (EPUB) application/epub+zip
.gz GZip Compressed Archive application/gzip
.gif Graphics Interchange Format (GIF) image/gif
.htm , .html HyperText Markup Language (HTML) text/html
.ico Icon format image/vnd.microsoft.icon
.ics iCalendar format text/calendar
.jar Java Archive (JAR) application/java-archive
.jpeg , .jpg JPEG images image/jpeg
.js JavaScript text/javascript (Specifications: HTML and RFC 9239)
.json JSON format application/json
.jsonld JSON-LD format application/ld+json
.mid , .midi Musical Instrument Digital Interface (MIDI) audio/midi , audio/x-midi
.mjs JavaScript module text/javascript
.mp3 MP3 audio audio/mpeg
.mp4 MP4 video video/mp4
.mpeg MPEG Video video/mpeg
.mpkg Apple Installer Package application/vnd.apple.installer+xml
.odp OpenDocument presentation document application/vnd.oasis.opendocument.presentation
.ods OpenDocument spreadsheet document application/vnd.oasis.opendocument.spreadsheet
.odt OpenDocument text document application/vnd.oasis.opendocument.text
.oga OGG audio audio/ogg
.ogv OGG video video/ogg
.ogx OGG application/ogg
.opus Opus audio audio/opus
.otf OpenType font font/otf
.png Portable Network Graphics image/png
.pdf Adobe Portable Document Format (PDF) application/pdf
.php Hypertext Preprocessor (Personal Home Page) application/x-httpd-php
.ppt Microsoft PowerPoint application/vnd.ms-powerpoint
.pptx Microsoft PowerPoint (OpenXML) application/vnd.openxmlformats-officedocument.presentationml.presentation
.rar RAR archive application/vnd.rar
.rtf Rich Text Format (RTF) application/rtf
.sh Bourne shell script application/x-sh
.svg Scalable Vector Graphics (SVG) image/svg+xml
.tar Tape Archive (TAR) application/x-tar
.tif , .tiff Tagged Image File Format (TIFF) image/tiff
.ts MPEG transport stream video/mp2t
.ttf TrueType Font font/ttf
.txt Text, (generally ASCII or ISO 8859-n) text/plain
.vsd Microsoft Visio application/vnd.visio
.wav Waveform Audio Format audio/wav
.weba WEBM audio audio/webm
.webm WEBM video video/webm
.webp WEBP image image/webp
.woff Web Open Font Format (WOFF) font/woff
.woff2 Web Open Font Format (WOFF) font/woff2
.xhtml XHTML application/xhtml+xml
.xls Microsoft Excel application/vnd.ms-excel
.xlsx Microsoft Excel (OpenXML) application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xml XML application/xml is recommended as of RFC 7303 (section 4.1), but text/xml is still used sometimes. You can assign a specific MIME type to a file with .xml extension depending on how its contents are meant to be interpreted. For instance, an Atom feed is application/atom+xml , but application/xml serves as a valid default.
.xul XUL application/vnd.mozilla.xul+xml
.zip ZIP archive application/zip
.3gp 3GPP audio/video container video/3gpp ; audio/3gpp if it doesn’t contain video
.3g2 3GPP2 audio/video container video/3gpp2 ; audio/3gpp2 if it doesn’t contain video
.7z 7-zip archive application/x-7z-compressed

Found a content problem with this page?

This page was last modified on Mar 3, 2023 by MDN contributors.

Источник

What is MIME Type for Excel Document ?

MIME (Multipurpose Internet Mail Extensions) is a media type used to identify a type of data on the Internet or by applications. Its name contains the word «Internet» but it is not only limited to the Internet.IANA is in charge of standardizing and disseminating these MIME classifications.

There are numerous popular extensions available among them. One of them is the Excel MIME type.

Please enable JavaScript

1 Type is a logical grouping of many MIME types that are similar to one another. All Excel files have an application as a type.

2 SubType is specific to a single file type within the «type«.They are unique within the «type».Some of the subtypes for excel files are: vnd.ms-excel,vnd.openxmlformats-officedocument.spreadsheetml.sheet,vnd.openxmlformats-officedocument.spreadsheetml.template,vnd.ms-excel.sheet.macroEnabled.12 etc.

There are various MIME types for Excel for various Excel-related files and their extensions such as. xls,.xlsx,.xlt,.xla, and so on.

Let’s look at Excel file MIME Type and extension used by them in table format.

Extension MIME Type (Type / SubType) Kind of Document
.xls application/vnd.ms-excel Microsoft Excel
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet Microsoft Excel (OpenXML)
.xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template Office Excel 2007 template
.xlsm application/vnd.ms-excel.sheet.macroEnabled.12 Office Excel 2007 macro-enabled workbook
.xltm application/vnd.ms-excel.template.macroEnabled.12 Office Excel 2007 macro-enabled workbook template
.xlam application/vnd.ms-excel.addin.macroEnabled.12 Office Excel 2007 macro-enabled add-in
.xlsb application/vnd.ms-excel.sheet.binary.macroEnabled.12 Office Excel 2007 non xml binary workbook

fig. various format for saving excel file

Let’s explain them in brief.

1 .xls

.xls is one of the older file extension of Microsoft Excel Spreadsheet.It is created by Excel 97 or Excel 2003. They by default generate .xls format.

MIME Type Supported by .xls file is application/vnd.ms-excel where the application of MIME type and vnd.ms-excel is subtypes and vnd here means vendor-specific which in this case vendor is Microsoft.

If you have an.xls file and want to open it in Excel before prior 2007, you can do so easily because Excel before 2007 recognizes application/vnd.ms-excel and does not require to afford to open it.

Despite the fact that the.xls file format is older, it can be opened in all versions of Excel due to backward compatibility in newer versions.

2 .xlsx

xlsx is the new file extension of the Microsoft Excel Spreadsheet. It is created by Excel 2007 and later versions.

If you create an excel file in Excel 2007 or later, it will be saved with the.xlsx extension by default; however, you can also save the same file in.xls format.xlsx is more secure and better for data storage(ie. smaller file size) than xls.

MIME type for .xlsx file is application/vnd.openxmlformats-officedocument.spreadsheetml.sheet where MIME type is application and subtype is vnd.openxmlformats-officedocument.spreadsheetml.sheet

It is a file format based on Office OPEN XML developed by Microsoft for representing spreadsheets. Because xlsx is an open standard, other software application vendors, such as Google (Google Sheets), can use it to interoperate with their spreadsheet applications.

You can open Xls file in excel 2007 and later and convert them to xlsx and save it.

3 .xltx

Microsoft Excel Template files with the. xltx extensions are based on the Office OpenXML file format specifications. It is used to generate a standard template file that can be used to generate XLSX files with the same settings as the XLTX file.

MIME type for .xlsx file is application/vnd.openxmlformats-officedocument.spreadsheetml.template where MIME type is application and subtype is vnd.openxmlformats-officedocument.spreadsheetml.sheet

It is XML based file format developed by Microsoft for representing templates. An XLTX is identical to an XLSX in every way except that Excel creates a new instance of an XLSX if the file opened is an XLTX.

4 .xlsm

An XLSM file is a macro-enabled spreadsheet created by Microsoft Excel that can also be opened with Google Sheets.XLSM files are based on the Office Open XML format, where the last «m» of an xlsm file extension indicates that the file contains macros.Macros can be stored within an xlsm file, allowing users to automate repetitive tasks.

MIME type for .xlsx file is application/vnd.ms-excel.sheet.macroEnabled.12 where MIME type is application and subtype is vnd.ms-excel.sheet.macroEnabled.12

5 .xlam

An XLAM file extension indicates an Excel Macro-Enabled Add-In file, which is used to provide additional functionality for spreadsheets.
It has the following MIME types:application/vnd.ms-excel.template.macroEnabled.12 where MIME type is application and subtype is vnd.ms-excel.template.macroEnabled.12

Because of the file’s purpose, there is built-in macro support in .xlam files.

6 .xlsb

An XLSB file is an Excel Binary Workbook file that stores data in binary rather than XML format. Because they are stored in binary, the read and write times in xlsb files are faster, and they have been found to be useful for very large and complex spreadsheets for this reason. They are also smaller in size than the XLSM format.

MIME type for .xlsx file is application/vnd.ms-excel.sheet.binary.macroEnabled.12 where MIME type is application and subtype is vnd.ms-excel.sheet.binary.macroEnabled.12

For generating a .xls file in C# code you have to mention application/vnd.ms-excel MIME types in response header as shown below.

For generating a .xls file in C# code you have to mention application/vnd.openxmlformats-officedocument.spreadsheetml.sheet MIME types in response header as shown below.

If you are generating Excel file target to xlsx file then you have to use above.

Ans: xlam is the replacement for the old .xla format.

Источник

Понравилась статья? Поделить с друзьями:
  • Application statusbar vba excel
  • Application software for word processing
  • Application sendkeys vba excel
  • Application screenupdating vba excel
  • Application run vba excel примеры