Dim d As Date = Date.Today
Dim d1 As Date = New Date(d.Year,d.Month,1)
Dim d2 As Date = New Date(d.Year,d.Month,d.DaysInMonth(d.Year,d.Month))
Dim cnt As Integer
cnt = DataTables("rz").Compute("Count([date])", "date >= # " & d1 & " # And date < # " & d2 & " #")
'msgbox( cnt )
Dim tm As String = ProjectPath & "Attachments\yxj.doc" '指定模板文件
Dim fl As String = ProjectPath & "Reports\yxj.doc" '指定目标文件
Dim wrt As New WordReport(Tables("rz"),tm,fl) '定义一个WordReport
wrt.Replace("[rzrs]",cnt) '统计当月入职人员总数
Dim rzs As String
Dim drs As List(Of DataRow)
drs = DataTables("rz").Select("[date] >= # " & d1 & " # And [date] < # " & d2 & " #","name DESC")
For Each dr As DataRow In drs
rzs = (dr("dep") & " : " & dr("name")) & " || " & rzs
'' rzs = (dr("dep") & " : " & dr("name")) & rzs
''msgbox(rzs)
Next
wrt.Replace("[rzs]",rzs)
Dim cnt1 As Integer
cnt1 = DataTables("lz").Compute("Count([date])", "date >= # " & d1 & " # And date < # " & d2 & " #")
'msgbox( cnt )
wrt.Replace("[lzrs]",cnt1)
Dim lzs As String
Dim drs1 As List(Of DataRow)
drs1 = DataTables("lz").Select("[date] >= # " & d1 & " # And [date] < # " & d2 & " #","name DESC")
For Each dr1 As DataRow In drs1
lzs = (dr1("dep") & " : " & dr1("name")) & " || " & lzs
' rzs = (dr("dep") & " : " & dr("name")) & rzs
'msgbox(rzs)
Next
wrt.Replace("[lzs]",lzs)
wrt.Build() '生成报表
wrt.show()