Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl As Table = Tables("外协加工")
Dim Rows As List(Of DataRow)
Dim Datas As List(Of String()) = tbl.DataTable.GetValues("加工单位|单据编号|日期|经办人",tbl.Filter)
doc.Pagesetting.LandScape = True
For Each Data As String() In Datas
rx = New prt.RenderText
rx.Style.FontSize = 16
rx.Style.FontBold = True
rx.Style.Spacing.Bottom = 6
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本内容水平居中
rx.Text = "外 协 发 料 单"
doc.Body.Children.Add(rx)
rx = New prt.RenderText
rx.Style.FontSize = 10
rx.Style.FontBold = False
rx.Style.Spacing.Bottom = 2
rx.Text = "加工单位: " & Data(0) & " 发料单号: " & Data(1) & " 日期: " & format(cdate(data(2)), "yyyy年MM月dd日") & " 经办人: " & data(3) & " 复核_______________"
doc.Body.Children.Add(rx)
rt = New prt.RenderTable
rt.Style.Font = Tables("外协加工").Font
rt.Style.TextAlignVert = prt.AlignVertEnum.Center
rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray)
rt.Style.Spacing.Bottom = 5
rt.CellStyle.Spacing.All = 1
rt.Style.Font = tbl.Font
If tbl.Filter = "" Then
Rows = tbl.DataTable.Select("加工单位 = '" & Data(0) & "' and [单据编号] = '" & data(1) & "'")
Else
Rows = tbl.DataTable.Select("加工单位 = '" & Data(0) & "' and [单据编号] = '" & data(1) & "' And (" & tbl.Filter & ")")
End If
Dim ColNames As String() = New String(){"零件图号", "零件名称","出库数量"}
For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
rt.Cells(0,c).Text = ColNames(c) '列名作为标题
rt.Cells(0,3).Text = "数量"
rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
rt.Cols(c).Width = tbl.Cols(ColNames(c)).PrintWidth '列宽等于实际列宽
If tbl.Cols(ColNames(c)).IsNumeric OrElse tbl.Cols(ColNames(c)).IsDate Then '如果是数值或日期列
rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平靠右
End If
For r As Integer = 0 To Rows.Count -1
rt.Cells(r + 1, c).Text = Rows(r)(ColNames(c))
Next
Next
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
doc.Body.Children.Add(rt)
Next
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距
doc.PageSetting.Width = 215 '纸张宽度为100毫米
doc.PageSetting.Height = 92 '纸张高度为120毫米
doc.preview()