30 Jun 2006

Avery Labels Printing via RDL / Reporting Services

I have just managed to solve the problem of how to give an application the ability to print Avery labels with data from our database. I only had to support two label formats (L7161 and L7163) and the data requirement was static as well. So I looked at RDL / Reporting Services and the Report Viewer control.

The way I wrote the report is as follows:
  • Set the page size to A4 and all the margins to 0cm.
  • Made sure that the report was not using a Header or Footer.
  • Placed one list control per column of labels on a sheet
  • Changed the size of the list control to be the same as a single label
  • Then set an expression on the list visibility based on the result of the rownumber modulus by the number of columns (making sure each column looked for a unique result)
  • Then added the textboxes for the data making sure there was a gap between the top and bottom of the list control. Also made sure that the text boxes didn’t push the list box size out.
I did have trouble trying to line the labels up 100% also using this approach does have some draw backs like updating will become a hard task and the use of the labels will be locked for one use only.

But now I have a template it should not be long before I will write Avery label component using RDL