Dim doc As New Printdoc
Dim rx As prt.RenderText
Dim rt As prt.RenderTable
Dim Rows As List(Of DataRow)
Dim ys As Integer =5 '页数
Dim tbl As Table = Tables("订单")
doc.PageSetting.Width = 240 '纸张宽度为100毫米
doc.PageSetting.Height = 100 '纸张高度为120毫米
'rt.Width = 120 '设置表格的宽度为120毫米
'rt.Height = 100 '设置表格的高度为100毫米
Doc.PageSetting.LeftMargin = 8 '设置左边距
Doc.PageSetting.RightMargin = 8 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 8 '设置下边距
For i As Integer = tbl.TopRow To tbl.BottomRow
Rows = Tables("订单").Rows(i).DataRow.GetChildRows("订单明细")
For j As Integer = 0 To math.Ceiling(Rows.Count /ys) - 1 '每页四行
rx = New prt.RenderText
rx.BreakBefore = prt.BreakEnum.Page '另起一页再打印
rx.Style.FontSize = 14
rx.Style.FontBold = True
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本内容水平居中
rx.Style.Spacing.Bottom = 5
' rx.Text = "订单号: " & Tables("订单").Rows(i)("订单号")
rx.Text = "产品发运审批单"
doc.Body.Children.Add(rx)
rx = New prt.RenderText
rx.Style.FontSize = 12
' rx.Style.FontBold = True
rx.Style.TextAlignHorz = prt.AlignHorzEnum.left '文本内容水平居左
rx.Style.Spacing.Bottom = 1
' rx.Text = "订单号: " & Tables("订单").Rows(i)("订单号")
rx.Text = "日期 产品发运审号:" &Tables("订单").Rows(i)("订单号")
doc.Body.Children.Add(rx)
rt = New prt.RenderTable
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.TextAlignVert = prt.AlignVertEnum.Center
rt.Style.Borders.Bottom = New prt.LineDef(0.3,Color.LightGray)
rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
rt.CellStyle.Spacing.All = 1
' rt.Cols.Count = 4
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.rows(0).Style.Borders.Top = New prt.LineDef(0.1,Color.LightGray)
' rt.rows(0).Style.Borders.Bottom = New prt.LineDef(0.1,Color.LightGray)
For r As Integer = j*ys To (j+1)*ys-1
If r < Rows.count
rt.Cells(r-j*ys,0).Text = rows(r)("商品名称")
rt.Cells(r-j*ys ,1).Text = rows(r)("规格型号")
rt.Cells(r-j*ys ,2).Text = rows(r)("计量单位")
rt.Cells(r-j*ys ,3).Text = rows(r)("数量")
rt.Cells(r-j*ys ,4).Text = rows(r)("单价")
rt.Cells(r-j*ys ,5).Text = rows(r)("金额")
rt.Cells(r-j*ys ,6).Text = rows(r)("等级")
rt.Cells(r-j*ys ,7).Text = rows(r)("电晕")
rt.Cells(r-j*ys ,8).Text = rows(r)("备注")
End If
Next
'--------设置报表列宽 开始
rt.Width = "Auto"
rt.Cols(0).Width = 10 '设置列宽
rt.Cols(1).Width = 15 '设置列宽
rt.Cols(2).Width = 20 '设置列宽
rt.Cols(3).Width = 25 '设置列宽
rt.Cols(4).Width = 30 '设置列宽
rt.Cols(5).Width = 36 '设置列宽
rt.Cols(6).Width = 42 '设置列宽
rt.Cols(7).Width = 20 '设置列宽
rt.Cols(8).Width = 20 '设置列宽
rt.Height = 40
'----------设置报表列宽 结束
doc.Body.Children.Add(rt)
rx = New prt.RenderText
rx.Style.FontBold = True
rx.Style.Spacing.Top = 3
rx.Text = "制单人: 第" & j+1 & "页,共" & math.Ceiling(Rows.Count /ys) & "页" '我改动
rx.Style.TextAlignHorz = prt.AlignHorzEnum.left
doc.Body.Children.Add(rx)
Next
Next
doc.Preview
'MessageBox.show("循环次数: " & i,"提示",MessageBoxButtons.OK)
' rx = New prt.RenderText() '再次定义一个文本对象
' rx.Text = "制单人: " & "第" & rr & "页,共" & rr & "页"
' doc.Body.Children.Add(rx) '将文本对象加入到表格中