Formatting Rules Combined With Tabular Fields

Tabular field cells can be inserted as links in a document. However when a parent field is inserted, EasyCatalog normally creates a table of individual fields for each cell. Specifying a Formatting Rule changes this behaviour. When the parent field is inserted,  a single link is created containing the populated formatting rule. All links are removed, so the document contains a single link to the parent field.

Inserting Formatting Rule

Take this example, the Table field contains a simple table:

The table is created by a simple script:

 

When inserted we want the following result. Specifically that the second column is excluded along with a fixed header:

In order to achieve this, a Formatting Rule called 1. Fixed Header Table is defined which specifies the basic table settings. The table is configured via the Table->Table Options menu to Populate Using Tabular Field, with the Use Once As Template option along with Preserve Header and Preserve Footer.

Additional filter can be applied to the content of the data, so only rows where a specific column matches a value are included. The Match: setting specifies are regular expression to compare to.

Inside the table there are fields to identify where data for each cell comes from. The Use Once As Template option inspect the links inside the table to determine which columns the data comes from. Any cell formatting, such as cell style, row strokes are carried over into the target table from the tabular field.

 

 

 

 

 

 

 

 

 

 

 

 

 

On the field options the Insert Behaviour has been set to Insert Formatting Rule and the name of the Rule defined.

Inserting Formatting Rule Once For Each Row

This option repeats the rule for each row in the table, so enables the creation of other kinds of output. For example:

The result when inserted is single field containing:

Using Embedded Logic

Embedded logic can also be used. Here we get a different result for the first row using a Lua script enclosed with [[ and ]]:

Result:

Note that the field command can also takes a link as a parameter, but needs to enclosed within quotes. The contents of the field are passed to field, and the field command removes the markers and returns the passed string.

Formatting Rule Name

Embedded commands can also be used to specify the rule name, for example:

FIELDSTR(style)

In this case the Formatting Rule name is derived from the contents of the style field. It’s important to add style to the Fields list, so when it its content changes the rule is updated.

How Updates Work

Tags created in this way are updated if the content of the Tabular Field or the Formatting Rule changes. In addition any named  fields are also checked. The actual contents of the document is not checked as this would be too slow.

Demo Data

The example data source and document for these example can be downloaded here:

Formatting Rules And Tabular Fields