看了一下,如果用窗口打印的话,没有办法,无法合并的。
只能用专业报表取巧一下,打印按钮的代码这样写,楼主自己调一下格式
Dim doc As PrintDoc = e.Form.GernatePrintDoc()
Dim ndoc As new PrintDoc
For Each o As object In Doc.Body.Children
If o.Gettype.name Like "*Table" Then
Dim rt As New prt.RenderTable '定义一个新表格
rt.x = o.x
rt.y = o.y
Dim tb As Table = Tables("销售单")
rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded '表格宽度超出页宽时,可以水平换页
rt.Style.Borders.All = New prt.Linedef
rt.Style.Font = tb.Font
For c As Integer = 0 To tb.Cols.Count -1 '逐列设置和填入内容
rt.Cells(0,c).Text = tb.Cols(c).Name '列名作为标题
rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
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+1, c).Text = tb(r,c)
Next
Next
ndoc.Body.Children.Add(rt)
Else
ndoc.body.Children.Add(o.clone)
End If
Next
ndoc.Preview()