以文本方式查看主题

-  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=109866)

--  作者:刘林
--  发布时间:2017/11/21 21:37:00
--  页眉打印
Tables("初中报名_table1").sort ="考试名称,单位名称,考号"
Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl As Table = Tables("初中报名_table1")
Dim ColNames As String() = New String(){"考号", "姓名"}
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String()) = tbl.DataTable.GetValues("考试名称|单位名称|考试室","","考试室") \'\'\'\'改后句子
Dim rm As prt.RenderEmpty
Doc.PageSetting.LeftMargin = 10 \'设置左边距
Doc.PageSetting.RightMargin = 10 \'设置右边距
Doc.PageSetting.TopMargin = 10 \'设置上边距
Doc.PageSetting.BottomMargin = 10 \'设置下边距
For Each region As String() In Regions
    rm = new prt.RenderEmpty \'定义一个新的空对象
    rm.BreakBefore = prt.BreakEnum.Page \'打印前换页
    doc.Body.Children.Add(rm)
    Dim rx1 As New prt.RenderTable
    rx1.Cells(0,1).Text = region(2)
    doc.Body.Children.Add(rx1)
    rt = New prt.RenderTable
    Doc.PageHeader = rx
    rt.Cols(0).Width = 70
    rt.Cols(1).width = 48
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中
    rt.Style.Gridlines.All = New prt.Linedef(Color.black) \'灰色网格线
    rt.CellStyle.Spacing.All = 2.8 \'内距设为0.5毫米
    rt.Style.GridLines.All = New prt.LineDef(0.3,Color.black)
    rt.Style.Spacing.Bottom = 2
    rt.CellStyle.Spacing.All = 1
    rt.Style.Font = New Font("宋体", 25, FontStyle.Bold)
    Rows = tbl.DataTable.Select("[单位名称] = \'" & region(1) & "\'And [考试室] =\'" & region(2) &  "\'and [考试名称] =\'" & region(0) & "\'","考试室,考号")
    For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内
        For r As Integer = 0 To Rows.Count -1
            rt.Cells(r+1,c).Text = Rows(r)(ColNames(c))
            rt.Rows(r+1).Height = 18
        Next
    Next
    doc.Body.Children.Add(rt)
Next
doc.Columns.Add()
doc.Columns.Add()
Doc.Columns(0).Spacing = 20
doc.preview()

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


老师,我想在每页的页的页眉或每栏的上方打印出分组的 region(2),结果是原来两栏顶部没对齐,如何实现对想法并对齐每页的两栏?



--  作者:有点蓝
--  发布时间:2017/11/21 23:53:00
--  
参考:http://foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=97680&skin=0
--  作者:有点甜
--  发布时间:2017/11/22 9:17:00
--  
 做个实例发上来测试。