We saw how to export with a Word template in this article.
Here we'll look at how to use tables for our Word export.
It is possible to generate a table whose number of rows will increment according to the number of linked elements you have in your table.
Let's take a simplified example of generating a quotation containing orders.
This is an order table, each order being assigned an amount:
And a quote table. Quotations are assigned orders:
We'll now turn our attention to the Word template.
This template will be generated from the quotation table, so we'll need to be careful to set the tags to the correct format:
${column_code} for data in the quotation table, e.g. ${quote_number}.
${link_code.column_code} for data from another table, with link_code being the column code of the link to the other table, and column_code being the column code in the other table.
Example: ${order.order_number} order being the code of the Order column in the quotation table and order_number the code of the Order number column in the order table.
As a reminder, a column code is not necessarily a column title.
You can find it in the column parameters:
Here is the Word template for our example:
First we have a Quotes title: with the tag that takes the number from the Quotes table.
Two columns, Order and Amount, with their titles in the first row and the tags that will retrieve the values from the Orders table in the second row.
Finally, we can add a Total with a tag that takes the total from the Quotes table.
Result:
The document generates the 4 order lines of quote number 2.