Automated Processing of Open XML Documents using PowerShell

I'm very excited today to announce a new open source project, PowerTools for Open XML .  Processing Open XML documents using PowerShell is a powerful approach for creating, modifying, and transforming Open XML documents.  The PowerTools for Open XML are examples and guidance that show how to do this.  They consist of PowerShell cmdlets, and a number of example scripts that demonstrate the use of the cmdlets.  Examples include automated word processing document and spreadsheet generation, and preparing documents for distribution external to a company, including removing comments, accepting revisions, applying a uniform theme to them, and applying a watermark to them.

This blog is inactive.
New blog: EricWhite.com/blog

Blog TOCIt’s important to note that this is not a new supported Microsoft product and doesn’t necessarily represent future product direction.  We think it will serve as inspiration for customers who need to create and modify Open XML documents in batches.  These tools also show the power and flexibility of Powershell.  They are good examples of PowerShell cmdlets.

These examples are primarily targeted at three types of users:

·         Developers who need to automatically generate documents programmatically.  For example, developers may need to generate word processing documents from an XML file containing customer data.

·         IT professionals who often need to send reports, charts, and spreadsheets that summarize the state of their network, servers, computers, and more.

·         Information workers who need to prepare documents for publication outside of their company.  To present a consistent appearance of documents, information workers may want to accept all revisions in the document, remove all comments, give a consistent style to the documents, digitally sign them, add a watermark, and more.

The included example scripts show all of the above uses of the PowerTools.

The PowerTools are based on the Open XML SDK.  Yesterday, the Open XML SDK 1.0 was released.  This is a great step forward for Open XML developers using .NET.  This is the final "go-live" Version 1, so you can deploy solutions that you build using this version.  The SDK makes it more convenient to write .NET applications that create and modify open XML documents.  Erika Ehrli has a great, informative, detailed blog post on this release.

Our purposes in creating the PowerTools cmdlets are twofold.  First, we want to show people some of the things that are possible using Open XML.  These cmdlets can serve as inspiration to people who want to expand on them.  We'd love to see folks create new cmdlets that do a wide variety of interesting things.  Second, we want to show the power of using Open XML in concert with PowerShell.  We're not trying to create a product here; we're just providing a head start for people who want to create and modify Open XML documents using PowerShell.

These cmdlets are available now.  They are released at www.CodePlex.com/PowerTools as an open source project.  They are licensed under the Microsoft Public License, which gives you a lot of freedom in how you use them.  You get full source code, and you can use the PowerTools in your own commercial applications.  It is pretty simple to download them, build them, and use them.

(Update, July 4, 2008: This post tells how you can get the prebuilt binary install, which is much more convenient.) 

These samples work with Office Open XML (Ecma 376 and IS29500) and PowerShell 1.0.  They create and modify the Open XML files directly, and do not use the Office object model - they don't require an installation of the 2007 Microsoft Office system.

Technical details on the implementation of the cmdlets are available here.

Special thanks to Staff Dot Net, and Bob McClellan, who developed the PowerTools.

PowerTools 1.0 cmdlets:

Accept-OpenXmlChange

Add-OpenXmlContent

Add-OpenXmlDigitalSignature

Add-OpenXmlDocumentIndex

Add-OpenXmlDocumentTOA

Add-OpenXmlDocumentTOC

Add-OpenXmlDocumentTOF

Add-OpenXmlPicture

Export-OpenXmlSpreadsheet

Export-OpenXmlToHtml

Export-OpenXmlWordprocessing

Get-OpenXmlBackground

Get-OpenXmlComment

Get-OpenXmlCustomXmlData

Get-OpenXmlDigitalSignature

Get-OpenXmlDocument

Get-OpenXmlFooter

Get-OpenXmlHeader

Get-OpenXmlStyle

Get-OpenXmlTheme

Get-OpenXmlWatermark

Lock-OpenXmlDocument

Remove-OpenXmlComment

Remove-OpenXmlDigitalSignature

Set-OpenXmlBackground

Set-OpenXmlContentFormat

Set-OpenXmlContentStyle

Set-OpenXmlCustomXmlData

Set-OpenXmlFooter

Set-OpenXmlHeader

Set-OpenXmlStyle

Set-OpenXmlTheme

Set-OpenXmlWatermark