以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [原创]批量预览生成的word报表  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=108123)

--  作者:天一生水
--  发布时间:2017/10/16 20:39:00
--  [原创]批量预览生成的word报表

下面这段批量生成报表的代码,我想预览生成的报表,但只显示了批量生成的报表中的一个,能否只打开一个word窗口,显示所有生成的报表?

 

Dim tm As String  = ProjectPath & "Attachments\\人员简历表.doc" \'指定模板文件
With Tables("员工资料")
    If .TopPosition > -1 Then \'如果选定区域包括数据行
        For i As Integer = .TopPosition To .BottomPosition
            Dim r As Row = .Rows(i)
            Dim fileName As String = ProjectPath & "Reports\\"& r("姓名") &".doc" \'指定目标文件
            Dim wrt As New WordReport(Tables("员工资料"),tm,fileName) \'定义一个WordReport
            wrt.BuildOne(r)

            wrt.Show() \'显示报表
            wrt.quit
        Next
    End If
End With


--  作者:有点蓝
--  发布时间:2017/10/16 21:48:00
--  
不能,除非你把报表全部生成到一个word文件中
--  作者:有点甜
--  发布时间:2017/10/17 9:16:00
--  

预览和生成分开处理,用下面代码预览

 

Dim tm As String  = ProjectPath & "Attachments\\人员简历表.doc" \'指定模板文件
With Tables("员工资料")
    If .TopPosition > -1 Then \'如果选定区域包括数据行
        Dim fileName As String = ProjectPath & "Reports\\预览.doc" \'指定目标文件
        Dim wrt As New WordReport(Tables("员工资料"),tm,fileName) \'定义一个WordReport
        For i As Integer = .TopPosition To .BottomPosition
            Dim r As Row = .Rows(i)
            wrt.BuildOne(r)
        Next
        wrt.Show() \'显示报表
    End If
End With


--  作者:天一生水
--  发布时间:2019/5/16 21:58:00
--  
老师好!
我想在窗口的web控件中显示生成的word报表,更换了加黑代码,为什么不能显示?

Dim tm As String  = ProjectPath & "Attachments\\人员简历表.doc" \'指定模板文件
With Tables("员工资料")
    If .TopPosition > -1 Then \'如果选定区域包括数据行
        Dim fileName As String = ProjectPath & "Reports\\预览.doc"     \'指定目标文件
        Dim wrt As New WordReport(Tables("员工资料"),tm,fileName)  \'定义一个WordReport
        For i As Integer = .TopPosition To .BottomPosition
            Dim r As Row = .Rows(i)
            wrt.BuildOne(r)
        Next
        \'wrt.Show() \'显示报表      ’这句去掉

     \'wrt.Build()
     \'wrt.Quit() 
     Dim wbr As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
     wbr.AddRess = fileName 

    End If
End With

--  作者:有点甜
--  发布时间:2019/5/16 22:08:00
--  

这两句代码不能去掉

 

wrt.Build()

wrt.Quit()