Announcing the Release of PowerTools for Open XML 2.2
We’re very happy to announce the release of PowerTools for Open XML version 2.2, now available for download at https://github.com/officedev/open-xml-powertools. There are a number of great features in this new release:
- Merge-OpenXmlDocument incorporates DocumentBuilder 2.0, which is a much more robust implementation of the ideas in DocumentBuilder 1.0.
- Export-OpenXmlToHtml uses the HtmlConverter code to produce the HTML. It has advantages over the previous version, including how it converts numbered and bulleted items.
- Confirm-OpenXmlValid uses the Open XML SDK 2.0 to determine that one or many Open XML documents are valid. Reports all errors.
- Edit-OpenXmlChange accepts tracked revisions. This cmdlet replaces Accept-OpenXmlChange.
- Get-OpenXmlFooter and Get-OpenXmlHeader enable you to get headers and footers in any section. Set-OpenXmlFooter and Set-OpenXmlHeader enable you to set headers and footers in any section.
- Merge-OpenXmlDocumentComment – if you have multiple documents that differ only in their comments, you can merge the comments from the documents into a single document.
- Remove-OpenXmlMarkup – This cmdlet enables you to simplify markup so that it is easier examine or process. It uses the MarkupSimplifier class, and exposes all of the options of that class to the cmdlet.
- Set-OpenXmlString – Implements search and replace for word-processing documents and for presentations.
In addition to the above enhancements, we improved the code in three key ways:
- The code demonstrates another approach to dealing with Open XML documents – documents are represented using the WmlDocument, SmlDocument, and PmlDocument classes. These classes primarily treat documents as an array of bytes rather than a class that implements IDisposable (i.e. WordprocessingML, SpreadsheetML, and PresentationML). Key advantages:
- It is much easier to clone an Open XML document – the operation is simply one of copying the byte array.
- The issues around IDisposable go away. The code is simpler to write.
- This approach significantly reduced the code in each of the cmdlets. All other things being equal, less code is better.
- This approach enables a new “Functional Programming” approach to working with Open XML. This is very cool. More to come on this soon.
- All of the code that implements functionality is separated from the code that implements the cmdlets. This separation means that it is easier to examine the sample C# code, and use that core code from C#. It is easier for us to maintain and enhance the core code, and the cmdlet code is simplified. It will be easier to record screen-casts that explain the various algorithms in the code.
- We have centralized utility methods and classes into PtUtil.cs, PtOpenXmlUtil.cs, and PtOpenXmlDocument.cs. This enables us to really refine this common functionality, provide good documentation for the classes and methods, and increase code reuse. These utility methods are useful in their own right for your Open XML projects. We’ll be blogging about these in the near future.
We have created a PowerTools for Open XML Resource Center here on OpenXMLDeveloper.org. This will be the central repository for all of the blog posts, screen-casts, and articles on PowerTools.
We have a lot to tell you about this version of PowerTools for Open XML. The blog posts and screen-casts are going to come very quickly now, so check back daily for new screen-casts, etc. on PowerTools. In the meantime, download PowerTools for Open XML 2.2, and install and start using it. You can follow the instructions in the readme in the download zip file, or you can view the following screen-cast that walks through building and installing PowerTools.
One important note: previously, DocumentBuilder, HtmlConverter, and RevisionAccepter were also available in their own zip files. To simplify the process of putting together new releases of PowerTools, all core functionality, and all PowerShell cmdlets are now in one zip file.
I’ve been working with Bob McClellan on this release. Many thanks to him for his (as usual) great work. This has been a fun release to build. This release has some features that are really helpful to developers. I know I’ll be using it on a daily basis, and I hope you will enjoy using it as much as we enjoyed putting it together.