BarCodeWiz Logo

GS1-128 (EAN-128) Barcodes with SQL Server Reporting Services SSRS

How to create barcodes in SSRS using BarCodeWiz Code 128 Barcode Fonts

  • This tutorial shows how to add GS1-128 (EAN-128) barcodes to SQL Server Reporting Services.
  • Barcodes are encoded using two text boxes: one for barcode image and one for human-readable text.
  • See the video. or simply follow the steps below.

Before You Begin


Step 1. Configure Report Properties

  • Open Properties Window - right-click in the report background area and click Report Properties...

Add Reference:

  • In the Report Properties window, select the References section
  • 1) Click Add to add the assembly
  • 2) Type: BarCodeWizFonts.Code128
  • 3) Click Add to add a class instance
  • 4) Type BarCodeWizFonts.Code128.Code128Fonts for class name and MyCode128 for instance name

Step 2. Verify your data source.

  • Ensure your Data Source and DataSet are in a correct format. The Barcode field is simply a text field with the full GS1-128 number.
  • Our data looks like this:

Step 3. Insert Data Text Boxes

  • Insert the text boxes into the report by dragging them from your DataSet.
  • Notice the Barcode field is inserted twice. This is our barcode image with human readable text.
  • We are placing the text boxes inside a Table (tablix). A tablix repeats the data once per each row in your DataSet.

Step 4. Edit Top Text Box Properties

  • Right-Click > Expression...

  • Edit the expression as shown
  • We are using the function GS1128()

  • Let's preview the report. It should look like this:

Step 5. Set Font Properties

  • Set Font Name to: BCW_Code128_2
  • Set Font Size to: 24

  • The Result So Far
  • Continue to Step 6 if you'd like to format the human-readable text.

(Optional) Step 6. Format text under barcode

  • Use the GS1128FormatText() function to format the human readable text under the barcode.
  • This function adds spaces, adds parentheses (if not supplied), and calculates check digits (if missing).

Done

  • This is the result after adding text formatting.

GS1-128 (EAN-128) Barcode Fonts Functions in SSRS


GS1128(barcode as String)

  • GS1128() Converts text into a proper GS1-128 (EAN-128) barcode. It accepts input in two possible formats (both formats produce the same barcode)
  • Format 1, with parentheses: GS1128("(XX)YYYYYY(XX)YYYYYY") - This is the preferred option. It adds any necessary FNC1 characters automatically. It also calculates and autocorrects check digits.
    Example: GS1128("(10)12345(30)123") or GS1128(Fields!FieldName.Value)
  • Format 2, with no parentheses: GS1128("XXYYYYYYXXYYYYYY") - This format requires the FNC1 characters to be added manually. To encode FNC1, enter: ^F1
    Example: GS1128("1012345^F130123") or GS1128(Fields!FieldName.Value)
  • This function should be used with one of the following fonts:
    BCW_Code128_1 through BCW_Code128_6 (does not show human-readable text)
  • This function requires the use of a barcode font without human-readable text. The text below should be displayed in a separate text box with a font such as Arial.
  • Example 1: =Code.MyCode128.GS1128("(01)95012345678903(3103)000123")
    Example 2: =Code.MyCode128.GS1128("01950123456789033103000123")
    Example 3: =Code.MyCode128.GS1128(Fields!ProductNumber.Value) - Encodes data from your ProductNumber column in your DataSet

GS1128FormatText(barcode as String)

  • This function formats the human readable portion of the barcode (the text). It adds parentheses and spaces. It also calculates and adds any necessary MOD10 check digits. Incorrect check digits are corrected automatically.
  • Example: =Code.MyCode128.GS1128FormatText("(01)9501234567890(3103)000123")
    Example Output: (01) 9 50 12345 67890 3 (3103) 000123

GS1128FormatText2(barcode as String)

  • This function formats the human readable portion of the barcode (the text). It adds parentheses. It does not add spaces. It also calculates and adds any necessary MOD10 check digits. Incorrect check digits are corrected automatically.
  • Example: =Code.MyCode128.GS1128FormatText2("(01)9501234567890(3103)000123")
    Example Output: (01)95012345678903(3103)000123

GS1128FormatText3(barcode as String)

  • This function formats the human readable portion of the barcode (the text) by grouping-by-4 digits. It calculates and adds any necessary MOD10 check digits. Incorrect check digits are corrected automatically.
  • Example: =Code.MyCode128.GS1128FormatText3("(01)9501234567890(3103)000123")
    Example Output: 0195 0123 4567 8903 3103 0001 23
 
 
 

GS1128FormatText4(barcode as String)

  • This function formats the human readable portion of the barcode (the text). It calculates and adds any necessary MOD10 check digits. Incorrect check digits are corrected automatically.
  • Example: =Code.MyCode128.GS1128FormatText4("(01)9501234567890(3103)000123")
    Example Output: 01950123456789033103000123

GS1128FormatTextCustom(barcode as String, format as String )

  • This function formats the human readable portion of the barcode (the text) in a user-defined format. It calculates and adds any necessary MOD10 check digits. Incorrect check digits are corrected automatically.
  • Example usage: =Code.MyCode128.GS1128FormatTextCustom("(01)9501234567890(3103)000123","??? ???? ?-?-?-??????????-??????")
    Example Output: 019 5012 3-4-5-6789033103-000123