Windward OhanaReport Designer Office Edition User Manual FAQsHow Do I Conditionally Format an Out Tag's Output?

How Do I Conditionally Format an Out Tag's Output?

This article shows how to use the Conditional Formatting Rule Manager to add conditional formatting to the output of your Out Tags in your Microsoft Office Word, Excel, and PowerPoint templates. 

Conditional formatting allows you to change the format of the output based on a certain conditions you set in your template.  An example of conditional formatting could include:

  • Change the text color to red if a value is negative
  • Set the cell background color based on whether a request is open (red), pending (yellow), or closed (green)
  • Use one parameter to change multiple format settings in an entire document
  • And much, much, more...

An Example

In this example, we'll use a very simple template with a ForEach Tag and some Out Tags and add conditional formatting. We'll use the attached Word template (which connects to our public Northwind database).

We begin with a basic template containing a simple data table:

Click on the "Output" button to view the output and choose the DOCX format.  Note the output doesn't display any formatting in the text. 

Let's change the UnitsOnOrder column values to be bold and have a red text color if they are greater than zero. 

To do this, open the Tag Editor by double clicking on the [UnitsOnOrder] Out Tag.

Click on the "…" button next to the condition property to bring up the Conditional Formatting Rule Manager.

In the "Condition" field, type the condition we want to use for our formatting rule. This condition will test to see if the [UnitsOnOrder] is a number greater than zero.

Remember when referencing data in a ForEach Tag, you must use the syntax =${VariableName.NodeName}.

Click on the wand button next to the "Format" field to open the Format Options window. Select the "Bold" option and type "ff0000" (the hex value for red) into the "Text color" field.

Click on "OK". You can now see the Format field contains a format code. Click on "OK" to set the format.

In the Tag Editor window, click on the "Save Tag" button to save our formatting changes to the Out Tag.

Click on the "Output" button and select the DOCX format.  In the output, the units on order with a greater value than zero will be formatted bold with red text. 

We've now used conditional formatting to enhance our template output.

Creating Multiple Conditions

The Conditional Formatting Rule Manager can be used to create multiple conditions which must be true before the corresponding format code goes into effect.

Continuing with our example, let's create a format rule which displays the UnitsOnOrder column values as bold and green if they are greater than 50.

Bring up the Conditional Formatting Rule Manager as before, and click on "Add New Rule."

Then, repeat the procedure of typing in the condition in the "Condition" field, click on the wand icon to bring up the "Format Options" window, select Bold, and enter the hex number "008000" for green.

Now when we generate output, we see the units on order with a value greater than 50 have changed from red to green.


Some Additional Notes

  • In the case of a SQL query, you must use the form ‘items[1].ColumnName’ to access a specific column in a row. 
  • The condition for a format rule is an expression that must have a result of true or false. Note that conditions begin with an "=" character.
  • If you have multiple rules, rules are applied in the order they appear in the Conditional Formatting Rules Manager. If you set the “Stop If True” checkbox for a rule, then when that rule evaluates to true, no further rules are applied for that Tag.
  • In a table in Microsoft Word, cell format settings are only applied to Tags within the cell.

0 Comments

Add your comment

E-Mail me when someone replies to this comment