Document template formats: DOCX, PDF, XLSX

Overview

Kompass renders project documents, invoice documents and report templates into one of four formats:

  • DOCX: Word documents (default for most templates)
  • PDF: for documents that should not be edited after generation
  • XLSX: Excel spreadsheets, useful for tabular reports
  • CSV: one sheet of an XLSX template as a plain text file, for importing into another system

The template file you upload decides which formats you can produce. A .docx template produces DOCX or PDF, and an .xlsx template produces XLSX, or CSV once it is set up for it (see CSV output).

DOCX templates

DOCX templates use template tags ({{ project.name }}, {% for item in quote_items %}) inside a normal Word document. Most text formatting is preserved, including bullet points and numbered lists.

Details and notes fields in Kompass support Markdown. To show it as Word formatting (bold, italic, bullets, numbered lists, links and headings) rather than raw **asterisks**, add the markdown filter, for example {{ project.details | markdown }}.

XLSX templates

XLSX templates use the same tags, placed in the cells of a spreadsheet. Typical uses include:

  • Project performance reports with many rows
  • Proposal Item exports formatted for a customer
  • Custom invoice schedules

Tags can be placed inside any cell. To repeat a row for each item of a list (for example all Proposal Items in a project), start the loop in the row's first cell and close it in the first cell of the next row:

A B
2 {% for item in quote_items %}{{ item.reference }} {{ item.name }}
3 {% endfor %}

Row 2 is written once per item. A loop that opens and closes in the same cell does not add rows.

CSV output

An XLSX template can also be downloaded as a CSV file. This is useful when another system (an accounting package, a client's portal) imports a CSV file in a fixed layout. CSV is switched off for every template until you choose which sheet to export.

Setting it up

Open the template in Kompass Admin (for example Kompass Admin → Projects → Document templates) and set these fields:

Field What it does
CSV export The sheet that goes into the CSV file: No CSV export (the default), Active sheet (the sheet that was selected when the file was last saved in Excel), or one of the template's sheets by name.
Csv delimiter The column separator: Comma (the default), Semicolon or Tab. Use the one the receiving system expects.
CSV byte order mark On by default. Excel needs it to show accented and other non-English characters correctly. Turn it off if the receiving system rejects the file.

CSV settings of an XLSX document template in Kompass Admin

Once a sheet is chosen, the Format option offers CSV next to XLSX when you create a document or run a report from the template.

Format option with XLSX and CSV in the document dialog

What goes into the file

  • Only the chosen sheet. Other sheets, such as summaries or pivot tables, are left out.
  • The CSV sheet does not have to be the sheet that holds the data. A separate sheet gets the same data, so you can add a sheet that lays out only the columns the import needs and keep your formatted sheet for XLSX. A report with more than one data source must use one of its data sheets for CSV.
  • Cells hold their values. Dates are written as YYYY-MM-DD, and dates with a time as YYYY-MM-DD HH:MM:SS. Empty rows and columns at the end of the sheet are dropped.
  • A formula is written as its text, not as its result, with a leading apostrophe (for example '=SUM(B2:B10)) so it cannot run when the file is opened. Text that starts with =, +, - or @ (such as a phone number +1 555 0100) gets the same apostrophe. Numbers are not affected. Put values rather than formulas on the CSV sheet.
  • The file name ends in .csv instead of .xlsx.

Map screenshots

Templates can include a map image of a project's map data:

  • In DOCX and PDF project documents, place {{ maps_screenshot }} where the image should appear. The image is inserted in place of the tag.
  • In XLSX documents, place {{ maps_screenshot() }} (with the brackets) in a cell; the image is placed at that cell. Report templates cover many projects, so pass the map data to draw, for example {{ maps_screenshot(entry.geometries) }}.

Only the project's own map data is drawn: no other projects and no other map layers. If the project has no map data, nothing is inserted.

All settings are optional. The defaults, in a DOCX or PDF document, are:

{{ maps_screenshot(width=600, height=400, scale=2, maptype="roadmap", width_cm=15) }}

XLSX documents take the same settings except width_cm.

  • width / height: size of the map area in pixels (maximum 640 each)
  • scale: image quality, 1 or 2; 2 doubles the pixel density for crisp printing
  • maptype: roadmap, satellite, hybrid or terrain
  • zoom: fixed zoom level from 0 to 21; leave it out to fit the map to the drawn data automatically
  • width_cm: printed width in the document (DOCX and PDF only)

Map screenshots use Google Maps and need the map view to be set up for your account. If document generation reports a missing API key, please contact support.

Images from file fields

A user-defined file field can hold photos and other files for a record. In DOCX templates, and in PDF documents made from them, its images can be placed in the document, at their natural size or at a width or height you give in centimetres. See Files and Images in Document Templates for the tags.

PDF output

A DOCX template can be rendered to PDF, which is useful for finalized invoices and quotes. When you generate a document from a DOCX template, choose PDF as the format.

File naming

The output filename is itself a template, set when you configure the document template. You can reference project, client and date fields:

{{ project.reference }} - {{ client.name }} - quote.docx

If the name comes out empty (for example a blank reference), the document is named after the template.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us