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

EAN-13 barcode is a code that makes use of numeric characters (twelve numbers) and a check digit. This barcode accepts only twelve numbers as a string to calculate a check digit (CheckSum) and add it to the thirteenth position. The check digit is an additional digit that can be used to verify that the barcode has been scanned accurately. When the CheckSum property is set to True, the check digit is automatically added.

A screenshot depicting EAN-13 barcode sparkline is shared below.

Formula definition

You can set EAN-13 barcode sparkline in a worksheet using the following formula:

=BC_EAN13(value, color, backgroundColor, showLabel, labelPosition, addOn, addOnLabelPosition, fontFamily, fontStyle, fontWeight, fontTextDecoration, fontTextAlign, fontSize, quietZoneLeft, quietZoneRight, quietZoneTop, quietZoneBottom)

Parameter

Name Description
value Specifies that the value length must be 12 or 13.
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)'
showLabel Specifies whether to show label text when the barcode has label.
labelPosition ​A value that represents the label position when the label is shown.
addOn ​A string that represents the add text of QRCode. Specifies that  value length must be 2 or 5.
addOnLabelPosition The position to add the text when text is shown.
fontFamily A string that represents the label text fontFamily. The default value is 'sans-serif'.
fontStyle A string that represents the label text fontStyle. The default value is 'normal'.
fontWeight A string that represents the label text fontWeight. The default value is 'normal'.
fontTextDecoration A string that represents the label text fontTextDecoration. The default value is 'none'.
fontTextAlign A string that represents the label text fontTextAlign. The default value is 'center'.
fontSize A string that represents the label text fontSize. The default value is '12px'.
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 EAN13 sparkline in the worksheet.

JavaScript
Copy Code

var sheet = spread.getActiveSheet();

// Set EAN13 Barcode Sparkline
sheet.setValue(3, 1, "EAN - 13", GC.Spread.Sheets.SheetArea.viewport);
sheet.setValue(3, 2, "6920312296219", 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_EAN13(C4)');