表格于统计代码如下:
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()
rt.Cols.Insert(0) '在左边插入一列,用于打印行号
rt.Cols(0).Width = 10 '设置行号列的宽度
For i As Integer = 1 To rt.Rows.Count - 1
rt.Cells(i,0).text = i '逐行写入行号
Next
请教下老师上面的代码怎么改才能让生成的行号随着数据增加?