Destination .NET! Platform Tools, Technologies & Resources
1 3 5 7 9
2 4 6 8 10
From VB4, C++ and Java to working on .Net Since Beta, 1.0.
Improving partner satisfaction and accelerating Microsoft platform adoption for managed ISVs.
Is your application compatible with Windows Vista? Make sure today by taking our self-test. Just follow the five steps of the Works with Windows Vista program so that you and your customers can be confident in your solution’s compatibility. Read More >>
What product/topic are you most interested in?
(Choose your top answer.)
Windows Vista
Windows Server 2008
2007 Microsoft Office system
SQL Server 2008
ASP.NET
Visual Studio 2008
Windows Mobile
Software as a Service
A little bit of everything
Just browsing, thanks

View Results
Whether you love the site or hate it, we want to know. Tell us what topics to cover, help us improve things, or just sound off on something we could've done better. Send your feedback directly to the editor by email.
 Print Print
Rate this item | 0 users have rated this item.
X Marks the .doc—An Overview of the Office Open XML File Format (cont'd)

Benefits of Open XML
When looking at the actual contents of the files themselves, certain advantages immediately become apparent.

Increased Resistance to Corruption
First of all, as anyone who played with the 2007 Microsoft Office beta can attest, the new format delightfully has improved corruption resistance. Even with product evolution during the beta cycle, even with files that became so damaged that Microsoft Office absolutely refused to open them, a developer could still salvage content using the ".zip" trick above.

Another aspect of this is the segmented architecture, with each type of content in a separate part within the package. Microsoft Office writes out the user-entered content first, and optional parts like style information afterward—that way, a truncated document (which is the most common type of externally induced file corruption) may lose some of the formatting but is unlikely to lose content.

Tight File Size
Though file size may not be as much of a consideration on a user level, IT managers should love the compression rate of the zip container, Office PowerPoint, Office Word and Office Excel files all come out smaller—especially handy when you have to send files via email. You'll see a marked difference in file sizes the first time you have to save down to previous Microsoft Office file formats.

Improved Security
Even the sturdiest of souls may give pause to opening .doc files from questionable sources. The new file format, however, handles macros completely differently, by saving documents to an "m" extension if they contain macro code, instead of "x". For example, when someone sends you a ".docm" file, you instantly know what you're getting since, by definition, it's impossible to run a macro in a .docx file. One caveat: Technically, the Open XML format does not include a definition for macro-enabled files such as .docm.

Royalty Free Open Standard
With Ecma standards approval happening in December 2006 (Ecma 376) and ISO/IEC standards approval on the way, Microsoft has shown a commitment to interoperability for the Office Open XML format. It has further demonstrated this commitment by supporting development of Open XML-based applications with a royalty-free promise.

Programmatic Creation and Modification
As previously noted, the Open XML file format gives developers the chance to build Microsoft Office files programmatically, without instantiating, or even installing a Microsoft Office app. But it also gives administrators more power to affect presentation of content. By basing documents on standardized styles, for example, organizations can change the look and feel for all documents at once simply by modifying the originating style. Programmatic access to the underlying content also opens the door for content inspection, such as removing confidential data from outbound documents or macros from inbound documents without impacting the ability to read the file. This all plays a big role in the creation of Office Business Applications, described elsewhere in this article.

Creating Office Files Without Microsoft Office
Knowing that a technology exists doesn't always mean it's easy to create real world solutions with it. Fortunately, in this case Microsoft has paved the way by providing a full set of code snippets and an SDK written specifically for creating and editing Open XML files. Looking through the snippets, you'll see a ton of code for things like "Excel: Get cell value" and "PowerPoint: Get a list of slide titles" and "Word: Convert DOCM to DOCX".

A quick perusal of the snippets code shows a common theme: You can access Open XML documents by instantiating the Package class, as well as other classes in the System.IO.Packaging namespace, such as PackageRelationship and PackagePart.

For example, this is a common start to any Open XML file access code (in C#):

using (Package wdPackage = Package.Open(docName,
FileMode.Open, FileAccess.ReadWrite)) 

You'll also see statements like the following for loading file content:

XmlDocument doc = new XmlDocument();
doc.Load(documentPart.GetStream());

These are just basic samples, which don't make much sense out of context. Hopefully they demonstrate that XML creation and manipulation isn't an abstract concept but is fully implemented in the .NET Framework 3.0 API. To learn more, start with the snippets, then dig deeper into the Packaging namespace. You should also check out the How to articles attached to the SDK announcement.

Previous Page: Introduction Next Page: Open XML and OBA
Page 1: IntroductionPage 3: Open XML and OBA
Page 2: Benefits of Open XML 
Submit article to:
Extending your solution to run on Microsoft technology is easier than ever. Through NXT, you can reach more customers, increase revenues and slash development time and costs, accelerating both your time to market and profitability. Get the details on NTX. >>
Sign up for your free e-mail newsletters today!
DevX Windows Developer Update

More Newsletters
Network Know-How: Exploring Network Algorithms
Serialize an Object Instance to XML
Book Excerpt: Microsoft Expression Blend Unleashed
Set the Computers Name Through .NET
Setting Up and Running Subversion and Tortoise SVN with Visual Studio and .NET



JupiterOnlineMedia

internet.com earthweb.com Devx.com mediabistro.com Graphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Copyright 2008 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers