Dim rs As List(of Row) = t.GetCheckedRows
If rs.Count > 0 Then '如果存在符合条件的行
Dim tm As String = ProjectPath & "Attachments\报告.doc" '指定模板文件
Dim fl As String = ProjectPath & "Reports\报告.doc"
Dim wrt As New WordReport(Tables("报告_Table1"),tm,fl) '定义一个WordReport
For Each r As Row In rs '逐行生成报表
wrt.BuildOne(r)
wrt.RecordsOnEachPage = 1
Next
wrt.Quit
'wrt.Show() '显示报表
Dim app As New MSWord.Application
try
Dim doc = app.Documents.Open(fl)
Doc.PrintPreview
app.Visible = True
Doc.PrintOut '打印
catch ex As exception
msgbox(ex.message)
finally
app.Quit
End try
Else
MessageBox.show("请先勾选要打印的报告!")
End If