New Capabilities with the Open XML File Format Visual Studio Tools for Office Mike Ormond Developer and Platform Group, Microsoft Ltd
Agenda Introduction to the file formats Solution development The document information panel Structured solutions with Word Dynamic documents Server document generation Visual Studio Tools for Office
OPEN XML FILE FORMATS Introduction to the new Open XML File Formats (OR: What does this thing look like anyway?)
Evolution Of File Formats Office 2000 Early Innovation XML document properties Office 97 Existing binary file formats designed in 1994, launched in Office 97 Office XP First XML Format Spreadsheet XML Office 2003 Breakthrough XML Support WordML, SpreadsheetML Custom-defined schema Office 2007 New XML Formats XML file format default XML PowerPoint format “Wave 12”
The Role Of XML With Documents ScenarioExample Document Assembly Server-based or user-assisted construction of documents from archived content or database content Create sales reports from financial and forecast data stored in a CRM system Content Reuse Much easier to move content between documents, including different document types Apply content stored in Word documents to Web pages quickly and efficiently Content Tagging Add domain-specific metadata to document content to enable custom solutions Tag presentations using a specific taxonomy to improve knowledge management efficiency Document Interrogation Query document repositories based on custom data, content types or document metadata Search for all documents containing a specific company name or sales contact Document Sanitization Remove unwanted content like comments or embedded code from your document when appropriate Remove all tracked changes and comments from a Word document before it is published
Open XML File Formats Default file format More efficient storage Program against full document contents Backward compatibility & legacy support Easy document assembly, conversion & integration Submitted to ECMA for standardization
Open XML Formats Architecture User view: single Office “file” Questionnaire. docx Developer view: modular file Document Parts Most parts are XML Each XML part is a discreet, compressed component Can add, extract and modify individual parts without using Office programs Corruption or absence of any part would not prohibit the file from being opened
Open XML File Formats
SOLUTION DEVELOPMENT Solution development with the new Open XML File Formats (OR: Great. Now do I make use of this from code?)
Tools for Accessing Data In Office Open XML files XML Editing Notepad? System.XML makes this easier ZIP Manipulation Compressed Folders in Windows? Third-Party Zip Libraries Microsoft’s Packaging API’s Office Open XML Resource Kit Code Snippets - Beta 2 C# and VB.NET Validation Library Parses a file and reports on schema, relationship errors and warnings Serialization/Deserialization Library Flattens package into a single file for ease of development in simple construction scenarios
System.IO.Packaging Part of.NET Fx 3.0 Allows you to Create / Open packages Create and delete parts and relationships Read and write part streams Iterate through collections of parts and relationships PackagePackagePartCollection └ PackagePart └ PackagePartPackageRelationshipCollection └ PackageRelationship └ PackageRelationshipPackUriHelper
System.IO.Packaging.Package Package class provides methods to create, enumerate and delete the following entities Package Package Relationships PackagePropertiesParts Core Properties Common Package Parts Thumbnail Digital Signatures officeDocument XML Part Specific Format Parts Etc… Part Rels XML Part Part Rels
System.IO.Packaging.Relationship Relationships tie the parts together Required to find parts (part names are not guaranteed) Iterate through RelationshipCollection by Type or ID Relationship Properties IDPackageRelationshipTypeSourceUriTargetModeTargetUri Package Relationships Core Properties Common Package Parts Thumbnail Digital Signatures officeDocument XML Part Specific Format Parts Etc… Part Rels XML Part Part Rels officeDocument XML Part
System.IO.Packaging.PackagePart Parts are the objects of data within the Package PackagePart provides support to create, enumerate and delete part relationships Get Part data as Stream PackagePart Properties: CompressionOptionContentTypePackageUri Package Relationships Core Properties Common Package Parts Thumbnail Digital Signatures officeDocument XML Part Specific Format Parts Etc… Part Rels XML Part Part Rels - The Quick Brown Fox jumped over the river. … XML Part - The Cow jumped over the moon. …
System.IO.Packaging.PackURIHelper Helper class to aid working with URIs URIs required to GetParts Create or Get URIs for PackagesParts Relationship parts Resolve relative URIs for parts from source to target part
Document Interrogation Scenarios When you need meta-data about Office files on a server Building reports from data in files Workflow and Content Management scenarios Validate compliance
Document Assembly Scenarios Useful when documents need to be generated from structured data Auto generate reports in Excel from data in database Create documents for users from form data Repurpose existing data (slide libraries) Recommendation: Start from a template
Document Sanitization Scenarios Security Remove active content (VBA, ActiveX) Privacy Remove comments, revisions, hidden text Remove or alter document properties Legal Insert copyrights, watermarks, images Run as part of Workflows, publishing, compliance scenarios
Solution Development
THE DOCUMENT INFORMATION PANEL Creating smart forms and dynamic documents (OR: How to leverage the power of InfoPath in your documents. You do know what InfoPath is don’t you?)
Document Information Panel Customisable form displayed in the client application Allows users to enter document properties (metadata) while working on the document SharePoint properties appear as metadata in the DIP
Custom Information Panel The Document Information Panel uses InfoPath technology This technology can be used to create business logic around any custom XML data All the power of InfoPath in Word Data connections, declarative rules engine, etc.
Document Info Panel
EXERCISING CONTROL Structured solution authoring with Word 2007 – Rich UI and robust editing behaviour. (OR: How to author multi-use and dynamic documents to make everyone’s life easier)
The Role Of XML Reference and custom-defined schemas Custom-defined Schemas Data-oriented (e.g., Price, Invoice) Represents the business information stored in the document Enable System Integration XML Reference Schemas Display-oriented (e.g. Bold, Italics, Tables, Paragraphs, Styles) Open Document Format Enable Archival & File Formats Interoperability
The Role Of XML Reference and custom-defined schemas XML Reference Schemas Display-oriented (e.g. Bold, Italics, Tables, Paragraphs, Styles) Open Document Format Enable Archival & File Formats Interoperability <w:p> John Doe John Doe Health Agency Health Agency </w:p>
3/24/2004 Health Agency % … Custom-defined Schemas Data-oriented (e.g., Price, Invoice) Represents the business information stored in the document Enable System Integration The Role Of XML Reference and custom-defined schemas
Content Controls (Word) Makes structured documents more robust & much less Word specific code needed Content restrictions, grouping & locking Code can be used for business logic! End user friendly and layout independent exposure of structured content No XML schema required Evolution of customer-defined XML with custom XML mapping capabilities (more detail in CD 305)
Solutions And Building Blocks Select and reuse any selection of WordprocessingML Building blocks and content controls Two steps to a document assembly solution Write 18 lines of UI code Make a few selections and clicks or attach a building block part
Content Controls
MAKING DOCUMENTS WORK FOR YOU Content Controls + Custom XML Store = Rich, Robust, Dynamic documents
Office XML Data Store Customer-defined XML (incl. WSS/Office properties) stored separately from WordprocessingML as a part in Open XML format Any XML can be stored (with or without XML schema) XML data is available as an editable tree (using familiar DOM) within Word Can be populated on a server using WinFX or a client using Word OM
XML Mapping Link content controls to nodes in the XML data store Provides for true data/view separation model in Word Mappings are created using standard XPath expressions Mappings can be set up to ‘auto-attach’ to incoming data Out of the box support for mapping to Office properties
Health Agency 100 … Content Controls + Custom XML
Dynamic Documents
WHAT ABOUT THE SERVER Generating Office Documents on the Server
Putting it all together Start with a Template Document Assembly System.IO.Packaging Delete / Create Parts & Relationships Document Manipulation System.IO.Packaging Word -> Content Controls + Custom XML Excel -> System.Xml + SpreadsheetML PowerPoint -> System.Xml + PresentationML
Document Assembly On the Server
VISUAL STUDIO TOOLS FOR OFFICE
Visual Studio Tools For Office Tool for building managed applications targeting Office 2003 / Office 2007 The managed code API for Office Generates a lot of the “plumbing” code Visual designers Separate date & presentation Robust run-time Flavours VSTO 2005, VSTO 2005 SE, VSTO V3 (Orcas)...
VSTO Editions VSTO Version Office 2003Office 2007 Additional Information docappdocapp 2003 Excel InfoPath Word Visual Studio.NET Excel InfoPath Word Outlook Data Caching Server-Side Programming Data Caching Server-Side Programming Integrated Designer Smart Tags ActionsPane Smart Tags ActionsPane 2005 SE Excel Outlook PowerP oint Visio Word InfoPath Excel InfoPath Outlook PowerP oint Visio Word Rbbon Customization Custom TaskPanes Outlook Form Regions Compatibility "V3" Excel Word Excel InfoPath Word All Ribbon Customization Custom TaskPanes Outlook Form Regions Ribbon Customization Custom TaskPanes Outlook Form Regions New Security Model ClickOnce Deployment AppDomain Isolation Runtime Standardization From Wouter van Vugt (
Visual Studio Tools for Office
Additional Resources Open XML File Formats General VSTO / Programmability
Additional Information UK MSDN Events Post events page including slide decks Upcoming events UK MSDN Site & Flash Newsletter Local news, events, nuggets & webcasts Register to receive the bi-weekly MSDN Flash by
© 2006 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.