To add a linear barcode in Crystal Reports, what you need is to create a formula field, calculate the barcode string for the field, and format the field with appropriate barcode fonts. Remember that many symbologies require start/stop characters as well as check characters - so you can not just format the field with a barcode font - you must convert the input to a valid barcode string.
There are two methods using external functions in Crystal Reports. The most widely used is to exploit the the Crystal Reports UFL (User Function Library). Anther method is to use Morovia Formula written in native Cyrstal Reports language. This article explains how to use Crystal Reports Formulas. If you are interested with working with UFL, click here.
Warning
Not all encoder functions are available in Crystal Reports Formula. Code128Ex
and EAN128Ex
are the two
that have no formula couterparts.
Advantages of using Crystal Reports Formula:
The formulas are embedded in the report file itself so all you need is to distribute the report file and the font.
Formula is easy to to use and maintain.
We use Crystal Reports version 9 for tutorial. If you are working on an earlier version the steps outlined still apply. You are authorized to use the Formulas provided by Morovia for free as long as you own a valid license to the font product. You are also allowed to distribute the formula with your report outside your organization with the purchase of a developer license.
The Morovia Formula component is included in every Fontware package (demo and release) as wells in Morovia Font Tools.
After you installed Morovia Font Tools, you can add Morovia Formulas into the Crystal Reports Repository to make them available to every new reports. To do this, perform the following steps:
Locate Morovia sample file (
crLinearFormulas.rpt
) under MoroviaFontTools folder (usually it is underc:\program files\common files\Morovia\MoroviaFontTools
folder). Open the file in Crystal Report by double clicking the file in Windows explorer.From the main menu select Formula Workshop. Expand the first node - Report Custom Function. Click every function to view the contents. Then click the button to add the function into Repository. Add every function into the Repository. If the program prompts that a version has already existed, click . After you finish, close the Formula Workshop and then close the sample file.
→ to pop up the
Now you are ready to use Morovia Formulas. You are now ready to use the functions.
In the following tutorial we will start with a blank report.
In the report we created several database fields. Now we want to add a barcode
field which encodes shipping ID. We choose Code128C
as
the barcode format.
First we switch to
design view
. This can be done with → (Ctrl+D)Now choose Field Explorer appear at the right side of the work space.
→ to haveWe are now ready to add the barcode field. Right click the Formula Fields to have the context menu pop up. Choose
Give a name to this new filed. In our case we simply call it
barcode
.Click on the Formula Workshop dialog pops up. Find Morovia barcode functions under the → → . If you can not find such section, it is likely that you did not add them into the respository.
button. TheSelect the appropriate barcode function (in our case is
Code128C
), double click it to make it appear in the bottom panel. Select the argument. Put the data field you want to encode. In our case, we put{Sheet1_.CustomerID}
because that filed is what we want to present in barcode form. Note that this field needs to be a text string. You can use Crystal Reports functionToText
to convert other format into text string.Dismiss the Formula workshop and return to the Field Explorer dialog.
Drag the new filed from Field Explorer to anywhere you want to place in the report.
Click on this new field, and format it with appropriate barcode font. In our case, we use
MRV Code128SA
and point size 12. Dismiss the Format dialog.Click on the Preview tab. the barcodes appear. We have successfully build a report with barcodes in minutes! Note that this tutorial uses the trial version of the Code128 Fontware, so the second barcode contains a “demo” watermark. This limitation will go away once you purchased the retail version.
Once you finish the report design, you can distribute your report application with Crystal run time files, barcode fonts. You do not need to distribute Morovia Formulas, because they are included in the report file.
First you must obtain enough license from Morovia Corporation. You can either purchase single user license for every computer you are going to install; or purchase a Corporate license if you have a large install base within your organization. If you want to distribute outside your company, a developer license is required.