Reporting Services中如何对数据进行分页合计?

Report services中不直接支持分页合计,实现这个功能得加些vb code(report code).
  • 右键report区域(BIDS中最外层的黄色区域),选择report properties;打开code tab.
  • 加入如下代码

public shared Dim _rowCount As Int32=0
public shared Dim _sum as Int32=0

public Function AddToRowCount() as Int32
 _rowCount = _rowCount + 1
 return _rowCount
End Function

public Function AddToSum(ByVal quantity as Int32) as Int32
 _sum+=quantity
 return quantity
End Function

public function GetSum() as Int32
 Dim currentSum= _sum
 _sum=0
 return currentSum
end function

public Function GetCurrentCountAndReset() As Int32
  Dim currentRowCount = _rowCount
  _rowCount = 0
  Return currentRowCount
End Function

  • 实现row index.

添加一个新列,设置它的expression为=Code.AddToRowCount

  • 实现quantity sum.

设计Quantity列(显示数额的列)的expression为=Code.AddToSum(Fields!Quantity.Value)

在Footer加入textbox, 并设置表达式为=Code.GetSum

Advertisements
This entry was posted in 计算机与 Internet. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s