span8
span4
span8
span4
Please note that this article applies to FME 2017 and prior. In FME 2018+, please consider using the Microsoft Word Writer and MSWordStyler transformer.
Jan Bliki of the European Environment Agency (http://eea.europa.eu) was kind enough to share this clever workflow for creating Word documents with FME.
Writing Word is possible because the .docx (Office Open XML) format is essentially a zipped folder of XML documents. Within the attached workspace and custom transformers Jan combines any required content into JSON snippets and then uses FME’s XMLTemplater and other XML transformers to structure and package the required content before zipping into a final .docx file. Use this example to create your own MS Word reports based on any data you want to read in FME.
Download and unzip the attached file ValidationReporter.zip (click the link at the top of the article).
Review the output Word file: <MicrosoftWordWriter>\wordTrial\demoNew.docx. The output file demonstrates and describes the possibilities of the workspace.
Open the workspace <MicrosoftWordWriter>\MicrosoftWord.fmw in FME Workbench 2014 Sp2 or later.
The purpose of each bookmark is described below:
The Word Document is initiated and the top level heading paragraph is created with the MSWordInitiator custom transformer. Other paragraphs are included using MSWordParagraph custom transformers. In this example the text is hard-coded within each of the custom transformers and you can edit this text within the transformers or create User Parameter if would like to read this text from a source dataset attribute etc.
A picture is added using the custom transformer MSWordPicture and by including a path to the image file
A table is created using data read into FME from a CSV source dataset. You can replace this reader with any other reader and use the MSWordTable custom transformer to define which attributes to use in your table.
A bullet list is created from content in an attribute, again using the MSWordParagraph custom transformer. This customer transformer has a drop down for different Body Styles and in this case the style is Bullet List.
The MSWordRaster custom transformer is used to include a raster feature in the Word file and the raster can be either read or created within FME. In this case the MapnikRasterizer is creating raster a raster feature from a Spatialite vector data source.
Statistics can be included within paragraph text, again using the MSWordParagraph custom transformer and embedded FME attributes.
The last bookmark shows how to produce a series of rasters and include them in the Word document.
Use File > Prompt and Run to ensure your source and destination file paths are correct and run the workspace. Examine the output Word file which should be written here: <MicrosoftWordWriter>wordTrial\demoNew.docx.
Optional: To help build your own workspace you can install all of the customer transformers provided by double-clicking on each of them in the folder: <MicrosoftWordWriter>\Transformers
Thank-you very much to Jan Bliki of the European Environment Agency (http://eea.europa.eu) for sharing this example. Jan also mentioned that receiving FME Training from our Gold Level Value Added Reseller Sweco (www.sweco-fme.com) was very effective in getting his team going with FME.
How to Convert CSV to Microsoft Excel
Reading Complex XML or GML using XfMap
Caching of WFS features when accessed via the ArcGIS Data Interoperability Extension
Using a Template File when Writing Excel Data
Read INSPIRE ATOM Download Services with FME
Working with Geodatabase Metadata: Writing/Updating Metadata
© 2019 Safe Software Inc | Legal