以文本方式查看主题

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

--  作者:168448704
--  发布时间:2017/11/24 0:53:00
--  求助
本人专业报表中编写代码如下, 绑定关联表,现在要求关联表每页打印15行后换页,代码该如何完善,编写的代码如下:
\'1.页面设置
Dim doc As New PrintDoc \'定义一个报表
doc.PageSetting.PaperKind = 9 \'纸张类型改为A4
Doc.PageSetting.LeftMargin = 25 \'设置左边距
Doc.PageSetting.RightMargin = 15 \'设置右边距
Doc.PageSetting.TopMargin = 20 \'设置上边距
Doc.PageSetting.BottomMargin = 15 \'设置下边距
Dim tbl As Table = Tables("案卷目录")\'指定表和打印范围从当前行到选定行
For i As Integer = tbl.TopRow To tbl.BottomRow 
    Dim rw As Row = tbl.Rows(i)
tbl.Position = i
\'2.表头设计
Dim rx As New prt.RenderText \'定义一个文本对象用于加表头
Dim ra As New prt.RenderArea \'定义一个容器
ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never  \'禁止容器因为分页而被垂直分割
rx.text = "卷内目录" \'加入标题
rx.Style.Font = New Font("仿宋", 22, FontStyle.Bold) \'设置字体为仿宋22号(二号)加粗
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中排列
rx.Style.Padding.Top = 1 \'上边距1毫米
rx.Style.Spacing.Bottom = 1 \'和下面的对象(表格)距离1毫米
ra.Children.Add(rx) \'加入到容器中
\'3.表格设计
Dim rt As New prt.RenderTable() \'定义一个表格对象
rt.Style.GridLines.All = New Prt.LineDef(0.5, Color.Black) \'定义外外边框线为0.5
rt.Style.GridLines.Horz = new Prt.LineDef(0.25,Color. Black) \'定义内水平网格线为0.25
rt.Style.GridLines.Vert = new Prt.LineDef(0.25,Color. Black) \'定义内竖直网格线为0.25
\'设置表格行数?列数?行高?列宽及网格线及字体
rt.Width = 170 \'表宽为170毫米
rt.Height = 7 \'表高为7毫米
rt.Cols.Count = 7 \'设置列数为4
rt.Rows.Count = 1 \'设置行数为1
\'设置字体及对齐方式
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中
rt.Style.Font = New Font("仿宋", 12) \'12号仿宋
rt.Cols(0).Width = 8 \'设置前列的宽度
rt.Cols(1).Width = 20
rt.Cols(2).Width = 22
rt.Cols(4).Width = 22
rt.Cols(5).Width = 12
rt.Cols(6).Width = 12
\'4副表头页眉?页脚设置
\'副表头设计
rt.Rows(0).Style.GridLines.All = New prt.LineDef("0mm", Color.white) \'去掉第一行的网格线
rt.Cells(0,0).SpanCols = 7 \'合并第一行全部单元格,用于显示副标题
rt.Cells(0,0).text = " 档  号: GL." & rw("档号") \'通过左边空格数量来调整副标题位置
rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Left \'副标题内容居左
rt.Rows(0).Height = 7 \'设置第一行的高度,拉开和表格主体的距离.
ra.Children.Add(rt) \'将表格对象加入到容器中
\'卷内目录
rt = New prt.RenderTable \'定义一个新的表格对象
rt.Style.GridLines.All = New Prt.LineDef(0.5, Color.Black) \'定义外边框线为0.5
rt.Style.GridLines.Horz = new Prt.LineDef(0.25,Color. Black) \'定义内水平网格线为0.25
rt.Style.GridLines.Vert = new Prt.LineDef(0.25,Color. Black) \'定义内竖直网格线为0.0.25
rt.Style.Font = New Font("仿宋", 12) \'设置字体为仿宋12号
rt.Style.FontBold = False \'字体不加粗
rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中
rt.Cols(3).Style.TextAlignHorz = prt.AlignHorzEnum.Left \'第四列左对齐
rt.Cells(0,3).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cols(3).CellStyle.Spacing.Left = 1 \'文件题名列单元格左内边距设为1毫米
rt.Cols(3).Style.LineSpacing = 125 \'简要描述1.2倍行距
rt.Width = 170 \'表宽为170毫米
rt.Height = 245 \'表高为110毫米
rt.Cols.Count = 7 \'设置列数为4列
rt.Rows.Count = 16 \'设置行数为16行
rt.Cols(0).Width = 8 \'设置前列的宽度
rt.Cols(1).Width = 20
rt.Cols(2).Width = 22
rt.Cols(4).Width = 22
rt.Cols(5).Width = 12
rt.Cols(6).Width = 12
rt.Cells(0,0).Text = "序号"
rt.Cells(0,1).Text = "文件编号"
rt.Cells(0,2).Text = "责任者"
rt.Cells(0,3).Text = "文件题名"
rt.Cells(0,4).Text = "日期"
rt.Cells(0,5).Text = "页次"
rt.Cells(0,6).Text = "备注"
With Tables("案卷目录.卷内目录")
    For r As Integer = 0 To .Rows.Count - 1  \'遍历关联表每一行
        rt.Cells(r+1,0).Text = .rows(r)("序号")
        rt.Cells(r+1,1).Text = .rows(r)("文件编号")
        rt.Cells(r+1,2).Text = .rows(r)("责任者")
        rt.Cells(r+1,3).Text = .rows(r)("文件题名")
        rt.Cells(r+1,4).Text = .rows(r)("日期")
        rt.Cells(r+1,5).Text = .rows(r)("页次")
        rt.Cells(r+1,6).Text = .rows(r)("备注") 
Next 
End With
ra.Children.Add(rt) \'加入到容器中
Doc.Body.ChildRen.Add(ra) \'将容器加入到报表中
Next
Doc.Preview() \'预览报表

--  作者:有点甜
--  发布时间:2017/11/24 9:32:00
--  

每一页,生成一个table,才行的,参考

 

http://www.foxtable.com/webhelp/scr/2241.htm

 

如果不会改,上传具体项目测试。