以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  分组打印换页  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=92253)

--  作者:刘林
--  发布时间: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()

--  作者:有点蓝
--  发布时间: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()

--  作者:刘林
--  发布时间: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




--  作者:刘林
--  发布时间:2016/10/31 9:49:00
--  
老师,我做了下外部数据源排序,好像行了,还不知道是不是个这原因