1140Merging Data and Automated Workflows in a Affinity Studio

Tested with Affinity Studio April '26 (4425) on MacOS 14.8.3

Problem: How to automate Catalogue Production in Affinity

Creating a catalogue involves copying and pasting assests, including texts, captions, names and images from data sources into Affinity. If the data source change, that process had to be repeated manually.

Solution: Data Merge!

Affinity offers the Data Merge feature which allows for the importing of structured data and the automatic generation of pages.

Overview of the Data Merge Process

  1. Create a source data file, in our example case we use Google Sheets to make a spreadsheet, which can be exported as CSV. Other source data types: Plain Text, CSV, TSV, JSON, XLSX

  2. Create a Affinity Layout document, design the fields you want to be populated with data from the CSV file. Images can be imported from URLs or from folder relative to the main Affinity document.

  3. In Affinity, use the from Window → Layout → Data Merge panel to import the CSV file and bind the data to the visual elements.

  4. Generate a new Affinity document based to the design & data source.

1. Creating the Data Source

Any structured data source can be used, we will be using Google Sheets, as it allows for collaborative editing. Data from Google Sheets can be exported as CSV by doing File → Download → Comma-separated values (.csv).

2. Importing the CSV in Affintiy

2.1. Opening the Data Merge Panel

The Data Merge Panel can be found in Window → Layout → Data Merge.

2.2. Adding the Data File

Clicking the Add Data File... Button opens up a dialogue, which allows you to upload your CSV file

2.3. Successful Import

Once imported, you can step through - and if necessary post-process - the data.

2.4. Binding Data Fields to Design Elements

This is where the magic happends:

  • Select the place where you want the data from the data field inserted. This can be within a textbox or in case of images, in the picture frame.

  • Select which field you want to bind. In our example CSV file, we only have Name, Image and Text.

2.5. Stepping through and Preview

Use the left/right arrows (◀︎ ▶︎) to step trough the data and see how it fits your design.

2.6. Generate

Once you are happy, press the Generate Button. This will take your design as a template and merge it with the data file, creating a new Affinity document. That means, that when the data changes, and data merge is run again, another new document will be created.

Files

Challenges

Can a generated document be updated when the data source changes?

No. Each time the Generate Button in the Data Merge panel is clicked a new document is generated.

Can I import text styles from the CSV file?

No, that's not possible. However, each field can be given the desired styles. In the case of longer text with embedded styles, a workaround it to use Markdown syntax to indicate **bold** and _italic_ in the source file and then do Find & Replace in the Generated Document.

1082array_merge behaves differently in PHP 7 and PHP 8

The array_merge function produces unexpected results on a PHP 8 server, as compared to a PHP 7 server.

$output = array_merge($array1, $array2);

In PHP 8, if array2 is empty, the $output array is also empty.

In PHP 7, if array2 is empty, the $output array is $array1.

TODO

  • [ ] Make test page.