Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

2.07 Tutorial 2-1. Formatting Text Objects

Tutorial 2-1. Formatting Text Objects

This tutorial demonstrates various formatting properties of the text object. Over the next few pages, you’ll add text objects to the Sandbox.rpt report and see how different formatting options affect the output.

  1. Add a text object to the report by right-clicking anywhere on the report and selecting Insert Text Object. You can also click on the menu option Insert > Text Object. This changes the mouse to a crosshair.
  2. Move the mouse to where you want the top left corner of the text object to be. I’m going to place my text object in the Report Header section, but you can add yours wherever you like.
  3. Click on the mouse button and hold it down to expand the text object to the size you want it. Let go of the mouse to finish. This places the cursor in the text object so you can type something.
  4. Type whatever you like in the text object. In my report I entered “This is a text object.” Remember, we are just playing around here so don’t stress out over what you put in the text object. Hopefully you are more creative than I am!


Using Fonts and Borders

This text object isn’t very exciting, so let’s spruce it up a bit! The most obvious thing you can do with text is change the font. Right-click on the text object and select Format Text. This opens the Format Editor. There are five formatting tabs here, but we’ll just look at the Font tab for now. The other tabs are discussed soon.



Figure 2-10. Font properties on the Format Editor dialog box.

The Font tab is pretty simple to understand. The top section lets you change the font, the style (regular, bold, italic), the font size and the color. The other sections let you set effects like strikeout and underline. You can also set the spacing between each character. I’m going to make my text a little more interesting.

  1. Right-click on the text object with the mouse and select Format Field. This opens the Format Editor dialog box.
  2. Click on the Font tab.
  3. Set the font to Comic Sans MS, the size to 30 and enable strikeout. At the bottom of this dialog box is a sample showing the effect your changes will make.
  4. Feel free to experiment any make more changes if you wish. Click the OK button when you are finished and want to see it on the report.

The Color property lets you use a color scale to specify a custom color. A new feature of Crystal Reports XI R2 is that it automatically saves any custom colors you create. You can open up a new report and it will show any custom colors created on previous reports.

The Border tab of the Format Editor lets you add a border around the text object, change the border style (single, double, dashed, dotted), and set the color. It also lets you add effects like a drop shadow or a background color.



Figure 2-11. Border properties on the Format Editor dialog box.

Let’s create a new text object and format it to be inverse.

  1. Create another text object (displaying any text you want) and open the Format Editor dialog box using the steps shown earlier.
  2. Click the Border tab.
  3. Click the Background option to select it and change the background color to Blue. Since the background is blue and the text is black, it will be difficult to read.
  4. Go to the Font tab and set the color of the text to White. Also set the style to Bold so that it stands out more. Click the OK button to save your changes. If you click on the Preview button your report might look similar to mine.


Financial reports use border formatting to give emphasis to certain types of numbers. The most common being sub-totals and grand totals. Sub-totals frequently display a single line below the number. Grand totals will have a single line above the number and a double-line below the number to make it stand out more.

Even though it’s easy to open the Format Editor dialog box to change the font and borders, it’s much easier to use the Formatting toolbar. Look at the top of the screen and it should be the second toolbar below the menu items (assuming you haven’t moved your toolbars around).


The first few items set the font and the font size. The next few buttons change the style. After that you can change the alignment, color, borders, etc. Just highlight the text you want to format and click on the button. Although not every formatting option is on this toolbar, the most common ones are there.

Rotating Text

Crystal Reports has another trick up its sleeve. It lets you rotate text vertically. You can rotate it either 90 or 270 degrees. Go to the Format Editor again and on the Common tab you’ll see the Text Rotation property in the middle. It’s set to zero by default (horizontal).


Formatting Paragraphs

The text objects we’ve created so far only display one line of text. But some formatting options are designed to display text in paragraph format. But first you have to make the text object large enough to display multiple lines. Select the text object and drag its corners to make the text object taller. The Paragraph tab from the Format Editor dialog box is shown in Figure 2-12.



Figure 2-12. Paragraph properties on the Format Editor dialog box.

The top portion has the paragraph indentation properties for the first line and left and right margins. This lets you offset the first line from the remaining text. The other options control the line spacing and the alignment.

If you have to print a lot of text in one area, some parts of the text might need to be formatted differently than the rest. For example, you might want to underline individual words to signify importance. Rather than format a bunch of text objects and line them up side by side, Crystal Reports supports RTF (Rich Text Format) output. This means that a single text object can have multiple formats applied to different parts of the text. To do so, type in all the text as you normally would. Then go back and highlight just the text that needs special formatting. Click the appropriate button on the Format toolbar and it gets applied to the highlighted text. Let’s try another example.