Thursday 2 April 2009

Generate Code 128 Barcode in Excel

Code 128 barcode is a high-density linear symbology that encodes text, numbers, numerous functions and the entire 128 ASCII character set (from ASCII 0 to ASCII 128). The barcode itself consists of a start character, data digits, a modulo 103 check digit and a stop character as shown below:



Barcode is just like any other font. First of all, you need to install barcode fonts on the Window system before you can use it anywhere, including Labview, notepoad or any other text editor. You may download the barcode fonts free from here.

Steps to install Font Code 128:

For Window XP
Go to control panel and open it. Then, find the fonts folder and double click on it. Finally, drag the fonts (files ending with .tiff) into the font folder.

For Window Vista
After extracting the fonts, right click on each font and select "install" in the popup menu.

On both systems, it is very likely that you will not see the fonts until after you reboot.

Since Code 128 barcode requires a check digit in the barcode (or it will not scan), you need to a converter unless you are writing your own application to create a barcode.

So, you can download the .NET DLL here to compute the check digit and creating the barcode string for use in your applications. This DLL encodes the data in multiple variants (b and c) to save linear space.

Barcode Generation in External Text Editor using Labview:

Technically, when you write into a file, you would still be writing a string of ASCII characters. Meaning that by default, you would be seeing numbers when you open it using any external text editor.

The problem with notepad is that is is capable of only displaying ONE font style for the whole document. For your implementation, you would need to display at least two (the human readable font and the barcode font) and this functionality is provided by Microsoft Word/Excel.

Next trouble is that you won't be able to change the text style just by using the basic File IO functions in Labview because there is no configuration options for font styles. A workaround would be to use the Report Generation Toolkit's VI.

With this, you can choose to save your file either in Word or Excel by changing the font format through Excel Easy Text.vi as shown below.




Code 128.vi