‘看看是这样吗?
Dim doc As New PrintDoc '定义一个报表
Dim Mtb As Table = Tables("订单")
Dim tb As Table = Tables("订单.订单明细")
Dim CurRow As Row = Tables("订单").Current
'设置打印纸张
doc.PageSetting.PaperKind = 9 'A4
'doc.PageSetting.Width = 210 '纸张宽度毫米
'doc.PageSetting.Height = 290 '纸张高度毫米
doc.PageSetting.Landscape = True '是否横向打印
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 8 '设置上边距
Doc.PageSetting.BottomMargin = 8 '设置下边距
Dim rt As New prt.RenderTable() '定义一个表格对象
'---------------------------------指定第一个表行数,列数,
rt.Cols.Count = 15 '设置总列数
'---------------------------------设置指定行的列宽,未指定的平分剩余宽度
Dim CW As String = "20|12|12|25|20|15|30|15|15|15|15|10"
Dim Cls As String() = CW.split("|")
For i As Integer = 0 To Cls.Length-1
rt.Cols(i).Width = Cls(i)
Next
'设置表格总体样式
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '文本垂直居中
rt.CellStyle.Spacing.All = 1 '单元格内容缩进1毫米
rt.Style.GridLines.All = New prt.Linedef(0.3,Color.Black) '设置网格线
rt.Style.Font = New Font("宋体", 12) '设置总体字体
'rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never '禁止被垂直分割
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded '表格宽度超出页宽时,可以水平换页
'设置主标题------------------------------------------------1
rt.Rows(rt.Rows.Count).Height = 12
rt.Rows(rt.Rows.Count-1).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉网格线
rt.Cells(rt.Rows.Count-1,0).SpanCols = 15
rt.Cells(rt.Rows.Count-1,0).text = "上海五金有限公司"
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 18, FontStyle.Bold) '设置主标题字体
'设置副标题------------------------------------------------2
rt.Rows(rt.Rows.Count).Height = 12
rt.Cells(rt.Rows.Count-1,0).SpanCols = 15
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 16, FontStyle.Bold) '设置副标题字体
rt.Rows(rt.Rows.Count-1).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉网格线
rt.Rows(rt.Rows.Count-1).Style.Borders.Bottom = New prt.LineDef("0.3mm", Color.Black) '去掉网格线
rt.Cells(rt.Rows.Count-1,0).text = "订单"
'设置各单元格的值及样式
'----------------------------------------------------------3
rt.Rows(rt.Rows.Count).Height = 9
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 12, FontStyle.Bold)
rt.Cells(rt.Rows.Count-1,0).SpanCols = 3
rt.Cells(rt.Rows.Count-1,0).Text= "编号:" & CurRow("编号")
rt.Cells(rt.Rows.Count-1,3).SpanCols = 2
rt.Cells(rt.Rows.Count-1,3).Text= "客户:" & CurRow("客户")
rt.Cells(rt.Rows.Count-1,5).SpanCols = 3
rt.Cells(rt.Rows.Count-1,5).Text = "订单类别:" & CurRow("订单类别")
'----------------------------------------------------------4
rt.Cells(rt.Rows.Count-1,8).SpanCols = 4
rt.Cells(rt.Rows.Count-1,8).Text = "制单日期:" & iif(CurRow.IsNull("制单日期"),"",CurRow("制单日期"))
rt.Cells(rt.Rows.Count-1,8).Spanrows = 3 '-----------增加了合并的代码就不正确了.
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 12, FontStyle.Bold)
rt.Cells(rt.Rows.Count-1,0).SpanCols = 3
rt.Cells(rt.Rows.Count-1,0).Text = "交货日期:" & iif(CurRow.IsNull("交货日期"),"",CurRow("交货日期"))
rt.Cells(rt.Rows.Count-1,3).SpanCols = 5
'----------------------------------------------------------5
rt.Rows(rt.Rows.Count).Height = 9
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 12, FontStyle.Bold)
rt.Cells(rt.Rows.Count-1,0).SpanCols = 3
rt.Cells(rt.Rows.Count-1,0).Text= "业务员:"
rt.Cells(rt.Rows.Count-1,3).SpanCols = 2
rt.Cells(rt.Rows.Count-1,5).SpanCols = 7
rt.Cells(rt.Rows.Count-1,12).SpanCols = 3
'----------------------------------------------------------6
rt.Rows(rt.Rows.Count).Height = 9
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 12, FontStyle.Bold)
rt.Cells(rt.Rows.Count-1,0).SpanCols = 3
rt.Cells(rt.Rows.Count-1,0).Text= "订单类别:库存订单"
rt.Cells(rt.Rows.Count-1,3).SpanCols = 4
rt.Cells(rt.Rows.Count-1,7).SpanCols = 8
'----------------------------------------------------------7
rt.Rows(rt.Rows.Count).Height = 9
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 12, FontStyle.Bold)
Dim ColNames As String() = New String(){"编号","品名","数量","单位","规格","备注"}
For c As Integer = 0 To ColNames.Length -1
rt.Cells(rt.Rows.Count-1,c).Text= ColNames(c)
Next
rt.RowGroups(0,7).Header = prt.TableHeaderEnum.Page '指定表头行
rt.Rows(rt.Rows.Count).Height = 8
rt.RowGroups(rt.Rows.Count-1,1).DataBinding.DataSource = BindTables("订单.订单明细") '将第四行绑定到订单明细表
For c As Integer = 0 To ColNames.Length -1
If tb.Cols(c).IsNumeric OrElse tb.Cols(c).IsDate Then '如果是数值或日期列
rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平靠右
End If
rt.Cells(rt.Rows.Count-1,c).Text = "[Fields!" & ColNames(c) & ".Value]" '设置绑定表达式
Next
'设置表尾----------------------------------------------------8
rt.Rows(rt.Rows.Count).Height = 6
rt.Rows(rt.Rows.Count-1).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉网格线
rt.Rows(rt.Rows.Count-1).Style.Borders.Top = New prt.LineDef("0.3mm", Color.Black) '恢复上方网格线
rt.Cells(rt.Rows.Count-1,1).Style.Borders.left = New prt.LineDef("0mm", Color.white)
rt.Cells(rt.Rows.Count-1,0).Text= "备注:"
rt.Cells(rt.Rows.Count-1,1).SpanCols = 14
rt.Cells(rt.Rows.Count-1,1).Text= CurRow("备注")
rt.Rows(rt.Rows.Count).Height = 6
rt.Rows(rt.Rows.Count-1).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉网格线
rt.Cells(rt.Rows.Count-1,0).SpanCols = 15
rt.Cells(rt.Rows.Count-1,0).Text = "第[PageNo]页,共[PageCount]页"
rt.RowGroups(rt.Rows.Count-1,1).Style.TextAlignHorz = prt.AlignHorzEnum.Right '文本水平位置
rt.RowGroups(rt.Rows.Count-2,2).Footer = prt.TableHeaderEnum.All '指定表尾行
doc.Body.Children.Add(rt) '将表格对象加入到报表中
Doc.Preview() '预览报表