Dim doc As New PrintDoc
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 15 '设置上边距
Doc.PageSetting.BottomMargin = 15 '设置下边距
Dim tb As Table = Tables("统计查询_Table1")
Dim prs As Integer = 38 '每页20行
For p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1
Dim rt As New prt.RenderTable
Dim rx As New prt.RenderText
Dim ra As New prt.RenderArea '定义一个容器
' ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never '禁止容器因为分页而被垂直分割
rx.text = "月统计奖励表"
rx.Style.FontBold = True '字体加粗
rx.Style.FontSize = 16 '大体大小为16磅
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
rx.Style.Spacing.Bottom = 3 '和下面的对象(表格)距离3毫米
' ra.Children.Add(rx)
Doc.Body.ChildRen.Add(rx)
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 0.5
rt.Width = "Parent.Width" '对象宽度等于页面宽度
rt.Height = "Parent.Height - Prev.Height" '对象高度等于页面高度
rt.Style.FontSize = 12 '大体大小为16磅
rt.Cols(0).Width = 60 '设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列)
rt.Cols(1).Width = 30
rt.Cols(2).Width = 30
Dim idx As Integer = 0
For c As Integer = 0 To tb.Cols.Count - 1
If tb.Cols(c).Visible = True Then
rt.Cells(0, idx).Text = tb.Cols(c).Name
For r As Integer = p * prs To math.min(tb.Rows.Count - 1, ( p + 1) * prs - 1)
rt.Cells(r - p * prs + 1, idx).Text = tb.rows(r)(c)
Next
idx += 1
End If
Next
If p < math.Ceiling(tb.Rows.Count / prs) - 1 Then
rt.BreakAfter = prt.BreakEnum.Page
End If
' ra.Children.Add(rt)
Doc.Body.ChildRen.Add(rt)
Next
doc.Preview()