Syscmd.Column.UnHide()
Dim doc As New PrintDoc
Dim rt As New Prt.RenderTable
Dim rx As prt.RenderText
Dim cnt As Integer
Dim tb As Table = Tables("计算表")
Dim ColNames As New List(Of String)
For Each cl As Col In tb.Cols '排除隐藏列
If cl.Visible Then
ColNames.Add(cl.Name)
End If
Next
rt.Style.Font = tb.Font
rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray)
rt.CellStyle.Spacing.All = 1
rt.Style.Font = tb.Font
Dim drs As List(Of DataRow)
Dim pds As List(Of String) = tb.DataTable.GetValues("计算部位",tb.Filter)
Dim md As New prt.RenderText
md.Text = ApplicationTitle.split(".")(0)
md.Style.Font = New Font("宋体", 16, FontStyle.Bold)
md.Style.TextAlignHorz = prt.AlignHorzEnum.Center
md.Style.Spacing.Bottom = 3
Doc.body.Children.Add(md)
For c As Integer = 0 To tb.Cols.Count - 1 '生成列标题
rt.Cells(0,c).Text = tb.Cols(c).Name
rt.Cols(c).Width = tb.Cols(c).PrintWidth
Next
For Each pd As String In pds '分产品打印
If tb.Filter > "" Then
drs = tb.DataTable.Select("计算部位 = '" & pd & "' And " & tb.Filter)
Else
drs = tb.DataTable.Select("计算部位 = '" & pd & "'" )
End If
For Each dr As DataRow In drs '逐行打印此产品的订单
cnt = rt.Rows.Count
For c As Integer = 0 To tb.Cols.Count - 1
rt.Cells(cnt, c).Text = dr(tb.Cols(c).Name)
Next
Next
cnt = rt.Rows.Count
rt.Cells(cnt, 0).Text = "小计 " & pd '打印产品的小计
rt.Cells(cnt,8).Text = tb.compute("Sum(重量t)", "计算部位 = '" & pd & "'")
rt.Cells(cnt,9).Text = tb.compute("Sum(油漆面积㎡)", "计算部位 = '" & pd & "'")
Next
cnt = rt.Rows.Count
rt.Cells(cnt, 0).Text = "合计 " '打印合计
rt.Cells(cnt, 8).Text = tb.compute("Sum(重量t)")
rt.Cells(cnt, 9).Text = tb.compute("Sum(油漆面积㎡)")
rt.Cols.Insert(0) '在左边插入一列,用于打印行号
rt.Cols(0).Width = 10 '设置行号列的宽度
For i As Integer = 1 To rt.Rows.Count - 1
rt.Cells(i,0).text = i '逐行写入行号
Next
doc.Body.Children.Add(rt)
doc.PageSetting.Landscape = True '横向打印
Dim my As New prt.RenderTable
my.Cells(0,0).Text = Date.Today
my.Cells(0,1).Text = ApplicationTitle.split(".")(0)
my.Cells(0,2).Text = "第[PageNo]页,共[PageCount]页"
my.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
my.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
my.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.Right
my.Style.FontSize = 8 '字体大小为8磅
Doc.PageFooter = my '作为页眉使用
doc.Preview()