Foxtable(狐表)用户栏目专家坐堂 → 分组打印换页


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

主题:分组打印换页

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


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
分组打印换页  发帖心情 Post By:2016/10/30 14:26:00 [只看该作者]

哦,谢谢,另外打印分班考号表,换页不对,出现是先把所有班级一页一页显示了,才集中打印出明细呢,请指导。
Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tb As Table = Tables("打印考试用表_table1")
Dim ColNames As String() = New String(){"考号", "姓名"}
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tb.DataTable.GetValues("班级")
Dim rm As prt.RenderEmpty
tb.sort = "班级,考号"
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.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Text = "班级: " & Region & "考号表"
    doc.Body.Children.Add(rx)
    rt = New prt.RenderTable
    Doc.PageSetting.LeftMargin = 10 '设置左边距
    Doc.PageSetting.RightMargin = 10 '设置右边距
    Doc.PageSetting.TopMargin = 10 '设置上边距
    Doc.PageSetting.BottomMargin = 10 '设置下边距
    rt.Cols(0).Width = 60
    rt.Cols(1).width = 50
    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.Style.Font = New Font("宋体", 8, FontStyle.Bold) '设置字体
    rt.Style.Spacing.All = 1
    Rows = tb.DataTable.Select("[班级] = '" & Region & "'")
    For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
        For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
            rt.Cells(r,c).Text = tb.Rows(r)(ColNames(c))
        Next
    Next
    '''' rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
Next
doc.Columns.Add()
doc.Columns.Add()
doc.Body.Children.Add(rt)
doc.preview()

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110567 积分:562725 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2016/10/31 8:38:00 [只看该作者]

Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tb As Table = Tables("打印考试用表_table1")
Dim ColNames As String() = New String(){"考号", "姓名"}
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tb.DataTable.GetValues("班级")
Dim rm As prt.RenderEmpty
tb.sort = "班级,考号"
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.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Text = "班级: " & Region & "考号表"
    doc.Body.Children.Add(rx)
    rt = New prt.RenderTable
    Doc.PageSetting.LeftMargin = 10 '设置左边距
    Doc.PageSetting.RightMargin = 10 '设置右边距
    Doc.PageSetting.TopMargin = 10 '设置上边距
    Doc.PageSetting.BottomMargin = 10 '设置下边距
    rt.Cols(0).Width = 60
    rt.Cols(1).width = 50
    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.Style.Font = New Font("宋体", 8, FontStyle.Bold) '设置字体
    rt.Style.Spacing.All = 1
    Rows = tb.DataTable.Select("[班级] = '" & Region & "'")
    For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
        For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
            rt.Cells(r,c).Text = tb.Rows(r)(ColNames(c))
        Next
    Next
doc.Body.Children.Add(rt)
    '''' rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
Next
doc.Columns.Add()
doc.Columns.Add()

doc.preview()

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


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2016/10/31 9:32:00 [只看该作者]

谢谢老师,这个问题找到了,现在有两个问题
1、http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=92271&page=2
2、我改了下方案如下,做了个教师用成绩上分单,要求分考试名称,单位名称,年级代码,班级,分班打印过分单,一个班一张纸上,但有个问题,排列不按考号顺序,请问问题在哪里?
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 '设置下边距
tbl.sort = "考试名称,单位名称,年级代码,班级,考号"
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.FontSize = 14
    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.Cols(1).Width =30
    ''  rt.Cols(2).Width =30
    ''  rt.Cols(2).Width =20
    ''  rt.Cols(1).Width =20
    rt.Style.Font = New Font("宋体", 9, FontStyle.Bold) '设置字体
    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,2).Text = "A"
        rt.Cells(0,3).Text = "B"
        rt.Cells(0,6).Text = "A"
        rt.Cells(0,7).Text = "B"
        rt.Cells(0,c+4).Text = ColNames(c)
        For r As Integer = 0 To Rows.Count -1
            If r<=30
              rt.Cells(r+1,c).Text = Rows(r)(ColNames(c))
            Else
            rt.Cells(r-30,c+4).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()

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:考试用表.rar




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


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2016/10/31 9:49:00 [只看该作者]

老师,我做了下外部数据源排序,好像行了,还不知道是不是个这原因

 回到顶部