Crystal报告11:如何处理或修剪特殊字符

phi*_*ill 7 crystal-reports

在我的水晶报告中,我注意到从表中拉出的一个字段有特殊字符.更具体地说,回车和制表符.有没有办法解决这个问题,所以它在我的报告中没有显示空白?

提前致谢.

Jos*_*ons 10

这应该这样做:

stringvar output := {TABLE_NAME.FIELD_NAME};
output := Trim(output);  //get rid of leading & trailing spaces
output := Replace(output,Chr(13),'');  //get rid of line feed character
output := Replace(output,Chr(10),'');  //get rid of carriage return character

//add any other special characters you want to strip out.
Run Code Online (Sandbox Code Playgroud)

如果您要删除很多字符,则可以使用这种稍微更加漂亮的方法.只需将要删除的任何字符添加到[]中:

stringvar input := {DROPME.TEST_FIELD};
stringvar output := '';
numbervar i;

input := Trim(input);

for i := 1 to Length(input) Step 1 do
  if not(input[i] in [Chr(13),Chr(10)]) then
    output := output + input[i];

output
Run Code Online (Sandbox Code Playgroud)