Partager via


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

Comments

  • Anonymous
    June 11, 2008
    Let’s see what the OpenXML guru’s take about it .. Here is full description from none other then …Erika

  • Anonymous
    June 11, 2008
    Open XML Format SDK – RTM , Version 1.0 Overview The 2007 Microsoft® Office system introduces a new file

  • Anonymous
    June 11, 2008
    La récente sortie du SDK Open XML devrait déjà vous permettre d’imaginer une quantité de scénarii pour

  • Anonymous
    June 11, 2008
    Very cool post from Eric White that introduces a new CodePlex project to create PowerTools for OpenXML

  • Anonymous
    June 12, 2008
    One of the namespaces introduced in the .NET Framework 3.0 is System.IO.Packaging (in the WindowsBase

  • Anonymous
    June 12, 2008
    The comment has been removed

  • Anonymous
    June 12, 2008
    You can script documents and spreasheets creation and proecessing on the server. A new open source project,

  • Anonymous
    June 12, 2008
    The Open XML Power Tools, an open source project on Codeplex to create PowerShell cmdlets for automating...

  • Anonymous
    June 12, 2008
    There is a new open source project, PowerTools for Open XML up on Codeplex .  With using  PowerShell

  • Anonymous
    June 13, 2008
    Eric White just posted an amazing set of Cmdlets on CodePlex .  They allow you to use PowerShell

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

  • Anonymous
    June 15, 2008
    Nun gibt es ein weiteres cooles Open Source Project, die PowerTools for Open XML . Das Erzeugen, Ändern

  • Anonymous
    June 18, 2008
    Sometimes you want to generate a wordprocessing document that contains a table. I've created an XML file

  • Anonymous
    June 19, 2008
    I am a newbie to PowerShell scripting. This is probably pretty obvious to anyone who has taken a look

  • Anonymous
    June 21, 2008
    Я много раз рассказывал как хорошо использовать OpenXML в различных сценариях, г

  • Anonymous
    July 03, 2008
    Staff Dot Net , a small consultancy and training company, is now providing binary builds of the PowerTools

  • Anonymous
    September 18, 2008
    Sometimes you need to create a list of all parts in a package so that you can write some generalized

  • Anonymous
    September 19, 2008
    About three months ago, I posted the PowerTools for Open XML on CodePlex. I also posted a video on installing

  • Anonymous
    November 18, 2008
    [Blog Map] This post contains a detailed description of each of the PowerTools for Open XML cmdlets.

  • Anonymous
    April 10, 2009
    Today, I’m pleased to announce the release of PowerTools for Open XML V1.1. PowerTools for Open XML is

  • Anonymous
    April 20, 2009
    PowerTools for Open XML v1.1.1 source code is now available. PowerTools for Open XML is an open source

  • Anonymous
    January 12, 2015
    An introduction to PowerTools for Open XML 1.0.