Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl= Tables("学生信息_table1")
tbl.sort = "班级,学生姓名"
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String()) = tbl.DataTable.GetValues("年级,班级") ''''改后句子
Dim rm As prt.RenderEmpty
Doc.PageSetting.LeftMargin = 5 '设置左边距
Doc.PageSetting.RightMargin = 5 '设置右边距
Doc.PageSetting.TopMargin = 5 '设置上边距
Doc.PageSetting.BottomMargin = 5 '设置下边距
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.Font = New Font("黑体", 16, FontStyle.Bold) '
rx.Style.FontBold = True
rx.Style.Spacing.Bottom = 2
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx.Text = Region(0) & "学生基本信息表"
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.Width = "auto"
rt.Style.Font = New Font("宋体", 8)
Rows = tbl.DataTable.Select("[班级] ='" & region(1) & "'", "学生姓名")
For c As Integer = 0 To tbl.Cols.Count -1 '
If tbl.Cols(c).Visible Then
rt.Cells(0,c).Text = tbl.Cols(c).Name
End If
Dim r As Integer
For r = 0 To Rows.Count -1
rt.Rows(0).Height = 5
rt.Rows(r+1).height = 4
rt.Cells(r+1,c).Text = rows(r)(tbl.Cols(c).Name)
Next
Next
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
doc.Body.Children.Add(rt)
Next
doc.preview()
老师,上面的代码总是说: 无法找到列 -1。请问是什么问题