Office Open XML Developer Workshop Office Open XML Overview Štěpán Bechynský
Office Open XML Developer Workshop Open XML Specification Part 1: Fundamentals, 173 pages Part 2: Open Packaging Convention, 129 pages Part 3: Primer, 472 pages Part 4: Markup Language Reference, 5219 pages Part 5: Markup Compatibility and Extensibility, 43 pages
Office Open XML Developer Workshop Programmer View of Open XML Files ZIP Archive Document Parts XML Parts Binary Parts Typed (RFC 2616) Relationships Connections between parts Content Type Stream A specially-named stream Defines mappings from part names to content types Not itself a part, not URI addressable Folder structure for convenience only DEMO
Office Open XML Developer Workshop Files and folders – NO!Parts and relationships – YES How to think about OPC packages
Office Open XML Developer Workshop Ecma Office Open XML Specifications WordprocessingMLSpreadsheetMLPresentationML ZIPXML + Unicode DrawingML Content Types Custom XMLBibliography Markup Languages Relationships Metadata Digital Signatures VML (legacy)Equations Open Packaging Convention Core Technologies Vocabularies
Office Open XML Developer Workshop WordprocessingML Document Architecture Document body properties fontTable headers/footers images numberingDefinitions styles customXML footnotes/endnotes comments A WordprocessingML file is a collection of multiple subdocuments: The main story Header(s) / Footer(s) Footnote(s) / Endnote(s) Subdocuments Comment(s)
Office Open XML Developer Workshop Paragraph Example Simple text formatting at the paragraph/run levels: Paragraph properties specify bold (default for the entire paragraph) The quick brown fox. The quick brown fox. Run properties specify italics (override for this run)
Office Open XML Developer Workshop Images An image is a w:pict element inside a run The v:imagedata element is defined in VML: xmlns:v="urn:schemas-microsoft-com:vml" The actual image is referenced via a relationship: The relationship points to an image part in the package: <Relationship Id="rId4” Type=" Target="image1.jpg"/> <Relationship Id="rId4” Type=" Target="image1.jpg"/>
Office Open XML Developer Workshop Hyperlinks A hyperlink is nested inside a paragraph, outside a run: The destination is stored in a relationship: Click here for OpenXmlDeveloper.org. <Relationship Id=“linkRel1“ Type=" Target=" TargetMode="External" /> <Relationship Id=“linkRel1“ Type=" Target=" TargetMode="External" />
Office Open XML Developer Workshop SpreadsheetML Workbook properties table chart styles calcChain sharedStrings sheet1..N drawing
Office Open XML Developer Workshop Minimal Workbook/Worksheet workbook.xml: sheet1.xml: relationship
Office Open XML Developer Workshop Strings in SpreadsheetML Two ways a string can be stored: 1.Inline strings Provided for ease of translation/conversion Useful in XSLT scenarios Excel and other consumers may convert to shared strings 2.An entry in the shared-strings table May be either a simple string or formatted text These approaches may be mixed/combined
Office Open XML Developer Workshop Inline Strings Inline string support provides a very simple mechanism for programmatically populating a worksheet Especially useful in XSLT scenarios Excel 2007 converts to shared strings on save If you’re consuming Open XML documents, you must handle both cases: inline strings and/or shared strings To convert our shared-strings example to inline strings, just replace sheetdata: Paris Seattle London Copenhagen Paris London
Office Open XML Developer Workshop Shared Strings By default, strings are stored in a shared-strings part: Each unique string is stored once Cells store the index (0-based) of the string This design is based on analysis of typical spreadsheet contents: highly repetitive strings are very common Benefits: Users: reduced file size, improved performance Developers: all strings are in one part, simplifying search, localization, and other common string-handling objectives
Office Open XML Developer Workshop Shared Strings: example Worksheet contents: sharedStrings.xml contents: Paris Seattle London Copenhagen 6 string references, 4 unique strings Paris = string 0 0
Office Open XML Developer Workshop