以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  打印添加表尾的问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=90867)

--  作者:lml88
--  发布时间:2016/9/23 11:30:00
--  打印添加表尾的问题

如下是我的代码,实现的效果是,表尾跑到第二页了,怎么样把他跟表显示在同一页

Dim doc As New PrintDoc \'定义一个报表

Doc.PageSetting.LeftMargin = 30 \'设置左边距
Doc.PageSetting.TopMargin = 10 \'设置左边距
doc.PageSetting.PaperKind = 9 \'纸张类型改为A4

Dim tb As Table = Tables(Args(0))
Dim hd As Integer = tb.HeaderRows \'获得表头的层数   

Dim prs As Integer = 40 \'每页40行
For p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1 
    Dim rx As New prt.RenderText
    rx.Text = "客运车辆超速记录统计表"
    rx.Style.Font = New Font("宋体", 16, FontStyle.Bold) 
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rx.Style.Spacing.Bottom = 3

    Doc.body.Children.Add(rx)
    Dim rx1 As New prt.RenderText
    rx1.Text = Date.Today() 
    rx1.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rx1.Style.Spacing.Bottom = 3
    Doc.body.Children.Add(rx1)

    Dim rt As New prt.RenderTable
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
    rt.CellStyle.Spacing.All = 0.5
    tb.CreateReportHeader(rt,False) \'生成多层表头
    rt.RowGroups(0, tb.HeaderRows).Header = prt.TableHeaderEnum.All \'利用行组功能设置表头
    rt.Style.Spacing.Bottom = 5 \'表和和后续对象的垂直间隔为10毫米
    rt.RowGroups(0,2).Style.BackColor = Color.LightGray \'前两行的颜色设为灰色
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中
    rt.Style.Font = tb.Font
 
    For c As Integer = 0 To tb.Cols.Count - 1
        For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
            rt.Cells(r - p * prs + tb.HeaderRows, c).Text = tb.rows(r)(c)
        Next
    Next
    If p < math.Ceiling(tb.Rows.Count / prs) - 1
        rt.BreakAfter = prt.BreakEnum.Page
    End If   
 
    doc.Body.Children.Add(rt)

    Dim rs As New prt.RenderText() \'定义一个文本对象
    rs.Text = "                               填报:                                                             签收:"
    rs.Style.Spacing.Bottom = 5
    doc.Body.Children.Add(rs) \'将文本对象加入到表格中
    
Next

doc.Preview()



--  作者:有点蓝
--  发布时间:2016/9/23 11:52:00
--  
Dim doc As New PrintDoc \'定义一个报表

Doc.PageSetting.LeftMargin = 30 \'设置左边距
Doc.PageSetting.TopMargin = 10 \'设置左边距
doc.PageSetting.PaperKind = 9 \'纸张类型改为A4

Dim tb As Table = Tables(Args(0))
Dim hd As Integer = tb.HeaderRows \'获得表头的层数
Dim rm As prt.RenderEmpty
Dim prs As Integer = 40 \'每页40行
For p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1
    Dim rx As New prt.RenderText
    rx.Text = "客运车辆超速记录统计表"
    rx.Style.Font = New Font("宋体", 16, FontStyle.Bold)
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rx.Style.Spacing.Bottom = 3
    
    Doc.body.Children.Add(rx)
    Dim rx1 As New prt.RenderText
    rx1.Text = Date.Today()
    rx1.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rx1.Style.Spacing.Bottom = 3
    Doc.body.Children.Add(rx1)
    
    Dim rt As New prt.RenderTable
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
    rt.CellStyle.Spacing.All = 0.5
    tb.CreateReportHeader(rt,False) \'生成多层表头
    rt.RowGroups(0, tb.HeaderRows).Header = prt.TableHeaderEnum.All \'利用行组功能设置表头
    rt.Style.Spacing.Bottom = 5 \'表和和后续对象的垂直间隔为10毫米
    rt.RowGroups(0,2).Style.BackColor = Color.LightGray \'前两行的颜色设为灰色
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中
    rt.Style.Font = tb.Font
    
    For c As Integer = 0 To tb.Cols.Count - 1
        For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
            rt.Cells(r - p * prs + tb.HeaderRows, c).Text = tb.rows(r)(c)
        Next
    Next
    
    doc.Body.Children.Add(rt)
    
    Dim rs As New prt.RenderText() \'定义一个文本对象
    rs.Text = "                               填报:                                                             签收:"
    rs.Style.Spacing.Bottom = 5
    doc.Body.Children.Add(rs) \'将文本对象加入到表格中

    If p < math.Ceiling(100 / prs) - 1
        rm = new prt.RenderEmpty \'定义一个新的空对象
        rm.BreakBefore = prt.BreakEnum.Page \'打印前换页
        doc.Body.Children.Add(rm) \'加入到报表中
    End If
Next

doc.Preview()

[此贴子已经被作者于2016/9/23 11:52:22编辑过]

--  作者:lml88
--  发布时间:2016/9/23 15:21:00
--  
效果实现了,谢谢

[此贴子已经被作者于2016/9/23 15:22:51编辑过]

--  作者:lml88
--  发布时间:2016/9/23 15:23:00
--  
Dim doc As New PrintDoc \'定义一个报表

Doc.PageSetting.LeftMargin = 30 \'设置左边距
Doc.PageSetting.TopMargin = 10 \'设置左边距
doc.PageSetting.PaperKind = 9 \'纸张类型改为A4

Dim tb As Table = Tables("日报表")
Dim hd As Integer = tb.HeaderRows \'获得表头的层数   

Dim prs As Integer = 45 \'每页40行
For p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1 

Dim rm As prt.RenderEmpty
    If p < math.Ceiling(100 / prs) - 1
        rm = new prt.RenderEmpty \'定义一个新的空对象
        rm.BreakBefore = prt.BreakEnum.Page \'打印前换页
        doc.Body.Children.Add(rm) \'加入到报表中
    End If

    Dim rx As New prt.RenderText
    rx.Text = "客运车辆超速记录统计表"
    rx.Style.Font = New Font("宋体", 16, FontStyle.Bold) 
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rx.Style.Spacing.Bottom = 3

    Doc.body.Children.Add(rx)
    Dim rx1 As New prt.RenderText
    rx1.Text = Date.Today() 
    rx1.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rx1.Style.Spacing.Bottom = 3
    Doc.body.Children.Add(rx1)

    Dim rt As New prt.RenderTable
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
    rt.CellStyle.Spacing.All = 0.5
    tb.CreateReportHeader(rt,False) \'生成多层表头
    rt.RowGroups(0, tb.HeaderRows).Header = prt.TableHeaderEnum.All \'利用行组功能设置表头
    rt.Style.Spacing.Bottom = 5 \'表和和后续对象的垂直间隔为10毫米
    rt.RowGroups(0,2).Style.BackColor = Color.LightGray \'前两行的颜色设为灰色
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中
    rt.Style.Font = tb.Font
 
    For c As Integer = 0 To tb.Cols.Count - 1
        For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
            rt.Cells(r - p * prs + tb.HeaderRows, c).Text = tb.rows(r)(c)
        Next
    Next
    \'If p < math.Ceiling(tb.Rows.Count / prs) - 1
        \'rt.BreakAfter = prt.BreakEnum.Page
    \'End If   
    doc.Body.Children.Add(rt)

    Dim rs As New prt.RenderText() \'定义一个文本对象
    rs.Text = "                     填报:                                            签收:"
    rs.Style.Spacing.Bottom = 5
    doc.Body.Children.Add(rs) \'将文本对象加入到表格中


Next

doc.Preview()
[此贴子已经被作者于2016/9/23 15:23:33编辑过]

--  作者:有点蓝
--  发布时间:2016/9/23 15:41:00
--  
什么问题?