此主题相关图片如下:微信图片_20200406134716.jpg
代码:
'定义表头
Dim rx As RenderText
Dim ra As New RenderArea
rx = New RenderText
rx.Text = dr!客户代码
rx.X = 1
rx.Y = 1
ra.Width = 宽 - 2 '设置标签宽度
ra.Height = 高 - 4
ra.SplitHorzBehavior = SplitBehaviorEnum.Never '禁止水平分割
ra.SplitVertBehavior = SplitBehaviorEnum.Never '禁止垂直分割
ra.Style.Spacing.Right = 2 '设置标签之间的所有和上下间隔为2毫米
ra.Style.Spacing.Bottom = 2
doc.Body.Children.Add(ra)
ra.Children.Add(rx)
Dim 客户名称 As New RenderText
客户名称.Text = hs.查询值("selec t 姓名 from 客户信息 where ID='" & dr!客户ID & "'")
客户名称.Y = 6
ra.Children.Add(客户名称)
Dim 源单编号 As New RenderText
源单编号.Text = dr!源单编号
源单编号.Y = 1
源单编号.X = 150
ra.Children.Add(源单编号)
Dim 终审时间 As New RenderText
终审时间.Text = dr!终审时间
终审时间.Y = 6
终审时间.X = 150
ra.Children.Add(终审时间)
'开始增加明细内容.
Dim prs As Integer = 10 '每页20行
For p As Integer = 0 To tbmx.Rows.Count - 1
Dim 物料代码 As New RenderText
物料代码.Y = p * 6 + 16
物料代码.Text = tbmx.Rows(p)("物料代码")
ra.Children.Add(物料代码)
Dim 物料名称 As New RenderText
物料名称.Y = p * 6 + 16
物料名称.X = 30
物料名称.Text = tbmx.Rows(p)("物料名称")
ra.Children.Add(物料名称)
Dim 规格型号 As New RenderText
规格型号.Y = p * 6 + 16
规格型号.X = 60
规格型号.Text = tbmx.Rows(p)("规格型号")
ra.Children.Add(规格型号)
Dim 单位名称 As New RenderText
单位名称.Y = p * 6 + 16
单位名称.X = 120
单位名称.Text = tbmx.Rows(p)("单位名称")
ra.Children.Add(单位名称)
Dim 数量 As New RenderText
数量.Y = p * 6 + 16
数量.X = 130
数量.Text = Format(tbmx.Rows(p)("数量"), "#####")
ra.Children.Add(数量)
Dim 单价 As New RenderText
单价.Y = p * 6 + 16
单价.X = 140
单价.Text = Format(tbmx.Rows(p)("单价"), "#.##")
ra.Children.Add(单价)
Dim 应付金额 As New RenderText
应付金额.Y = p * 6 + 16
应付金额.X = 160
应付金额.Text = Format(tbmx.Rows(p)("应付金额"), "#.##")
ra.Children.Add(应付金额)
Next
Dim 大写合计 As New RenderText
大写合计.Y = 50
大写合计.Text = "大写合计:"
ra.Children.Add(大写合计)
Dim 应付大写 As New RenderText
应付大写.Y = 50
应付大写.X = 15
应付大写.Text = Currency.Converter.ConvertToCapsString(tbmx.Compute("sum(应付金额)"))
ra.Children.Add(应付大写)
Dim 应付小写 As New RenderText
应付小写.Y = 50
应付小写.X = 160
应付小写.Text = tbmx.Compute("sum(应付金额)")
ra.Children.Add(应付小写)
' doc.Preview()
doc.PageSetting.Width = 宽 '纸张宽度为100毫米
doc.PageSetting.Height = 高 '纸张高度为120毫米
doc.PageSetting.LeftMargin = 左边距
doc.PageSetting.TopMargin = 上边距
doc.PageSetting.BottomMargin = 下边距
doc.PageSetting.RightMargin = 右边距
doc.PageSetting.Landscape = Vars("纵向")
doc.AutoRotate = False
doc.PrinterName = Vars!打印机
doc.Print()