Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共11 条记录, 每页显示 10 条, 页签: [1] [2]
[浏览完整版]

标题:专业报表合并

1楼
狐哥 发表于:2009/6/2 14:18:00

哪位老师帮我看看如下公式,我想让前六列(按照第一列内容 "工作号" 相同) 相同内容合并,公式不会做.

For c As Integer = 0 To tb.Cols.Count -1 
        Dim FirstRow As Integer = 1
        For r As integer = 0 To tb.Rows.Count -1
                If tb(r,c) Is Nothing Then
                    Continue for
                End if
                If r > 0 AndAlso tb.Cols(c).IsString AndAlso tb(r,c) = tb(r - 1,c) Then
                    rt.Cells(FirstRow,c).SpanRows =  rt.Cells(FirstRow,c).SpanRows  + 1
                Else
                    rt.Cells(r + 1, c).Text = tb(r,c)
                    FirstRow = r + 1
                End if
            Next
    Next

[此贴子已经被作者于2009-6-2 14:24:34编辑过]
2楼
yangming 发表于:2009/6/2 14:41:00
不太明白,是前六列的什么合并?单元格?
3楼
狐哥 发表于:2009/6/2 14:48:00
比如:

工作号        列1         列2     列3   ...  列7
001             M            N        S           A1
001             M            N        S           A2
002             M            V        P           A3
002             M            V        P           A4

合并后为:

工作号        列1         列2     列3 ....  列7
001             M            N        S          A1
                                                        A2
002             M            V        P          A3
                                                        A4

4楼
yangming 发表于:2009/6/2 15:11:00
我给你的代码加了头和尾,是可以按你的要求打印的啊
Dim doc As New PrintDoc
Dim tb as Table = Tables("表A")
Dim rt As New prt.RenderTable() '定义一个表格对象
rt.Style.GridLines.All = New prt.Linedef '设置网格线
For c As Integer = 0 To tb.Cols.Count -1
        Dim FirstRow As Integer = 1
        For r As integer = 0 To tb.Rows.Count -1
                If tb(r,c) Is Nothing Then
                    Continue for
                End if
               If r > 0 AndAlso tb.Cols(c).IsString AndAlso tb(r,c) = tb(r-1,c) Then
                    rt.Cells(FirstRow,c).SpanRows = rt.Cells(FirstRow,c).SpanRows  + 1
                Else
                    rt.Cells(r + 1, c).Text = tb(r,c)
                    FirstRow = r + 1
                End if
            Next
   Next
doc.Body.Children.Add(rt) '将表格对象加入到报表中
doc.Preview()

[此贴子已经被作者于2009-6-2 15:12:03编辑过]
5楼
狐哥 发表于:2009/6/2 15:28:00
姐姐,我是只要求合并前6列,根据第一列内容来合并.不是所有列.

For c As Integer = 0 To tb.Cols.Count -1
这个公式如何改为:

For c As Integer = 0 To 6,前6列
[此贴子已经被作者于2009-6-2 15:28:10编辑过]
6楼
yangming 发表于:2009/6/2 15:35:00
你第七列的数据不是每行都不一样吗?这就不会合并了啊
7楼
yangming 发表于:2009/6/2 16:14:00

看红色部分
Dim doc As New PrintDoc
Dim tb as Table = Tables("表A")
Dim rt As New prt.RenderTable() '定义一个表格对象
Dim ColNames As New List(Of String)
For Each cl As Col In tb.Cols '排除隐藏列
    If cl.Visible Then
        ColNames.Add(cl.Name)
    End If
Next
rt.Style.GridLines.All = New prt.Linedef '设置网格线
For c As Integer = 0 To tb.Cols.Count -1
        Dim FirstRow As Integer = 1
        For r As integer = 0 To tb.Rows.Count -1
                If tb(r,c) Is Nothing Then
                    Continue for
                End if
         If r > 0 AndAlso c <= 5 AndAlso tb.Cols(c).IsString AndAlso tb(r,c) = tb(r-1,c) Then

                    rt.Cells(FirstRow,c).SpanRows = rt.Cells(FirstRow,c).SpanRows + 1

                Else
                    rt.Cells(r + 1, c).Text = tb(r,c)
                    FirstRow = r + 1
                End if
            Next
   Next

doc.Body.Children.Add(rt) '将表格对象加入到报表中
doc.Preview()

[此贴子已经被作者于2009-6-2 16:14:10编辑过]
8楼
狐哥 发表于:2009/6/2 16:23:00

感谢MING姐,我试试

9楼
狐哥 发表于:2009/6/2 16:26:00
成功了,感谢MING姐.
10楼
狐哥 发表于:2009/6/2 19:10:00
If r > 0 AndAlso c <= 5 AndAlso tb.Cols(c).IsString AndAlso tb(r,c) = tb(r-1,c) Then

将上面红色部分改的列C改成实际列名,就可以按条件合并了.如:   tb(r,"工作号") = tb(r-1,"工作号") 就可以工作号条件将相同的列合并,而避免报关不美观.
再次感谢热心MING姐.
共11 条记录, 每页显示 10 条, 页签: [1] [2]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02734 s, 2 queries.