以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  做了一个专业报表,发现插入的行无法自动合并,求指教  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=103690)

--  作者:xietan417
--  发布时间:2017/7/14 16:05:00
--  做了一个专业报表,发现插入的行无法自动合并,求指教
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
    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 ColNames As String() = New String(){"报价序号","CODE","项目","二级项目","币种","金额","单位","税率","备注"} 
   Dim cn As String() = New String(){"NO.","CODE","项目","二级项目","币种","金额","单位","税率","备注"} \' 别名
   Dim mc As Integer = 3 \'合并前三个列
    \'tbl.Sort ="报价序号,CODE,项目"
    For c As Integer = 0 To ColNames.Length - 1
        Dim lr As Integer   \'用于保存合并区域的起始行
        rt.Cells(0,c).Text = cn(c) \'第一列使用别名
        rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.Cols(c).Width = tbl.Cols(c).PrintWidth
      
        For r As Integer = 0 To Rows.Count -1 
            If c <= mc -1 Then \'如果是要合并的列
               Dim  merge As Boolean = True 
              If r = 0 Then
                merge = False
              Else
                For n As  Integer = 0 To c
               If Rows(r)(Colnames(n)) <> Rows(r-1)(Colnames(n))
                merge = False
                 Exit For
                End If
            Next
         End If
         If merge Then
            rt.cells(lr,c).SpanRows = rt.Cells(lr,c).SpanRows + 1
         Else
            rt.Cells(r + 1,c).Text = rows(r)(ColNames(c))
            lr = r + 1
         End If
         Else
             rt.Cells(r + 1,c).Text = rows(r)(ColNames(c))
          End If

        Next
    Next
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All \'将第一行作为表头.
    doc.Body.Children.Add(rt)
Next
doc.preview()

--  作者:xietan417
--  发布时间:2017/7/14 16:06:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:微信图片_20170714160356.png
图片点击可在新窗口打开查看

在通关费用中无法合并!
[此贴子已经被作者于2017/7/14 16:07:02编辑过]

--  作者:有点甜
--  发布时间:2017/7/14 17:04:00
--  

这个代码

 

Rows = tbl.DataTable.Select("[报价大类] = \'" & Region & "\'")

 

改成

 

Rows = tbl.DataTable.Select("[报价大类] = \'" & Region & "\'",  "报价序号,CODE,项目")


--  作者:xietan417
--  发布时间:2017/7/15 9:05:00
--  
测试OK!谢谢指点!