SpreadJS Documentation
Setting QRCode
SpreadJS Documentation > Developer's Guide > Managing Data Visualization and Objects > Working with Barcodes > Setting QRCode

QRCode is a two dimensional barcode representing symbology that enables effective handling of numeric, alphanumeric and byte data. This barcode can encode up to 7,366 characters.

A screenshot depicting QRCode barcode sparkline is shared below.

Formula definition

You can set QRCode sparkline in a worksheet using the following formula:

=BC_QRCODE(value, color, backgroundColor, errorCorrectionLevel, model, version, mask, connection, connectionNo, charCode, charset, quietZoneLeft, quietZoneRight, quietZoneTop, quietZoneBottom)

Parameter

Name Description
value A string that represents encode on the symbol of QRCode.
color A color that represents the barcode color. The default value is 'rgb(0,0,0)'.
backgroundColor A color that represents the barcode backgroundcolor. The default value is 'rgb(255, 255, 255)'
errorCorrectionLevel A string that represents the error correction level of QRCode. It has 'L|M|Q|H' four error correction levels. The default value is 'L'.
model A value that represents the model of QRCode. It has 1 and 2 models. The default value is 2.
version Vesion range is 1-14 for model1 and model 2. It has 'auto|1-14|1-40' values. The default value is  'auto'.
mask A value that represents mask pattern for QRCode. It has 'auto and 0-7' eight mask pattern.
connection A value that represents whether the symbol is part of a structured append message. The default value is false.
connectionNo Specifies which block the symbol is in the structured append message. It has '0-15' values. The default value is '0'.
charCode A value that represents the collection of characters of QRCode.
charset A value that represents which charset to use. It has 'UTF-8 and Shift-JIS'.
quietZoneLeft A value that represents the size of left quiet zone.
quietZoneRight A value that represents the size of right quiet zone.
quietZoneTop A value that represents the size of top quiet zone.
quietZoneBottom A value that represents the size of bottom quiet zone.

Using Code

This example code sets a QRCode sparkline in the worksheet.

JavaScript
Copy Code

var sheet = spread.getActiveSheet();

// Set QR Code Barcode Sparkline
sheet.setValue(3, 1, "QR Code", GC.Spread.Sheets.SheetArea.viewport);
sheet.setValue(3, 2, "Police:911", GC.Spread.Sheets.SheetArea.viewport);

// Set Style
sheet.setRowHeight(3, 100);
for (var col = 1; col < 4; col++)
{
    sheet.setColumnWidth(col, 200);
}
sheet.getRange(3, 0, 1, 4).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
sheet.getRange(3, 0, 1, 4).vAlign(GC.Spread.Sheets.VerticalAlign.center);

// Set Formula
sheet.setFormula(3, 3, '=BC_QRCODE(C4)');