【问题标题】:Crystal reports 11: How to handle or trim special charactersCrystal 报表 11:如何处理或修剪特殊字符
【发布时间】:2013-12-04 07:31:04
【问题描述】:

在我的水晶报表中,我注意到从表格中提取的一个字段有特殊字符。更具体地说,回车和制表符。有没有办法把它去掉,所以它不会在我的报告中显示为空白?

提前致谢。

【问题讨论】:

  • 仅供参考,如果你想删除标签,Chr 代码是 Chr(9)。

标签: crystal-reports


【解决方案1】:

应该这样做:

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.

如果您有很多字符要删除,您可以使用这种稍微花哨的方法。只需将要删除的任何字符添加到 in[]:

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

【讨论】:

  • 我同时使用了 Chr(13) 和 Chr(10),因为我想将 Windows/DOS 回车转换为 HTML
    。顶级公式也适用于此目的。 :)
猜你喜欢
  • 2014-07-31
  • 1970-01-01
  • 1970-01-01
  • 2012-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多