Foxtable(狐表)用户栏目专家坐堂 → [求助]专业报表连续打印页码问题


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

主题:[求助]专业报表连续打印页码问题

帅哥,在线噢!
hahahehe21
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:92 积分:1784 威望:0 精华:0 注册:2014/4/11 21:10:00
[求助]专业报表连续打印页码问题  发帖心情 Post By:2018/11/10 23:55:00 [只看该作者]

求助:第几页,几页代码出问题
连续打印时如果选中两行,即打印两份报表
假设第一份报表有2页,第二份报表有2页。
两份报表页码应显示为  
第1页,共2页
第2页,共2页
第1页,共2页
第2页,共2页

现在变成了 
第1页,共4页 
第2页,共4页 
第3页,共4页
第4页,共4页
如何修改代码?

Dim doc As New Printdoc
doc.PageSetting.Landscape = True
Doc.PageSetting.LeftMargin = 15 '设置左边距
Doc.PageSetting.RightMargin = 15 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 5 '设置下边距
Dim rx As prt.RenderText
Dim rt As prt.RenderTable
Dim Rows As List(Of DataRow)
Dim tbl As Table = Tables("估价产品资料")
For i As Integer = tbl.TopRow To tbl.BottomRow 
    '设置标题
    rx = New prt.RenderText
    rx.BreakBefore = prt.BreakEnum.Page
    rx.Text = "印刷业务估价单" '设置文本对象的内容
    rx.Style.Font = New Font("宋体", 20 , FontStyle.Bold) '设置文本对象的字体
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.center '文本内容水平居中
    rx.Style.Spacing.top = 5
    rx.Style.Spacing.Bottom = 1
    doc.Body.Children.Add(rx) '将文本对象加入到表格中
   
    '印刷资料
    rx = New prt.RenderText
    rx.Style.FontSize = 11
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 1
    rx.Text = "一.印刷资料"
    doc.Body.Children.Add(rx)
   
    '印刷资料表格
    rt = New prt.RenderTable
    rt.Style.FontSize = 9
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.Borders.Bottom = New prt.LineDef(0.3,Color.LightGray)
    rt.CellStyle.Spacing.All = 1
    rt.Cols.Count = 11
    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 = "拼版"
    rt.Cells(0,7).Text = "放数"
    rt.Cells(0,8).Text = "实印数"
    rt.Cells(0,9).Text = "印色"
    rt.Cells(0,10).Text = "印色说明"
    rt.Cols(0).Width = 32
    rt.Cols(1).Width = 65
    rt.Cols(2).Width = 20
    rt.Cols(3).Width = 32
    rt.Cols(4).Width = 16
    rt.Cols(5).Width = 14
    rt.Cols(6).Width = 10
    rt.Cols(7).Width = 10
    rt.Cols(8).Width = 15
    rt.Cols(9).Width = 10
    rt.Cols(10).Style.TextAlignHorz = prt.AlignHorzEnum.left
    rt.Cells(0,10).Style.TextAlignHorz = prt.AlignHorzEnum.center
    rt.RowGroups(0,1).Style.BackColor = Color.LightGray '前1行的颜色设为灰色
   
    Rows = Tables("估价产品资料").Rows(i).DataRow.GetChildRows("估价印刷")
    For r As Integer = 0 To Rows.Count - 1 '遍历关联表每一行
        rt.Cells(r+1,0).Text = rows(r)("PNum")
        rt.Cells(r+1,1).Text = rows(r)("Product")
        rt.Cells(r+1,2).Text = rows(r)("PartsName")
        rt.Cells(r+1,3).Text = rows(r)("DevName")
        rt.Cells(r+1,4).Text = rows(r)("PrintScale")
        rt.Cells(r+1,5).Text = rows(r)("MPStyle")
        rt.Cells(r+1,6).Text = rows(r)("MPCount")
        rt.Cells(r+1,7).Text = rows(r)("LCount")
        rt.Cells(r+1,8).Text = rows(r)("PCount")
        rt.Cells(r+1,9).Text = rows(r)("PrintColor")
        rt.Cells(r+1,10).Text = rows(r)("PrintColorDes")
    Next
   
    rt.Cols.Insert(0) '在左边插入一列,用于打印行号
    rt.Cols(0).Width = 7 '设置行号列的宽度
    For t As Integer = 1 To rt.Rows.Count - 1
        rt.Cells(t,0).text = t '逐行写入行号
    Next
    rt.Style.GridLines.All = New prt.Linedef '设置网格线
    rt.Style.Spacing.Bottom = 2
    doc.Body.Children.Add(rt)
   
    rx = New prt.RenderText '纸张用料标题
    rx.Style.FontSize = 11
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 1
    rx.Text = "二.纸张资料"
    doc.Body.Children.Add(rx)
    '纸张用料表格
    rt = New prt.RenderTable
    rt.Style.FontSize = 9
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.Borders.Bottom = New prt.LineDef(0.3,Color.LightGray)
    rt.CellStyle.Spacing.All = 1
    rt.Cols.Count = 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 = "拼版"
    rt.Cells(0,7).Text = "放数"
    rt.Cells(0,8).Text = "原纸数"
    rt.Cells(0,9).Text = "单位"
    rt.Cells(0,10).Text = "纸张价"
    rt.Cells(0,11).Text = "备注"
    rt.Cells(0,12).Text = "不打折"
    rt.Cells(0,13).Text = "金额"
    rt.Cols(0).Width = 32
    rt.Cols(1).Width = 0
    rt.Cols(2).Width = 26
    rt.Cols(3).Width = 32
    rt.Cols(4).Width = 18
    rt.Cols(5).Width = 17
    rt.Cols(6).Width = 10
    rt.Cols(7).Width = 10
    rt.Cols(8).Width = 14
    rt.Cols(9).Width = 10
    rt.Cols(10).Width = 13
    rt.Cols(12).Width = 12
    rt.Cols(13).Width = 15
    rt.Cols(13).Style.TextAlignHorz = prt.AlignHorzEnum.right
    rt.Cells(0,13).Style.TextAlignHorz = prt.AlignHorzEnum.center
    rt.RowGroups(0,1).Style.BackColor = Color.LightGray '前1行的颜色设为灰色
    Rows = Tables("估价产品资料").Rows(i).DataRow.GetChildRows("估价纸张")
    For r As Integer = 0 To Rows.Count - 1 '遍历关联表每一行
        rt.Cells(r+1,0).Text = rows(r)("PNum")
        rt.Cells(r+1,1).Text = rows(r)("Product")
        rt.Cells(r+1,2).Text = rows(r)("PartsName")
        rt.Cells(r+1,3).Text = rows(r)("PaperName")
        rt.Cells(r+1,4).Text = rows(r)("Scale")
        rt.Cells(r+1,5).Text = rows(r)("数量")
        rt.Cells(r+1,6).Text = rows(r)("MPCount")
        rt.Cells(r+1,7).Text = rows(r)("LCount")
        rt.Cells(r+1,8).Text = rows(r)("SrcCount")
        rt.Cells(r+1,9).Text = rows(r)("CalUnit")
        rt.Cells(r+1,10).Text = rows(r)("纸张单价")
        rt.Cells(r+1,11).Text = rows(r)("备注")
        rt.Cells(r+1,12).Text = rows(r)("不打折")
        rt.Cells(r+1,13).Text = rows(r)("金额")
        If rows(r)("不打折") = True Then
            rt.Cells(r+1,12).Text = "是"
        Else
            rt.Cells(r+1,12).Text = ""
        End If
    Next
   
    rt.Cols.Insert(0) '在左边插入一列,用于打印行号
    rt.Cols(0).Width = 7 '设置行号列的宽度
    For t As Integer = 1 To rt.Rows.Count - 1
        rt.Cells(t,0).text = t '逐行写入行号
    Next
    rt.Style.GridLines.All = New prt.Linedef '设置网格线
    rt.Style.Spacing.Bottom = 2
    doc.Body.Children.Add(rt)
   
    rx = New prt.RenderText '工序资料标题
    rx.Style.FontSize = 11
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 1
    rx.Text = "三.工序资料:"
    doc.Body.Children.Add(rx)
    '工序资料表格
    rt = New prt.RenderTable
    rt.Style.FontSize = 9
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.center
    rt.Style.Borders.Bottom = New prt.LineDef(0.3,Color.LightGray)
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '将第一行作为表头.
    rt.CellStyle.Spacing.All = 1
    rt.Cols.Count = 11
    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 = "单位"
    rt.Cells(0,7).Text = "加工规格"
    rt.Cells(0,8).Text = "K/包数"
    rt.Cells(0,9).Text = "工艺要求及备注"
    rt.Cells(0,10).Text = "不打折"
    rt.Cells(0,11).Text = "金额"
    rt.Cols(0).Width = 32
    rt.Cols(1).Width = 0
    rt.Cols(2).Width = 26
    rt.Cols(3).Width = 20
    rt.Cols(4).Width = 22
    rt.Cols(5).Width = 17
    rt.Cols(6).Width = 10
    rt.Cols(7).Width = 18
    rt.Cols(8).Width = 13
    rt.Cols(10).Width = 12
    rt.Cols(11).Width = 15
    rt.Cols(11).Style.TextAlignHorz = prt.AlignHorzEnum.right
    rt.Cells(0,11).Style.TextAlignHorz = prt.AlignHorzEnum.center
    rt.Cols(9).Style.TextAlignHorz = prt.AlignHorzEnum.left
    rt.Cells(0,9).Style.TextAlignHorz = prt.AlignHorzEnum.center
    rt.RowGroups(0,1).Style.BackColor = Color.LightGray '前1行的颜色设为灰色
    Rows = Tables("估价产品资料").Rows(i).DataRow.GetChildRows("估价工序资料")
    For r As Integer = 0 To Rows.Count - 1 '遍历关联表每一行
        rt.Cells(r+1,0).Text = rows(r)("PNum")
        rt.Cells(r+1,1).Text = rows(r)("Product")
        rt.Cells(r+1,2).Text = rows(r)("PartsName")
        rt.Cells(r+1,3).Text = rows(r)("PPItem")
        rt.Cells(r+1,4).Text = rows(r)("估价工序")
        rt.Cells(r+1,5).Text = rows(r)("数量")
        rt.Cells(r+1,6).Text = rows(r)("CalUnit")
        rt.Cells(r+1,7).Text = rows(r)("Scale")
        rt.Cells(r+1,8).Text = rows(r)("K数")
        rt.Cells(r+1,9).Text = rows(r)("工艺要求")
        rt.Cells(r+1,10).Text = rows(r)("不打折")
        rt.Cells(r+1,11).Text = rows(r)("金额")
        If rows(r)("不打折") = True Then
            rt.Cells(r+1,10).Text = "是"
        Else
            rt.Cells(r+1,10).Text = ""
        End If
    Next
   
    rt.Cols.Insert(0) '在左边插入一列,用于打印行号
    rt.Cols(0).Width = 7 '设置行号列的宽度
    For t As Integer = 1 To rt.Rows.Count - 1
        rt.Cells(t,0).text = t '逐行写入行号
    Next
    rt.Style.GridLines.All = New prt.Linedef '设置网格线
    doc.Body.Children.Add(rt)
   
    '产品资料
    rx = New prt.RenderText
    rx.Style.FontSize = 11
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 1
    rx.Style.Spacing.Top = 3
    rx.Text = "四.产品资料及估价合计:"
    doc.Body.Children.Add(rx)
    '产品资料表格
    rt = New prt.RenderTable
    rt.Style.FontSize = 9
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.Borders.Bottom = New prt.LineDef(0.3,Color.LightGray)
    rt.CellStyle.Spacing.All = 1
    rt.Rows.Count = 3 '设置行数
    rt.Cols.Count = 12 '设置列数
    rt.cols(0).Style.FontBold = True
    rt.cols(2).Style.FontBold = True
    rt.cols(4).Style.FontBold = True
    rt.cols(6).Style.FontBold = True
    rt.cols(8).Style.FontBold = True
    rt.cols(10).Style.FontBold = True
    rt.cols(11).Style.FontBold = True
    rt.Rows(1).Height = 8 '第7行的高度为50毫米
    rt.Rows(2).Height = 8 '第7行的高度为50毫米
    rt.Cells(0,1).SpanCols = 3
    rt.Cells(0,5).SpanCols = 3
    rt.Cells(1,10).SpanRows = 2
    rt.Cells(1,11).SpanRows = 2
    rt.Cols(0).Width = 20 '设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列)
    rt.Cols(1).Width = 20
    rt.Cols(2).Width = 20
    rt.Cols(3).Width = 20
    rt.Cols(4).Width = 20
    rt.Cols(5).Width = 20
    rt.Cols(6).Width = 20
    rt.Cols(7).Width = 20
    rt.Cols(8).Width = 18
    rt.Cols(9).Width = 16
    '下面很简单,指定每一个单元格的内容
    rt.Cells(0,0).Text= "客户名称:"
    rt.Cells(0,1).Text = Tables("估价产品资料").Rows(i)("Customer")
    rt.Cells(0,4).Text= "产品名称:"
    rt.Cells(0,5).Text = Tables("估价产品资料").Rows(i)("Product")
    rt.Cells(0,8).Text= "订单数量:"
    rt.Cells(0,9).Text = Tables("估价产品资料").Rows(i)("PCount")
    rt.Cells(0,10).Text= "审    核"
    rt.Cells(0,10).Style.FontSize = 15
    rt.Cells(0,11).Text= "审    批"
    rt.Cells(0,11).Style.FontSize = 15
    rt.Cells(1,0).Text= "纸张费:"
    rt.Cells(1,1).Text = Tables("估价产品资料").Rows(i)("纸张费")
    rt.Cells(2,0).Text= "质检费:"
    rt.Cells(2,1).Text = Tables("估价产品资料").Rows(i)("质检费")
    rt.Cells(1,2).Text= "可打折小计:"
    rt.Cells(1,3).Text = Tables("估价产品资料").Rows(i)("可打折小计")
    rt.Cells(2,2).Text= "不打折小计:"
    rt.Cells(2,3).Text = Tables("估价产品资料").Rows(i)("不打折小计")
    rt.Cells(1,4).Text= "税前合计:"
    rt.Cells(1,5).Text = Tables("估价产品资料").Rows(i)("税前合计")
    rt.Cells(2,4).Text= "价税合计:"
    rt.Cells(2,5).Text = Tables("估价产品资料").Rows(i)("价税合计")
    rt.Cells(1,6).Text= "合同单价:"
    rt.Cells(1,7).Text = Tables("估价产品资料").Rows(i)("Price")
    rt.Cells(2,6).Text= "合同金额:"
    rt.Cells(2,7).Text = Tables("估价产品资料").Rows(i)("SumPrice")
    rt.Cells(1,8).Text= "折  扣:"
    rt.Cells(1,9).Text = Tables("估价产品资料").Rows(i)("折扣")
    rt.Cells(2,8).Text= "设计费:"
    rt.Cells(2,9).Text = Tables("估价产品资料").Rows(i)("设计费")
    rt.Cells(1,10).Text = Tables("估价产品资料").Rows(i)("审核")
    If rt.Cells(1,10).Text = "开发者" Then
        rt.Cells(1,10).Text = "韦保建"
    End If
    rt.Cells(1,10).Style.Font = New Font("米开第一封情书", 24) '设置文本对象的字体
    rt.Style.GridLines.All = New prt.Linedef '设置网格线
    rt.Style.Spacing.Bottom = 2
    doc.Body.Children.Add(rt)
   
    '制单人
    rx = New prt.RenderText
    rx.Style.FontSize = 11
    rx.Style.Spacing.top = 2
    rx.Text = "制单人:侯雯雯"
    doc.Body.Children.Add(rx)
'设置页眉
    rt = New prt.RenderTable
    rt.Cells(0,0).Text = "开单日期: " & Tables("估价产品资料").Rows(i)("InDate")
    rt.Cols(0).Width = 40
    rt.Cells(0,1).Text = "合同号: " & Tables("估价产品资料").Rows(i)("ContractNum")
    rt.Cols(1).Width = 50
    rt.Cells(0,2).Text = "工单号: " & Tables("估价产品资料").Rows(i)("PNum")
    rt.Cols(2).Width = 60
    rt.Cells(0,3).Text = "开单员: " & Tables("估价产品资料").Rows(i)("Maker")
    rt.Cols(2).Width = 60
    rt.Cells(0,4).Text = "业务员: " & Tables("估价产品资料").Rows(i)("Sales")
    rt.Cols(2).Width = 60
    rt.Cells(0,5).Text = "第[PageNo]页,共[PageCount]页"
    rt.Cols(5).Style.TextAlignHorz = prt.AlignHorzEnum.right
    rt.Style.Borders.Bottom = New prt.LineDef '设置底边框
    rt.CellStyle.Spacing.Bottom = 0.5 '底端内容缩进0.5毫米
    rt.Style.FontSize = 8 '字体大小为8磅
    Doc.PageHeader = rt '作为页眉使用
   
    '设置页脚
    rx = New prt.RenderText '设置文本对象的内容
    rx.Text = "第[PageNo]页,共[PageCount]页" '设置文本内容
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.center '靠右对齐
    rx.Style.FontSize = 8 '字体大小为8磅
    rx.Style.Spacing.Bottom = 0.5
    Doc.PageFooter = rx '作为页眉使用
Next
doc.Preview

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


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

1、如果你用【页脚】,那么所有页的总页数都是一样的。

 

2、你可以不用页脚,而是在最后插入一个文本,文本显示你设置的内容。

 

3、你可以不打印在一个文档里面,分两个文档生产厂,也就是生成两次专业报表。


 回到顶部