以下是向“狐狸爸爸”学习的代码:
Tables("报名表").Sort = "编号"
Tables("报名表").Filter="竞赛名称='" & mc.text & "' and 项目 not like '*集体*' and 审核 = 'true' and 兼项 = 'false'"
Dim doc As New PrintDoc
Dim r As New prt.RenderText
Dim rt As New prt.RenderText
Dim xmdr0 As DataRow = DataTables("项目表"). Find ("竞赛名称简称 = '" & mc.text & "'")
Dim jsmc As String = xmdr0("竞赛名称全称")
'设置表名
r = New prt.RenderText
r.Text= jsmc
r.Style.Font = New Font("楷体", 18, 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("楷体", 18, FontStyle.Bold)
r.Style.FontBold = True
r.Style.TextAlignHorz = prt.AlignHorzEnum.Center
r.Style.Spacing.Bottom = 3
doc.Body.Children.Add(r)
Dim s As String
For Each dqs As String() In DataTables("报名表").GetUniqueValues("竞赛名称 = '" & mc.text & "'","区号","区")
Dim dq As String = dqs(1)
rt = new prt.RenderText
rt.Style.FontSize = 14
rt.Style.FontBold = True
rt.Style.Spacing.Bottom = 2
rt.text = vbcrlf & dq & "代表队:"
doc.body.Children.add(rt)
s = ""
For Each nm As String In DataTables("报名表").GetUniqueValues("竞赛名称 = '" & mc.text & "' And 区 = '" & dq & "'","领队")
s = s & nm & ","
Next
rt = new prt.RenderText
rt.Style.Font = New Font("楷体", 14, FontStyle.Bold)
rt.Style.FontBold = True
rt.Style.Spacing.Bottom = 2
rt.text = "领队: " & s.trim(",")
doc.body.Children.add(rt)
s = ""
For Each nm As String In DataTables("报名表").GetUniqueValues("竞赛名称 = '" & mc.text & "' And 区 = '" & dq & "'","教练")
s = s & nm & " "
Next
rt = new prt.RenderText
rt.text = "教练:" & s.trim(",")
rt.Style.Font = New Font("楷体", 14)
rt.Style.Spacing.Bottom = 2
doc.body.Children.add(rt)
Dim drs As List(of DataRow) = DataTables("报名表").Select("竞赛名称 = '" & mc.text & "' And 区 = '" & dq & "' and 项目 not like '*集体*'" ,"编号")
Dim tb As new prt.RenderTable
tb.Width = "Auto"
For i As Integer = 0 To drs.count -1 Step 5 '每行五个队员
For n As Integer = i To math.Min(drs.count -1,i + 4) '打印这五个队员
tb.cells(n \ 5, (n Mod 5) * 2).text = drs(n)("编号")
For m As Integer = 0 To 8 Step 2
tb.Cols(m).Width = Tables("报名表").Cols("编号").PrintWidth '(51)
tb.Style.FontSize = 11
tb.cells(n \ 5, (n Mod 5) * 2 + 1).text = drs(n)("姓名")
Next
For m1 As Integer = 1 To 9 Step 2
tb.Cols(m1).Width = Tables("报名表").Cols("姓名").PrintWidth '(77)
tb.Style.FontSize = 11
tb.rows(n \ 5).height = 6
Next
Next
Next
doc.body.Children.add(tb)
Next
doc.PageSetting.PaperKind = 9
Doc.PageSetting.LeftMargin = 25 '设置左边距
Doc.PageSetting.RightMargin = 25 '设置右边距
Doc.PageSetting.TopMargin = 22 '设置上边距
Doc.PageSetting.BottomMargin = 22 '设置下边距
doc.Preview()
之前使用正常,这次出现一个令人费解的问题,东西湖代表队出现两次,开头一次;正常地方又出现一次
检查代码,应该没问题,搞了一上午没解决,现请狐狸爸爸看看,问题出在哪里?
谢谢!!!
以下是报表截图
不应该出现在这里:
此主题相关图片如下:qq图片20131203134520.jpg
出现在这里是正常的
此主题相关图片如下:qq图片20131203134923.jpg