以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- printdoc 如何写到自定义函数 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=157297) |
-- 作者:xietan417 -- 发布时间:2020/10/11 17:03:00 -- printdoc 如何写到自定义函数 dim doc as new printdoc() 这个如何写到自义函数啊? dim doc as printdoc = args(0) 这样写也不对啊!
|
-- 作者:有点蓝 -- 发布时间:2020/10/11 21:00:00 -- 肯定没有问题!提示什么错误?怎么调用函数的? |
-- 作者:xietan417 -- 发布时间:2020/10/11 21:51:00 -- 调用不到哦,没有提示错误,只生成了空白页 |
-- 作者:有点蓝 -- 发布时间:2020/10/11 21:53:00 -- 具体详细代码??? |
-- 作者:xietan417 -- 发布时间:2020/10/11 21:57:00 -- 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) \'将表格对象加入到报表中 运行代码 Dim rs As Row = Tables("Mainsale").Current Dim Rows As List(Of DataRow) Rows = Tables("Mainsale").Current.DataRow.GetChildRows("Detailesale") Dim ct As Integer = Tables("Mainsale").Current("qtytotal") Dim doc As New PrintDoc() \'定义一个报表 Rows = Tables("Mainsale").Current.DataRow.GetChildRows("Detailesale") For Each r As DataRow In Rows For i1 As Integer = 1 To r("Qty") Dim dr As DataRow = DataTables("label").Find("item = \'"& r("Item") &"\'") \'tbl.compute("Sum(数量)") If dr IsNot Nothing Then If dr("监造商") = Nothing Then Functions.AsyncExecute("table1") End If End If Next Next Doc.PrinterName = "Xprinter XP-DT426B" DoC.Print() \'Doc.Preview() [此贴子已经被作者于2020/10/11 21:59:26编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/10/11 21:58:00 -- 怎么调用这个函数的?调用的代码?? |
-- 作者:xietan417 -- 发布时间:2020/10/11 22:01:00 -- q我修改了,想多线程运行,不然数量大的时候一直卡在打印界面那里 |
-- 作者:xietan417 -- 发布时间:2020/10/11 22:04:00 -- 这个异步函数好像也没有什么作用啊?还是要打印完才能操作 |
-- 作者:有点蓝 -- 发布时间:2020/10/11 22:37:00 -- 首先调用函数时根本就没有传入任何参数:http://www.foxtable.com/webhelp/topics/1486.htm Functions.AsyncExecute("table1",参数1, 参数2, 参数3,doc)
2、执行函数 Foxtable提供了一个Functions类型,用于管理和执行自定义函数,执行自定义函数的语法为: Functions.Execute(函数名, 参数1, 参数2, 参数3....) |
-- 作者:xietan417 -- 发布时间:2020/10/11 22:44:00 -- 打印能不能后台打印啊?不然打印个几百张,不是要一直卡在那里? |