代码如下,运行效果,是一个记录一行 不是想要的 我想实现的是
一个班级一张总表
分别按照学生姓名 分组 显示与该学生姓名相关的记录
然后再显示第二个班的
麻烦老师继续指导下 谢谢
代码如下:
Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl As Table = Tables("学生信息登记")
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String()) = tbl.DataTable.GetValues("学校|年级|班级")
doc.Pagesetting.LandScape = True
For Each Region As String() In Regions
rx = New prt.RenderText
rx.Style.FontSize = 14
rx.Style.FontBold = True
rx.Style.Spacing.Bottom = 2
rx.Text = "班级: " & Region(0) & Region(1) & Region(2)
doc.Body.Children.Add(rx)
rt = New prt.RenderTable
rt.Style.Font = Tables("学生信息登记").Font
rt.Style.TextAlignVert = prt.AlignVertEnum.Center
rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray)
rt.Style.Spacing.Bottom = 5
rt.CellStyle.Spacing.All = 1
rt.Style.Font = tbl.Font
'Rows = tbl.DataTable.Select("[学校] = '" & Region(0) & "' and 年级='" & Region(1) & "'and 班级='" & Region(2) & "'and 学生姓名='" & Region(3) & "'")
Rows = tbl.DataTable.Select("[学校] = '" & Region(0) & "' and 年级='" & Region(1) & "'and 班级='" & Region(2) & "'")
Dim nms() As String = {"学生姓名","亲属姓名","与学生关系","身份证号","联系电话","现居住地"}
For c As Integer = 0 To nms.length - 1
rt.Cells(0,c).Text = tbl.Cols(nms(c)).Name
rt.Cols(c).Width = tbl.Cols(nms(c)).PrintWidth
For r As Integer = 0 To Rows.Count -1
rt.Cells(r + 1, c).Text = rows(r)(tbl.Cols(nms(c)).Name)
Next
Next
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
doc.Body.Children.Add(rt)
Next
doc.preview()
此主题相关图片如下:43.png
