phone: (540)338-0194
email: ken@kenhamady.com

ReCrystalize

(The following material was submitted by David White, a Crystal Reports developer and instructor in the UK. )

The Quest for the Perfect Table

 If you have ever attempted to construct tables within a Crystal report, you will have discovered the inadequacies of the drawing tools and your ability to control them. There isn’t a dedicated Table tool of any description, so you have to resort to manually drawing lines and boxes around your report items. You can easily end up with a table which, although it serves its purpose, doesn’t look quite right. Horizontal lines which don’t meet up with verticals. Spacing within rows which is varying, giving an unprofessional, uneven appearance ... the list goes on.


As someone who has been frustrated by this, and it seems to be an issue which the software developers consider low priority, because it doesn’t look like the drawing options have been changed through a number of version upgrades, I have managed to work out some ways in which I can arrive at a reasonable looking table without pulling my hair out. I thought it might be of use to share a few tips.

 

1.       Change the default grid size and make sure Snap To Grid is selected

For v2008, these properties are located on the Layout Tab in the menu under "File => Options".

 

I usually work with 1/10th of a centimetre (0.1), but it appears Crystal can’t handle this exactly, it changes it to 0.101. Near enough! This makes the grid appear with a dot pattern which makes your eyes go crossed, but it is much more manageable.

 

2.     Go in the menu to "View => Guidelines => Design view".  This helps you to see where your Guides are set by placing horizontal and vertical dotted lines on the page.

 

3.       Now you are ready to draw the outside borders of your table. You can either use the Draw Box tool, or draw individual Top/Bottom/Left/Right lines. A box can ‘cross’ the section boundaries, as can vertical lines. So here we go

 

a.       First, place four guides on the rulers, one for each side of your table. The guides will ‘snap to’ the grid dividers, just as drawn objects will. That is to say, when you drag to draw, you will ‘feel’ your drawing tool step through the 1/10th increments. I found something interesting here. When you use the box tool, the vertical edges of the box are truly snapped to the guides – when you drag a guide on the top ruler, it resizes the box. I couldn’t get this to happen with the horizontal lines, or when I used the line tool.

 

 

 

 

 

b.      Create two measure line tools, one horizontal and one vertical. These are just short lines which you will use to ‘jump’ down or across the number of grid increments in order to make your rows and columns equal width (if that’s what you need). I colour mine red.

c.       Let’s start with the rows. Drag or use the keyboard arrow keys to position your horizontal measure on the top row of your table, overlapping the vertical border

d.      Now press the down arrow key on the keyboard and count how many times, to position the measure tool where you need the first row divider to be. (Here, it’s 7 jumps)

e.      Grab the Line tool and starting at the point where your measure tool hits the vertical border, drag to draw your line across the table. You should find that the drawn line snaps to the grid, so you get a perfect ‘joint’ at both ends.

If not, you can move the line left or right using the keyboard right/left arrow keys and you will still be using the grid to align correctly. If you drag manually, you may find you end up ‘in between’ the gridlines. You can lengthen or shorten the line by using Shift + right/left arrow key – again,

If you are working with a table which was constructed before you reset the grid measurement, you may well find that existing lines ‘fall between’ the new gridlines, and if you try to nudge the line using arrow keys, it doesn’t solve the problem. What you need to do is to select the line, cut it to the clipboard (Ctrl + X), then paste (Ctrl + V). When you click to re-place the line, it will now be on the gridlines.

f.        Next, reselect your measure tool line, and press the down keyboard arrow key the same number of times you previously counted to get the position of the next row divider. Draw this line in the same way you did the first one ... and keep on going until you have the correct number of rows.

4.       You can use the exact same method for your vertical column dividers using your vertical measure tool.

When you have finished, you should have a perfectly regular table, with evenly spaced rows and columns. All that is left to do is to delete the measure tools. And populate the table, of course.