-- 作者:晕了快扶我
-- 发布时间:2013/3/11 20:06:00
-- 还是没搞定的分页,求指点
Dim Doc As New PrintDoc
Dim prs As Integer = 15 \'每页行数 Dim tb As Table = Tables("销售出库单主表.销售出库单子表") For p As Integer = 0 To Math.Ceiling(tb.Rows.Count / prs) - 1 Dim rx As New prt.RenderTable rx.CellStyle.Spacing.All = 0.6 \'单元格内距设为0.5毫米 rx.Style.GridLines.All = New prt.Linedef(0.1, Color.black) Dim icou As Integer rx.Width = 201 rx.Style.Font = New Font("宋体", 9) rx.Style.TextAlignVert =prt.AlignVertEnum.Center Dim hd As Integer = tb.HeaderRows Dim cnt As Integer tb.CreateReportHeader(rx,True) rx.Cols.Insert(0) \'在左边插入一列,用于打印行号 rx.Cols(0).Width = 8 \'设置行号列的宽度 rx.Cells(0,0).SpanRows =2 rx.Cells(0,0).Text = "№" For c As Integer = 0 To tb.Cols.Count - 1 If tb.Cols(c).Visible For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1) rx.Rows(r).Height = 5.5 rx.Cells(r - p * prs + hd, cnt+1).Text = tb.rows(r)(c) rx.Cells(r - p * prs + hd,0).text = r+1 \' rx.Cols(7).Style.Font = New Font("Times New Roman",9) rx.Cols(6).Style.Font = New Font("Times New Roman",9) rx.Cols(5).Style.Font = New Font("Times New Roman",9) rx.Cols(4).Style.Font = New Font("Times New Roman",9) rx.Cells(r - p * prs + hd,10).Text = "***" rx.Cells(r - p * prs + hd,9).Text = "***" rx.Cells(r - p * prs + hd,8).Text = Format(tb.rows(r)(7),"#,###,###") rx.Cells(r - p * prs + hd,7).Text =Format(tb.rows(r)(6),"#,###,###") rx.Cells(r - p * prs + hd,6).Text =Format(tb.rows(r)(5),"#,###,###") rx.Cells(r - p * prs + hd,5).Text =Format(tb.rows(r)(4),"#,###,###") rx.Cells(r - p * prs + hd,4).Style.TextAlignHorz =prt.AlignHorzEnum.Center rx.Cols(4).Width = 8 rx.Cols(10).Width = 10 rx.Cols(9).Width = 10 rx.Cols(8).Width = 15 rx.Cols(7).Width = 15 rx.Cols(6).Width = 15 rx.Cols(5).Width = 15 rx.Cols(3).Width = 32 rx.Cols(2).Width = 41 Next If p = math.Ceiling(tb.Rows.Count / prs) - 1 Dim i As Integer =tb.Rows.count - (math.Ceiling(tb.Rows.Count / prs) - 1)*15 ’取最后一页的行数 rx.Cells(i+hd,0).text = "" \' rx.Rows(i+hd).Height = (15-i)*5.5 ElseIf p < math.Ceiling(tb.Rows.Count / prs) - 1 rx.BreakAfter = prt.BreakEnum.Page End If cnt = cnt+1 End If Next doc.Body.Children.Add(rx) Next doc.Preview()
想要的效果是这样的
此主题相关图片如下:2.jpg
第一页是没有问题的,一旦换页就有问题了,表格底部会多出行来,如下图
此主题相关图片如下:报表1.jpg
此主题相关图片如下:报表2.jpg
请高手帮忙改改,折腾几天了,之前那个帖子有误导大家了,我求证后改过来
|
-- 作者:狐狸爸爸
-- 发布时间:2013/3/12 13:22:00
--
Dim Doc As New PrintDoc
Dim prs As Integer = 15 \'每页行数 Dim tb As Table = Tables("销售出库单主表.销售出库单子表") For p As Integer = 0 To Math.Ceiling(tb.Rows.Count / prs) - 1 Dim rx As New prt.RenderTable rx.CellStyle.Spacing.All = 0.6 \'单元格内距设为0.5毫米 rx.Style.GridLines.All = New prt.Linedef(0.1, Color.black) Dim icou As Integer rx.Width = 201 rx.Style.Font = New Font("宋体", 9) rx.Style.TextAlignVert =prt.AlignVertEnum.Center Dim hd As Integer = tb.HeaderRows Dim cnt As Integer tb.CreateReportHeader(rx,True) rx.Cols.Insert(0) \'在左边插入一列,用于打印行号 rx.Cols(0).Width = 8 \'设置行号列的宽度 rx.Cells(0,0).SpanRows =2 rx.Cells(0,0).Text = "№" For c As Integer = 0 To tb.Cols.Count - 1 If tb.Cols(c).Visible For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1) rx.Rows(r - p * prs + hd).Height = 5.5 rx.Cells(r - p * prs + hd, cnt+1).Text = tb.rows(r)(c) rx.Cells(r - p * prs + hd,0).text = r+1 \' rx.Cols(7).Style.Font = New Font("Times New Roman",9) rx.Cols(6).Style.Font = New Font("Times New Roman",9) rx.Cols(5).Style.Font = New Font("Times New Roman",9) rx.Cols(4).Style.Font = New Font("Times New Roman",9) rx.Cells(r - p * prs + hd,10).Text = "***" rx.Cells(r - p * prs + hd,9).Text = "***" rx.Cells(r - p * prs + hd,8).Text = Format(tb.rows(r)(7),"#,###,###") rx.Cells(r - p * prs + hd,7).Text =Format(tb.rows(r)(6),"#,###,###") rx.Cells(r - p * prs + hd,6).Text =Format(tb.rows(r)(5),"#,###,###") rx.Cells(r - p * prs + hd,5).Text =Format(tb.rows(r)(4),"#,###,###") rx.Cells(r - p * prs + hd,4).Style.TextAlignHorz =prt.AlignHorzEnum.Center rx.Cols(4).Width = 8 rx.Cols(10).Width = 10 rx.Cols(9).Width = 10 rx.Cols(8).Width = 15 rx.Cols(7).Width = 15 rx.Cols(6).Width = 15 rx.Cols(5).Width = 15 rx.Cols(3).Width = 32 rx.Cols(2).Width = 41 Next If p = math.Ceiling(tb.Rows.Count / prs) - 1 Dim i As Integer =tb.Rows.count - (math.Ceiling(tb.Rows.Count / prs) - 1)*15 \'取最后一页的行数 rx.Cells(i+hd,0).text = "" \' rx.Rows(i+hd).Height = (15-i)*5.5 ElseIf p < math.Ceiling(tb.Rows.Count / prs) - 1 rx.BreakAfter = prt.BreakEnum.Page End If cnt = cnt+1 End If Next doc.Body.Children.Add(rx) Next doc.Preview()
|