workbook.xml in Office Open XMLThe file workbook.xml is the core manifest of an Excel workbook when it is stored in the Open XML format (.xlsx). Inside the zipped package, workbook.xml resides in the xl folder and defines the overall structure of the workbook the sheets it contains, their order, defined names, and many global settings.
A modern Excel file is a ZIP archive with a fixed internal layout. The most relevant parts are:
xl/workbook.xml the workbook definition.xl/worksheets/sheet1.xml, sheet2.xml, the actual sheet data.xl/styles.xml style definitions.docProps/ document properties.workbook.xmlBelow is a simplified excerpt of a typical workbook.xml file to illustrate its structure:
<?xml version="1.0" encoding="UTF-8"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> <fileVersion appName="xl"> <!-- version information > </fileVersion> <workbookPr defaultThemeVersion="166925"></workbookPr> <bookViews> <workbookView xWindow="240" yWindow="105" windowWidth="14805" windowHeight="8010"/> </bookViews> <sheets> <sheet name="Sheet1" sheetId="1" r:id="rId1"/> <sheet name="Data" sheetId="2" r:id="rId2"/> </sheets> <definedNames> <definedName name="MyRange">Data!$A$1:$B$10</definedName> </definedNames> <calcPr calcId="125724"></calcPr></workbook>
| Element | Purpose |
|---|---|
<fileVersion> | Indicates the version of the application that created the file. |
<workbookPr> | Global workbook properties such as default theme version. |
<bookViews> | Window position, size, and view options for the workbook when opened. |
<sheets> | Lists each sheet, its display name, an internal ID, and a relationship ID that points to the sheets XML file. |
<definedNames> | Named ranges, formulas, and print areas that are scoped to the whole workbook or a specific sheet. |
<calcPr> | Calculation settings (iteration, precision, etc.). |
Each sheet element has an r:id attribute that references a relationship defined in xl/_rels/workbook.xml.rels. The relationship file maps the ID to the actual sheet XML file:
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/> <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet2.xml"/></Relationships>
Understanding this mapping is essential when you want to add, delete, or rename sheets programmatically.
xl/_rels/workbook.xml.rels and locate the Relationship for the sheet you wish to rename.<sheet> element in workbook.xml and change the name attribute..xlsx.You need to create three items:
sheetN.xml file (usually a copy of an existing sheet).Relationship entry in workbook.xml.rels with a unique Id (e.g., rId5).<sheet> entry in workbook.xml that references the new r:id and provides a name.Delete the sheets XML file, remove its Relationship entry, and delete the <sheet> element from workbook.xml. Be sure to renumber any sheetId values if you need a contiguous sequence (Excel tolerates gaps, but a tidy file is easier to read).
The <definedNames> block can hold a variety of names:
MyRange Sheet1!$A$1:$B$5MySum =SUM(Sheet1!$C$1:$C$10)Print_Area Sheet1!$A$1:$D$20localSheetId attribute.When editing defined names manually, ensure that the reference syntax follows the A1 style and that sheet names containing spaces or special characters are wrapped in single quotes, e.g. 'My Data'!$A$1.
Excel stores a calcId attribute inside <calcPr>. This GUIDlike value changes when the calculation engine is updated. Although most tools ignore it, preserving the original value helps maintain compatibility with older versions of Excel.
workbook.xml| Tool | Key Features |
|---|---|
| Open XML SDK (C#) | Strongly typed classes for WorkbookPart, Sheet, and DefinedName. Supports LINQ to XML for custom queries. |
Python openpyxl | Highlevel API to add/rename/remove sheets without touching XML directly, but also provides .wb._writer.workbook_xml for lowlevel access. |
| LibreOffice / OpenOffice | Can open .xlsx files and save them as .ods, allowing inspection of the underlying XML via the XML Filter option. |
| 7Zip / WinZip | Simple way to unzip the package, edit workbook.xml in any text editor, and rezip. |
| XML editors (e.g., XMLSpy, VS Code) | Provide syntax highlighting, schema validation (use the Open XML schema), and formatting utilities. |
workbook.xmlhttp://schemas.openxmlformats.org/spreadsheetml/2006/main) catches missing required attributes and misspelled element names.<sheet> elements helps tools that rely on visual ordering.encoding="UTF-8" to avoid characterset issues.r:id referenced by a sheet must have a matching entry in workbook.xml.rels. Missing or duplicate IDs cause File is corrupted errors.name attribute in <sheet> is unique, caseinsensitively.definedName element is correctly scoped and that the target cell reference exists.workbook.xml is the central manifest that tells Excel which worksheets belong to a workbook, how they are ordered, and which named ranges or calculation settings are present. Its simple, wellstructured XML format makes it approachable
