Foxtable(狐表)用户栏目专家坐堂 → 报表


  共有2294人关注过本帖树形打印复制链接

主题:报表

帅哥哟,离线,有人找我吗?
刘林
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1942 积分:14925 威望:0 精华:0 注册:2016/4/28 9:58:00
报表  发帖心情 Post By: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()

 

 

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


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By: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


 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1942 积分:14925 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2017/6/14 20:18:00 [只看该作者]

没有效果呢,这个是用打印分班考号表,当行多时能换页,当行少时也固定行高

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/14 20:39:00 [只看该作者]

 我测试没问题,请上传实例测试。

 回到顶部