Barcode Image Generation in Spreadsheet Document

Note
The example reads the shop data described in The Business Layer.

Barcode Generation in Microsoft Spreadsheet

Template Syntax

  • Add a textbox to your template at the place where you want a barcode image to be inserted.
  • Add the following syntax:
<<barcode [customer.Barcode] -qr>>
Tip
For detailed technical information about syntax, expressions and report generation by the engine, please visit: Working with GroupDocs.Assembly Engine

Download Template

Get the template from here.

The Code

Warning
On Linux, a QR code needs the workbook’s default font (its Normal style font) installed. This sample template is set in Arial, which ttf-mscorefonts-installer provides; a template set in Calibri, the Excel default, needs Calibri itself. Without the font the QR code cannot be drawn: the call raises Value cannot be null. (Parameter 'trueTypeFont'), and a substitute font such as Carlito is not used. See System Requirements.
import json

from groupdocs.assembly import DataSourceInfo, DocumentAssembler

with open("customer.json", encoding="utf-8") as f:
    customer = json.load(f)

assembler = DocumentAssembler()
assembler.assemble_document("barcode.xlsx", "barcode-report.xlsx", DataSourceInfo(customer, "customer"))

The following sample file is used in this example: barcode.xlsx

The following sample file is used in this example: customer.json

Binary file (XLSX, 13 KB)

Download full output

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.