这个又如何 写合计呢(垂直方向)
Dim dtb As New DataTableBuilder("配送单")
dtb.AddDef("客户", Gettype(String), 16)
dtb.AddDef("地址", Gettype(String), 20)
dtb.AddDef("收货人", Gettype(String), 16)
dtb.AddDef("联系电话", Gettype(String), 16)
For Each prds As String() In DataTables("订单明细").GetValues("产品|规格")
dtb.AddDef(prds(0)& "_" & prds(1), Gettype(String))
Next
dtb.Build()
For Each cus As String() In DataTables("订单").GetValues("客户名称|客户地址|收货人|联系电话","送货员= '侯先童'","所属乡镇")
Dim dr As DataRow = DataTables("配送单").AddNew()
dr("客户") = cus(0)
dr("地址") = cus(1)
dr("收货人") = cus(2)
dr("联系电话") = cus(3)
For Each prds As String() In DataTables("订单明细").GetValues("产品|规格")
dr(prds(0)& "_" & prds(1))= DataTables("订单明细").Compute("Sum(数量)","客户名称 = '" & cus(0) & "' And [产品] = '" & prds(0) & "' And [规格] = '" & prds(1) & "'")
Next
Next
MainTable= Tables("配送单")
Dim doc As New PrintDoc '定义一个新报表
Dim rt As New prt.RenderTable '定义一个新表格
Dim rs As New prt.RenderText
rs.Text = "侯先童配送单" &" " & Date.Today.AddDays(1) '设置文本对象的内容
rs.Style.Spacing.Bottom = 10 '表和和后续对象的垂直间隔为10毫米
rs.Style.Font = New Font("宋体", 20 , FontStyle.Bold) '设置文本对象的字体
rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本内容水平居中
doc.Body.Children.Add(rs) '将文本对象加入到表格中
Dim tb As Table = Tables("配送单")
Dim hd As Integer = tb.HeaderRows '获得表头的层数
rt.Style.Font = New Font("宋体",12) '设置字体
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
rt.CellStyle.Spacing.All = 0.8 '单元格内距设为0.5毫米
rt.RowGroups(0, tb.HeaderRows).Header = prt.TableHeaderEnum.All '利用行组功能设置表头
tb.CreateReportHeader(rt,False) '生成表头,包括所有列
For c As Integer = 0 To tb.Cols.Count -1 '逐列设置和填入内容
rt.Cols(c).Width = tb.Cols(c).PrintWidth '列宽等于实际列宽
If tb.Cols(c).IsNumeric OrElse tb.Cols(c).IsDate Then '如果是数值或日期列
rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平靠右
End If
For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
rt.Cells(r + hd, c).Text = tb(r,c)
Next
Next
rt.Cols(0).Width = 100
rt.Cols(1).Width = 80
rt.Cols(2).Width = 30
rt.Cols(3).Width = 50
'rt.width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
'rt.height= 40
doc.Body.Children.Add(rt) '将表格加入到报表
doc.PageSetting.Landscape = True '横向打印
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距
doc.Preview()