Object operations in XLSX templates

Modern templating engine

Still using Classic syntax? See the Classic documentation.

Learn the differences.

Object operations allow you to insert special objects, such as barcodes, QR codes, and pictures, into your Excel workbook.

In this article, you’ll find a list of all the object operations you can use in XLSX templates. Each one comes with examples to help you see how you can use them in your documents.

barcode

Use the #barcode operation to generate barcodes in your template.

Syntax:

{{#barcode value "TYPE" width height}}

  • value — the token containing the barcode value

  • TYPE — barcode type (must be in quotes)

  • width — barcode width in pixels

  • height — barcode height in pixels

Example:

Template

Data

Result

{{#barcode value "CODE128" 300 100}}
{
    "value": "test barcode"
}

the barcode

#barcode operation result

This code generates a CODE128 barcode that is 300 pixels wide and 100 pixels high.

If you’d like to create a square barcode, you can leave out the height. This generates a barcode with a width and height of 300 pixels:

{{#barcode value "CODE128" 300}}

There are different types of the barcodes.

The following barcode types are supported:

Barcode type

Template

JSON data

CODE128

{{#barcode value "CODE128" 200 100}}

{
    "value": "12345678"
}

CODE11

{{#barcode value "CODE11" 200 100}}

{
    "value": "01234567"
}

CODE39

{{#barcode value "CODE39" 200 100}}

{
    "value": "ABC1234"
}

UPCA

{{#barcode value "UPCA" 200 100}}

{
    "value": "72527273070"
}

MSI

{{#barcode value "MSI" 200 100}}

{
    "value": "01234567"
}

ISBN

{{#barcode value "ISBN" 200 100}}

{
    "value": "9781234567897"
}

EAN13

{{#barcode value "EAN13" 200 100}}

{
    "value": "978020137962"
}

ITF14

{{#barcode value "ITF14" 200 100}}

{
    "value": "01234567890123"
}

qrcode

This operation allows you to insert a QR code into your template. You only need to set one parameter: the width in pixels. Since QR codes are always square, the height will match the width automatically.

Template

Data

Result

{{#qrcode value 150}}
{
    "value": "https://plumsail.com/"
}

the qrcode

#qrcode operation result

There are different types of QR codes, you can specify it in the JSON.

URL

To encode the text of a URL, for example, https://plumsail.com/, encode the https://plumsail.com/ URL text in the JSON. Include the http:// protocol to ensure it is recognized as a URL.

{
      "value": "https://plumsail.com/"
}

Telephone Numbers

To encode a telephone number, use a telephone URI to ensure that the digits are recognized as a telephone number and include prefixes which make the number internationally accessible.

{
      "value": "tel:+1-234-555-6677"
}

SMS

To encode an SMS short code or number, create an SMS URI. For example, to create a link to the 12345 number, encode sms:12345. You may use other URI forms, such as sms:number:subject, and other prefixes, such as smsto:.

{
      "value": "sms:12345"
}

Geolocations

To encode a point on the earth, including altitude, use a geo URI.

{
      "value": "geo:42.65049,23.37925,100"
}

Hint

Read this article to get inspired on how to enrich your documents with various QR codes.

checkbox

#checkbox - activates checkboxes in a your template.

For example, a user fills out some online form and the #checkbox operation activates checkboxes in a XLSX template depending on the forms’ values.

The resulting document could be an application or questionnaire.

Template

Data

Result

{{#checkbox prop1}}
{{#checkbox prop2}}
{
    "prop1": true,
    "prop2": false
}

XLSX file with activated checkboxes

#checkbox operation result

picture

The #picture operation resolves URL or base64 string and converts it to an image. This operation doesn’t compress the source picture and keeps its original quality.

There are several parameters that you can use to customize how the image comes out in the final document:

Parameter

Description

Examples

width and height

Default sizing options.

For example, to fit your picture into a 300x300 square, use the operation as follows: {{#picture imageData 300 300}}

To calculate the height automatically, feel free to just leave out the height parameter like so: {{#picture imageData 300}}

rotate

Allows you to rotate your picture by 90, 180, 270, or 360 degrees. Only those values are supported.

{{#picture imageData 100 rotate:90}}

flip

Flips the image horizontally (X), vertically (Y), or both (XY).

{{#picture imageData 100 flip:X}}

{{#picture imageData 100 flip:Y}}

{{#picture imageData 100 flip:XY}}

Fit

Picture proportions are preserved and fit into the specified size.

{{#picture imageData 100 50 Fit}}

Stretch

This is the default behavior. The picture will be stretched according to the specified sizes.

{{#picture imageData 100 50 Stretch}}

Feel free to mix and match these parameters. For example, if you want to fit the image to a 400x350 resolution, rotated it by 90 degrees and flip it both ways, you’d write it like this: {{#picture imageData 400 350 Fit rotate:90 flip:XY}}

Examples

Template

Data

Result

{{#picture imageData}},

{{#picture imageData 300}},

{{#picture imageData 150 200}},

{{#picture imageData 200 300 flip:Y}},

{{#picture imageData 300 rotate:270}},

{{#picture imageData 100 50 flip:XY rotate:90}}

{{#picture imageData 100 50 Fit flip:XY rotate:90}}
{
    "imageData": "https://picturesite.com/pics/picture.png"
}


{
    "imageData": "iVBORw0KGgoAAAANSUhEUgAAAIAAAAA9CAYAAABlamFgAA"
}
the image

pictureCompress

The #pictureCompress operation resolves URL or base64 string and converts it to an image. This operation compresses the source picture.

There are several parameters that you can use to customize how the image comes out in the final document:

Parameter

Description

Examples

width and height

Default sizing options.

For example, to fit your picture into a 300x300 square, use the operation as follows: {{#pictureCompress imageData 300 300}}

To calculate the height automatically, feel free to just leave out the height parameter like so: {{#pictureCompress imageData 300}}

rotate

Allows you to rotate your picture by 90, 180, 270, or 360 degrees. Only those values are supported.

{{#pictureCompress imageData 100 rotate:90}}

flip

Flips the image horizontally (X), vertically (Y), or both (XY).

{{#pictureCompress imageData 100 flip:X}}

{{#pictureCompress imageData 100 flip:Y}}

{{#pictureCompress imageData 100 flip:XY}}

Fit

Picture proportions are preserved and fit into the specified size.

{{#pictureCompress imageData 100 50 Fit}}

Stretch

This is the default behavior. The picture will be stretched according to the specified sizes.

{{#pictureCompress imageData 100 50 Stretch}}

Feel free to mix and match these parameters. For example, if you want to fit the image to a 400x350 resolution, rotated it by 90 degrees and flip it both ways, you’d write it like this: {{#pictureCompress imageData 400 350 Fit rotate:90 flip:XY}}

Examples

Template

Data

Result

{{#pictureCompress imageData}},

{{#pictureCompress imageData 300}},

{{#pictureCompress imageData 150 200}},

{{#pictureCompress imageData 200 300 flip:Y}},

{{#pictureCompress imageData 300 rotate:270}},

{{#pictureCompress imageData 100 50 flip:XY rotate:90}}

{{#pictureCompress imageData 100 50 Fit flip:XY rotate:90}}
{
    "imageData": "https://picturesite.com/pics/picture.png"
}


{
    "imageData": "iVBORw0KGgoAAAANSUhEUgAAAIAAAAA9CAYAAABlamFgAA"
}
the image