2、我改了下方案如下,做了个教师用成绩上分单,要求分考试名称,单位名称,年级代码,班级,分班打印过分单,一个班一张纸上,但有个问题,排列不按考号顺序,请问问题在哪里?
Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl As Table = Tables("打印考试用表_table1")
Dim ColNames As String() = New String(){"考号", "姓名"}
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String()) = tbl.DataTable.GetValues("考试名称|单位名称|年级代码|班级") ''''改后句子
Dim rm As prt.RenderEmpty
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距
tbl.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.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx.Text = Region(1) & Region(0) & Region(2) & "级" & Region(3) & "班过分单"
doc.Body.Children.Add(rx)
rt = New prt.RenderTable
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
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.Height = 250 '设
'' rt.Cols(1).Width =30
'' rt.Cols(2).Width =30
'' rt.Cols(2).Width =20
'' rt.Cols(1).Width =20
rt.Style.Font = New Font("宋体", 9, FontStyle.Bold) '设置字体
Rows = tbl.DataTable.Select("[单位名称] = '" & region(1) & "'and [班级] ='" & region(3) & "'and [年级代码] ='" & region(2) & "'and [考试名称] ='" & region(0) & "'")
For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内
rt.Cells(0,c).Text = ColNames(c) '列名作为标题
rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(0,2).Text = "A"
rt.Cells(0,3).Text = "B"
rt.Cells(0,6).Text = "A"
rt.Cells(0,7).Text = "B"
rt.Cells(0,c+4).Text = ColNames(c)
For r As Integer = 0 To Rows.Count -1
If r<=30
rt.Cells(r+1,c).Text = Rows(r)(ColNames(c))
Else
rt.Cells(r-30,c+4).Text = Rows(r)(ColNames(c))
End If
Next
Next
'' rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
doc.Body.Children.Add(rt)
Next
''doc.Columns.Add()
'doc.Columns.Add()
doc.preview()