问题:“教练”没有显示出来。原因可能出在红色代码中,经测试没有获得"[Fields!区.Value]"的文本。
如何修改,请专家指教!!!
Tables("报名表").Sort = "区号,级别,学校"
Dim doc As New PrintDoc
Dim r As New prt.RenderText
Dim rt As New prt.RenderText
Dim ra1 As New prt.RenderArea
Dim ra2 As New prt.RenderArea
Dim ra3 As New prt.RenderArea
'设置表名
r = New prt.RenderText
r.Text= jsmc
r.Style.Font = New Font("楷体", 16, FontStyle.Bold)
r.Style.FontBold = True
r.Style.TextAlignHorz = prt.AlignHorzEnum.Center
r.Style.Spacing.Bottom = 5
doc.Body.Children.Add(r)
r = New prt.RenderText
r.Text= "号码对照表"
r.Style.Font = New Font("楷体", 16, FontStyle.Bold)
r.Style.FontBold = True
r.Style.TextAlignHorz = prt.AlignHorzEnum.Center
r.Style.Spacing.Bottom = 5
doc.Body.Children.Add(r)
'设置一级分组
ra1.Style.Spacing.Bottom = 5
ra1.Stacking = prt.StackingRulesEnum.InlineLeftToRight
ra1.DataBinding.DataSource = BindTables("报名表")
ra1.DataBinding.Grouping.Expressions.Add("Fields!区.Value")
'打印一级分组的组名
rt = New prt.RenderText
rt.Text= "[Fields!区.Value]代表队:"
rt.Style.FontSize = 12
rt.Style.FontBold = True
rt.Style.Spacing.Bottom = 2
ra1.Children.Add(rt)
rt = New prt.RenderText
rt.Text= "领队: [Fields!领队.Value]"
rt.Style.FontSize = 12
rt.Style.FontBold = True
rt.Style.Spacing.Bottom = 2
'rt.DataBinding.DataSource = ra1.DataBinding.DataSource
ra1.Children.Add(rt)
rt = New prt.RenderText
Dim str As String = "[Fields!编号.Value]"
Dim ss As String
Dim jl As String
Dim jls As List(of String) = DataTables("报名表").GetUniqueValues("竞赛名称 = '海模' And 区 = '"[Fields!区.Value]"',"辅导老师")
For Each jl In jls
ss = ss & " " & jl
Next
rt.Text= "教练: "& ss &""
rt.Style.FontSize = 12
rt.Style.FontBold = True
rt.Style.Spacing.Bottom = 2
'rt.DataBinding.DataSource = ra1.DataBinding.DataSource
ra1.Children.Add(rt)
ra3 = New prt.RenderArea
ra3.Width = 33
ra3.Style.Spacing.Bottom = 1
ra3.Stacking = prt.StackingRulesEnum.InlineLeftToRight
rt = New prt.RenderText
rt.Text = "[Fields!编号.Value]"
rt.Width = 15
rt.Style.Spacing.Bottom = 1
rt.Style.FontSize = 10.5
ra3.Children.Add(rt)
rt = New prt.RenderText
rt.Text = "[Fields!姓名.Value]"
rt.Width = 18
rt.Style.Spacing.Bottom = 1
rt.Style.FontSize = 10.5
ra3.Children.Add(rt)
ra3.DataBinding.DataSource = ra1.DataBinding.DataSource
ra1.Children.Add(ra3)
doc.body.Children.Add(ra1)
Doc.PageSetting.LeftMargin = 25 '设置左边距
Doc.PageSetting.RightMargin = 15 '设置右边距
Doc.PageSetting.TopMargin = 20 '设置上边距
Doc.PageSetting.BottomMargin = 15 '设置下边距
Tables("报名表").Sort = ""
doc.Preview()