Code 128 Barcodes with SQL Server Reporting Services SSRS -As Text
How to create barcodes in SSRS using BarCodeWizFonts.Code128.dll
- This tutorial shows how you can add barcodes to SQL Server Reporting Services.
- Barcodes are encoded using text inserted into a table. (see also: Create barcodes as Images)
Before You Begin
- Ensure BarCodeWizFonts.Code128.dll as well as the font files are installed on the server.
- See BarCodeWiz Fonts in SSRS - Installation
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. Insert a data column
- Drag and drop a one of your columns from your DataSet into the report.
- In this example, the data field is placed inside a Table
Step 3. Edit Properties
- Right-Click > Expression...
- Edit the expression as shown
- We are using the function Code128B()
- Let's preview the report. It should look like this:
Step 4. Set Font Properties
- Set Font Name to: BCW_Code128B_2
- Set Font Size to: 22
The Result
- The report is now ready.
Code 128 Fonts Functions in SSRS
Code128Auto(barcode as String)
- Code128Auto() Encodes data in the most efficient way possible, using a combination of subsets if necessary. Supports all 128 ASCII characters.
- 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. However, the text can easily be displayed in a separate formula field with a font such as Arial.
- To encode a control character, enter it in the format: ^000, where 000 is its digital ASCII value. For example, ABC^009 encodes ABC followed by TAB. To encode FNC1, enter: ^F1
- Example 1: =Code.MyCode128.Code128Auto("abc123")
Example 2: =Code.MyCode128.Code128Auto("abc123^009") - Encodes abc123 followed by TAB
Example 3: =Code.MyCode128.Code128Auto(Fields!ProductNumber.Value) - Encodes data from your ProductNumber column in your DataSet
Code128A(barcode as String)
- Code128A() Encodes data using Code 128 Subset A only. It supports numbers, upper case letters, control characters (such as tab or new-line), space, and the following: !"#$%&'()*+,-./:;<=>?@[\]^_
To encode a special character (like TAB), encode it in the format ^000, where 000 is the decimal ASCII number. - Use this function with one of the following fonts:
BCW_Code128A_1 through BCW_Code128A_6 (shows human-readable text under barcode)
BCW_Code128_1 through BCW_Code128_6 (does not show human readable text) - Example 1: =Code.MyCode128.Code128A("ABC123")
Example 2: =Code.MyCode128.Code128A("ABC123^009") - (Encodes ABC123 followed by TAB)
Code128B(barcode as String)
- Code128B() Encodes data using Code 128 Subset B only. It supports numbers, upper and lower-case letters, space, and the following characters: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
To encode special characters like TAB or CARRIAGE RETURN, use format ^000 where 000 is the decimal ASCII number (For example, ^009 for TAB). Special characters are supported by temporarily shifting to Subset A. This process is automatic. - Use this function with one of the following fonts:
BCW_Code128B_1 through BCW_Code128B_6 (shows human-readable text under barcode)
BCW_Code128_1 through BCW_Code128_6 (does not show human readable text) - Example 1: =Code.MyCode128.Code128B("abc123")
Example 2: =Code.MyCode128.Code128B("abc123^009") - Encodes abc123 followed by TAB
Example 3: =Code.MyCode128.Code128B(Fields!ProductNumber!Value) - Encodes data from your ProductNumber column in your DataSet
Code128C(barcode as String)
- Code128C() Encodes data using Code 128 Subset C. It supports numbers only and must contain an even number of digits.
- The digits are encoded in pairs of two, resulting in a barcode about half as wide as subset A or B.
- Use this function with one of the following fonts:
BCW_Code128C_1 through BCW_Code128C_6 (shows human-readable text under barcode)
BCW_Code128_1 through BCW_Code128_6 (does not show human readable text) - Example 1: =Code.MyCode128.Code128C("00123456")
Example 2: =Code.MyCode128.Code128C(Fields!ProductNumber!Value) - Encodes data from your ProductNumber column in your DataSet
Combine Data from Two or More Fields
- Two fields separated by space:
=Code.MyCode128.Code128B( Fields!item_sku.Value + " " +
Fields!item_name.Value)
- Two fields separated by comma (with spaces):
=Code.MyCode128.Code128B( Fields!item_sku.Value + "," +
Fields!item_name.Value)
- Two fields separated by TAB:
=Code.MyCode128.Code128B( Fields!item_sku.Value + "^009" +
Fields!item_name.Value)