-- 作者:大红袍
-- 发布时间:2015/6/14 16:49:00
--
DataTables("考试数据表").LoadFilter = "" DataTables("考试数据表").Load
Dim nms As String() = {"短日期","起始时间","教室"} \'指定生成目录树的各列 Dim qts As String() = {"\'","\'","\'"} \'指定将各列的值括起来的符号,这里都是字符型,所以都是单引号 Dim trv As WinForm.TreeView = e.Form.Controls("签到单时间") Dim filter As String For Each nd As object In trv.AllNodes If nd.Level > 2 Then If nd.Checked Then Dim rts() As String = nd.FullPath.Split("\\") Dim val As String = "" For i As Integer = 1 To rts.length - 1 If val > "" Then val = val & " And " End If val = val & nms(i-1) & " = " & qts(i-1) & rts(i) & qts(i-1) Next If filter > "" Then filter = filter & " Or (" & val & ")" Else filter = val End If End If End If Next
filter = filter.Replace("(","").Replace(")","")
msgbox(filter)
DataTables("考试数据表").ResumeRedraw DataTables("考试数据表").StopRedraw For Each ary() As String In DataTables("考试数据表").GetValues("短日期|起始时间|教室", filter) Vars("qdd1") = ary(0) Vars("qdd2") = ary(1) Vars("qdd3") = ary(2)
With Tables("考试数据表") .Filter = "机考安排 is null and 短日期 = \'" & ary(0) & "\' and 起始时间 = \'" & ary(1) & "\' and 教室 = \'" & ary(2) & "\'" If .Rows.count > 0 Then .Select(0,0,.Rows.count - 1,.Cols.count - 1 ) Dim Book As New XLS.Book(ProjectPath & "Attachments\\纸考签到单.xls") Dim fl As String = ProjectPath & "Reports\\纸考签到表\\" & ary(0) & " " & ary(1).Replace(":", "点") & " " & ary(2) & "签到单.xls" Book.Build() \'生成细节区 Book.Save(fl) \'保存工作簿 End If End With With Tables("考试数据表") .Filter = "机考安排 is not null and 短日期 = \'" & ary(0) & "\' and 起始时间 = \'" & ary(1) & "\' and 教室 = \'" & ary(2) & "\'" If .Rows.count > 0 Then .Select(0,0,.Rows.count - 1,.Cols.count - 1 ) Dim book = New XLS.Book(ProjectPath & "Attachments\\机考签到单.xls") Dim fl = ProjectPath & "Reports\\机考签到表\\" & ary(0) & " " & ary(1).Replace(":", "点") & " " & ary(2) & "签到单.xls" Book.Build() \'生成细节区 Book.Save(fl) \'保存工作簿 End If End With Next \'结束遍历value2s的数组 DataTables("考试数据表").ResumeRedraw
|