表格与统计
用表格形式统计不同产品的销售额。
代码如下:
Dim
 doc 
As New PrintDoc
Dim rx As 
New prt.RenderText
Dim rt As 
New prt.RenderTable
Dim Agg1 As 
New prt.DataBinding.Aggregate("数量小计")
Dim Agg2 As 
New prt.DataBinding.Aggregate("金额小计")
rt.Style.GridLines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 1
rt.Cells(0,0).Text 
= "产品"
rt.Cells(0,1).Text 
= "数量"
rt.Cells(0,2).Text 
= "金额"
rt.Cells(1,0).Text 
= "[Fields!产品.Value]"
rt.Cells(1,1).Text 
= "[Aggregates!数量小计.Value]"
rt.Cells(1,2).Text 
= "[Aggregates!金额小计.Value]"
With rt.RowGroups(1,1)
    .DataBinding.DataSource = BindTables("订单")
    .DataBinding.Grouping.Expressions.Add("Fields!产品.Value")
    agg1.DataBinding = .DataBinding 
    agg1.Running = 1
    agg1.ExpressionText = 
"Fields!数量.Value" 
    doc.DataSchema.Aggregates.Add(agg1)
    agg2.DataBinding = .DataBinding 
    agg2.Running = 1
    agg2.ExpressionText = 
"Fields!金额.Value" 
    doc.DataSchema.Aggregates.Add(agg2)
End With
doc.body.Children.Add(rt)
doc.Preview()
执行结果:

 
    
本页地址:http://www.foxtable.com/webhelp/topics/1266.htm