' 不知道您的二级分类是什么,暂定为“酒店名称”
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
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
Dim jds As List(Of String) = tbl.DataTable.GetValues("酒店名称", "区域名称 = '" & Region & "'")
For Each jd As String In jds
Dim ColNames As String() = New String() {"区域楼层", "区域名称", "订单类别", "产品名称", "图片", "工艺描述", "销售单价", "计价单位", "数量", "金额小计", "备注" }
rt.Cells(rt.Rows.Count, 0).SpanCols = ColNames.Length
rt.Cells(rt.Rows.Count - 1, 0).Text = jd
rt.Cells(rt.Rows.Count - 1, 0).CellStyle.Font = New Font("宋体", 14, FontStyle.Bold)
rt.Rows(rt.Rows.Count).Height = 8
rt.Rows(rt.Rows.Count - 1).Style.BackColor = Color.LightGray
rt.Rows(rt.Rows.Count - 1).Style.Font = New Font("宋体", 12, FontStyle.Bold)
For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
rt.Cells(rt.Rows.Count - 1, c).Text = ColNames(c) '列名作为标题
rt.Cells(rt.Rows.Count - 1, c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
Next
Rows = tbl.DataTable.Select("[区域名称] = '" & Region & "' and 酒店名称 = '" & jd & "'")
Dim tb As Table = Tables("订单_产品主表")
rt.Style.Font = tb.Font
For r As DataRow In Rows '开始填入该列内容
rt.Rows(rt.Rows.Count).Height = 6
For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
rt.Cells(rt.Rows.Count - 1, c).Text = r(ColNames(c))
Next
Next
Next
rt.Cols(10).Width = tb.Cols(ColNames("备注")).PrintWidth
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()
[此贴子已经被作者于2022/4/24 21:11:21编辑过]