Print Templates
Every document in Controlata is printed from a template. Each section already has a default template, so printing works
right away and there is nothing to set up.
You need your own template when a document has to look a certain way: a letterhead with your logo and company details,
your own set of columns and totals, a form your counterparty or your accountant asks for. A section can hold several
templates.
A template is simple: it is an Excel file with variables like {{number}} in its cells. On print Controlata puts the
operation data in their place and keeps all the formatting of the file: fonts, fills, borders, merged cells, images.
Templates work in every section: materials, products, purchases, productions, sales, write-offs, resources, transfers,
audits, suppliers and customers. You can print to Excel or to PDF.
Getting started
There is no need to build a template from scratch, start from the default one.
1. Open Settings → Print templates.
2. Find the section you need and click the download icon next to the default template. You get the very file Controlata
prints from, with all the variables in place.
3. Open the file in Excel and change it to suit you. Everything can be changed: the formatting, the set and the order
of the columns, the captions, and you can add your own blocks and images. Your company logo, for instance.
4. Go back to the settings, click Add template, pick the section, enter a name and attach the file.
The template shows up in the list of that section and is offered in the print dialog alongside the default one. Drag the
items to reorder them: the template that stands first is selected by default.
Print templates are managed by a company admin. The supported files are .xlsx and .xls.
The default template always stays where it is. You can print from it at any time, or download it again if you need to
start over.
Variables
A variable is a field name in double curly braces. On print it is replaced with the value, and the formatting of the
cell is kept:
Sale {{number}} of {{date_placed}}
Fields of related objects are written with a dot:
{{customer.name}}
Which variables are available depends on the section. The full list is gathered in a separate article, Print template
variables.
If a variable has a mistake in it, or the section has no field by that name, the cell prints #ERROR with an explanation.
That way a typo is visible straight away, instead of showing up as an empty column in a finished document.
Access rights
The template is the same for every employee, but the data in it depends on their rights. If an employee has no access to
prices or to costs, those values come out empty, while the captions and the columns stay where they are. Rights do not
change the structure of the document.
Tables
The items of a document are printed as a table. A template needs two rows for it.
The first one is the sample row, and its variables start with the prefix of the table:
{{item.number}} {{item.name}} {{item.sku}} {{item.quantity}} {{item.price}} {{item.total}}
The second one goes right under it and sets how many rows to print:
{{ repeatRow(15) }}
On print the sample row is repeated once per item, and the row with repeatRow does not make it into the document. The
formatting of the sample is repeated on every row: fonts, fills, borders, row height, merged cells. If there are no
items at all, the sample row is removed.
Each table has its own prefix, and it is given in the list of variables. A document can hold several tables: a
production has three, the produced products, the materials used and the resources.
Functions
Four functions are available inside variables.
| Function | Description | | -------- | ----------- | | repeatRow(n) | Repeats the sample row once per item, but no more
than n times. It is written under the sample and does not make it into the document. By default n equals 1000, which is
also the limit. | | removeRow() | Removes the row it stands in. | | removeColumn() | Removes the column it stands in. |
| length() | Called on a table, for example items.length(), and returns the number of rows that were printed. On an
ordinary field it returns the length of the value in characters. |
Removing a row when a field is empty. The caption and the value disappear together:
{{ customer.phone ? "Phone" : removeRow() }}
{{ customer.phone ? customer.phone : removeRow() }}
A counter of the printed rows:
Showing {{ orders.length() }} of {{ orders_count }} sales
Conditions
A condition is written with the ternary operator, as in Excel or in programming languages:
{{ condition ? value if yes : value if no }}
Text inside a condition is written in double quotation marks. If you need a quotation mark inside the text, put it
twice: ""Daisy"".
What you can use in a condition:
- A check for a value. {{ notes ? "Notes" : "" }} prints the word "Notes" if the notes field has something in it, and
leaves the cell empty if it does not.
- Negation !. {{ !notes ? "No notes" : "" }} prints "No notes" when the field is empty.
- Comparison == and !=. {{ type == "materials" ? "Materials" : "Products" }} prints "Materials" if materials are being
moved, and "Products" in every other case.
- Number comparison >, <, >=, <=. {{ total > 10000 ? "Large sale" : "" }} prints "Large sale" for sales over 10,000.
- Logical && and ||. {{ phone && email ? "Contacts" : "" }} prints "Contacts" only if both fields have something in
them. With || one of them is enough.
- Joining text &. {{ "Sale " & number }} prints "Sale 0103".
Formatting
Print area
The print area sets what goes to the printer from Excel. In the default template it is already set up and stretches down
by itself as the item table grows. But if you have added your own blocks beyond its former bounds, it will not stretch
to cover them.
So after editing a template check the print area and set it again if you need to: Page Layout → Print Area → Set Print
Area. Make sure all your blocks are inside it.
It does not affect printing to PDF from Controlata: the PDF is built from the whole sheet, and the print area plays no
part in it. It matters when you download the document to Excel and print from there.
Table borders
Set the separators between rows with the bottom border of the sample row: only that one is repeated under every item.
Controlata does not carry over the top border when it repeats a row.
Numbers, tax IDs, phones
If a value is an identifier rather than a number, set the cell format to Text. Otherwise Excel treats it as a number: a
leading zero is lost and the value is pushed to the right edge. Amounts and quantities, on the contrary, do not need the
text format, and then your number or currency format applies.
If something went wrong
- The cell printed "#ERROR: unknown field". This section has no such field. Usually it is a typo. Check it against the
list of variables.
- The cell printed "#ERROR" with a different explanation. The mistake is in the expression itself: a single = instead
of == for a comparison, an unclosed quotation mark, a typo in a function name.
- The variable printed as it is, braces and all. Most likely the braces are not paired, or the field name has an extra
space in it.
- The value is empty. The field exists but is not filled in in the operation itself, or the employee has no rights to
it.
- The sample row printed once, with variables instead of data. Check the prefix of the table, it has to match the one
given in the list of variables.
- The table stops short. The repeatRow limit kicked in. Raise the number or drop the argument.
- Part of the document does not print from Excel. Check the print area, your blocks may have ended up outside its
bounds.
If you cannot get a template to work at all, download the default one again and move your formatting into it, that will
be quicker than hunting for the fault.