[]
        
(Showing Draft Content)

EAN-13

EAN-13 barcode 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 adds 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. This is mainly used in supermarkets and other retail businesses.

The below image displays EAN-13 barcode in a PDF document.

EAN-13 barcode

Formula definition

You can set EAN-13 barcode 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)

Note: The 'labelPosition' parameter can only be set to top or bottom. This holds true for all the barcodes that support 'labelPosition' parameter in GcExcel.

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 EAN-13. 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 in the worksheet.

// Create a new workbook
var workbook = new GrapeCity.Documents.Excel.Workbook();

// Set worksheet layout and data
IWorksheet worksheet = workbook.Worksheets[0];
worksheet.Range["B:C"].ColumnWidth = 15;
worksheet.Range["D:G"].ColumnWidth = 20;
worksheet.Range["4:7"].RowHeight = 60;
worksheet.Range["A:A"].ColumnWidth = 5;
worksheet.Range["B2"].Value = "EAN-13";
worksheet.Range["B2:F2"].Merge(true);
worksheet.Range["B3:G3"].Value = new object[,]{
    {"Name", "Number", "Defult", "Change addOn", "Change addOnLabelPosition", "Explain"}
};
worksheet.Range["B4:C7"].HorizontalAlignment = HorizontalAlignment.Center;
worksheet.Range["B4:C7"].VerticalAlignment = VerticalAlignment.Center;
worksheet.Range["B2:F3"].HorizontalAlignment = HorizontalAlignment.Center;
worksheet.Range["B2:F3"].VerticalAlignment = VerticalAlignment.Center;
worksheet.Range["B4:C6"].Value = new object[,]
  {
    {"Medicine", "692031229621"},
    {"Pen", "6945091701532"},
    {"value length is 13", "8142486545683"}
  };
worksheet.Range["G6"].Value = "No EAN-13 generated, because the last digit is check-sum digit and it is invalid";
worksheet.Range["G6"].Font.Color = Color.Red;
worksheet.Range["B4:C6"].WrapText = true;
worksheet.Range["G6"].WrapText = true;
worksheet.PageSetup.Orientation = PageOrientation.Landscape;
worksheet.PageSetup.PrintGridlines = true;

// Set formula
for (var i = 4; i < 7; i++)
{
   worksheet.Range["D" + i].Formula = "=BC_EAN13" + "(C" + i + ")";
   worksheet.Range["E" + i].Formula = "=BC_EAN13" + "(C" + i + ",,,,,22)";
   worksheet.Range["F" + i].Formula = "=BC_EAN13" + "(C" + i + ",,,,,22,\"bottom\")";
}

// Save to a pdf file
workbook.Save("ean13.pdf");