Combining the technologies of PowerShell and Open XML is a powerful and convenient way to do server-side document processing. The PowerTools for Open XML are sample source code and guidance for developers showing how to build PowerShell cmdlets that can create and modify Open XML documents. Also included are a number of examples of PowerShell scripts that use the cmdlets.

For an introduction and screen-cast on the PowerTools for Open XML, see Automated Processing of Open XML Documents using PowerShell.

For information and a screen-cast on PowerTools for Open XML v1.1, see Announcing the Release of PowerTools for Open XML V1.1.

To install and build the PowerTools for Open XML from source code:

Following are links to download pre-built binaries of the PowerTools for Open XML v1.1. The CodePlex Terms of Use apply to external sites.

April 19, 2009 - the following binaries are for version 1.1, not version 1.1.1. This is currently being updated - stay tuned...
  • Julien Chable has posted the binaries here.

April 19, 2009 - the following binaries are for version 1.1.1.

PowerTools for Open XML Home Page: http://blogs.msdn.com/ericwhite/pages/PowerTools.aspx

Set-OpenXmlCustomXmlData

The Set-OpenXmlCustomXmlData cmdlet sets or replaces the specified custom XML part in the document.

Remove-OpenXmlComment

The Remove-OpenXmlComment cmdlet locates and removes comment contents and references from Wordprocessing documents.

Add-OpenXmlDocumentTOC

The Add-OpenXmlDocumentTOC cmdlet creates a Table of Contents based on the headings found it in the document. The TOC will be created at the end of the document.

Add-OpenXmlDocumentIndex

The Add-OpenXmlDocumentIndex cmdlet creates an index based on the index references found in the document. The index will be created at the end of the document.

Set-OpenXmlWatermark

The Set-OpenXmlWatermark cmdlet adds watermark text to the background of a document. iI the DiagonalOrientation parameter is specified, then the text will be in a diagonal
orientation rather than horizontal.

Add-OpenXmlPicture

The Add-OpenXmlPicture cmdlet inserts a picture at a specific location inside an OpenXML document. The picture will be stored inside the document as an embedded resource. Picture location is specified by an XPath query expression.

Set-OpenXmlHeader

The Set-OpenXmlHeader cmdlet inserts header parts into all sections of a Wordprocessing document.

Lock-OpenXmlDocument

The Lock-OpenXmlDocument cmdlet sets a lock inside one or more Wordprocessing documents to prevent them from being edited.

Get-OpenXmlStyle

The Get-OpenXmlStyle cmdlet retrieves the styles definition part from a WordprocessingML or SpreadsheetML document and returns an XDocument object containing the styles content.

Get-OpenXmlTheme

The Get-OpenXmlTheme cmdlet extracts the whole theme part from a Wordprocessing document as a thmx file (with media resources embedded). A Package object (System.IO.Packaging.Package) is returned that corresponds to the theme file.

Accept-OpenXmlChange

The Accept-OpenXmlTextChange cmdlet processes documents with text revisions (change tracking elements), by accepting all the text changes performed on the document.

Set-OpenXmlBackground

The Set-OpenXmlBackground cmdlet changes the background image or background color of a Wordprocessing document.

Get-OpenXmlComment

The Get-OpenXmlComment extracts all the comments from a document, and return all of them in a XDocument

Add-OpenXmlDigitalSignature

The Add-OpenXmlDigitalSignature cmdlet uses a digital certificate to digitally sign a Wordprocessing document.

Get-OpenXmlDocument

The Get-OpenXmlDocument cmdlet returns an OpenXML document object for each document file. The actual object will depend on the type of document in the file. For example, if it is a spreadsheet, the object will be a SpreadsheetDocument, which is derived from OpenXMLDocument.

Get-OpenXmlCustomXmlData

The Get-OpenXmlCustomXmlData cmdlet gets the first customXml part that matches the given name and returns it as an XDocument object.

Export-OpenXmlToHtml

The Export-OpenXmlToHtml cmdlet transforms the content of Wordprocessing documents into an html file by applying an XSLT transformation over the main content and extracting images from the package to a given location.

Add-OpenXmlDocumentTOA

The Add-OpenXmlDocumentTOA cmdlet creates a Table of Authorities based on the citations (references or authorities) found it in the document. The TOA will be created at the end of the document.

Set-OpenXmlStyle

The Set-OpenXmlStyle cmdlet replaces the style library in a WordprocessingML or SpreadsheetML document.

Get-OpenXmlFooter

The Get-OpenXmlFooter cmdlet retrieves all the specified footer parts from a document and returns an XDocument array of those footers. An object is returned for the specified footer in each Section of the document.

Get-OpenXmlDigitalSignature

The Get-OpenXmlDigitalSignature cmdlet returns a summary of digital signatures present in the Wordprocessing document

Set-OpenXmlTheme

The Set-OpenXmlTheme cmdlet sets the current theme in a Wordprocessing document to the specified theme.

Remove-OpenXmlDigitalSignature

The Remove-OpenXmlDigitalSignature cmdlet removes digital signatures from a Wordprocessing document

Add-OpenXmlContent

The Add-OpenXmlContent cmdlet injects custom xml markup inside a given part from a Wordprocessing document

Export-OpenXmlWordprocessing

The Export-OpenXmlWordprocessing uses plain text to create a Wordprocessing document.

Set-OpenXmlContentFormat

The Set-OpenXmlContentFormat cmdlet inserts markup containing format to be applied on a given run or paragraph. Format location is specified as an xpath query.

Set-OpenXmlFooter

The Set-OpenXmlFooter cmdlet inserts footer parts into all sections of a Wordprocessing document.

Get-OpenXmlWatermark

The Get-OpenXmlWatermark cmdlet retrieves the text of the document's watermark.

Get-OpenXmlBackground

The Get-OpenXmlBackground cmdlet extracts the background (color or image) from a document according to the parameters Image or Color.

Export-OpenXmlSpreadsheet

The Export-OpenXmlSpreadsheet gets the public properties from any objects and generates a spreadsheet with columns showing for each property. Optionally, a chart can be created from a subset of those properties.

Set-OpenXmlContentStyle

The Set-OpenXmlContentStyle cmdlet inserts inserts markup containing the style format to be applied on a given run or paragraph. Format location is specified as an xpath query.

Add-OpenXmlDocumentTOF

The Add-OpenXmlDocumentTOF cmdlet creates a Table of Figures based on the figures found it in the document. The TOF will be created at the end of the document.

Get-OpenXmlHeader

The Get-OpenXmlHeader retrieves all the existing header parts from a document. The execution returns an XDocument array of all the header parts found in the document.

If you have any issues with downloading, building, or using the PowerTools for Open XML, please feel free to contact Eric White: white.eric (at) microsoft.com
Last edited Apr 20 at 8:00 PM by EricWhiteDpe, version 16

 

Want to leave feedback?
Please use Discussions or Reviews instead.

Archived page comments (4)

Updating...
© 2006-2009 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | Version 2009.6.1.15196