以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  专业报表怎么实现标题栏不分栏,细节区分栏呢  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=113069)

--  作者:873773115
--  发布时间:2018/1/8 15:40:00
--  专业报表怎么实现标题栏不分栏,细节区分栏呢
Dim doc As New PrintDoc \'定义一个报表
Dim rt As New prt.RenderTable() \'定义一个表格对象
Dim rx As New prt.RenderText() \'定义一个文本对象
rt.Style.GridLines.All = New prt.Linedef

Dim tb As Table = Tables("选定排单明细")
Dim Rows As List(Of DataRow)

Dim dh As List(of String) = tb.DataTable.GetValues("排单单号")
Doc.PageSetting.LeftMargin = 10 \'设置左边距
Doc.PageSetting.RightMargin = 10 \'设置右边距
Doc.PageSetting.TopMargin = 10 \'设置上边距
Doc.PageSetting.BottomMargin = 10 \'设置下边距
rt.CellStyle.Spacing.All = 2
Doc.Columns.Add() \'增加第一栏
Doc.Columns.Add()


For Each dh1 As String In dh
Dim kh As List(Of String) = tb.DataTable.GetValues("物货其他","排单单号 = \'"& dh1 & "\'")
    rt.BreakAfter = prt.BreakEnum.Page
    rt = New prt.RenderTable
    rt.Cells(0,0).text = format(Date.Today().AddDays(1),"yyyy年MM月dd日") &"-" & "出货计划"
    rt.Cells(0,0).SpanCols = 10 \'合并第一行全部单元格,用于显示主标题
    rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'主标题居中
    rt.Cells(0,0).Style.Font = New Font("微软雅黑", 16, FontStyle.Bold)
    
    rt.Cells(1,0).text = "                                                                                                                                                                   第[PageNo]页,共[PageCount]页"
    rt.Cells(1,0).SpanCols = 10 \'合并第二行全部单元格,用于显示副标题
    rt.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Cells(1,0).Style.Font = New Font("微软雅黑", 10, FontStyle.Bold)
    rt.Rows(1).Height = 8
    
    rt.cells(2,0).text = "排单时间:" & Date.Today()
    rt.Cells(2,0).SpanCols = 2 \'合并0-1,用于显示排单时间,车号,司机.时间点
    rt.cells(2,2).text = "排单单号:" & dh1
    rt.Cells(2,2).SpanCols = 3 \'合并2-3,排单单号
    rt.cells(2,5).text = "车号:" & "15620"
    rt.Cells(2,5).SpanCols = 2
    rt.cells(2,7).text = "司机:" & "梁锋"
    rt.Cells(2,7).SpanCols = 2
    rt.cells(2,9).text = "早上"
    rt.Rows(2).Height = 10
    rt.RowGroups(0,3).Header = prt.TableHeaderEnum.All
    For p As Integer = 0 To 9
        rt.Cells(2,p).Style.Font = New Font("微软雅黑", 9, FontStyle.Bold)
    Next
    Doc.body.Children.Add(rt)
    For Each kh1 As String In kh
        rt = New prt.RenderTable
        rx = New prt.RenderText
        rx.Style.FontSize = 10
        rx.Style.FontBold = True
        rx.Style.Spacing.Bottom = 2
        rx.Text = "客户: " & kh1
        doc.Body.Children.Add(rx)
        
        Rows = tb.DataTable.Select("[物货其他] = \'" & kh1 & "\'and [排单单号] = \'"& dh1 & "\'")
        For c As Integer = 1 To 4
            \'rt.Cells(4,c).Text = tb.Cols(c).Name
            rt.Cols(c).Width = tb.Cols(c).PrintWidth
            For r As Integer = 0 To Rows.Count -1
                rt.Cells(r + 4, c).Text = rows(r)(tb.Cols(c).Name)
            Next
        Next
        Doc.body.Children.Add(rt)
    Next
Next
doc.Preview()
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.zip


--  作者:有点甜
--  发布时间:2018/1/8 15:57:00
--  

方法一:

 

Dim doc As New PrintDoc \'定义一个报表
Dim rt As New prt.RenderTable() \'定义一个表格对象
Dim rx As New prt.RenderText() \'定义一个文本对象
rt.Style.GridLines.All = New prt.Linedef


Dim tb As Table = Tables("选定排单明细")
Dim Rows As List(Of DataRow)


Dim dh As List(of String) = tb.DataTable.GetValues("排单单号")
Doc.PageSetting.LeftMargin = 10 \'设置左边距
Doc.PageSetting.RightMargin = 10 \'设置右边距
Doc.PageSetting.TopMargin = 10 \'设置上边距
Doc.PageSetting.BottomMargin = 10 \'设置下边距
rt.CellStyle.Spacing.All = 2
Doc.Columns.Add() \'增加第一栏
Doc.Columns.Add()

For Each dh1 As String In dh
    Dim kh As List(Of String) = tb.DataTable.GetValues("物货其他","排单单号 = \'"& dh1 & "\'")
    rt.BreakAfter = prt.BreakEnum.Page
    rt = New prt.RenderTable
    rt.x = 10
    rt.y = 10
    rt.width = "parent.width*2"
    Doc.PageSetting.TopMargin = 30 \'设置上边距
    rt.Cells(0,0).text = format(Date.Today().AddDays(1),"yyyy年MM月dd日") &"-" & "出货计划"
    rt.Cells(0,0).SpanCols = 10 \'合并第一行全部单元格,用于显示主标题
    rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'主标题居中
    rt.Cells(0,0).Style.Font = New Font("微软雅黑", 16, FontStyle.Bold)
   
    rt.Cells(1,0).text = "第[PageNo]页,共[PageCount]页"
    rt.Cells(1,0).SpanCols = 10 \'合并第二行全部单元格,用于显示副标题
    rt.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Cells(1,0).Style.Font = New Font("微软雅黑", 10, FontStyle.Bold)
    rt.Rows(1).Height = 8
    rt.cells(2,0).text = "排单时间:" & Date.Today()
    rt.Cells(2,0).SpanCols = 2 \'合并0-1,用于显示排单时间,车号,司机.时间点
    rt.cells(2,2).text = "排单单号:" & dh1
    rt.Cells(2,2).SpanCols = 3 \'合并2-3,排单单号
    rt.cells(2,5).text = "车号:" & "15620"
    rt.Cells(2,5).SpanCols = 2
    rt.cells(2,7).text = "司机:" & "梁锋"
    rt.Cells(2,7).SpanCols = 2
    rt.cells(2,9).text = "早上"
    rt.Rows(2).Height = 10
    rt.RowGroups(0,3).Header = prt.TableHeaderEnum.All
    For p As Integer = 0 To 9
        rt.Cells(2,p).Style.Font = New Font("微软雅黑", 9, FontStyle.Bold)
    Next
    Doc.body.Children.Add(rt)
    For Each kh1 As String In kh
        rt = New prt.RenderTable
        rx = New prt.RenderText
        rx.Style.FontSize = 10
        rx.Style.FontBold = True
        rx.Style.Spacing.Bottom = 2
        rx.Text = "客户: " & kh1
        doc.Body.Children.Add(rx)
       
        Rows = tb.DataTable.Select("[物货其他] = \'" & kh1 & "\'and [排单单号] = \'"& dh1 & "\'")
        For c As Integer = 1 To 4
            \'rt.Cells(4,c).Text = tb.Cols(c).Name
            rt.Cols(c).Width = tb.Cols(c).PrintWidth
            For r As Integer = 0 To Rows.Count -1
                rt.Cells(r + 4, c).Text = rows(r)(tb.Cols(c).Name)
            Next
        Next
        Doc.body.Children.Add(rt)
    Next
Next
doc.Preview()


--  作者:有点甜
--  发布时间:2018/1/8 15:59:00
--  
方法二:为什么要分栏?细节区为什么不直接用两列的表格处理?用表格处理不是更容易?
--  作者:873773115
--  发布时间:2018/1/8 16:01:00
--  
EXCEL报表做吗
--  作者:873773115
--  发布时间:2018/1/8 16:01:00
--  
谢谢甜老师!
--  作者:有点甜
--  发布时间:2018/1/8 16:07:00
--  
以下是引用873773115在2018/1/8 16:01:00的发言:
EXCEL报表做吗

 

可以用excel来做;也可以用专业报表来做,不要分栏,添加一个表格,这个表格是两列的表格,每一列都显示你查询的内容,不是更简单?


--  作者:873773115
--  发布时间:2018/1/9 0:43:00
--  
比较笨,想很久才理解甜老师的意思,我重写了一下,确实  这样简单很多

Dim doc As New PrintDoc \'定义一个报表
Dim rt As New prt.RenderTable() \'定义一个表格对象
Dim rx As New prt.RenderText() \'定义一个文本对象
rt.Style.GridLines.All = New prt.Linedef

Dim tb As Table = Tables("选定排单明细")
Dim Rows As List(Of DataRow)

Dim doc As New PrintDoc \'定义一个报表
Dim rt As New prt.RenderTable() \'定义一个表格对象
Dim rx As New prt.RenderText() \'定义一个文本对象
rt.Style.GridLines.All = New prt.Linedef

Dim tb As Table = Tables("选定排单明细")
Dim Rows As List(Of DataRow)

Dim dh As List(of String) = tb.DataTable.GetValues("排单单号")
Doc.PageSetting.LeftMargin = 10 \'设置左边距
Doc.PageSetting.RightMargin = 10 \'设置右边距
Doc.PageSetting.TopMargin = 10 \'设置上边距
Doc.PageSetting.BottomMargin = 10 \'设置下边距
rt.CellStyle.Spacing.All = 2
\'Doc.Columns.Add() \'增加第一栏
\'Doc.Columns.Add()
\'

For Each dh1 As String In dh
    Dim kh As List(Of String) = tb.DataTable.GetValues("物货其他","排单单号 = \'"& dh1 & "\'")
    rt.BreakAfter = prt.BreakEnum.Page
    rt = New prt.RenderTable
    rt.Cells(0,0).text = format(Date.Today().AddDays(1),"yyyy年MM月dd日") &"-" & "出货计划"
    rt.Cells(0,0).SpanCols = 10 \'合并第一行全部单元格,用于显示主标题
    rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'主标题居中
    rt.Cells(0,0).Style.Font = New Font("微软雅黑", 16, FontStyle.Bold)
    
    rt.Cells(1,0).text = "                                                                                                                                                                   第[PageNo]页,共[PageCount]页"
    rt.Cells(1,0).SpanCols = 10 \'合并第二行全部单元格,用于显示副标题
    rt.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Cells(1,0).Style.Font = New Font("微软雅黑", 10, FontStyle.Bold)
    rt.Rows(1).Height = 8
    
    rt.cells(2,0).text = "排单时间:" & Date.Today()
    rt.Cells(2,0).SpanCols = 2 \'合并0-1,用于显示排单时间,车号,司机.时间点
    rt.cells(2,2).text = "排单单号:" & dh1
    rt.Cells(2,2).SpanCols = 3 \'合并2-3,排单单号
    rt.cells(2,5).text = "车号:" & "15620"
    rt.Cells(2,5).SpanCols = 2
    rt.cells(2,7).text = "司机:" & "梁锋"
    rt.Cells(2,7).SpanCols = 2
    rt.cells(2,9).text = "早上"
    rt.Rows(2).Height = 10
    rt.RowGroups(0,3).Header = prt.TableHeaderEnum.All
    For p As Integer = 0 To 9
        rt.Cells(2,p).Style.Font = New Font("微软雅黑", 9, FontStyle.Bold)
    Next
    Doc.body.Children.Add(rt)
    For Each kh1 As String In kh
        rt = New prt.RenderTable
        rx = New prt.RenderText
        rx.Style.FontSize = 10
        rx.Style.FontBold = True
        rx.Style.Spacing.Bottom = 2
        rx.Text = "客户: " & kh1
        doc.Body.Children.Add(rx)
        
        Rows = tb.DataTable.Select("[物货其他] = \'" & kh1 & "\'and [排单单号] = \'"& dh1 & "\'")
        For c As Integer = 0 To 2
            \'rt.Cells(4,c).Text = tb.Cols(c).Name
            rt.Cols(c).Width = tb.Cols(c).PrintWidth
            Dim y As Integer = Round2((Rows.Count)/3,0)
            For r As Integer = 0 To y -1
                rt.Cells(r + 4, c).Text = rows(r)(tb.Cols(c).Name)
            Next
            For p As Integer = y To y*2-1
                rt.Cells(p-y+4, c+3).Text = rows(p)(tb.Cols(c).Name)
            Next
            For o As Integer = y*2 To Rows.Count-1
                rt.cells(o-y*2+4,c+6).text = Rows(o)(tb.Cols(c).name)
            Next
        Next
        Doc.body.Children.Add(rt)
    Next
Next
doc.Preview()