【问题标题】:How can I prevent rounding off in rdlc report?如何防止 rdlc 报告中的四舍五入?
【发布时间】:2018-12-23 06:11:05
【问题描述】:

在 RDLC 中,一列输出是 2.099。我希望它是 2.09。我已经在 RDLC 表达式中使用了 Format 和 FormatNumber 函数。但输出是 2.10。但我需要 2.09。怎么样??

我尝试过以下方法:

=FormatNumber (Sum(Switch((Fields!IsConsiderGPA.Value) = True , (Fields!Credit.Value) * (Fields!GPA.Value) )) / Sum(Switch(Fields!IsConsiderGPA.Value = True , (Fields!Credit.Value))),2)

=Format (Sum(Switch((Fields!IsConsiderGPA.Value) = True , (Fields!Credit.Value) * (Fields!GPA.Value) )) / Sum(Switch(Fields!IsConsiderGPA.Value = True , (Fields!Credit.Value))),"N")

=Format (Sum(Switch((Fields!IsConsiderGPA.Value) = True , (Fields!Credit.Value) * (Fields!GPA.Value) )) / Sum(Switch(Fields!IsConsiderGPA.Value = True , (Fields!Credit.Value))),"D")

并且还更改了文本框属性中的数字类型。但是失败了.....

【问题讨论】:

    标签: report rdlc


    【解决方案1】:

    在你的表达式中使用 Math.Trucate,例如:

    =Math.Truncate(Sum(Switch((Fields!IsConsiderGPA.Value) = True , (Fields!Credit.Value) * (Fields!GPA.Value) )) / Sum(Switch(Fields!IsConsiderGPA.Value = True , (Fields!Credit.Value))))*100)/100

    然后,您可以在文本框属性的“数字”垂直选项卡中设置数字格式。

    【讨论】:

    • Here 是我设置小数点后 3 位而不四舍五入的答案,对吗?
    【解决方案2】:

    在“报告属性”下的代码选项卡中创建以下自定义函数:

        Public Function WithoutRound(vl As String)
    
            Dim temp As String
    
            temp = FormatNumber(vl, 4)
    
            temp = Left(temp, Len(temp) - 2)
    
            Return temp
    
        End Function
    

    并在文本框中使用它

    =Code.WithoutRound(Fields!RunningBalance.Value)

    【讨论】:

      猜你喜欢
      • 2021-10-29
      • 2019-08-14
      • 2023-01-12
      • 1970-01-01
      • 2022-11-21
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多