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)
![](https://media.barcodewiz.com/images/6395f57a-3be3-49c8-850a-ae0deefe41de-ssrs_report_preview_4_videotutorial.png)
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...
![](https://media.barcodewiz.com/images/acf2855d-8ae0-451e-9084-d3501c06a44e-ssrsdll2.png)
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
![](https://media.barcodewiz.com/images/3fcfd42c-39b6-40a5-8b18-9bcab5ad11f8-ssrsdll3_1.png)
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
![](https://media.barcodewiz.com/images/5531dc64-a0a8-440b-922d-343d6478f265-ssrsdll4_1.png)
Step 3. Edit Properties
- Right-Click > Expression...
![](https://media.barcodewiz.com/images/1dbf80b0-6fdb-4e18-82fd-dca20e211718-ssrsdll5_1.png)
- Edit the expression as shown
- We are using the function Code128B()
![](https://media.barcodewiz.com/images/f370b730-af55-492b-80c3-b4998b10ff90-ssrsdll6_4.png)
- Let's preview the report. It should look like this:
![](https://media.barcodewiz.com/images/a28f7946-6190-4095-b9db-28659056e8ea-ssrsdll7.png)
Step 4. Set Font Properties
- Set Font Name to: BCW_Code128B_2
- Set Font Size to: 22
![](https://media.barcodewiz.com/images/0375e2b7-68bf-42a6-83d8-832304d5f1c1-ssrsdll8.png)
![](https://media.barcodewiz.com/images/f6eb4c0f-53c3-45bd-a9b5-04ae7100d8aa-ssrsdll9.png)
The Result
- The report is now ready.
![](https://media.barcodewiz.com/images/3a9b4562-af9b-460f-8d60-f3d61c686676-ssrsdll10.png)
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)
![](https://media.barcodewiz.com/images/a429d7d9-f71c-4107-a361-e06e58bfbaf8-c128_ssrs_combine1.png)
- Two fields separated by comma (with spaces):
=Code.MyCode128.Code128B( Fields!item_sku.Value + "," +
Fields!item_name.Value)
![](https://media.barcodewiz.com/images/2c39b0ce-fd3a-4b20-a8ab-5f1eac5696c1-c128_ssrs_combine2.png)
- Two fields separated by TAB:
=Code.MyCode128.Code128B( Fields!item_sku.Value + "^009" +
Fields!item_name.Value)
![](https://media.barcodewiz.com/images/512751da-8c92-489f-94b6-f49f8927a37b-c128_ssrs_combine3.png)