Foxtable(狐表)用户栏目专家坐堂 → 报表分页时无法显示指定行表头


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

主题:报表分页时无法显示指定行表头

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


加好友 发短信
等级:三尾狐 帖子:724 积分:6436 威望:0 精华:0 注册:2011/6/26 11:45:00
报表分页时无法显示指定行表头  发帖心情 Post By:2017/8/2 11:56:00 [只看该作者]

Dim doc As New PrintDoc ' 定义一个报表
Dim Line As New prt.LineDef(0.5, Color.Black) ' 定义一条黑色的线条
Dim rt As Prt.RenderTable ' 定义一个表格对象
Dim rx As prt.RenderText ' 定义一个文本对象
Dim rm As New prt.RenderImage() '定义一个图片对象
rm.Image = GetImage("EGLOGO.png") '设置图片
Dim CurRow As Row = Tables("报价单主表").Current
Dim tbl As Table = Tables("报价单主表.报价单明细")
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tbl.DataTable.GetValues("报价大类","[RCId] = '" & CurRow("RCId") & "'","大类序号") 
doc.Pagesetting.LandScape = False  '只需将Landscape属性设为True,即可横向打印.
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距



rt = New prt.RenderTable 
doc.Body.Children.Add(rt) '将表格对象加入到报表中
rt.Style.GridLines.All = New prt.Linedef  '设置网格线
rt.CellStyle.Spacing.All = 0.5 '内容距离网格线1毫米

rt.Cells(0,0).RenderObject = rm '将单元格内容设置为图片对象rm
rt.Cells(0,0).SpanRows = 3
rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Right '图片水平居中
rm.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center '图片垂直居中
rm.Style.ImageAlign.StretchHorz = True '禁止水平方向扩展图片
rm.Style.ImageAlign.StretchVert = True '禁止垂直方向扩展图片
rt.Style.GridLines.All = New prt.LineDef("0mm", Color.white) '去掉第一行的网格线 

'设置主标题
rt.Cells(0,1).text = "Dong Guan Ever Gain Logistics Management Co., Ltd." 
rt.Cells(0,1).SpanCols = 6 '合并第一行全部单元格,用于显示主标题
rt.Cells(0,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center '主标题居中
rt.Cells(0,1).Style.Font = New Font("Times New Roman", 15 , FontStyle.Bold) '设置文本对象的字体
rt.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第一行的网格线 
rt.Rows(0).Height = 7
'设置副标题一
rt.Cells(1,1).text = "東莞永得利物流管理有限公司" 
rt.Cells(1,1).SpanCols = 6 '合并第一行全部单元格,用于显示主标题
rt.Cells(1,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center '主标题居中
rt.Cells(1,1).Style.Font = New Font("宋体", 15 , FontStyle.Bold) '设置文本对象的字体
rt.Rows(1).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第二行的网格线 
'设置副标题二
rt.Cells(2,1).text = "EVER GAIN GROUP (永得利集团)"  '通过左边空格数量来调整副标题位置
rt.Cells(2,1).SpanCols = 6 '合并地二行全部单元格,用于显示副标题
rt.Cells(2,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center '副标题内容居中
rt.Cells(2,1).Style.Font = New Font("宋体", 10 , FontStyle.Bold) 
rt.Rows(2).Style.Borders.All = New prt.LineDef("3mm", Color.white) '去掉第三行的网格线
rt.Rows(2).Style.Borders.Bottom = New prt.Linedef  '恢复第三行底端的网格线
rt.Rows(2).Height = 5 '设置第二行的高度,拉开和表格主体的距离. 
rt.RowGroups(0,3).Header = prt.TableHeaderEnum.all  '指定表头行

rx = New prt.RenderText '创建文本对象
rx.Text = "报价书&协议" '设置文本对象的内容
rx.Style.FontBold = True '加粗字体
rx.Style.CharSpacing = 0.02 '字符间距
rx.Style.Font = New Font("微软雅黑", 15 , FontStyle.Bold) '设置文本对象的字体
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本内容水平居中
rx.Style.Spacing.Bottom = 3 
doc.Body.Children.Add(rx) '将文本对象加入到表格中
'------------------------以上代码生成表头格式


rt = New prt.RenderTable ' 创建表格对像
rt.Style.GridLines.All = New prt.Linedef '设置网格线
rt.Rows.Count = 7 '设置总行数
rt.Cols.Count = 9 '设置总列数
rt.Height = 40 '设置表格的高度为120毫米
'rt.Rows(6).Height = 50 '第7行的高度为50毫米
rt.Cells(0,1).SpanCols = 4 '第1行第2个单元格向右合并2列
rt.Cells(1,1).SpanCols = 4
rt.Cells(2,1).SpanCols = 4
rt.Cells(3,1).SpanCols = 4
rt.Cells(0,6).SpanCols = 4
rt.Cells(1,6).SpanCols = 4
rt.Cells(2,6).SpanCols = 4
rt.Cells(3,6).SpanCols = 4
rt.Cells(4,1).SpanCols = 9
rt.Cells(5,1).SpanCols = 9
rt.Cells(6,1).SpanCols = 9
rt.Cells(0,0).Text = "客户公司名称" 
rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(0,0).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold) 
rt.Cells(1,0).Text = "客户公司地址"
rt.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(1,0).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(2,0).Text = "客户公司担当"
rt.Cells(2,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(2,0).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(3,0).Text = "报价日期"
rt.Cells(3,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(3,0).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(4,0).Text = "报价内容"
rt.Cells(4,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(4,0).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(5,0).Text = "货物明细"
rt.Cells(5,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(5,0).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(6,0).Text = "业务内容"
rt.Cells(6,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(6,0).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(0,5).Text = "报价公司名称"
rt.Cells(0,5).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(0,5).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(1,5).Text = "报价公司地址"
rt.Cells(1,5).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(1,5).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(2,5).Text = "报价公司担当"
rt.Cells(2,5).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(2,5).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(3,5).Text = "报价编号"
rt.Cells(3,5).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cells(3,5).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)

rt.Cells(0,1).Text = CurRow("客户公司名称")
rt.Cells(0,1).Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Cells(0,1).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(1,1).Text = CurRow("客户公司地址")
rt.Cells(1,1).Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Cells(1,1).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(2,1).Text = CurRow("客户公司担当")
rt.Cells(2,1).Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Cells(2,1).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(3,1).Text = CurRow("报价日期")
rt.Cells(3,1).Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Cells(3,1).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(4,1).Text = CurRow("报价内容")
rt.Cells(4,1).Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Cells(4,1).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(5,1).Text = CurRow("货物明细")
rt.Cells(5,1).Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Cells(5,1).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(6,1).Text = CurRow("业务内容")
rt.Cells(6,1).Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Cells(6,1).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(0,6).Text = "东莞永得利物流管理有限公司"
rt.Cells(0,6).Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Cells(0,6).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(1,6).Text = "广东省东莞市麻涌镇新沙港永得利物流园"
rt.Cells(1,6).Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Cells(1,6).Style.Font = New Font("微软雅黑", 7 , FontStyle.Bold)
rt.Cells(3,6).Text = CurRow("RCId")
rt.Cells(3,6).Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Cells(3,6).Style.Font = New Font("微软雅黑", 8 , FontStyle.Bold)
rt.Style.Spacing.Bottom = 3
doc.Body.Children.Add(rt)


rx = New prt.RenderText '创建文本对象
Dim s As String
s = "   根据《中华人民共和国合同法》有关规定,本着自愿有偿,诚实信用的原则,经双方协商一致,就甲方委托乙方向其提供运输,装卸及通关等相关服务,"
s = s &  vbcrlf & "参照以下费用及协议执行:"
rx.Text = s '设置文本对象的内容
rx.Style.Font = New Font("微软雅黑", 8 , FontStyle.Bold) '设置文本对象的字体
rx.Style.LineSpacing = 100 '设置双倍行距
rx.Style.Spacing.Bottom = 3
doc.Body.Children.Add(rx) '将文本对象加入到报表

rx = New prt.RenderText '创建文本对象
rx.Text = "【协议条件】" '设置文本对象的内容
rx.Style.FontBold = True '加粗字体
rx.Style.CharSpacing = 0.02 '字符间距
rx.Style.Font = New Font("微软雅黑", 8 , FontStyle.Bold) '设置文本对象的字体
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Left '文本内容水平居中
rx.Style.Spacing.Bottom = 3
doc.Body.Children.Add(rx) '将文本对象加入到表格中


rx = New prt.RenderText '创建文本对象
Dim s1 As String
s1 = "                         1  甲方应对其储存的货物向保险公司足额投保货物保险并支付保险费.另外,如万一发生事故,所产生的损失由甲方或者甲方客户方利用所投险种进行处理."
s1 = s1 & vbcrlf & "                             乙方有义务进行投保责任保险?若因乙方责任造成货物损失的,乙方通过其投保的物流责任险进行理赔,但不负责赔偿超过其物流责任险规定的赔偿额度以外."
s1 = s1 & vbcrlf & "                             乙方将相关保险单复印件加盖乙方公章提交给甲方存档."
s1 = s1 & vbcrlf & "                          2  乙方按照甲方的要求规范操作,甲方有义务提供相关必要信息和协助."
s1 = s1 & vbcrlf & "                             甲方有权随时对货物收,发,存,安全管理等情况进行核查,乙方有义务提供相关信息和协助."
s1 = s1 & vbcrlf & "                          3  如有在乙方报价表业务范围外,即责任范围以外发生的实际业务操作的情况下,乙方将对实际发生的费用向甲方请款."
s1 = s1 & vbcrlf & "                          4  在发生难以预料的天灾,战争等不可抗力致使货物无法如期到达目的地及业务不能顺利进行的情况下,"
s1 = s1 & vbcrlf & "                             乙方不承担自身业务过失责任以外的责任."
s1 = s1 & vbcrlf & "                          5  码头等公共设施产生的费用以及商检等产生的代垫费,由乙方向甲方按照实际发生请款,其中如果产生fa piao税金,由甲方承担."
s1 = s1 & vbcrlf & "                             另外,关于税金税率等详细内容,需基于中国国家税务局的规定来执行."
s1 = s1 & vbcrlf & "                          6  若因甲方临时取消业务给乙方带来上述报价中未列明的费用损失,由乙方另行向甲方请款."
s1 = s1 & vbcrlf & "                          7  在本报价有效期内,发生难以预料事件及成本大幅度变动的情况下,或以上条件以外发生变化的情况下,乙方将再度向甲方报价."
s1 = s1 & vbcrlf & "                          8  业务发生月的最后日为结算日,乙方将于业务发生次月上旬制作业务请款书并向甲方发送.甲方在业务发生次月算起30日之内付款到乙方指定的银行账户."
s1 = s1 & vbcrlf & "                             甲方需按时支付所有费用,逾期需要支付滞纳金.滞纳金从约定支付日起,每逾期一天须支付拖欠总金额的0.5%(千分之五). "
s1 = s1 & vbcrlf & "                          9  本报价书&协议一式二份,双方各执一份,经双方签字并加盖有效公章后生效."
rx.Text = s1 '设置文本对象的内容
rx.Style.Font  = New Font("微软雅黑", 7, FontStyle.Regular) '设置字体
rx.Style.LineSpacing = 150 '设置双倍行距
rx.Style.Spacing.Bottom = 3

doc.Body.Children.Add(rx) '将文本对象加入到报表


rx = New prt.RenderText '创建文本对象
rx.Text = "【有效期限】" '设置文本对象的内容
rx.Style.FontBold = True '加粗字体
rx.Style.CharSpacing = 0.02 '字符间距
rx.Style.Font = New Font("微软雅黑", 8 , FontStyle.Bold) '设置文本对象的字体
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Left '文本内容水平居中
rx.Style.Spacing.Bottom = 3
doc.Body.Children.Add(rx) '将文本对象加入到表格中

rx = New prt.RenderText '创建文本对象
Dim s3 As String
s3 = "                            " & CurRow("有效期限")
s3 = s3 & vbcrlf & "                            " & CurRow("有效期限备注")
rx.Text = s3 '设置文本对象的内容
rx.Style.Font  = New Font("微软雅黑", 7, FontStyle.Regular) '设置字体
rx.Style.LineSpacing = 150 '设置双倍行距
rx.Style.Spacing.Bottom = 3
doc.Body.Children.Add(rx) '将文本对象加入到报表


rx = New prt.RenderText '创建文本对象
rx.Text = "【报价详细】" '设置文本对象的内容
rx.Style.FontBold = True '加粗字体
rx.Style.CharSpacing = 0.02 '字符间距
rx.Style.Font = New Font("微软雅黑", 8 , FontStyle.Bold) '设置文本对象的字体
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Left '文本内容水平居中
rx.Style.Spacing.Bottom = 3
doc.Body.Children.Add(rx) '将文本对象加入到表格中


For Each Region As String In Regions
    rx = New prt.RenderText '创建文本对象
    rx.Style.FontSize = 9  '字体大小为8磅
    rx.Style.FontBold = True '加粗字体
    rx.Style.Spacing.Bottom = 2 '和下面的对象(表格)距离2毫米
    rx.Text = Region
    doc.Body.Children.Add(rx) ' 加入至报表中
    rt = New prt.RenderTable '创建文本对象
    'rt.Style.Font = Tables("报价单主表.报价单明细").Font '字体
    rt.Style.Font =  New Font("微软雅黑",7,FontStyle.Bold) '设置文本对象的字体
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center ''垂直居中
    rt.Style.GridLines.All = New prt.LineDef(0.2,Color.Black) '设置网格线颜色
    rt.Style.Spacing.Bottom = 3 '和下面的对像距离为3毫米
    rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never '禁止被垂直分割
    rt.CellStyle.Spacing.All = 1 '单元格内距设为1毫米
    rt.Style.Font = tbl.Font
   Rows = tbl.DataTable.Select("[报价大类] = '" & Region & "'and [RCId] = '" & CurRow("RCId") & "'",  "报价序号,CODE,项目") '筛选报价大类
   Dim ColNames As String() = New String(){"报价序号","CODE","项目","二级项目","币种","金额","单位","税率","备注"} '明细列名集合
   Dim cn As String() = New String(){"NO.","CODE","项目","子项目","币种","金额","单位","税率","备注"} ' 明细列名的别名
   Dim mc As Integer = 3 '合并前三个列
    'tbl.Sort ="报价序号,CODE,项目"
    For c As Integer = 0 To ColNames.Length - 1
        Dim lr As Integer   '用于保存合并区域的起始行
        rt.Cells(0,c).Text = cn(c) '第一列使用别名
        rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center
        'rt.Cols(c).Width = tbl.Cols(c).PrintWidth
        rt.Cols(0).Width = 10 '第一列列宽
        rt.Cols(1).Width = 12
        rt.Cols(2).Width = 30 
        rt.Cols(3).Width = 20 
        rt.Cols(4).Width = 10
        rt.Cols(5).Width = 10 
        rt.Cols(6).Width = 12 
        rt.Cols(7).Width = 10   
        rt.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '唯独第一列内容居中
        rt.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
      
        For r As Integer = 0 To Rows.Count -1 
            If c <= mc -1 Then '如果是要合并的列
               Dim  merge As Boolean = True 
              If r = 0 Then
                merge = False
              Else
                For n As  Integer = 0 To c
               If Rows(r)(Colnames(n)) <> Rows(r-1)(Colnames(n))
                merge = False
                 Exit For
                End If
            Next
         End If
         If merge Then
            rt.cells(lr,c).SpanRows = rt.Cells(lr,c).SpanRows + 1
         Else
            rt.Cells(r + 1,c).Text = rows(r)(ColNames(c))
            lr = r + 1
         End If
         Else
             rt.Cells(r + 1,c).Text = rows(r)(ColNames(c))
          End If

        Next
    Next
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '将第一行作为表头.
    rt.Style.Font = New Font("微软雅黑", 7, FontStyle.Bold) '设置字体
    doc.Body.Children.Add(rt)
Next
rt.Style.TextAlignHorz = prt.AlignHorzEnum.left '所有文本内容靠右对齐
rt.Style.Spacing.Bottom = 5

rx = New prt.RenderText '创建文本对象
rx.Text =  CurRow("客户公司名称") & "(甲方)" & "                                  "  & "东莞永得利物流管理有限公司" & "(乙方)"'设置文本对象的内容
rx.Style.Font  = New Font("微软雅黑", 12, FontStyle.Regular) '设置字体
rx.Style.FontBold = True '加粗字体
rx.Style.Spacing.Bottom = 3
doc.Body.Children.Add(rx) '将文本对象加入到报表

doc.preview()

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


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

 你为什么要new 两个表格?不能在一个表格上显示?分开的两个table不能再用你需要的功能的。

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


加好友 发短信
等级:三尾狐 帖子:724 积分:6436 威望:0 精华:0 注册:2011/6/26 11:45:00
  发帖心情 Post By:2017/8/2 14:04:00 [只看该作者]

一个是主表,一个是分表。分表要分组汇总!


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

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

[此贴子已经被作者于2017/8/2 14:07:34编辑过]

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


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

方法一:你可以用页眉页脚

 

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

 

方法二:你可以在一个大表里面生产数据,而不是两个表。


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


加好友 发短信
等级:三尾狐 帖子:724 积分:6436 威望:0 精华:0 注册:2011/6/26 11:45:00
  发帖心情 Post By:2017/8/2 16:00:00 [只看该作者]

还是用页眉算了! 比较方便点!

 回到顶部