以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  报表  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=102178)

--  作者:刘林
--  发布时间:2017/6/14 15:15:00
--  报表

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 = 20 \'设置左边距
Doc.PageSetting.RightMargin = 20 \'设置右边距
Doc.PageSetting.TopMargin = 20 \'设置上边距
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)
    rx = New prt.RenderText
    rx.Style.Font = New Font("黑体", 16, FontStyle.Bold) \'
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rx.Text =  Region(1) & Region(0) & Region(2) & "级" & Region(3) & "班考号表"
    doc.Body.Children.Add(rx)
    rt = New prt.RenderTable
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中
    rt.Style.GridLines.All = New prt.LineDef(0.3,Color.black)
    rt.Style.Spacing.Bottom = 2
    rt.CellStyle.Spacing.All = 1
    rt.Height = 250
    rt.Style.Font = New Font("宋体", 11) \'设置字体
    Rows = tbl.DataTable.Select("[单位名称] = \'" & region(1) & "\'and [班级] =\'" & region(3) &  "\'and [年级代码] =\'" & region(2) &  "\'and [考试名称] =\'" & region(0) & "\'")
    For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内
        rt.Cells(0,c).Text = ColNames(c) \'列名作为标题
        rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.Cells(0,c+2).Text = ColNames(c)
        Dim han As Integer = Math.Floor(Rows.count/2)-1
        For r As Integer = 0 To Rows.Count -1
            If r<= han
                rt.Cells(r+1,c).Text = Rows(r)(ColNames(c))
            Else
                rt.Cells(r-han,c+2).Text = Rows(r)(ColNames(c))
            End If
        Next
    Next
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
    doc.Body.Children.Add(rt)
Next
\'\'doc.Columns.Add()
\'doc.Columns.Add()
doc.preview()

 

 

老师,请问当一个班的记录少时也要占一满页,造成每行间隔很大,如何改进?


--  作者:有点色
--  发布时间:2017/6/14 15:50:00
--  

 设置一下行的高度

 

    Rows = tbl.DataTable.Select("[单位名称] = \'" & region(1) & "\'and [班级] =\'" & region(3) &  "\'and [年级代码] =\'" & region(2) &  "\'and [考试名称] =\'" & region(0) & "\'")
    For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内
        rt.Cells(0,c).Text = ColNames(c) \'列名作为标题
        rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        rt.Cells(0,c+2).Text = ColNames(c)
        Dim han As Integer = Math.Floor(Rows.count/2)-1
        For r As Integer = 0 To Rows.Count -1

            If Rows.Count < 10 Then

                rt.rows(r).height = 10

            End If
            If r<= han
                rt.Cells(r+1,c).Text = Rows(r)(ColNames(c))
            Else
                rt.Cells(r-han,c+2).Text = Rows(r)(ColNames(c))
            End If
        Next
    Next


--  作者:刘林
--  发布时间:2017/6/14 20:18:00
--  
没有效果呢,这个是用打印分班考号表,当行多时能换页,当行少时也固定行高
--  作者:有点色
--  发布时间:2017/6/14 20:39:00
--  
 我测试没问题,请上传实例测试。