以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 再问自定义函数 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=150565) |
-- 作者:czy66ds -- 发布时间:2020/6/2 11:28:00 -- 再问自定义函数 经过询问和老师回答,对于内部函数args参数写法头脑中清晰一些了,知道了args的强大。但是对于代码段的处理还是蒙圈,例如: Dim cmd As New SQLCommand \'定义一个SQL命令 cmd.C Dim dt As DataTable \'定义一个数据表变量 Dim dt1 As DataTable \'定义一个数据表变量 Dim cm As WinForm.ComboBox = e.Form.Controls("ComboBox1") Dim T2 As Table = e.Form.Controls("Table2").Table
\' --------服务器时间---------------------------- Dim sj As Date cmd.CommandText = "Select
GetDate()" sj = cmd.ExecuteScalar() sj = Format(sj, "yyyy-M-d")
\'2008-2-28 If cm.value = "差旅费" Then For Each r2 As Row In T2.GetCheckedRows Dim spbh As String = r2("审批编号") Dim doc As New PrintDoc \'定义一个报表 Dim rt As New prt.RenderTable() Dim rx As New prt.RenderText doc.PageSetting.Width = 240 doc.PageSetting.Height = 140 Doc.PageSetting.LeftMargin = 20 Doc.PageSetting.RightMargin = 10 Doc.PageSetting.TopMargin = 15 Doc.PageSetting.BottomMargin = 10 \'===========标题======= rx.text = r2("申请人") & "差旅费报销单" rx.Style.FontBold = True rx.Style.FontSize = 12 rx.Width = 178.5 rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx.Style.Spacing.Bottom = 2 doc.Body.Children.Add(rx) \'======= 主表(一) ====== rt = New prt.RenderTable rt.Style.TextAlignVert = prt.AlignVertEnum.Center
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Left
rt.Cols(2).Style.TextAlignHorz =prt.AlignHorzEnum.Right
rt.Style.Spacing.Bottom = 1 rt.Style.FontSize = 9 rt.style.Ffont-size: 9pt; font-family: 宋体;">宋体" rt.Width = 178.5 rt.Cols(0).Width = 60 rt.Cols(2).Width = 40 rt.Height = 10 \'rt.Style.GridLines.All = New
prt.LineDef \'将网格线类型设为默认类型 rt.Rows.Count = 2 \' 二行 rt.Cols.Count = 3 \' 三列 rt.Cells(0,0).Text = "审批编号:" & r2("审批编号") rt.Cells(1,0).Text = "申请人:" & r2("申请人") rt.Cells(0,1).Text = "审批人:" & r2("审批人") rt.Cells(1,1).Text = "部门:" & r2("部门") rt.Cells(0,2).Text = "提交时间:" & r2("提交时间") rt.Cells(1,2).Text = "报销总额:" & r2("报销总额") doc.Body.Children.Add(rt) \'将表格对象加入到报表中 \'========== 明细表
================================== rt = New prt.RenderTable rt.Style.FontSize = 9 rt.style.F cmd.CommandText =" select 出发时间,出发地,到达时间,到达地,当日返回
as 当日,车费,油补,过道费 as 过道,餐补,宿费,其他费用 as 其它,费用小计 as 小计 f rom{差旅费记录表1} where 审批编号 = \'" & spbh & "\'" dt1 = cmd.ExecuteReader() Dim Count As Integer = 0 For Each Col As DataCol In
Dt1.DataCols rt.Cells(0,Count).Text = Col.Name For r As Integer = 0 To dt1.DataRows.Count
- 1 rt.Cells(r +1,Count).Text = dt1.DataRows(r)(Col.Name) Next \' 设置列宽------使用循环设置,减少代码量------ Dim lk As Integer() = New Integer(){20,25,20,25,9,10,10,10,10,10,10,15} \'列宽 Dim c As Integer For c = 0 To 11 rt.Cols(c).Width =
lk(c) Next rt.Width = "Auto" Count = Count + 1 Next rt.Style.GridLines.All = New prt.Linedef
rt.CellStyle.Spacing.All = 0.8 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.Spacing.Bottom = 1 doc.Body.Children.Add(rt) \'========= 主表(二)
================================================ rt = New prt.RenderTable \'rt.Style.GridLines.All = New
prt.LineDef \'将网格线类型设为默认类型 rt.Style.FontSize = 9 \'字体大小为9磅 rt.style.Ffont-size: 9pt; font-family: 宋体;">宋体" rt.Width = 178.5 rt.Rows.Count = 2 rt.Cols.Count = 3 rt.Cols(1).Width = 50 rt.Cols(2).Width = 40 rt.Cells(1,0).SpanCols = 3 rt.Rows(0).Height = 5 rt.Rows(1).Height = 20 rt.Cols(2).Style.TextAlignHorz =prt.AlignHorzEnum.Right
rt.Cells(0,0).text = "出差人员:"
& r2("出差人员")
rt.Cells(0,1).text = "打印人:" & user.name
rt.Cells(0,2).text = "打印日期:" & sj
rt.Cells(1,0).text = "出差任务:" & r2("出差任务") doc.Body.Children.Add(rt) \'doc.Preview() doc.Print() Next End If
其中红色部分该如何参数化? |
-- 作者:有点蓝 -- 发布时间:2020/6/2 11:46:00 -- 如果列名和格式是固定的,通过数组传入即可。否则不适合使用函数处理 |
-- 作者:czy66ds -- 发布时间:2020/6/2 16:11:00 -- 如何把 rt.Cells(0,0).text = "出差人员:" & r2("出差人员") rt.Cells(0,1).text = "打印人:" & user.name rt.Cells(0,2).text = "打印日期:" & sj rt.Cells(1,0).text = "出差任务:" & r2("出差任务") 传进来? |
-- 作者:有点蓝 -- 发布时间:2020/6/2 16:27:00 -- dim n1() as string = {"出差人员","出差任务"} Functions.Execute("xxx",n1,false)
------- dim n1() as string = args(0) rt.Cells(0,0).text = n1(0) & ":" & r2(n1(0)) rt.Cells(0,1).text = "打印人:" & user.name rt.Cells(0,2).text = "打印日期:" & sj rt.Cells(1,0).text = n1(1) & ":" & r2(n1(1)) |