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 TOC
It’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

Comments (22)

  1. Let’s see what the OpenXML guru’s take about it .. Here is full description from none other then …Erika

  2. Open XML Format SDK – RTM , Version 1.0 Overview The 2007 Microsoft® Office system introduces a new file

  3. La récente sortie du SDK Open XML devrait déjà vous permettre d’imaginer une quantité de scénarii pour

  4. Very cool post from Eric White that introduces a new CodePlex project to create PowerTools for OpenXML

  5. One of the namespaces introduced in the .NET Framework 3.0 is System.IO.Packaging (in the WindowsBase

  6. Doug Mahugh says:

    Hot on the heels of the release of Version 1 of the Open XML SDK earlier this week, Eric White has posted

  7. You can script documents and spreasheets creation and proecessing on the server. A new open source project,

  8. The Open XML Power Tools, an open source project on Codeplex to create PowerShell cmdlets for automating…

  9. There is a new open source project, PowerTools for Open XML up on Codeplex .  With using  PowerShell

  10. Eric White just posted an amazing set of Cmdlets on CodePlex .  They allow you to use PowerShell

  11. CodePlex 上周發佈了一個好用工具: 使用 PowerShell 來操作 Open XML 的一個範例, 將它放置在伺服器(Server-Side)上做批次檔案的處理的一個好選擇。 更多資訊: http://www.codeplex.com/PowerTools

  12. Nun gibt es ein weiteres cooles Open Source Project, die PowerTools for Open XML . Das Erzeugen, Ändern

  13. Sometimes you want to generate a wordprocessing document that contains a table. I’ve created an XML file

  14. I am a newbie to PowerShell scripting. This is probably pretty obvious to anyone who has taken a look

  15. Я много раз рассказывал как хорошо использовать OpenXML в различных сценариях, г

  16. Staff Dot Net , a small consultancy and training company, is now providing binary builds of the PowerTools

  17. Sometimes you need to create a list of all parts in a package so that you can write some generalized

  18. About three months ago, I posted the PowerTools for Open XML on CodePlex. I also posted a video on installing

  19. [Blog Map] This post contains a detailed description of each of the PowerTools for Open XML cmdlets.

  20. Today, I’m pleased to announce the release of PowerTools for Open XML V1.1. PowerTools for Open XML is

  21. PowerTools for Open XML v1.1.1 source code is now available. PowerTools for Open XML is an open source

  22. An introduction to PowerTools for Open XML 1.0. says:

    An introduction to PowerTools for Open XML 1.0.

Skip to main content