按客户名称汇总模式生成的专业报表,第一列客户名称需要单元格合并,帮助里面的合并单元格的代码应该如何整合进去? 研究了几天弄不出来,麻烦老师帮忙完善下代码,谢谢!
此主题相关图片如下:qq截图20210105231034.jpg
Dim doc As New PrintDoc
Dim rt As New Prt.RenderTable
Dim rx As prt.RenderText
Dim cnt As Integer
Dim tbl As Table = Tables("订单明细")
Dim drs As List(Of DataRow)
Dim pds As List(Of String) = tbl.DataTable.GetValues("客户名称",tbl.Filter)
rt.Style.GridLines.All = New prt.LineDef(0.1,Color.LightGray)
rt.CellStyle.Spacing.All = 1
rt.Style.FontSize = 10.5 '字体大小为16磅
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
rt.Rows(0).Style.FontBold = True '字体加粗
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center '内容垂直居中
rt.Rows(0).Style.FontSize = 11 '字体大小为16磅
For c As Integer = 0 To tbl.Cols.Count - 1 '生成列标题
rt.Cells(0,c).Text = tbl.Cols(c).Name
rt.Rows(0).Height=7
rt.Cols(0).Width = 50
rt.Cols(1).Width = 50
rt.Cols(2).Width = 30
rt.Cols(3).Width = 30
rt.Cols(4).Width = 30
Next
For Each pd As String In pds '分产品打印
If tbl.Filter > "" Then
drs = tbl.DataTable.Select("客户名称 = '" & pd & "' And " & tbl.Filter)
Else
drs = tbl.DataTable.Select("客户名称 = '" & pd & "'" )
End If
For Each dr As DataRow In drs '逐行打印此产品的订单
cnt = rt.Rows.Count
For c As Integer = 0 To tbl.Cols.Count - 1
rt.Cells(cnt, c).Text = dr(tbl.Cols(c).Name)
Next
Next
cnt = rt.Rows.Count
rt.Cells(cnt, 0).Text = pd & "合计 " '打印产品的小计
rt.Cells(cnt, 0).style.TextAlignHorz = prt.AlignHorzEnum.right '水平居中排列
rt.Cells(cnt, 0).Style.FontBold = True '字体加粗
rt.Cells(cnt, 0).Style.FontSize = 10.5 '大体大小为16磅
rt.Cells(cnt, 2).Style.FontBold = True '字体加粗
rt.Cells(cnt, 2).Style.FontSize = 10.5 '大体大小为16磅
rt.Cells(cnt, 3).Style.FontBold = True '字体加粗
rt.Cells(cnt, 3).Style.FontSize = 10.5 '大体大小为16磅
rt.Cells(cnt,0).SpanCols = 2 '第5行第2个单元格向右合并3列(用于显示地址)
rt.Cells(cnt,2).Text = tbl.compute("Sum(数量)", "客户名称 = '" & pd & "'") & "件"
rt.Cells(cnt,3).Text = tbl.compute("Sum(欠款)", "客户名称 = '" & pd & "'") & "元"
Next
doc.Body.Children.Add(rt)
doc.preview()