Foxtable(狐表)用户栏目专家坐堂 → 求解:专业报表设计中 设计的行数是21行 排除两行作为表头 那么余下19行有效打印区 当数据大于19时候,报表不另行第二页开始打印 而是直接在第一个表中打印所有的表行数据 求解!


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

主题:求解:专业报表设计中 设计的行数是21行 排除两行作为表头 那么余下19行有效打印区 当数据大于19时候,报表不另行第二页开始打印 而是直接在第一个表中打印所有的表行数据 求解!

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


加好友 发短信
等级:九尾狐 帖子:2472 积分:17346 威望:0 精华:0 注册:2013/1/31 0:03:00
求解:专业报表设计中 设计的行数是21行 排除两行作为表头 那么余下19行有效打印区 当数据大于19时候,报表不另行第二页开始打印 而是直接在第一个表中打印所有的表行数据 求解!  发帖心情 Post By:2014/8/2 22:02:00 [只看该作者]

求解:专业报表设计中 设计的行数是21行 排除两行作为表头 那么余下19行有效打印区 当数据大于19时候,报表不另行第二页开始打印 而是直接在第一个表中打印所有的表行数据 求解!

图片点击可在新窗口打开查看此主题相关图片如下:121212.jpg
图片点击可在新窗口打开查看

报表事件代码如下:
Dim doc As New PrintDoc '定义一个报表
Dim Rows As List(Of DataRow)
Dim tbl As Table = Tables("卷内目录")
Dim rt As New prt.RenderTable() '定义一个表格对象
Dim rs As New prt.RenderText() '定义一个文本对象

Doc.PageSetting.LeftMargin = 30 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 25 '设置上边距
Doc.PageSetting.BottomMargin = 20 '设置下边距
doc.PageSetting.Width = 210 '纸张宽度为100毫米
doc.PageSetting.Height = 295 '纸张高度为120毫米
Doc.Style.Padding.right = 1
Doc.Style.Padding.Left = 1

rs.Text = "卷内目录表"  '设置文本对象的内容
rs.Style.Font = New Font("宋体", 24 , FontStyle.Bold) '设置文本对象的字体
rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本内容水平居中
doc.Body.Children.Add(rs) '将文本对象加入到表格中
'doc.Body.Children.Add(rt) '将表格对象加入到报表中
rt.Style.GridLines.All = New prt.Linedef '设置网格线
rt.RowGroups(0,2).Header = prt.TableHeaderEnum.All


rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
'rt.Width = "Auto"
rt.Cols(0).Width = 10 '设置列宽
rt.Cols(1).Width = 20 '设置列宽
rt.Cols(2).Width = 20 '设置列宽
rt.Cols(3).Width = 20 '设置列宽
rt.Cols(4).Width = 15 '设置列宽
rt.Cols(5).Width = 50 '设置列宽
rt.Cols(6).Width = 10 '设置列宽
rt.Cols(7).Width = 10 '设置列宽
rt.Cols(8).Width = 20 '设置列宽

rt.Rows.Count = 21 '设置总行数
rt.Cols.Count = 9 '设置总列数
rt.Style.Spacing.Top = 4 '表格和前面对象的垂直间隔为4毫米
rt.Style.Spacing.Bottom = 10 '表和和后续对象的垂直间隔为10毫米

rt.Height = 235 '设置表格的高度为120毫米
rt.Cells(0,3).SpanCols = 2 '第5行第2个单元格向右合并3列
rt.Cells(0,0).SpanRows = 2 '第1行第5个单元格向下合并6行
rt.Cells(0,1).SpanRows = 2 '第1行第5个单元格向下合并6行
rt.Cells(0,4).SpanRows = 2 '第1行第5个单元格向下合并6行
rt.Cells(0,5).SpanRows = 2 '第1行第5个单元格向下合并6行
rt.Cells(0,6).SpanRows = 2 '第1行第5个单元格向下合并6行
rt.Cells(0,7).SpanRows = 2 '第1行第5个单元格向下合并6行
rt.Cells(0,2).SpanRows = 2 '第1行第5个单元格向下合并6行
rt.Cells(0,8).SpanRows = 2 '第1行第5个单元格向下合并6行



    
    rt.Cells(0,0).Text= "序号"
    rt.Cells(0,0).Style.Font=New Font("宋体", 16, FontStyle.Bold)
    rt.Cells(0,1).Text = "来源"
    rt.Cells(0,2).Text = "责任人"
    rt.Cells(0,3).Text= "文件编号"
    rt.Cells(1,3).Text= "字号"
    rt.Cells(1,4).Text= "文号"
    rt.Cells(0,4).Text = "标题"
    rt.Cells(0,5).Text = "标题"
    rt.Cells(0,6).Text = "起始页"
    rt.Cells(0,7).Text = "结束页"
    rt.Cells(0,8).Text = "备注"
    
    rt.Cells(0,1).Style.Font=New Font("宋体", 16, FontStyle.Bold)
    rt.Cells(0,2).Style.Font=New Font("宋体", 16, FontStyle.Bold)
    rt.Cells(0,3).Style.Font=New Font("宋体", 16, FontStyle.Bold)
    rt.Cells(0,4).Style.Font=New Font("宋体", 16, FontStyle.Bold)
    rt.Cells(0,5).Style.Font=New Font("宋体", 16, FontStyle.Bold)
    rt.Cells(0,6).Style.Font=New Font("宋体", 16, FontStyle.Bold)
    rt.Cells(0,7).Style.Font=New Font("宋体", 16, FontStyle.Bold)
    rt.Cells(0,8).Style.Font=New Font("宋体", 16, FontStyle.Bold)
    rt.Cells(1,3).Style.Font=New Font("宋体", 16, FontStyle.Bold)
    rt.Cells(1,4).Style.Font=New Font("宋体", 16, FontStyle.Bold)
    rt.RowGroups(0,2).Header = prt.TableHeaderEnum.All '前两行作为表头
    'rt.RowGroups(0,2).Style.BackColor = Color.LightGray '前两行的颜色设为灰色
    rt.RowGroups(0,2).Style.TextAlignHorz = prt.AlignHorzEnum.Center '前两行的文本水平居中
    rt.RowGroups(0,2).Style.TextAlignVert = prt.AlignVertEnum.Center '前两行的文本垂直居中
    For i As Integer = tbl.TopRow To tbl.BottomRow
    Rows = Tables("卷宗封面").Rows(i).DataRow.GetChildRows("卷内目录")
   
        For r As Integer = 0 To Rows.Count - 1
            rt.Cells(r+2,0).Text = rows(r)("序号")
            rt.Cells(r+2,1).Text = rows(r)("来源")
            rt.Cells(r+2,2).Text = rows(r)("责任人")
            rt.Cells(r+2,3).Text = rows(r)("材料编号_字号")
            rt.Cells(r+2,4).Text = rows(r)("材料编号_文号")
            rt.Cells(r+2,5).Text = rows(r)("标题")
            rt.Cells(r+2,6).Text = rows(r)("起始页")
            rt.Cells(r+2,7).Text = rows(r)("结束页")
            rt.Cells(r+2,8).Text = rows(r)("备注")
            
        Next
    'End With
Next
doc.Body.Children.Add(rt)




Dim rx As New prt.RenderTable
'rx.Cells(0,0).Text = Date.Today
'rx.Cells(0,1).Text = "抗震救灾专题"
rx.Cells(0,2).Text = "第[PageNo]页,共[PageCount]页"
rx.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rx.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
'rx.Style.Borders.Bottom = New prt.LineDef '设置底边框
rx.CellStyle.Spacing.Bottom = 0.5 '底端内容缩进0.5毫米
rx.Style.FontSize = 8 '字体大小为8磅
Doc.PageFooter=rx '作为页眉使用


Doc.Preview() '预览报表
[此贴子已经被作者于2014-8-2 22:04:26编辑过]

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


加好友 发短信 一级勋章
等级:超级版主 帖子:7235 积分:40556 威望:0 精华:16 注册:2008/8/31 23:23:00
  发帖心情 Post By:2014/8/2 22:13:00 [只看该作者]

http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=54028&replyid=&skin=1

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/8/3 10:11:00 [只看该作者]


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


加好友 发短信
等级:九尾狐 帖子:2472 积分:17346 威望:0 精华:0 注册:2013/1/31 0:03:00
回复:(有点甜)?不理解你想说什么?ht...  发帖心情 Post By:2014/8/3 14:30:00 [只看该作者]

是想实现关联表数据每页只打印20行记录 大于20行的记录重新开页打印 就是打印在 第二页上

而不是像现在一样 全部集中在一页 改变了每行之间的行高  不美观


rt.Rows.Count = 21 '设置总行数
rt.Cols.Count = 9 '设置总列数
rt.Style.Spacing.Top = 4 '表格和前面对象的垂直间隔为4毫米
rt.Style.Spacing.Bottom = 10 '表和和后续对象的垂直间隔为10毫米
[此贴子已经被作者于2014-8-3 14:31:21编辑过]

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/8/3 14:32:00 [只看该作者]


 回到顶部
帅哥哟,离线,有人找我吗?
李孝春
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2472 积分:17346 威望:0 精华:0 注册:2013/1/31 0:03:00
回复:(有点甜) 参考 http://www.fox...  发帖心情 Post By:2014/8/3 14:53:00 [只看该作者]

这个帮助我试了一下 不会根据我自己的报表设计来进行对应打印 而是获取所有表利名进行打印

继续求解!

那代码我无法整合到专业报表事件代码中 求指导!

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/8/3 14:55:00 [只看该作者]

 那就学习啊,你要全部帮你写好么?

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/8/3 15:09:00 [只看该作者]

 代码

 

Dim doc As New PrintDoc '定义一个报表
Dim Rows As List(Of DataRow)
Dim tbl As Table = Tables("卷内目录")


Doc.PageSetting.LeftMargin = 30 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 25 '设置上边距
Doc.PageSetting.BottomMargin = 20 '设置下边距
doc.PageSetting.Width = 210 '纸张宽度为100毫米
doc.PageSetting.Height = 295 '纸张高度为120毫米
Doc.Style.Padding.right = 1
Doc.Style.Padding.Left = 1

 

Dim prs As Integer = 20 '每页20行
Dim idx As Integer = 0
For i As Integer = tbl.TopRow To tbl.BottomRow
    Rows = Tables("卷宗封面").Rows(i).DataRow.GetChildRows("卷内目录")
    Dim rt As prt.RenderTable
    For r As Integer = 0 To Rows.Count - 1
        If idx Mod prs = 0 Then
            Dim rs As New prt.RenderText() '定义一个文本对象
            rt = New prt.RenderTable
            rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
            rs.Text = "卷内目录表"  '设置文本对象的内容
            rs.Style.Font = New Font("宋体", 24 , FontStyle.Bold) '设置文本对象的字体
            rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本内容水平居中
            doc.Body.Children.Add(rs) '将文本对象加入到表格中
            'doc.Body.Children.Add(rt) '将表格对象加入到报表中
            rt.Style.GridLines.All = New prt.Linedef '设置网格线
            rt.RowGroups(0,2).Header = prt.TableHeaderEnum.All
           
            rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
            'rt.Width = "Auto"
            rt.Cols(0).Width = 10 '设置列宽
            rt.Cols(1).Width = 20 '设置列宽
            rt.Cols(2).Width = 20 '设置列宽
            rt.Cols(3).Width = 20 '设置列宽
            rt.Cols(4).Width = 15 '设置列宽
            rt.Cols(5).Width = 50 '设置列宽
            rt.Cols(6).Width = 10 '设置列宽
            rt.Cols(7).Width = 10 '设置列宽
            rt.Cols(8).Width = 20 '设置列宽
           
           
            rt.Rows.Count = 21 '设置总行数
            rt.Cols.Count = 9 '设置总列数
            rt.Style.Spacing.Top = 4 '表格和前面对象的垂直间隔为4毫米
            rt.Style.Spacing.Bottom = 10 '表和和后续对象的垂直间隔为10毫米
           
           
            rt.Height = 235 '设置表格的高度为120毫米
            rt.Cells(0,3).SpanCols = 2 '第5行第2个单元格向右合并3列
            rt.Cells(0,0).SpanRows = 2 '第1行第5个单元格向下合并6行
            rt.Cells(0,1).SpanRows = 2 '第1行第5个单元格向下合并6行
            rt.Cells(0,4).SpanRows = 2 '第1行第5个单元格向下合并6行
            rt.Cells(0,5).SpanRows = 2 '第1行第5个单元格向下合并6行
            rt.Cells(0,6).SpanRows = 2 '第1行第5个单元格向下合并6行
            rt.Cells(0,7).SpanRows = 2 '第1行第5个单元格向下合并6行
            rt.Cells(0,2).SpanRows = 2 '第1行第5个单元格向下合并6行
            rt.Cells(0,8).SpanRows = 2 '第1行第5个单元格向下合并6行
           
            rt.Cells(0,0).Text= "序号"
            rt.Cells(0,0).Style.Font=New Font("宋体", 16, FontStyle.Bold)
            rt.Cells(0,1).Text = "来源"
            rt.Cells(0,2).Text = "责任人"
            rt.Cells(0,3).Text= "文件编号"
            rt.Cells(1,3).Text= "字号"
            rt.Cells(1,4).Text= "文号"
            rt.Cells(0,4).Text = "标题"
            rt.Cells(0,5).Text = "标题"
            rt.Cells(0,6).Text = "起始页"
            rt.Cells(0,7).Text = "结束页"
            rt.Cells(0,8).Text = "备注"
           
            rt.Cells(0,1).Style.Font=New Font("宋体", 16, FontStyle.Bold)
            rt.Cells(0,2).Style.Font=New Font("宋体", 16, FontStyle.Bold)
            rt.Cells(0,3).Style.Font=New Font("宋体", 16, FontStyle.Bold)
            rt.Cells(0,4).Style.Font=New Font("宋体", 16, FontStyle.Bold)
            rt.Cells(0,5).Style.Font=New Font("宋体", 16, FontStyle.Bold)
            rt.Cells(0,6).Style.Font=New Font("宋体", 16, FontStyle.Bold)
            rt.Cells(0,7).Style.Font=New Font("宋体", 16, FontStyle.Bold)
            rt.Cells(0,8).Style.Font=New Font("宋体", 16, FontStyle.Bold)
            rt.Cells(1,3).Style.Font=New Font("宋体", 16, FontStyle.Bold)
            rt.Cells(1,4).Style.Font=New Font("宋体", 16, FontStyle.Bold)
            rt.RowGroups(0,2).Header = prt.TableHeaderEnum.All '前两行作为表头
            'rt.RowGroups(0,2).Style.BackColor = Color.LightGray '前两行的颜色设为灰色
            rt.RowGroups(0,2).Style.TextAlignHorz = prt.AlignHorzEnum.Center '前两行的文本水平居中
            rt.RowGroups(0,2).Style.TextAlignVert = prt.AlignVertEnum.Center '前两行的文本垂直居中
            idx = 0
            Doc.Body.Children.Add(rt)
        End If
       
       
        rt.Cells(idx+2,0).Text = rows(r)("序号")
        rt.Cells(idx+2,1).Text = rows(r)("来源")
        rt.Cells(idx+2,2).Text = rows(r)("责任人")
        rt.Cells(idx+2,3).Text = rows(r)("材料编号_字号")
        rt.Cells(idx+2,4).Text = rows(r)("材料编号_文号")
        rt.Cells(idx+2,5).Text = rows(r)("标题")
        rt.Cells(idx+2,6).Text = rows(r)("起始页")
        rt.Cells(idx+2,7).Text = rows(r)("结束页")
        rt.Cells(idx+2,8).Text = rows(r)("备注")
       
        idx += 1
    Next
    'End With
Next

Dim rx As New prt.RenderTable
'rx.Cells(0,0).Text = Date.Today
'rx.Cells(0,1).Text = "抗震救灾专题"
rx.Cells(0,2).Text = "第[PageNo]页,共[PageCount]页"
rx.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rx.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
'rx.Style.Borders.Bottom = New prt.LineDef '设置底边框
rx.CellStyle.Spacing.Bottom = 0.5 '底端内容缩进0.5毫米
rx.Style.FontSize = 8 '字体大小为8磅
Doc.PageFooter=rx '作为页眉使用

 


Doc.Preview() '预览报表


 回到顶部
帅哥哟,离线,有人找我吗?
李孝春
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2472 积分:17346 威望:0 精华:0 注册:2013/1/31 0:03:00
回复:(有点甜) 那就学习啊,你要全部帮你写好...  发帖心情 Post By:2014/8/3 15:09:00 [只看该作者]

之前没有类似操作经验 现在仅仅是马马虎虎看得懂那代码 

Dim doc As New PrintDoc
Dim 
tb As Table = Tables("订单")
Dim 
prs As Integer = 20 '每页20行
For 
p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1 
    Dim 
rt As New prt.RenderTable
    rt
.Style.Gridlines.All = New prt.Linedef(Color.Gray)
    rt
.CellStyle.Spacing.All = 0.5
   
For c As Integer = 0 To tb.Cols.Count - 1
        
rt.Cells(0,c).Text = tb.Cols(c).Name
        For 
r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
            rt
.Cells(r - p * prs + 1, c).Text = tb.rows(r)(c
)
        Next
    Next

    If 
p < math.Ceiling(tb.Rows.Count / prs) - 1
        rt.BreakAfter = prt.BreakEnum.Page
    End If

    doc
.Body.Children.Add(rt)
Next

doc
.Preview()


红色部分因为我是采用了固定显示字符  所以不知道怎么进行变通 求解!

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/8/3 15:10:00 [只看该作者]

看8楼。

 回到顶部
总数 19 1 2 下一页