【问题标题】:Display Serial Number as Roman letters in Crystal Reports在 Crystal Reports 中将序列号显示为罗马字母
【发布时间】:2012-06-17 06:07:01
【问题描述】:


需要在我的水晶报告中将序列号显示为罗马字母(i、ii、iii、iv 等)。我将序列号捕获为记录号(1,2,3,4...)。所以我必须在水晶报告中为它做些什么。

【问题讨论】:

    标签: crystal-reports crystal-reports-8.5


    【解决方案1】:

    只需使用水晶报表提供的Roman()函数

    【讨论】:

      【解决方案2】:

      我不能承担太多功劳;我只是将代码从 this VB Helper article 移植到 Crystal,但这是一个有趣的练习:

      NumberVar iCounter := 0;
      Local StringVar ch := "";
      Local NumberVar result := 0;
      Local NumberVar new_value := 0;
      Local NumberVar old_value := 0;
      Local StringVar temp := "";
      
      temp := UpperCase({?@Roman});
      
      old_value = 1000;
      
      For iCounter := 1 To Len(temp) do
      (
          // See what the next character is worth.
          ch := Mid(temp, iCounter, 1);
      
          if ch = "I" then new_value := 1
          else if ch = "V" then new_value := 5
          else if ch = "X" then new_value := 10
          else if ch = "L" then new_value := 50
          else if ch = "C" then new_value := 100
          else if ch = "D" then new_value := 500
          else if ch = "M" then new_value := 1000;
      
          // See if this character is bigger
          // than the previous one.
          If new_value > old_value Then
              // The new value > the previous one.
              // Add this value to the result
              // and subtract the previous one twice.
              result := result + new_value - 2 * old_value
          Else
              // The new value <= the previous one.
              // Add it to the result.
              result := result + new_value;
      
          old_value := new_value;
      );
      
      // Format the number without commas or decimals
      ToText(result, 0, "");
      

      只需将我的 {?@Roman} 参数占位符替换为您的变量,一切就绪。

      【讨论】:

        猜你喜欢
        • 2020-07-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-09-23
        • 1970-01-01
        • 2011-07-14
        • 1970-01-01
        相关资源
        最近更新 更多