Make files in a run
An automation often ends with a file someone needs: a spreadsheet of checked shipments, a packing list to print, a label with a barcode. Four blocks make files from data earlier steps produced, and the trigger can hand those files back to whoever started the run. This guide is for authors building those automations.
| Block | Makes |
|---|---|
| Write Excel | An Excel workbook from rows, with a bold header, a filter and real dates. |
| Write CSV | A plain CSV file from rows, for systems that import CSV. |
| Create PDF | A PDF, such as an invoice, packing list or letter, from a template and your data. |
| Create barcode | A QR code or barcode image, to put in a PDF, attach to an email or store. |
Every file a block makes is an output, like any other value. Later blocks can attach it to an email, write it to storage, or return it from the run.
1. Turn rows into a spreadsheet
Section titled “1. Turn rows into a spreadsheet”Write Excel and Write CSV take the same Rows: a Table or a List of Records from an earlier step, such as Select Rows, Parse CSV, or the Results of a For each loop. Each record becomes one row, and the first row holds the column names.
- Add Write Excel, or Write CSV for a file another system imports.
- Set Rows to the table or list.
- Set File name. Type
@to put values from the run in it, such as an order number. The.xlsxor.csvending is added when it’s missing. Left empty, the file isrows.xlsxorrows.csv.
The block writes every column it gets, in order. To keep only some columns or change their order, build the rows first with Set Value and For each, one record per row with the fields you want. To keep only some rows, use Select Rows.
Write Excel keeps text as text, so a commodity code keeps its leading zero and nothing in a cell runs as a formula. Dates in a date column become Excel dates. Write CSV puts a ' in front of text that starts like a formula, such as = or +, so a spreadsheet shows it instead of running it.
Either file holds up to 500,000 rows and 50 MiB. Over either limit, the step fails and writes nothing. The block’s Row count output says how many rows it wrote.
2. Make a PDF
Section titled “2. Make a PDF”Create PDF fills a template with your data. It suits documents with a fixed layout: invoices, packing lists, delivery notes, letters.
- Add Create PDF.
- Under Named inputs, add each value the document needs and give it a name, such as
order,linesorlogo. A record becomes something the template reads asorder.number; a list becomes rows you can repeat; a file, such as a logo, becomes an image the template can place. - Write the Template. It is written in Typst, a markup language for documents, and sets the page size, margins, fonts, headers, footers and page numbers.
- Set File name, for example
packing-list-{{order.number}}.pdf. Empty usesdocument.pdf.
Create PDF won’t publish while a named input is empty: enter a value for each one, or remove it.
A file input, such as a logo, can come from an earlier step, including a File cell of a table such as Read Reference Table › Table › #1 › Logo, or be uploaded on its row. If that row or cell has no file, the step fails and names the input. Open the row’s … menu and choose Upload file…; the row then shows the file’s name and size, and Clear value removes it. The file is kept with the automation, and each published version keeps the files it uses. You can also ask the workspace Agent to attach a file from the chat to a row. A duplicated block gets its own copy of the file. An automation you import, or start from a template, leaves the file out: the row says it needs an upload, and the automation can’t be published until you upload the file.
You don’t need to write Typst yourself. Ask the workspace Agent to make the template: it starts from ready templates for an invoice, a packing list and a commercial invoice, makes a draft run and opens the PDF to check it before it hands it back.
A long table carries on over as many pages as it needs and repeats its header row on each. Fonts are Noto Sans, Noto Serif and Noto Sans Mono. A template can’t read other files, load web addresses or import packages, and a template error stops the step and names the line.
A PDF can take up to 30 seconds and run to 500 pages and 50 MiB. PDFs are made one at a time, alongside Extract document text, so a step may wait for its turn.
3. Add a barcode or QR code
Section titled “3. Add a barcode or QR code”Create barcode turns a reference, link or ID into a code a scanner can read.
- Add Create barcode before Create PDF.
- Set Text, for example the order reference.
- Pick the Type: QR code for any text, including links; Code 128 for letters and digits; or Data Matrix, EAN-13, GS1-128 or PDF417 when a label standard asks for one.
- Pick the Format: SVG stays sharp at any size and suits PDFs; PNG suits email and label printers.
To print it in the PDF, add the barcode’s Image to Create PDF’s Named inputs, for example as code, and place it in the template with #image(code, width: 60mm). The template sets the printed size.
Text a type can’t hold, such as letters in an EAN-13, stops the step and says why.
4. Hand the files back
Section titled “4. Hand the files back”An Operation trigger can give the person who submitted the form what the run made:
- Open the trigger.
- Under Returned files, pick the files, such as Create PDF’s PDF or Write Excel’s File.
- Under Returns, add any values to show with them, such as Write Excel’s Row count.
When the run ends, the values and files show under the form, in the editor’s Run window and at the top of the run page, where people can preview and download them. They say how long they’re kept.
To send a file instead, attach it in Send email. To keep it in your own storage, use Write object.
5. Check the file
Section titled “5. Check the file”Make a draft run with sample data, then open the step in the run and look at the file it made. See Runs in the editor. Open a spreadsheet in the program your team uses, and print a label once to check that the scanner reads it at the size you set.
- Read data from a document, to get the rows in the first place
- Look up reference data, to pick and shape rows with Select Rows
- Triggers, for Returns and Returned files