Thursday 14 November 2013

How do I add scan-able barcode in my SSRS report?

Many times we need to show a barcode on ssrs report.
We might need it for SalesId, PurchId, ItemId, CustId etc.

Follow these steps to implement this:

1. On the temporary table of the ssrs report, add a new string field "Mybarcode".
2. Set the extended data type property to "BarCodeString".

Now we have added the field that would hold the barcode string. Now there are two phases we need to cover:
1. Implement logic in our report data provider class (RDP class) to populate our field "Mybarcode" with the barcode string.
2. Make changes in our report designer to display the newly added barcode field.

Add this code in your RDP class, in this example we are using ItemId field.
    Mybarcode= BarcodeCode128::construct();
    Mybarcode.string(true,myTmpTable.ItemId);
    Mybarcode.encode();
    myTmpTable.Mybarcode= barcodePurch.barcodeStr(); 
2.  Now open your ssrs report in the visual studio, update the data set. Make sure, it shows the newly added field.

Add a new text box in the report designer, set the expression and font as shown in the attached screenshots.
Well that's all you need to do.