以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何在每页都加入一个条形码? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=86788) |
-- 作者:scofields -- 发布时间:2016/6/26 9:58:00 -- 如何在每页都加入一个条形码? 狐爸爸,我如何才能实现在每页都加入一个条形码,但我好像怎么改,这个条形码好像被分割一样,你看这个怎么修改? Dim doc As New PrintDoc \'定义一个报表 doc.PageSetting.PaperKind = 13 doc.PageSetting.Landscape = True \'横向打印 Dim rtx As prt.RenderText Dim tbl As Table = Tables("FAJHB") Doc.PageSetting.LeftMargin = 10 \'设置左边距 Doc.PageSetting.RightMargin = 10 \'设置右边距 Doc.PageSetting.TopMargin = 5 \'设置上边距 Doc.PageSetting.BottomMargin = 10 \'设置下边距 Dim rep As New prt.RenderEmpty \'定义一个新的空对象 rep.BreakBefore = prt.BreakEnum.Page \'打印前换页 doc.Body.Children.Add(rep ) \'加入到报表中 For i As Integer = tbl.TopRow To tbl.BottomRow Dim CurRow As Row = tbl.Rows(i) Dim rt As New prt.RenderTable() \'定义一个表格对象 Dim rx As New prt.RenderText \'定义一个文本对象 Dim rrt As New prt.RenderText \'定义一个文本对象 Dim ra As New prt.RenderArea \'定义一个容器 ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never \'禁止容器因为分页而被垂直分割 \'加入标题 Dim rbc As New prt.RenderBarCode() ‘定义一个条形码 rbc.Height = 20 ’设置条形码的高度为20 rbc.BarCodeType = BarCodeEnum.Code93 ‘条形码类型 rbc.BarDirection = BarDirectionEnum.Normal rbc.Text = Currow("发货编号") ’根据发货编号生成一个唯一性的条形码 rbc.ShowText = False ‘条形码不显示文本内容 doc.Body.Children.Add(rbc) ’将条形码加入到容器之中 rx.text = CurRow("发运日期") & "清新公司发运通知单" rx.Style.FontBold = True \'字体加粗 rx.Style.FontSize = 16 \'大体大小为16磅 rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中排列 rx.Style.Spacing.Bottom = 5 \'和下面的对象(表格)距离3毫米 ra.Children.Add(rx) \'加入到容器中 rrt.Height = 20 Doc.Body.Children.Add(rrt) \'加入到容器中 \'指定行数?列数?列宽?行高 rt.Rows.Count = 12 \'设置总行数 rt.Cols.Count = 8 \'设置总列数 rt.Height = 100 \'设置表格的高度为100毫米 rt.Rows(11).Height = 18 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Rows(12).Height = 20 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Cols(0).Width = 30 \'设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列) rt.Cols(1).Width = 50 rt.Cols(2).Width = 20 rt.Cols(4).Width = 20 \'设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列) rt.Cols(3).Width = 30 rt.Cols(5).Width = 30 \'设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列) rt.Cols(6).Width = 20 rt.Cols(7).Width = 20\'设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列) rt.Rows(0).Height = 8 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Rows(1).Height = 8 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Rows(2).Height = 8 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Rows(3).Height = 8 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Rows(4).Height = 8 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Rows(5).Height = 8 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Rows(6).Height = 8 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Rows(7).Height = 8 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Rows(8).Height = 8 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Rows(9).Height = 8 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 rt.Rows(10).Height = 8 \'设置第11行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行 \'设置合并单元格 rt.Cells(0,1).SpanCols = 2 \'第1行第2个单元格向右合并5列(用于显示备注) rt.Cells(0,4).SpanCols = 4 \'第1行第5个单元格向右合并3列(用于显示备注) rt.Cells(1,1).SpanCols = 2 \'第1行第2个单元格向右合并5列(用于显示备注) rt.Cells(1,4).SpanCols = 4 \'第1行第5个单元格向右合并3列(用于显示备注) rt.Cells(2,1).SpanCols = 3 \'第3行第2个单元格向右合并5列(用于显示备注) rt.Cells(2,5).SpanCols = 4 \'第3行第6个单元格向右合并2列(用于显示备注) rt.Cells(3,1).SpanCols = 2 \'第3行第2个单元格向右合并5列(用于显示备注) rt.Cells(3,4).SpanCols = 4 \'第3行第6个单元格向右合并2列(用于显示备注) rt.Cells(4,0).SpanCols = 8 \'第3行第6个单元格向右合并2列(用于显示备注) rt.Cells(11,1).SpanCols = 7 \'第11行第1个单元格向右合并6列(用于显示备注) rt.Cells(12,1).SpanCols = 7 \'第11行第1个单元格向右合并6列(用于显示备注) \'设置表格样式 rx.Style.Spacing.top= 20 rt.CellStyle.Spacing.All = 0.5 \'单元格内容缩进1毫米 rt.Style.GridLines.All = New prt.Linedef \'设置网格线 rt.Style.TextAlignVert = prt.AlignVertEnum. TOP\'内容垂直居中 rt.Rows(11).Style.TextAlignVert = prt.AlignHorzEnum.Center \'唯独第7行是备注,内容靠上对齐 rt.Rows(12).Style.TextAlignVert = prt.AlignHorzEnum.Center \'唯独第7行是备注,内容靠上对齐 rt.Rows(3).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'唯独第7行是备注,内容靠上对齐 rt.Rows(4).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'唯独第7行是备注,内容靠上对齐 rt.Rows(5).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'唯独第7行是备注,内容靠上对齐 rt.Rows(6).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'唯独第7行是备注,内容靠上对齐 rt.Rows(7).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'唯独第7行是备注,内容靠上对齐 rt.Rows(8).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'唯独第7行是备注,内容靠上对齐 rt.Rows(9).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'唯独第7行是备注,内容靠上对齐 \'下面很简单,指定每一个单元格的内容 rt.Cells(0,0).Text= "发货日期" rt.Cells(0,1).Text = CurRow("发运日期") rt.Cells(0,3).Text="有效日期" rt.Cells(0,4).Text = CurRow("有效时间") rt.Cells(1,0).Text="发货编号" rt.Cells(1,1).Text = CurRow("发货编号") rt.Cells(1,3).Text= "计划单号" rt.Cells(1,4).Text = CurRow("计划单号") rt.Cells(2,0).Text="客户名" rt.Cells(2,1).Text = CurRow("客户名") rt.Cells(2,4).Text= "子客户" rt.Cells(2,5).Text = CurRow("子客户") rt.Cells(3,3).Text= "包装" rt.Cells(3,4).Text = CurRow("包装") rt.Cells(3,0).Text= "品种" rt.Cells(3,1).Text = CurRow("品种") rt.Cells(4,0).Text= "以下为预报车号信息" rt.Cells(5,0).Text= "车号1" rt.Cells(5,1).Text = CurRow("车号1") rt.Cells(5,2).Text= "吨位1" rt.Cells(5,3).Text = CurRow("吨位1") rt.Cells(5,4).Text= "车号6" ra.Children.Add(rt) \'加入到容器中 Doc.Body.ChildRen.Add(ra) \'将容器加入到报表中 Next rtx = New prt.RenderText \'设置文本对象的内容 rtx.Text = "【" & "第[PageNo]页,共[PageCount]页 " & "】" & " " & "打印人:" & " " & User.Name & " " & "打印时间:" & " " & Date.now() & "----广东清新水泥有限公司----------服务到终点,满意到终点" \'设置文本内容 rtx.Style.TextAlignHorz = prt.AlignHorzEnum.Right \'靠右对齐 rtx.Style.Borders.Bottom = New prt.LineDef(0.3, Color.RED) \'设置底边框 rtx.Style.Padding.Bottom = 0.5 \'底端内容缩进0.5毫米 rtx.Style.FontSize = 10 \'字体大小为10磅 Doc.PageFooter = rtx \'作为页眉使用 Doc.Preview() \'预览报表 |
-- 作者:大红袍 -- 发布时间:2016/6/26 14:22:00 -- 你条码可以放在某个单元格里面啊,如
rt.Cells(100, 0).Area.Children.Add(rbc) |
-- 作者:scofields -- 发布时间:2016/6/26 17:25:00 -- 红袍老师,我已放在某个单元格了,但感觉不太美观。我还是想放在某个空白的地方 |
-- 作者:scofields -- 发布时间:2016/6/26 17:29:00 -- Dim rm As New prt.RenderGraphics Dim Bar As New BarCodeBuilder Bar.Symbology = Barpro.Symbology.Code93 bar.Code = Currow("发货编号") rm = new prt.RenderGraphics bar.DrawOnCanvas(rm.Graphics,0,0,1) rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center \'图片水平居中 rm.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center \'图片垂直居中 rm.Height = 20 rm.Style.ImageAlign.StretchHorz = False \'禁止水平方向扩展图片 rm.Style.ImageAlign.StretchVert = True \'禁止垂直方向扩展图片 rt.Cells(12,1).RenderObject = rm \'将单元格内容设置为图片对象rm rt.Cells(12,0).Text= "条形码"
|
-- 作者:zcgmxf -- 发布时间:2016/6/26 18:24:00 -- 你可以在那里插入一个只有一个单元格的表,先安装foxtable提供的条形码字体。 |
-- 作者:大红袍 -- 发布时间:2016/6/26 23:53:00 -- 尝试写
ra.Children.Add(rbc)
如果有问题,尽量做实例说明一下。 |