Crystal Reports: Passing Multiline Parameter Values

10,557

Solution 1

If you want to retain line breaks you should replace them with something obscure as described by sindre j. In order for the line breaks to display correctly in Crystal Reports you need to replace the obscure characters in a Crystal Report formula with html breaks. Then add your formula field to the report and right-click, select 'Format Field', select the 'Paragraph' tab, and change the 'Text Interpretation' to 'HTML Text'. You also need to make sure the 'Can Grow' attribute is checked on the 'Common' tab. See the example formula below:

"<html>" + Replace({?ParameterField}, "___", "<br>") + "<html/>"

Hope this helps.

Solution 2

You have to replace the \r\n pair with something obscure before passing it to the report, then make a crystal formula that converts it back to cr-lf pair in the report.

Example with converting cr-lf to three underscores

C#

ReportDocument.DataDefinition.FormulaFields[somefield].Text = textWithCrLf.Replace("\r\n","___");

Crystal formula:

Replace({somefield}, "___", chr(13))

Share:
10,557
Admin
Author by

Admin

Updated on June 13, 2022

Comments

  • Admin
    Admin almost 2 years

    I want to pass some parameters to a Crystal Report like this:

    ReportDocument.DataDefinition.FormulaFields[parameterName].Text   = 'Text';
    

    This workes fine unless I want to pass a multiline textbox from ASPX (containing \n and \r chars.)

    The reportviewer reports that "The matching ' for this string is missing.".

    Is there any example/list/suggestion how to parse the (multiline) text and make this work?

    Thanks,

    Stefan