【问题标题】:Page Wise totals on last page in RDLC reprotRDLC 报告最后一页的 Page Wise 总计
【发布时间】:2015-06-19 21:36:35
【问题描述】:

我在带有 MS Sql Express 的 VB (Visual Studio) 中使用 rdlc reprot。我想要如下所示的输出:

SrNo.      Amount
1          100
2          100
3          100
4          100
Group Total = 400
5          200
6          200
Page1 Total = 800
***************************PAGE1 END HERE****************
7.         200
8.         200
9          200
Group2 Total=1000
Page2 Total = 600
****************************PAGE 2 END HERE*****************

Page1 Total = 800
Page 2 Total =600

Grand Total = 1400
******************************LAST PAGE END HERE**************

除了最后一页的第 1 页总计和第 2 页总计之外,我可以获得所有输出。

对于 Group Total,我使用了 rdlc 的 Sum 函数和 Table1_Group2 Scope。

对于总计,我使用了具有数据集范围的 rdlc 的 Sum 函数。

对于每个页面上的 Page Wise 总计,我使用了带有代码 =Sum(ReportItems!amt.Value) 的 Reprot 页脚文本框。

如何在最后一页再次获得每一页的总和?

【问题讨论】:

    标签: report rdlc


    【解决方案1】:

    您可以在代码选项卡中使用 vb 代码。 添加共享列表属性和方法接受 2 参数 共 1 页 2- 页码(使用此方法“Globals!PageNumber.ToString()”) 在页脚和表达式中添加文本框调用此方法 在最后一页 ("Globals!PageNumber.ToString() = Globals!TotalPages.ToString()") 使用共享属性

    【讨论】:

      【解决方案2】:

      我已经在我的环境中测试过了,下面的步骤供大家参考。

      1-通过单击报告菜单-->报告属性打开报告代码窗口,然后单击代码选项卡

      2-在代码窗口中添加以下代码

      Public Shared PageTotal As System.Collections.Generic.Dictionary(Of Integer, Decimal)
      Public Shared Function Total(ByVal Item As Integer, byval Amount As Decimal) As Decimal
      If PageTotal Is Nothing Then
      PageTotal = New System.Collections.Generic.Dictionary(Of Integer, Decimal)
      End If
      If Not PageTotal.ContainsKey(Item) Then
      PageTotal.Add(Item, Amount)
      End If
      Return Amount
      End Function
      Public Shared Function GetTotal(ByVal Item As Integer) As String
      if Item=1 then return ""
      Return PageTotal(Item-1).ToString()
      End Function
      

      3-在报告页脚上,将您当前的表达式替换为以下内容 =Code.Total(Globals!PageNumber,Sum(Reportitems!Credit.Value))

      4-在页眉上,添加一个文本框并输入下面的表达式 =Code.GetTotal(Globals!PageNumber)

      运行项目

      ****注意 设置查看报告前的显示模式

      reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);

      【讨论】: