Question

MS Word Styler/Writer Issues - Ordering data & removing attributes.

  • 4 February 2019
  • 4 replies
  • 22 views

Badge

I have a workspace that produces statistics from some survey data and then writes a finished report as a Microsoft Word document. However I am having some issues.

Firstly, there seem to be FME system attributes being passed through to the final report. Namely, "fme_feature_type" and "fme_type" (see image 1 - highlighted rows). These aren't selected in either the writer or reader Format Attributes tab, and I have tried a number of ways of removing them including using Attribute Managers, Removers, Keepers & Testers. The problem is they aren't showing up at any stage of the workflow, except in the final output report.

 

IMG 1

 

Secondly, I am having trouble with ordering data within a table as required. I pass the relevant attributes through to an Attribute Manager, sort them as I need (image 2), and then pass them to a MS Word Styler and a MS Word writer. However, they are then sorted differently in the final report (image 1). I can't work out how to sort them as I want, or what rules are determining how they are currently being sorted.

 

IMG 2

 

Lastly, I have attempted to load in a template document (see image 3), but am struggling to understand how this influences the final output. So far it seems that whatever document I write is just being appended to the end of a template, and not using it for formatting at all.

 

IMG 3

 

Any help for any of these issues would be great! This is the first time I have used the MS Word Styler and Writer so I might be making some fairly basic mistakes here so am really grateful for any tips or tricks.

 

Zach

 


4 replies

Userlevel 3
Badge +17

Hi @zacharypurver

Are you using an AttributeExploder in your workflow? This transformer will create features from unexposed attributes like format attributes such as fme_feature_type and fme_type. You can enable feature caching and inspect the output of each transformer to see where they are originating from.

The order features are written is controlled by the physical order in which features enter the Word writer. Using the AttributeManager may not be enough to 'sort' and you may need to use the Sorter instead depending on your workflow.

The meaning of 'template' in the Word writer is different from the native meaning of 'templates' in MS Word. This can be confusing and there will be a change to the terminology used from 'template file' to 'base file' in FME 2019.

In FME, new data is appended to the end of the base/template file and there is no way to fill the base/template with new data in a form-like fashion. The writer adds to the base file using the base file's settings (for example, for headings, fonts, colors, etc.), and saves a new file.

I hope this helps.

Badge

Hi @zacharypurver

Are you using an AttributeExploder in your workflow? This transformer will create features from unexposed attributes like format attributes such as fme_feature_type and fme_type. You can enable feature caching and inspect the output of each transformer to see where they are originating from.

The order features are written is controlled by the physical order in which features enter the Word writer. Using the AttributeManager may not be enough to 'sort' and you may need to use the Sorter instead depending on your workflow.

The meaning of 'template' in the Word writer is different from the native meaning of 'templates' in MS Word. This can be confusing and there will be a change to the terminology used from 'template file' to 'base file' in FME 2019.

In FME, new data is appended to the end of the base/template file and there is no way to fill the base/template with new data in a form-like fashion. The writer adds to the base file using the base file's settings (for example, for headings, fonts, colors, etc.), and saves a new file.

I hope this helps.

Hi @DebbiAtSafe

Thanks for your reply. I am using an Attribute Exploder, this is to solve another issue I am having regarding transposing a table. Similar issue here: (https://knowledge.safe.com/questions/75631/ms-word-styler-how-to-create-vertical-transposed-t.html)

Is there anyway to transpose the table without an Attribute Exploder, or if not, is there a way to remove the features from these unexposed attributes?

 

Thanks for the rest of your comments, that's really helpful!

Zach

Userlevel 3
Badge +17

Hi @DebbiAtSafe

Thanks for your reply. I am using an Attribute Exploder, this is to solve another issue I am having regarding transposing a table. Similar issue here: (https://knowledge.safe.com/questions/75631/ms-word-styler-how-to-create-vertical-transposed-t.html)

Is there anyway to transpose the table without an Attribute Exploder, or if not, is there a way to remove the features from these unexposed attributes?

 

Thanks for the rest of your comments, that's really helpful!

Zach

You're very welcome, I'm glad the information helped.

It is possible to use the AttributeExploder and a Tester to filter out format attributes as described in this tutorial.

Alternatively, if you use the custom FME Hub transformer AttributeTransposer, it may be possible to skip using an AttributeExploder. I have attached a workspace demonstrating the AttributeTransposer approach.

In addition, to demonstrate a possible use of template/base files, instead of ouputting features as a table, I have chosen to write them as paragraphs instead.

To do this, I have specified a special base file in which I modified the Normal style to contain a tab stop at a certain position. In my workspace, I created a new attribute by concatenating the attribute name, a horizontal tab, and attribute value. In the MSWordStyler, I specified the content type as Paragraph and the style to be Normal.

In the output file, because the base file has a tab stop for the style, attribute values are positioned at the tab stop.

mswordtransposer.fmwt

Badge

You're very welcome, I'm glad the information helped.

It is possible to use the AttributeExploder and a Tester to filter out format attributes as described in this tutorial.

Alternatively, if you use the custom FME Hub transformer AttributeTransposer, it may be possible to skip using an AttributeExploder. I have attached a workspace demonstrating the AttributeTransposer approach.

In addition, to demonstrate a possible use of template/base files, instead of ouputting features as a table, I have chosen to write them as paragraphs instead.

To do this, I have specified a special base file in which I modified the Normal style to contain a tab stop at a certain position. In my workspace, I created a new attribute by concatenating the attribute name, a horizontal tab, and attribute value. In the MSWordStyler, I specified the content type as Paragraph and the style to be Normal.

In the output file, because the base file has a tab stop for the style, attribute values are positioned at the tab stop.

mswordtransposer.fmwt

Hi Debbie, some very interesting ideas there that I will be sure to check out. I like the thought of outputting certain elements of the report as paragraphs as this is probably more appropriate and I believe there are more customisation options with the Paragraph setting. Thanks for attaching the workspace, I will take a look at that.

One thing probably worth noting is I managed to get around the format attributes problem by using an Attribute Exposer. By explicitly choose to 'reveal' these attributes, it meant I could remove them as normal with an Attribute Manager (or Keeper/Remover) later on so that's another way around that issue.

Reply