Generating a Custom Letter using PowerTools for Open XML and PowerShell
Lawrence Hodson has written a cool article (with accompanying example PowerShell scripts) published on OpenXmlDeveloper.org that uses PowerTools for Open XML v1.1 to generate a letter. His scenario is interesting – he generates a service level agreement (SLA) report based on information that he retrieves using PowerShell cmdlets. His example includes assembling the document from multiple source documents and making use of content controls that are bound to custom XML. One of the most interesting things about this article is that it shows generation of a very nicely formatted document, yet the developer generating the document doesn’t need to deal with the intricacies of formatting at all. Instead, all formatting is done in Word, and the Merge-OpenXmlDocument cmdlet takes care of moving the formatted content to the newly assembled document.
When assembling the final document, he takes content from one document that has customer specific information in it:
He also extracts some content from a document that contains a number of paragraphs. Only one paragraph is extracted based on whether the service is in compliance with the SLA:
And he appends some standard content at the end of the letter:
The final generated document looks like this:
This article and example shows some pretty nice functionality in just a few lines of PowerShell script. Nice job, Lawrence.
Posted: Monday, April 06, 2009 8:43 PM by EricWhite
Eric White's Blog : Generating a Custom Letter using PowerTools for Open XML and PowerShell
No comments:
Post a Comment