Dim r As DataRow = args(0)
Dim dr As DataRow = args(1)
Dim ct As Integer = args(2)
Dim doc As PrintDoc = args(3) '定义一个报表
doc.PageSetting.Landscape = True '横向打印
doc.PageSetting.Width = 82 '纸张宽度为82毫米
doc.PageSetting.Height = 60 * ct '纸张高度为62毫米
Doc.PageSetting.LeftMargin = 3 '设置左边距
Doc.PageSetting.RightMargin = 1 '设置右边距
Doc.PageSetting.TopMargin = 1.5 '设置上边距
Doc.PageSetting.BottomMargin = 1.5 '设置下边距
doc.PageSetting.Landscape = True
Dim rt As prt.RenderTable
rt = New prt.RenderTable() '定义一个表格对象
'rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
rt.Style.GridLines.All = New Prt.LineDef(0.05, Color.white) ' White
rt.Width = "Auto"
rt.Width = 76 '表宽为150毫米
rt.Height = 58 '表高为150毫米
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.Never '禁止水平分割
rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never '禁止垂直分割
rt.Rows.Count = 19 '设置行数
rt.Cols.Count = 8 '设置列数
rt.Cells(0,0).SpanCols = 8
rt.Rows(0).Height = 7
rt.Cells(0,0).Text = "丫丫手工辣食"
rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '主标题居中
rt.Cells(0,0).Style.Font = New Font("华文行楷", 18, FontStyle.Bold) '设置主标题字体
rt.Cells(1,0).SpanCols = 8
'rt.Rows(0).Height = 2
rt.Cells(1,0).Text = "产品名称:" & r("Item")
rt.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
rt.Cells(1,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(2,0).SpanCols = 8
'rt.Rows(0).Height = 2
rt.Cells(2,0).Text = "配料:" & dr("配料")
rt.Cells(2,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
rt.Cells(2,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(3,0).SpanCols = 8
rt.Cells(3,0).Text = "添加剂:" & dr("添加剂")
rt.Cells(3,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
rt.Cells(3,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
'rt.Cells(4,0).SpanCols = 8
'rt.Cells(4,0).Text = " " '"监造商:" & dr("监造商")
'rt.Cells(4,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
'rt.Cells(4,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(4,0).SpanCols = 8
rt.Cells(4,0).Text = "生产厂商:"& dr("生产厂商")
rt.Cells(4,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
rt.Cells(4,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(5,0).SpanCols = 8
rt.Cells(5,0).Text = "厂址:"& dr("厂址")
rt.Cells(5,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
rt.Cells(5,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(6,0).SpanCols = 8
rt.Cells(6,0).Text = "食品生产许可证:" & dr("食品生产许可证")
rt.Cells(6,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
rt.Cells(6,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(7,0).SpanCols = 8
rt.Cells(7,0).Text = "保质期:"& dr("保质期")
rt.Cells(7,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
rt.Cells(7,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(8,0).SpanCols = 8
rt.Cells(8,0).Text = "执行标准:"& dr("执行标准")
rt.Cells(8,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
rt.Cells(8,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(9,0).SpanCols = 8
rt.Cells(9,0).Text = "生产日期:"& Tables("Mainsale").Current("pdate")
rt.Cells(9,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
rt.Cells(9,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(10,0).SpanCols = 4
rt.Cells(10,0).Text = "联系电话:18673077168"
rt.Cells(10,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
rt.Cells(10,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(10,4).SpanCols = 4
rt.Cells(10,4).Text = "营养成份"
rt.Cells(10,4).Style.TextAlignHorz = prt.AlignHorzEnum.center '主标题居中
rt.Cells(10,4).Style.TextAlignVert = prt.AlignHorzEnum.Center'居中
rt.Cells(10,4).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(11,0).SpanCols = 4
rt.Cells(11,0).Text = "净含量:" & dr("净含量")
rt.Cells(11,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(11,0).Style.Font = New Font("华文楷体", 7, FontStyle.Bold) '设置主标题字体
rt.Cells(11,4).Text = "项目"
rt.Cells(11,4).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(11,4).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(11,4).Style.Borders.Top = New Prt.LineDef(0.05, Color.black) '画边钱
rt.Cells(11,4).Style.Borders.Bottom = New Prt.LineDef(0.05, Color.black) '画边钱
rt.Cells(11,4).Style.Borders.Left = New Prt.LineDef(0.05, Color.black) '画边钱
rt.Cells(11,5).SpanCols = 2
rt.Cells(12,5).SpanCols = 2
rt.Cells(13,5).SpanCols = 2
rt.Cells(14,5).SpanCols = 2
rt.Cells(15,5).SpanCols = 2
rt.Cells(16,5).SpanCols = 2
rt.Cells(17,5).SpanCols = 2
'rt.Cols(5).Width = 6
'rt.Cols(6).Width = 6
rt.Cells(11,5).Text = "每100克(g)"
rt.Cells(11,5).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
rt.Cells(11,5).Style.TextAlignVert = prt.AlignHorzEnum.Center '居中
rt.Cells(11,5).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(11,5).Style.Borders.Top = New Prt.LineDef(0.05, Color.black) '画边钱
rt.Cells(11,5).Style.Borders.Bottom = New Prt.LineDef(0.05, Color.black)'画边钱
rt.Cells(11,7).Text = "营养素参考值%"
rt.Cols(7).Width = 15
rt.Cells(11,7).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题左
rt.Cells(11,7).Style.TextAlignVert = prt.AlignHorzEnum.Center‘'居中
rt.Cells(11,7).Style.Font = New Font("华文楷体", 6, FontStyle.Bold) '设置主标题字体
rt.Cells(11,7).Style.Borders.Top = New Prt.LineDef(0.05, Color.black) '画边钱
rt.Cells(11,7).Style.Borders.Bottom = New Prt.LineDef(0.05, Color.black) '画边钱
rt.Cells(11,7).Style.Borders.right = New Prt.LineDef(0.05, Color.black) '画边钱
rt.Cells(12,0).SpanCols = 4
rt.Cells(12,0).SpanRows = 6
rt.Cells(14,0).SpanCols = 4
rt.Cells(15,0).SpanCols = 4
rt.Cells(16,0).SpanCols = 4
rt.Cells(17,0).SpanCols = 4
rt.Cells(13,0).SpanRows = 4
Dim i As Integer
For i = 12 To 17
rt.Cells(i,4).Style.Borders.Left = New Prt.LineDef(0.05, Color.black) '画边钱
rt.Cells(i,7).Style.Borders.right = New Prt.LineDef(0.05, Color.black) '画边钱
Next
rt.Cells(17,4).Style.Borders.Bottom = New Prt.LineDef(0.05, Color.black)'画边钱
rt.Cells(17,5).Style.Borders.Bottom = New Prt.LineDef(0.05, Color.black)'画边钱
rt.Cells(17,7).Style.Borders.Bottom = New Prt.LineDef(0.05, Color.black)'画边钱
Dim rg As New prt.RenderGraphics
Dim Bar As New BarCodeBuilder
Bar.Symbology = Barpro.Symbology.ean13
bar.Code = dr("条型码")
Bar.BarWidth = 0.3
Bar.BarHeight = 9 '数值越小条码越大
Bar.QuietZoneWidth = 2 '数值越小条码下面的数字间隔越宽
Bar.GuardBarHeight = 10 '数值越大条码线条越往增长
rg = new prt.RenderGraphics
bar.DrawOnCanvas(rg.Graphics,0,1,1)
rt.Cells(12,0).RenderObject = rg
rt.Rows(12).Height = 2.5
rt.Rows(13).Height = 2.5
rt.Rows(14).Height = 2.5
rt.Rows(15).Height = 2.5
rt.Rows(16).Height = 2.5
rt.Rows(17).Height = 2.5
rt.Cells(12,4).Text = "能量"
rt.Cells(12,4).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(12,4).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(13,4).Text = "蛋白质"
rt.Cells(13,4).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(13,4).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(14,4).Text = "脂肪"
rt.Cells(14,4).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(14,4).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(15,4).Text = "碳水化合物"
rt.Cells(15,4).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(15,4).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(16,4).Text = "钠"
rt.Cells(16,4).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(16,4).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(12,5).Text = dr("能量")
rt.Cells(12,5).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(12,5).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(13,5).Text = dr("蛋白质")
rt.Cells(13,5).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(13,5).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(14,5).Text = dr("脂肪")
rt.Cells(14,5).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(14,5).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(15,5).Text = dr("碳水化合物")
rt.Cells(15,5).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(15,5).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(16,5).Text = dr("钠")
rt.Cells(16,5).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(16,5).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(12,7).Text = dr("能量百分比")
rt.Cells(12,7).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(12,7).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(13,7).Text = dr("蛋白质百分比")
rt.Cells(13,7).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(13,7).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(14,7).Text = dr("脂肪百分比")
rt.Cells(14,7).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(14,7).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(15,7).Text = dr("碳水化合物百分比")
rt.Cells(15,7).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(15,7).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
rt.Cells(16,7).Text = dr("钠百分比")
rt.Cells(16,7).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居左
rt.Cells(16,7).Style.Font = New Font("华文楷体", 5, FontStyle.Bold) '设置主标题字体
If dr("温馨提示") = "有" Then
rt.Cells(18,0).SpanCols = 8
rt.Cells(18,0).Text = "温馨提示:如有胀包?漏气,请勿食用"
rt.Cells(18,0).Style.TextAlignHorz = prt.AlignHorzEnum.center '主标题居中
rt.Cells(18,0).Style.Font = New Font("华文楷体", 6, FontStyle.Bold) '设置主标题字体
ElseIf dr("温馨提示") = "无" Then
rt.Cells(18,0).SpanCols = 8
rt.Cells(18,0).Text = " "
rt.Cells(18,0).Style.TextAlignHorz = prt.AlignHorzEnum.center '主标题居中
rt.Cells(18,0).Style.Font = New Font("华文楷体", 6, FontStyle.Bold) '设置主标题字体
End If
doc.Body.Children.Add(rt) '将表格对象加入到报表中