Dim rta As New prt.RenderTable() '定义一个表格对象
doc.Body.Children.Add(rta) '将表格对象加入到报表中
rta.Style.GridLines.All = New prt.Linedef '设置网格线
rta.CellStyle.Spacing.All = 0.5 '内容距离网格线0.5毫米
rta.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
rta.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center '第一行内容垂直居中
rta.Rows(0).Style.BackColor = Color.LightGray '第一行背景颜色设为灰色.
rta.Cols(0).Width = 16
rta.RowGroups(0,1).Header = prt.TableHeaderEnum.All '将第一行作为表头.
'下面的代码向表格中填入值
rta.Cells(0,0).Text = "子类"
rta.Cells(0,1).Text = "型号"
Dim RowIndex As Integer = 1
For Each dr As DataRow In drs
Dim pn As String = dr("型号")
Dim fdr As DataRow = DataTables("元件").find("型号 = '" & pn & "'")
If fdr IsNot Nothing Then
Dim ss As String = fdr("子类")
rta.Cells(RowIndex,0).Text = ss
rta.Cells(RowIndex,1).Text = pn
RowIndex = RowIndex + 1
If (RowIndex Mod 10) = 0 Then
rta.Cells(RowIndex,0).Text = " "
rta.Cells(RowIndex,1).Text = "___________"
RowIndex = RowIndex + 1
End If
End If
Next