1、模板
[班级] 领队:[领队]
[人员]
2、代码
Dim tm As String = ProjectPath & "Attachments\0101.docx" '指定模板文件
Dim fl As String = ProjectPath & "Reports\0101.docx" '指定目标文件
Dim t As Table = Tables("报名表")
Dim wrt As New WordReport(t,tm,fl) '定义一个WordReport
For Each bj As String In t.DataTable.GetValues("班级", "班级 is not null", "_sortkey")
Dim fdr = t.DataTable.find("班级='" & bj & "'")
Dim str As String = ""
Dim drs = t.DataTable.Select("班级='" & bj & "'", "号码")
Dim s1 As String = ""
Dim s2 As String = ""
For i As Integer = 0 To drs.count-1
If i>0 AndAlso i Mod 8 = 0 Then
str &= s1 & vbcrlf & s2 & vbcrlf
str &= vbcrlf
s1 = ""
s2 = ""
End If
s1 &= drs(i)("号码") & chr(9)
s2 &= drs(i)("姓名") & chr(9)
Next
msgbox(str)
wrt.ReplaceOne("[人员]",str)
wrt.BuildOne(fdr)
Next
wrt.Show() '显示报表