August 2009 - Posts

Open XML Code Snippets
30 Aug 2009 12:30 PM

In a previous blog post I mentioned the Open XML SDK, and the code snippets I wrote are finally available for download here:

http://www.microsoft.com/downloads/details.aspx?FamilyID=78bea298-a3f9-44cf-bde0-b4f30dc986df&displaylang=en

This package includes 50 code snippets you can use as part of an application, and indicates lots of ways to use the Open XML SDK 2.0 to read/write/query Word/Excel/PowerPoint documents.

 

Using Office 2007 Documents as a Data Store
21 Aug 2009 9:44 AM

Don't know what's up, but recently I've gotten a bunch of questions about programming using Office 2007 documents as data--that is, the need to programmatically manipulate the contents of Word, Excel, or PowerPoint 2007 documents. Most people rely solely on automation (that is, the technique we learned back in 1997 for opening the host application, using it to open the document, and then using the host application's object model to do the work.) This is slow. Very, very slow.

If you want better performance, you must use the OpenXML File Formats introduced in Office 2007 to do the work. Because Office 2007 documents (Word, Excel, and PowerPoint, at least) are stored in a completely transparent ZIP-file-based set of XML parts, it's easy enough to simply manipulate the XML contents of the file, rather than opening Word (or Excel or PowerPoint) to do the work.

This is, of course, far more difficult in practice than it is in theory (isn't everything?)--to make it simpler, Microsoft has been preparing the Open XML SDK 2.0, which provides higher-level wrappers on the code you would need to write in order to crack open and manipulate the XML content within Office documents. You can find information about the SDK here: 

http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&DisplayLang=en

In addition, the Office team commissioned a set of 50 code snippets demonstrating the use of the Open XML SDK 2.0 (and I had the privilege of creating these snippets--it was loads of fun). They should be available soon, and I'll post a link once you can download them. This technology isn't for the faint-hearted, that's for sure. Even simple operations require some heavy lifting, but the results are much, much faster than using automation (at runtime, at least!)

If you need to manipulate Office 2007 content, and you don't mind getting your hands a little dirty, check out the SDK.

by KenG | with no comments
Don't Dual Boot in Windows 7!
10 Aug 2009 10:39 AM

If you're a busy developer, you often need to work with beta versions of products; hopefully, you've realized that installing beta versions on your everyday installation of Windows is an exercise in frustration. Many developers (including me) have used the dual boot technique, which requires a lot of effort to set up the multiple partitions on the hard drive. I've tried, over and over, to be happy developing in a virtual machine, but it always feels just a little too slow for comfort.

Using Windows 7, you have an alternate choice. You can create a virtual disk (a VHD file) containing a full Windows installation, and you can boot from the VHD--you get the benefit of multiple partitions, without the hassles of fiddling with hardware! Blogger extraordinaire Scott Hanselman has documented it all on his blog, here: http://www.hanselman.com/blog/LessVirtualMoreMachineWindows7AndTheMagicOfBootToVHD.aspx. I fully intend to use this technique, once I get a day free to install the RTM version of Windows 7 (now available to TechNet and MSDN subscribers for download).

Give it a try--it seems like a great way to get the benefit of dual booting without the hassles!

by KenG | with no comments