Crystal Reports: Passing Multiline Parameter Values

若如初见. 提交于 2020-01-04 14:01:07

问题


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


回答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.




回答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))




回答3:


Regardless of your parsing technique, you may want to use the Parameter's DefaultValues or CurrentValues collections. The DefaultValues collection populates the list of available values. The CurrentValues collection populates the list of selected values.



来源:https://stackoverflow.com/questions/324776/crystal-reports-passing-multiline-parameter-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!