以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  求教:专业报表合并单元格问题(已解决)  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=17834)

--  作者:yangming
--  发布时间:2012/3/26 15:12:00
--  求教:专业报表合并单元格问题(已解决)
我的要求:
1.按日期排序
2.合并往来单位 ,小计和电话号码三列,并且这三列是放在最后的,打印的顺序是:日期\\商品名称\\单价\\数量\\金额\\往来单位\\小计\\电话号码,发票号码不打印,只是由于小计是根据发票号进行统计的,所以留在狐表文件中

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:入库明细.table

[此贴子已经被作者于2012-3-27 9:00:21编辑过]

--  作者:狐狸爸爸
--  发布时间:2012/3/26 16:32:00
--  
Dim doc As New PrintDoc
Dim rt As New prt.RenderTable
Dim tb As Table = Tables("入库明细")
Dim ColNames As String() = New String(){"日期","商品名称","单价","数量","金额","往来单位","小计","电话号码"}
tb.Sort = "" \'根据合并列排序
rt.Width = "Auto"
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded
rt.Style.Font = tb.Font
rt.Style.TextAlignVert = prt.AlignVertEnum.Center
rt.RepeatGridLinesVert = True \'换页后重复表格线
For c As Integer = 0 To ColNames.Length - 1
    Dim lr As Integer \' 用于保存合并区域的起始行
    rt.Cells(0,c).Text = ColNames(c)
    rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth
    If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right
    End If
    For r As Integer = 0 To tb.Rows.Count - 1
        If c >=5 AndAlso c <=7 Then
            Dim Merge As Boolean = True
            If r = 0 Then
                Merge = False
            Else
                For n As Integer = 5 To c
                    If tb.Rows(r)(ColNames(n)) <> tb.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 = tb.Rows(r)(ColNames(c))
                rt.Cells(r + 1, c).VertSplitBehavior = prt.CellSplitBehaviorEnum.Copy \'换页后重复单元格
                lr = r + 1
            End If
        Else
            rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
        End If
    Next
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 0.5
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
doc.Body.Children.Add(rt)
doc.Preview()

--  作者:yangming
--  发布时间:2012/3/27 9:00:00
--  
谢谢贺老师,问题解决了
--  作者:shaolingyuan
--  发布时间:2012/8/24 17:02:00
--  

怎么解决的啊?