As mentioned at the beginning of the chapter, Crystal Reports is a true Windows report writer. This means that it can use most of the fonts and graphical capabilities of Windows.
Don t hesitate to use symbol fonts that are installed on your computer. In particular, the Symbol and Wingdings symbol fonts are included as part of Windows and should be available to most target systems that will be running your report.
Caution | Don t forget that any fonts you use when designing your reports must also be present on the machine that runs your reports if you expect the report to look identical on both machines. Using Times Roman, Arial, Symbol, and Wingdings fonts, at a minimum, is pretty safe, because they are installed by default on all Windows systems. |
Both Symbol and Wingdings fonts contain typographical symbols instead of letters and numbers. Although you type letters and numbers into a text object or formula formatted with a text font initially, you ll see them replaced with the symbol characters once you change the font from a text font to one of the symbol fonts. You ll need either a font table (typically available from Windows Control Panel) or a little extra time to experiment and figure out what symbols display when you type certain letters , numbers , or special characters.
Figure 9-3 shows a report using the Wingdings font. In this example, the following formula is being displayed on the report next to the order amount, formatted using the Wingdings font:
If {Orders.Order Amount} < 1000 Then
"L"
Else
If {Orders.Order Amount} > 1000 And
{Orders.Order Amount} < 2500 Then
"K"
Else
"J"
If you are planning to create reports that approach the quality of output from page publishing programs, you ll soon have a need to use bitmap graphics in your reports. Bitmap graphics are common graphics files most often associated with the Web (such as .JPG files) or Windows paint program files (such as .BMP and .PCX, and .WMF files). You may have a company logo that you want included on the title page of the report. Or, you may want to add a smaller graphical element, such as an icon, to another section of the report.
To insert a bitmap graphic, first make sure you are displaying the Design tab. Although it s possible to add a graphic while viewing the Preview tab, this is risky, because you won t always be sure which report section the graphic will end up in. Click the Insert Picture button on the Insert Tools toolbar, or choose Insert Picture from the pull-down menus . A familiar File Open dialog box will appear, asking you to choose a bitmap format file. Navigate to the necessary drive and folder, and the dialog box will show any files at that location that can be added to the report. Choose the correct file and click OK.
An outline will appear alongside your mouse cursor. Drag the outline to the section of the report where you want the graphic to be placed, and click the left mouse button to drop it there. If the graphic happens to cover more than one report section, it will be dropped in the section where the upper-left corner of the outline is when the mouse is clicked. Once you drop the graphic, you ll see it appear in the Design tab.
You have complete control over how the graphic is sized and cropped. You can simply drag the graphic to a new location on the report, or resize it using the sizing handles on the sides and corners. You can also position the graphic (or any other object on the report, for that matter) with the Object Size and Position dialog box. Select the object that you want to position, right-click, and choose Size and Position from the pop-up menu. You can also choose Format Size and Position from the pull-down menus.
To format the graphic more precisely, you can use the Format Editor. Make sure the graphic is still selected. Then, click the Format button in the Expert Tools toolbar, right-click the graphic, and choose Format Graphic from the pop-up menu; or choose Format Format Graphic from the pull-down menus. The Picture tab allows you to specify exact cropping and scaling specifications.
Tip | Only common bitmap graphic formats are supported in Crystal Reports. It will not recognize specialized formats, such as Adobe Photoshop, or vector formats (other than Windows Metafile), such as those from CorelDRAW or Adobe Illustrator. If you wish to use these graphics in a report, you need to convert them to common bitmap formats with another program before adding them to your report. And if you wish to include graphics from web pages, you must use .JPG format ”Crystal Reports won t recognize .GIF files. |
Although using symbol fonts, such as Wingdings, is very powerful, you are limited to what is included in the font itself. Also, the symbols are generally simple two-dimensional images and can be displayed only in a single color . Wouldn t it be nice if you could use smaller bitmap files, such as icon-like graphics that look more three-dimensional and include several colors, on your report?
Because you can suppress bitmap files conditionally, just like other objects, you have real power and flexibility in creating visually appealing and interesting reports using bitmap graphics. Figure 9-4 shows a report with unique icons indicating the status of an order. Orders that have been shipped (or are closed ) have a closed file folder next to them. Open orders (not shipped) have an open file folder next to them.
This report uses a technique that could be called mutually exclusive suppression. There are two different bitmap files on the report: an open-file bitmap and a closed-file bitmap. They are placed right on top of each other in the details section. They are conditionally suppressed in such a way that only one will ever be displayed at a time. In this case, they are suppressed using the Shipped field (a Boolean field that returns true or false) from the XTRME Sample Database Orders table.
The open-file bitmap is conditionally suppressed using this formula:
{Orders.Shipped}
while the closed-file bitmap is conditionally suppressed using this formula:
Not {Orders.Shipped}
Because of this, only one bitmap will ever be visible at a time.
The success of this technique depends on Crystal Reports allowing multiple objects to be placed right on top of each other. You have the ability to do this with any text or graphic object whenever and wherever you choose. Just make sure you implement some technique similar to this to prevent them from splattering all over each other. You can also use the Move to Back, Move Backward, Move Forward, and Move to Front options from the Format pull-down menu or from the pop-up menu that appears when you right-click an object. These options determine which objects have priority when they are placed on top of each other.
You can use the Border tab on the Format Editor to control lines on all four sides of individual objects. While this lets the individual objects stand out by having lines or boxes appear around them, you may want more flexibility to have groups of objects highlighted with boxes or to have lines stretch partially or completely across sections.
Crystal Reports lets you use line and box drawing tools to create these boxes and lines. To create a line or box, ensure that you have the Design tab chosen . Inserting lines or boxes in the Preview tab may give you undesirable results if you don t put them in the right section.
To add a line or box to your report, perform these steps:
Click the Insert Line or Insert Box button in the Insert Tools toolbar. You can also choose Insert Line or Insert Box from the pull-down menus.
When you make either of these choices, your mouse cursor changes to a pencil. Point the pencil to where you want to begin the line or box, and hold down the left mouse button.
Drag the line or box to its ending position and release the button. Notice that you can draw only perfectly vertical or horizontal lines ”diagonal lines can t be drawn.
The line or box will appear on the report, complete with sizing handles. You can now drag or resize the line or box just like any other object. You may also format the line or box with the Format Editor (using options from the Format pull-down menu, or by right-clicking the line or box and choosing Format from the pop-up menu). You can choose the color, size, and style of the line or box, along with other options (Crystal Reports allows you to create rounded boxes, for example). Figure 9-5 shows a report that uses a horizontal line to delineate group footers, and places a filled, rounded box around report totals.
Tip | You can draw lines and boxes that traverse multiple report sections. This is handy if you want to have a single box enclose a column starting in the page header and ending in the page footer, including all the sections in between. However, this can sometimes result in odd behavior if, for example, you start a line in the page header but end it in the details section or a group footer. If your lines or boxes traverse sections, make sure you preview the report to check that you get the desired results. |