Friday, March 12, 2010

Font Style Formula in Crystal reports

Under certain scenario’s, the need to have some Bold text fields in the report detail section is a common requirement.

The usual technique is to create 2 identical detail sections; use the compress logic based on the scenario. One of these sections will have the fields as Bold. The problem with this flow is that each time we make a change in fields (length\font), we need to do it both sections and take care of the alignment issues.

The alternate method I found more efficient is to use only 1section. Change each field format - Use the formula for the Style section.
if (Need Regular) then
  crRegular
else if (Need Bold Font) then
   crBold
else if (Need Italic Font ) then
   crItalic
else if (Need Bold+Italic) then
   crBoldItalic
else
   crRegular