Home > Crystal Reports, Ripplestone, Ripplestone Tips > Truncating Fields in the Crystal Reports Web Viewer

Truncating Fields in the Crystal Reports Web Viewer

The Problem

There are times when building a Crystal Report that you want a field to be short and if the data is too long for the field for it to be truncated.  This works fine when developing the report in the Crystal Reports Designer, but when you publish the report to Ripplestone and run the report the data in the field will overlap with the field(s) to the right. 

The screenshot below is from the Crystal Reports Web Viewer and the HTML that is generates allows the data to “spill-over” to the two fields to the right of the Title field.

FieldOverlapWebViewer

What you want it to look like is this.  The screen shot below is the same report, but the viewer in Ripplestone was changed to pdf.  When exporting to pdf Crystal Reports does the proper thing and truncates the data in the Title field to the length that was set at design time.

FieldPDFViewer

 

The Solution

To fix the problem we need to head back to the Crystal Reports Designer and make a change to the field that is overflowing (the Title field in the example).  Open the Format Editor by right clicking on the field and selecting the Format Field option.  On the Common tab we want to check the Can Grow option and set the Maximum number of lines to 1.

CRFormatEditor

After making the change to the report you can re-publish the report to Ripplestone and the field should be truncated and will fit the set width.  Below is the report in the Crystal Reports web viewer after the Can Grow option has been checked.

FieldAfterCanGrow

 

Conclusion

If you have a field in a Crystal Report that needs to be a specified width and cannot flow over to other fields and you need to view the report in the Crystal Reports Web Viewer you will need to set the Can Grow option along with the Maximum number of lines option.  Setting these two options in the Crystal Reports designer and then publishing that report to Ripplestone will cause the field to be truncated when displayed with the Crystal Reports Web Viewer.

Thanks to Patrick Kansa for help with this solution.

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.