-- 作者:程兴刚
-- 发布时间:2012/5/23 19:12:00
--
这是我填写【成文厚】记账凭证的代码,仅供参考!
Dim doc As New PrintDoc() \'定义一个报表 \'doc.PageSetting.Width = 210 \'纸张宽度为210毫米 \'doc.PageSetting.Height = 120 \'纸张高度为120毫米 \'doc.AutoRotate = False \'禁止自动旋转打印内容 \'doc.PageSetting.Landscape = True \'横向打印 Doc.PageSetting.LeftMargin = 15 \'设置左边距 Doc.PageSetting.RightMargin = 15 \'设置右边距 Doc.PageSetting.TopMargin = 0 \'设置上边距 Doc.PageSetting.BottomMargin = 0 \'设置下边距
Dim rt As prt.RenderText \'定义一个文本对象 rt = New prt.RenderText() \'创建文本对象 rt.Text = Tables("记帐凭证").Current("凭证号").SubString(0,4) \'设置文本对象的内容 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Width = 10 \'自动设置宽度 rt.x = "70mm" rt.y = "32.5mm" doc.Body.Children.Add(rt) \'将文本对象加入到报表 rt = New prt.RenderText() \'创建文本对象 rt.Text = Tables("记帐凭证").Current("凭证号").SubString(4,2) \'设置文本对象的内容 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Width = 10 \'自动设置宽度 rt.x = "90mm" rt.y = "32.5mm" doc.Body.Children.Add(rt) \'将文本对象加入到报表 rt = New prt.RenderText() \'创建文本对象 rt.Text = format(Date.DaysInMonth(Val(Tables("记帐凭证").Current("凭证号").SubString(0,4)),(Tables("记帐凭证").Current("凭证号").SubString(4,2))),"00") \'设置文本对象的内容 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Width = 10 \'自动设置宽度 rt.x = "107mm" rt.y = "32.5mm" doc.Body.Children.Add(rt) \'将文本对象加入到报表 rt = New prt.RenderText() \'创建文本对象 rt.Text = Tables("记帐凭证").Current("凭证号").SubString(7,7) \'设置文本对象的内容 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Width = "19mm" \'自动设置宽度 rt.x = "160mm" rt.y = 32.5 doc.Body.Children.Add(rt) \'将文本对象加入到报表 Dim drs As List(Of DataRow) drs = DataTables("成本明细帐").Select("[项目名称] = \'" & Tables("记帐凭证").Current("项目名称") & "\' And [凭证号]= \'" & Tables("记帐凭证").Current("凭证号") & "\'") For i As Byte = 1 To 6 rt = New prt.RenderText() \'创建文本对象 rt.Style.Padding.left = 1 \'上边距25毫米 If i = 6 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平靠左 rt.Style.Font = New Font("宋体", 10, FontStyle.Bold) \'设置字体 rt.Text = "本凭证合计" Else rt.Style.TextAlignHorz = prt.AlignHorzEnum.left \'内容水平靠左 If i> drs.Count rt.Text = "--" Else rt.Text = drs(i-1)("摘要") \'设置文本对象的内容 End If End If rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Width = "42mm" \'自动设置宽度 rt.Height = "7.2mm" rt.x = "7mm" rt.y = (i*7.8+47) & "mm" doc.Body.Children.Add(rt) \'将文本对象加入到报表 rt = New prt.RenderText() \'创建文本对象 rt.Style.Padding.left = 1 \'上边距25毫米 If i = 6 rt.Text = "" Else If i> drs.Count rt.Text = "--" Else rt.Text = drs(i-1)("科目") \'设置文本对象的内容 End If End If rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Width = "28mm" \'自动设置宽度 rt.Height = "7.2mm" rt.x = "50mm" rt.y = (i*7.8+47) & "mm" doc.Body.Children.Add(rt) \'将文本对象加入到报表 rt = New prt.RenderText() \'创建文本对象 rt.Style.Padding.left = 1 \'上边距25毫米 If i = 6 rt.Text = "" Else If i> drs.Count rt.Text = "--" Else rt.Text = drs(i-1)("费用类别") \'设置文本对象的内容 End If End If rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Width = "28mm" \'自动设置宽度 rt.Height = "7.2mm" rt.x = "80mm" rt.y = (i*7.8+47) & "mm" doc.Body.Children.Add(rt) \'将文本对象加入到报表 rt = New prt.RenderText() \'创建文本对象 rt.Style.Padding.left = 1 \'上边距25毫米 If i = 6 rt.Text = "" Else If i> drs.Count rt.Text = "--" Else If drs(i-1)("审核标记") = True rt.Text = "√" \'设置文本对象的内容 If drs(i-1)("科目") = "应付款" rt.x = "137mm" Else rt.x = "97.7mm" End If Else rt.Text = "" \'设置文本对象的内容 End If End If End If rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Width = "28mm" \'自动设置宽度 rt.Height = "7.2mm" rt.y = (i*7.8+47) & "mm" doc.Body.Children.Add(rt) \'将文本对象加入到报表 If i < 6 For A As Byte = 1 To 10 rt = New prt.RenderText() \'创建文本对象 rt.Style.Padding.left = 1 \'上边距25毫米 If i> drs.Count rt.Text = "-" Else rt.Text = GetDigit(drs(i-1)("金额"),A-3,"¥") \'设置文本对象的内容 If drs(i-1)("科目") = "应付款" rt.x = (175+A*-3.29) & "mm" Else rt.x = (135.8+A*-3.29) & "mm" End If End If rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Width = "28mm" \'自动设置宽度 rt.Height = "7.2mm" rt.y = (i*7.8+47) & "mm" doc.Body.Children.Add(rt) \'将文本对象加入到报 Next End If IF i = 6 Dim Multi As String = "已付款|应付款" Dim Values() As String Values = Multi.split("|") For Index As Integer = 0 To Values.Length - 1 For A As Byte = 1 To 10 rt = New prt.RenderText() \'创建文本对象 rt.Style.Padding.left = 1 \'上边距25毫米 rt.Text = GetDigit(DataTables("成本明细帐").Compute("Sum(金额)", "项目名称 = \'" & Tables("记帐凭证").Current("项目名称") & "\' And 科目 = \'" & Values(Index) & "\' And 凭证号 = \'" & Tables("记帐凭证").Current("凭证号") & "\'"),A-3,"¥") If Values(Index) = "已付款" rt.x = (135.8+A*-3.29) & "mm" Else rt.x = (175+A*-3.29) & "mm" End If rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Width = "28mm" \'自动设置宽度 rt.Height = "7.2mm" rt.y = (i*7.8+47) & "mm" doc.Body.Children.Add(rt) \'将文本对象加入到报 Next Next End If Next rt = New prt.RenderText() \'创建文本对象 rt.Text = Tables("成本明细帐").Compute("Max(单据编号)", "项目名称 = \'" & Tables("记帐凭证").Current("项目名称") & "\' And 凭证号 = \'" & Tables("记帐凭证").Current("凭证号") & "\'") rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Width = "6mm" \'自动设置宽度 rt.x = "189mm" rt.y = "76mm" doc.Body.Children.Add(rt) \'将文本对象加入到报表 Doc.Preview() \'预览报表 \'doc.Print() \'打印报表
|