代码逻辑问题:
Dim doc As New PrintDoc '定义一个新报表
Dim rt As prt.RenderTable '定义一个新表格
Dim tb As Table = Tables("信息")
Dim rx As prt.RenderText
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tb.DataTable.GetUniqueValues("","班级")
doc.PageSetting.PaperKind = 9
Doc.PageSetting.TopMargin = 5 '设置上边距
Doc.PageSetting.BottomMargin = 8
For Each Region As String In Regions
rx = New prt.RenderText
rx.BreakBefore = prt.BreakEnum.Page '打
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
rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded '表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font
Rows = tb.DataTable.Select("[班级] = '" & Region & "'")
For c As Integer = 0 To tb.Cols.Count - 1
rt.Cells(0,c).Text = tb.Cols(c).Name
rt.Cols(c).Width = tb.Cols(c).PrintWidth
rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.center '数据水平居中
rt.Cols(c).Style.TextAlignVert = prt.AlignVertEnum.Center
For r As Integer = 0 To Rows.Count -1
rt.Cells(r + 1, c).Text = rows(r)(tb.Cols(c).Name)
Next
Next
For r As Integer = 0 To rt.Rows.Count -1
rt.Rows(r).Height = 8
Next
' rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头
doc.Body.Children.Add(rt) '将表格加入到报表
Next
doc.Preview()