Dim doc As New PrintDoc
Dim rt As New prt.RenderTable
Dim tb As Table = Tables("订单")
Dim ColNames As String() = New String(){"产品", "客户","单价", "数量", "金额"}
For c As integer = 0 To ColNames.Length -1
rt.Cells(0,c).Text = ColNames(c)
rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth
If ColNames(c) = "金额" OrElse ColNames(c) = "数量" Then
rt.Cells(1, c).Text = "[format(Fields!" & ColNames(c) & ".Value, ""#,###"")]" '设置绑定表达式
Else
rt.Cells(1, c).Text ="[Fields!"&ColNames(c)&".Value]"
End If
Next
rt.RowGroups(0,1).Style.TextAlignVert = prt.AlignVertEnum.Center '第一行内容垂直居中
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '将第一行作为表头.
rt.RowGroups(1,1).DataBinding.DataSource = BindTables("订单") '将第二行绑定到订单表
doc.Body.Children.Add(rt)
doc.Preview()