Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim CurRow As Row = Tables("活动家居产品库").Current
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
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 & "'")
Dim tb As Table = Tables("活动家居产品库")
Dim ColNames As String() = New String(){"分类","产品名称","型号","原始图片","备注"}
rt.Style.Font = tb.Font
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 '标题内容水平居中
If ColNames(c) <> "备注" Then '
rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth
End If
For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
rt.Cells(0,4).Image = GetImage(CurRow("原始图片")) 还是不显示图片 不知道哪里不多 求助
Next
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
rt.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头.
doc.Body.Children.Add(rt) '将表格加入到报表
Next
doc.preview()