Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tb As Table = Tables("打印考试用表_table1")
Dim ColNames As String() = New String(){"考号", "姓名"}
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tb.DataTable.GetValues("班级")
Dim rm As prt.RenderEmpty
tb.sort = "班级,考号"
For Each Region As String In Regions
rm = new prt.RenderEmpty '定义一个新的空对象
rm.BreakBefore = prt.BreakEnum.Page '打印前换页
doc.Body.Children.Add(rm)
rx = New prt.RenderText
rx.Style.FontSize = 14
rx.Style.FontBold = True
rx.Style.Spacing.Bottom = 2
rx.Text = "班级: " & Region & "考号表"
doc.Body.Children.Add(rx)
rt = New prt.RenderTable
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距
rt.Cols(0).Width = 60
rt.Cols(1).width = 50
rt.Style.TextAlignVert = prt.AlignVertEnum.Center
rt.Style.GridLines.All = New prt.LineDef(0.3,Color.black)
rt.Style.Spacing.Bottom = 2
rt.CellStyle.Spacing.All = 1
rt.Style.Font = New Font("宋体", 8, FontStyle.Bold) '设置字体
rt.Style.Spacing.All = 1
Rows = tb.DataTable.Select("[班级] = '" & Region & "'")
For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
rt.Cells(r,c).Text = tb.Rows(r)(ColNames(c))
Next
Next
doc.Body.Children.Add(rt)
'''' rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
Next
doc.Columns.Add()
doc.Columns.Add()
doc.preview()