Dim bb As New SQLGroupTableBuilder("秩序册","考试数据表")
bb.Groups.AddDef("日期")
bb.Groups.AddDef("时间")
bb.Groups.AddDef("试卷号")
bb.Groups.AddDef("保密号")
bb.Totals.AddExp("人数","1")
bb.Build
MainTable = Tables("秩序册")
DataTables("最终秩序册").DataRows.Clear
For Each arrr As Row In Tables("秩序册").Rows
If arrr IsNot Nothing Then
Dim ar3 As DataRow
ar3 = DataTables("最终秩序册").AddNew()
ar3("日期") = arrr("日期")
ar3("时间") = arrr("时间")
ar3("试卷号") = arrr("试卷号")
ar3("保密号") = arrr("保密号")
ar3("人数") = arrr("人数")
End If
Next
For Each rs As Row In Tables("最终秩序册").rows
Dim dr11 As DataRow = DataTables("考试数据表").find("保密号 = '" & rs("保密号") & "'")
If dr11 IsNot Nothing Then
rs("试卷名称") = dr11("试卷名称")
rs("考试类型") = dr11("考试类型")
rs("短日期") = dr11("短日期")
rs("考场号") = dr11("考场号")
rs("是否留考") = dr11("是否留考")
rs("考场号") = dr11("考场号")
rs("起始时间") = dr11("起始时间")
rs("教室") = dr11("教室")
rs("结束时间") = dr11("结束时间")
rs("时长") = dr11("时长")
End If
Next
Dim str As String = "日期,保密号"
Dim idx As String = ""
Dim ary7() As String = str.Split(",")
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
For Each dr As DataRow In DataTables("最终秩序册").Select("日期 is not null", str)
Dim flag As Boolean = False
For Each a As String In ary7
If pdr IsNot Nothing AndAlso dr(a) <> pdr(a) Then
flag = True
End If
Next
If flag = False Then
count += 1
Else
'If count = 1 Then
idx &= pdr("_Identify") & ","
'End If
count = 1
End If
pdr = dr
Next
For Each a As String In ary7
If pdr IsNot Nothing AndAlso Tables("最终秩序册").Rows(Tables("最终秩序册").Rows.count-2)(a) <> pdr(a) Then
idx &= pdr("_Identify") & ","
End If
Next
DataTables("最终秩序册").DeleteFor("_Identify not in (" & idx.trim(",") & ")")
Tables("最终秩序册").Sort = "日期,起始时间,教室"
Dim Book2 As New XLS.Book(ProjectPath & "Attachments\秩序册.xls ")
Dim fl1 As String = ProjectPath & "Reports\秩序册.xls"
Book2.Build() '生成细节区
Book2.Save(fl1) '保存工作簿

此主题相关图片如下:qq截图20150618190240.png