-- 作者:有点甜
-- 发布时间:2019/1/10 9:19:00
--
变通处理,如
Dim dt As DataTable Dim doc As New PrintDoc \'定义一个报表 Doc.PageSetting.LeftMargin = 5 \'设置左边距 Doc.PageSetting.RightMargin = 5 \'设置右边距 Doc.PageSetting.TopMargin = 5 \'设置上边距 Doc.PageSetting.BottomMargin = 5 \'设置下边距 Doc.PageSetting.PaperKind = 9 \'定义纸张为A4纸
Dim rs As New prt.RenderText() \'定义一个文本对象 rs.Text = "名 帅 生 产 制 单" \'设置文本对象的内容 rs.Style.Font = New Font("宋体", 18 , FontStyle.Bold) \'设置文本对象的字体 rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'文本内容水平居中 doc.Body.Children.Add(rs) \'将文本对象加入到表格中
Dim rt As New prt.RenderTable() \'定义一个表格对象 rt.Style.Spacing.Top = 3 \'表格和前面对象的垂直间隔为4毫米 rt.Style.Spacing.Bottom = 2 \'表和和后续对象的垂直间隔为10毫米 rt.CellStyle.Spacing.All = 2 \'内容距离网格线1毫米 rt.Style.GridLines.All = New prt.Linedef \'设置网格线 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Cols(0).Width = 20 rt.Cols(1).Width = 70 rt.Cols(2).Width = 18 rt.Cols(3).Width = 22 rt.Cols(4).Width = 50 rt.Cells(0,0).Text = "订单名称" rt.Cells(0,1).Text = "" rt.Cells(0,1).SpanCols = 2 rt.Cells(0,3).Text = "业务员" rt.Cells(0,4).Text = ""
rt.Cells(1,0).Text = "客户名称" rt.Cells(1,1).Text = "" rt.Cells(1,2).Text = "发货日期" rt.Cells(1,3).Text = "" Dim rbc As New prt.RenderBarCode() \'设置条形码对象 rbc.BarCodeType = BarCodeEnum.Code39 \'QRCode rbc.BarDirection = BarDirectionEnum.Normal rbc.Text = "12345" rbc.ShowText = True rt.Cells(1,4).RenderObject = rbc rt.Cells(1,4).SpanRows = 2 \' rt.Cells(2,0).Text = "发货地址" rt.Cells(2,1).Text = "" rt.Cells(2,2).Text = "发货方式" rt.Cells(2,3).Text = "" doc.Body.Children.Add(rt)
rt = New prt.RenderTable() rt.Style.GridLines.All = New prt.Linedef \'设置网格线 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Style.Spacing.Top = 1 \'表格和前面对象的垂直间隔为4毫米 rt.Style.Spacing.Bottom = 1 \'表和和后续对象的垂直间隔为10毫米 rt.CellStyle.Spacing.All = 1 \'内容距离网格线1毫米 Dim i As Integer = 0 \'这里用来计算增加的行数 rt.Cells(i,0).Text = "唛架版号" rt.Cells(i,1).Text = "" rt.Cells(i,1).SpanCols = 3 rt.Cells(i,4).Text = "人群" rt.Cells(i,5).Text = "" rt.Cells(i,6).Text = "打印机" rt.Cells(i,7).Text = "" rt.Cells(i,7).SpanCols = 2 rt.Cells(i,9).Text = "注意事项" rt.Cells(i,9).SpanCols = 2 i = i + 1
rt.Cells(i,0).Text = "款式描述" rt.Cells(i,1).Text = "效果图" rt.Cells(i,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.Cells(i,1).SpanCols = 3 rt.Cells(i,4).Text = "号码" rt.Cells(i,5).Text = "名字" rt.Cells(i,6).Text = "上衣尺码" rt.Cells(i,7).Text = "裤子尺码" rt.Cells(i,8).Text = "数量" rt.Cells(i,9).SpanCols = 2 i = i + 1
\'产品名字号码开始
rt.Cells(i,0).Text = "第一套衣服" Dim dts1 As DataTable = DataTables("尺码表") rt.Cells(i,0).SpanRows = dts1.DataRows.Count
Dim rm As New prt.RenderImage() rm.Image = GetImage("timg.jpg") \'请改为实际的图标名称和路径 rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Right \'图片水平左对齐 rm.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center \'图片垂直居中 rm.Style.ImageAlign.StretchHorz = True \'禁止水平方向扩展图片 rm.Style.ImageAlign.StretchVert = True \'禁止垂直方向扩展图片 rt.Cells(i+dts1.DataRows.Count\\2,1).RenderObject = rm \'将单元格内容设置为图片对象rm rt.Cells(i+dts1.DataRows.Count\\2,1).SpanCols = 3 rt.Cells(i+dts1.DataRows.Count\\2, 1).Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.Cells(i,1).SpanRows = dts1.DataRows.Count\\2 rt.Cells(i,1).SpanCols = 3 rt.Cells(i+dts1.DataRows.Count\\2+1,1).SpanRows = dts1.DataRows.Count\\2 rt.Cells(i+dts1.DataRows.Count\\2+1,1).SpanCols = 3
\'生成订单的注意事项 rt.Cells(i,9).SpanRows = dts1.DataRows.Count rt.Cells(i,9).SpanCols = 2 rt.Cols(9).Style.TextAlignHorz = prt.AlignHorzEnum.left rt.Cells(i,9).Text = "" \'生成订单注意事项结束 For Each hm As DataRow In dts1.DataRows rt.Cells(i,4).Text = hm("号码") rt.Cells(i,5).Text = hm("名字") rt.Cells(i,6).Text = hm("尺码") rt.Cells(i,7).Text = hm("尺码") rt.Cells(i,8).Text = hm("数量") i = i + 1 Next \'产品名字号码结束 \'生产工艺开始
If dts1.DataRows.Count > 0 Then rt.Cells(i,0).Text = "生产工艺" rt.Cells(i,0).SpanRows = 10 rt.Cells(i,1).Text = "工艺内容" rt.Cells(i,1).SpanCols = 10 rt.Rows(i).Style.Borders.Bottom = New prt.LineDef("0mm", Color.white) i = i + 1 rt.Rows(i-1).Style.Borders.Bottom = New prt.LineDef(0.5, Color.Black) End If \'生产工艺结束 doc.Body.Children.Add(rt)
rs = New prt.RenderText \'设置文本对象的内容 rs.Text = "第[PageNo]页,共[PageCount]页" \'设置文本内容 rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'靠右对齐 rs.Style.Padding.Bottom = 0.5 \'底端内容缩进0.5毫米 rs.Style.FontSize = 8 \'字体大小为8磅 Doc.PageFooter = rs \'作为页眉使用 doc.Preview()
|