Inside a XLSX File: Signature, Structure and MIME Type
Learn how XLSX is identified and what its internal components mean.
ZIP Container and the First Bytes
Start with the bytes, not the .xlsx suffix. At offset 0x0000, a genuine workbook package normally begins with the ZIP local-file-header signature used by the Open Packaging Convention (OPC):
50 4B 03 04
These four bytes correspond to the ASCII characters PK. Every XLSX must begin with this sequence. The same signature appears across DOCX, PPTX, and other OPC-based formats, so the signature alone confirms a ZIP container but not the spreadsheet payload.
Validation check: Run file example.xlsx on Unix or inspect the first four bytes in a hex editor. If bytes 0–3 are not 50 4B 03 04, the file is either corrupted or carries a misleading .xlsx extension—often a binary XLS renamed.
MIME Type at the Container and Part Level
Two distinct MIME types apply to XLSX, and they identify different layers.
The container MIME type, used in HTTP Content-Type headers and desktop file associations:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
This is the IANA-registered media type for the complete XLSX package. It replaces the legacy application/vnd.ms-excel used by binary XLS files.
Inside the archive, the workbook part declares its own content type in [Content_Types].xml:
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml
The first value identifies the ZIP-wrapped OPC package. The second identifies the primary spreadsheet payload within that package. Tools that sniff MIME types must distinguish between the two; serving the internal part type as the file-level type causes interoperability failures.
Required Internal Components
Renaming an XLSX to .zip and extracting it reveals a fixed directory structure. Every valid XLSX must contain the following entries.
[Content_Types].xml — Part Registry
This file sits at the archive root and maps every part to a content type. At minimum it must include an override for the workbook:
<Override PartName="/xl/workbook.xml"
ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>
Every part referenced by the package—worksheets, styles, shared strings, theme, metadata—requires a corresponding <Override> or <Default> entry. A missing entry for an existing part causes parsers to reject the part silently or throw a conformance error. The specification does not permit fallback discovery.
Validation check: Parse [Content_Types].xml with any XML parser. Collect all PartName attributes and confirm each resolves to a file present in the archive. A mismatch indicates structural invalidity.
_rels/.rels — Root Relationship Map
The root relationships file links the package to its primary document:
<Relationship Id="rId1"
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
Target="xl/workbook.xml"/>
If this relationship is absent, points to a nonexistent target, or uses an unrecognized Type URI, the package is not a valid XLSX. The relationship type URI is fixed by the specification; no alternatives are permitted for the workbook pointer.
xl/workbook.xml — Workbook Definition
This part defines sheet names, their order, and their relationship IDs. A minimal valid workbook:
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<sheets>
<sheet name="Sheet1" sheetId="1" r:id="rId1"/>
</sheets>
</workbook>
The r:id attribute must match an Id in xl/_rels/workbook.xml.rels. That relationships file maps each sheet ID to a physical part such as worksheets/sheet1.xml. A sheet with an unresolved r:id is a specification violation.
Hard limit: The sheetId attribute is an unsigned integer. The specification caps the number of sheets at the maximum positive integer representable in the schema, but practical implementations impose lower bounds—Excel itself limits sheets to 255 per workbook in current versions.
xl/worksheets/sheetN.xml — Cell Data
Each worksheet part contains row and cell elements. A cell referencing a shared string:
<row r="1">
<c r="A1" t="s">
<v>0</v>
</c>
</row>
The t attribute declares the cell data type. Allowed values include s (shared string index), n (number), b (boolean), e (error), str (inline string), and inlineStr (rich text). Omitting t implies n. The <v> element holds the value or string index.
Hard limit: Row numbers and column references follow the A1 notation. The maximum row is 1,048,576 (2^20). The maximum column is XFD, corresponding to column index 16,384 (2^14). Cells outside these bounds violate the specification.
xl/sharedStrings.xml — String Table
Strings that appear in cells with t="s" are stored once in this part and referenced by zero-based index:
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<si><t>Q1 Revenue</t></si>
<si><t>Q2 Revenue</t></si>
</sst>
A cell with <v>0</v> displays "Q1 Revenue". If sharedStrings.xml is missing, empty, or contains fewer entries than the highest index referenced by any cell, string cells display blank or produce errors. The sst element carries a count attribute and a uniqueCount attribute; both must match the actual number of <si> elements.
Validation check: Extract all <v> values from cells where t="s". The maximum value must be less than the count of <si> elements in sharedStrings.xml. An index equal to or greater than the count is an out-of-bounds reference.
xl/styles.xml — Style Definitions
Fonts, fills, borders, number formats, and cell alignments are defined here as indexed collections. Cells reference a style via the s attribute on <c>, which holds a zero-based index into the cell style cross-reference table defined in this part. A missing xl/styles.xml strips all formatting but leaves raw data intact.
Relationship Resolution and Structural Validity
The OPC model requires every relationship to resolve to an existing part. The resolution chain for a single sheet:
_rels/.relspoints toxl/workbook.xml.xl/workbook.xmlcontains<sheet r:id="rId1"/>.xl/_rels/workbook.xml.relsmapsrId1toworksheets/sheet1.xml.[Content_Types].xmlmust declare a content type for/xl/worksheets/sheet1.xml.
A break at any step makes the file structurally invalid. Partial extraction followed by recompression with standard ZIP tools often breaks this chain because relationship targets are relative paths that must be preserved exactly.
When a File Is Not a Valid XLSX
The following conditions each independently invalidate an XLSX file, regardless of extension:
- First four bytes are not
50 4B 03 04. The file is not a ZIP archive and cannot be an OPC package. [Content_Types].xmlis absent. No part registry exists; parsers cannot discover content types.xl/workbook.xmlis absent. The package has no spreadsheet entry point.- Root relationship to
xl/workbook.xmlis missing or broken. The parser cannot locate the workbook definition. sharedStrings.xmlexists but contains fewer<si>elements than the highest index referenced by a cell. String data is corrupted by out-of-bounds references.- Any relationship target does not resolve to an existing part. The internal link graph is broken.
The MS-XLSX specification defines conformance classes "Strict" and "Transitional." Most production files use Transitional, which permits legacy elements for backward compatibility. Strict conformance prohibits those elements. A file that fails the checks above meets neither class.
Reference for inside a xlsx file structure and signature
Microsoft Open XML Specifications: MS-XLSX
https://learn.microsoft.com/en-us/openspecs/office_standards/ms-xlsx/