Dim doc As New PrintDoc '定义一个报表
Doc.PageSetting.LeftMargin = 30 '设置左边距
Doc.PageSetting.TopMargin = 10 '设置左边距
doc.PageSetting.PaperKind = 9 '纸张类型改为A4
Dim tb As Table = Tables(Args(0))
Dim hd As Integer = tb.HeaderRows '获得表头的层数
Dim rm As prt.RenderEmpty
Dim prs As Integer = 40 '每页40行
For p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1
Dim rx As New prt.RenderText
rx.Text = "客运车辆超速记录统计表"
rx.Style.Font = New Font("宋体", 16, FontStyle.Bold)
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx.Style.Spacing.Bottom = 3
Doc.body.Children.Add(rx)
Dim rx1 As New prt.RenderText
rx1.Text = Date.Today()
rx1.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx1.Style.Spacing.Bottom = 3
Doc.body.Children.Add(rx1)
Dim rt As New prt.RenderTable
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 0.5
tb.CreateReportHeader(rt,False) '生成多层表头
rt.RowGroups(0, tb.HeaderRows).Header = prt.TableHeaderEnum.All '利用行组功能设置表头
rt.Style.Spacing.Bottom = 5 '表和和后续对象的垂直间隔为10毫米
rt.RowGroups(0,2).Style.BackColor = Color.LightGray '前两行的颜色设为灰色
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中
rt.Style.Font = tb.Font
For c As Integer = 0 To tb.Cols.Count - 1
For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
rt.Cells(r - p * prs + tb.HeaderRows, c).Text = tb.rows(r)(c)
Next
Next
doc.Body.Children.Add(rt)
Dim rs As New prt.RenderText() '定义一个文本对象
rs.Text = " 填报: 签收:"
rs.Style.Spacing.Bottom = 5
doc.Body.Children.Add(rs) '将文本对象加入到表格中
If p < math.Ceiling(100 / prs) - 1
rm = new prt.RenderEmpty '定义一个新的空对象
rm.BreakBefore = prt.BreakEnum.Page '打印前换页
doc.Body.Children.Add(rm) '加入到报表中
End If
Next
doc.Preview()
[此贴子已经被作者于2016/9/23 11:52:22编辑过]