-- 老师变量序号a=a+1放在哪里比较合适,现在不按顺序加数
Dim tb As Table = Tables(args(5))
Dim prs As Integer =30
Dim ir As Integer = Math.Ceiling(tb.Rows.Count / prs)
Dim a As Integer = 1
For i As Integer = 0 To ir - 1
Dim rt As New prt.RenderTable() \'定义一个表格对象
Dim rx, rx1, rx2 As New prt.RenderText \'定义一个文本对象
Dim ra As New prt.RenderArea \'定义一个容器
If Tables("处方打印设置").Current("标题一") > "" Then
rx.text = Tables("处方打印设置").Current("标题一")
rx.Style.FontBold = True \'字体加粗
rx.Style.FontSize = CStr(Tables("处方打印设置").Current("标题一字体大小"))
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中排列
rx.Style.Spacing.Bottom = 1 \'和下面的对象(表格)距离3毫米
doc.Body.Children.Add(rx) \'加入到报表中
End If
If Tables("处方打印设置").Current("标题二") > "" Then
rx1 = New prt.RenderText
rx1.text = Tables("处方打印设置").Current("标题二")
rx.Style.FontBold = True \'字体加粗
rx1.Style.FontSize = CStr(Tables("处方打印设置").Current("标题二字体大小"))
rx1.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中排列
rx1.Style.Spacing.Bottom = 3 \'和下面的对象(表格)距离3毫米
ra.Children.Add(rx1)
End If
rx2 = New prt.RenderText
rx2.text = "姓名:" & Args(0) & " 性别:" & Args(1) & " 年龄:" & args(2) & " 日期:" & format(Args(3), "yyyy年MM月dd日") & " 电话:" & Args(8)
rx.Style.FontBold = True \'字体加粗
rx2.Style.FontSize = CStr(Tables("处方打印设置").Current("内容字体大小"))
rx2.Style.TextAlignHorz = prt.AlignHorzEnum.center \'水平居中排列
rx2.Style.Spacing.Bottom = 1 \'和下面的对象(表格)距离3毫米
ra.Children.Add(rx2)
rx = New prt.RenderText
rx.text = "--------------------------------------------------------------------------------------------------------------------------"
rx.Style.FontBold = True \'字体加粗
rx.Style.FontSize = CStr(Tables("处方打印设置").Current("内容字体大小"))
rx.Style.TextAlignHorz = prt.AlignHorzEnum.center \'水平居中排列
rx.Style.Spacing.Bottom = 1 \'和下面的对象(表格)距离3毫米
ra.Children.Add(rx)
rt.Style.Font = New font("宋体", CStr(Tables("处方打印设置").Current("内容字体大小")))
rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.FontSize = 11 \'大体大小为16磅
rt.Rows(6).Style.TextAlignVert = prt.AlignVertEnum.Top
For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内容
If c = 0 Then
rt.Cells(0, 0).Text = "序号"
End If
rt.Cells(0, c + 1).Text = ColNames(c) \'列名作为标题
rt.Cells(0, c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中
For r As Integer = i * prs To math.min(tb.Rows.Count - 1, ( i + 1) * prs - 1)
For f As Integer = 0 To tb.Cols.Count
If f = 0 Then
rt.Cells(r - i * prs + 1, 0).Text = a
Else
rt.Cells(r - i * prs + 1, c + 1).Text = tb.rows(r)(ColNames(c))
End If
rt.Cells(r - i * prs + 1, c).Style.TextAlignHorz = prt.AlignHorzEnum.Center
Next
Next
Next
a = a + 1
ra.Children.Add(rt) \'将表格对象加入到报表中
rx = New prt.RenderText
rx.text = "--------------------------------------------------------------------------------------------------------------------------"
rx.Style.FontBold = True \'字体加粗
rx.Style.FontSize = CStr(Tables("处方打印设置").Current("内容字体大小"))
rx.Style.TextAlignHorz = prt.AlignHorzEnum.center \'水平居中排列
rx.Style.Spacing.Bottom = 1 \'和下面的对象(表格)距离3毫米
ra.Children.Add(rx) \'加入到报表中
If i = math.Ceiling(tb.Rows.Count / prs) - 1 Then\'如果是最后一页
For r As Integer = tb.Rows.Count To ( i + 1) * prs - 1 \'补空行
rt.Rows.Count = rt.Rows.Count + 1
rt.Rows(rt.Rows.count - 1)(0).text = " "
Next
Else
rt.BreakAfter = prt.BreakEnum.Page \'否则换页
End If
If i < math.Ceiling(tb.Rows.Count / prs) - 1 Then
rt.BreakAfter = prt.BreakEnum.Page
End If
doc.Body.Children.Add(ra)
Next
rx = New prt.RenderText
rx.text = "副数:" & Args(6) & "副" & " 合计金额:" & Args(7) & "元"
rx.Style.FontSize = CStr(Tables("处方打印设置").Current("表尾字体大小"))
rx.Style.TextAlignHorz = prt.AlignHorzEnum.center \'水平居中排列
rx.Style.Spacing.Bottom = 1 \'和下面的对象(表格)距离3毫米
doc.Body.Children.Add(rx) \'加入到报表中
[此贴子已经被作者于2023/11/9 21:44:51编辑过]