以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  WORD报表打印  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=54810)

--  作者:石四
--  发布时间:2014/8/5 10:29:00
--  WORD报表打印
WORD报表模板设置好了,不用系统菜单,窗口上的“打印报表”按钮代码怎么写?
--  作者:Bin
--  发布时间:2014/8/5 10:30:00
--  
http://www.foxtable.com/help/topics/2890.htm
--  作者:石四
--  发布时间:2014/8/5 11:37:00
--  

课堂笔记:

Dim tm As String  = ProjectPath & "Attachments\\送检单.doc" \'指定模板文件
Dim fl As String = ProjectPath & "Reports\\送检单.doc" \'指定目标文件
Dim wrt As New WordReport(Tables("销售出库"),tm,fl) \'定义一个WordReport
wrt.Build() \'逐行生成报表
wrt.Show() \'显示报表

 

原来的专业报表代码也暂时存放这楼,方便以后查看:

 

Dim doc As New Printdoc

Dim rx As prt.RenderText

Dim rt As prt.RenderTable

 

rx = New prt.RenderText

rx.Style.FontSize = 10

\'rx.Style.Spacing.Bottom = 5

rx.Text = Tables("销售出库").Current("日期")

rx.Style.FontBold = True

rx.x = 120

rx.y = 28

doc.Body.Children.Add(rx)

 

rx = New prt.RenderText

rx.Style.FontSize = 10

rx.Text = Tables("销售出库").Current("库房")

rx.Style.FontBold = True

rx.x = 92

rx.y = 34

doc.Body.Children.Add(rx)

 

rt = New prt.RenderTable

rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center

rt.Style.TextAlignVert = prt.AlignVertEnum.Center

rx.Style.FontBold = True

With Tables("销售出库.销售明细")

    For r As Integer = 0 To .Rows.Count - 1 \'遍历关联表每一行

        rt.Cells(r+1,0).Text = .rows(r)("零件图号")

        rt.Cells(r+1,1).Text = .rows(r)("零件名称")

        rt.Cells(r+1,2).Text = .rows(r)("单位")

        rt.Cells(r+1,3).Text = .rows(r)("数量")

    Next

    rt.Width = "Auto"

    For i As Integer = 0 To 3

        rt.Cols(0).Width = 24  \'设置列宽

        rt.Cols(1).Width = 26  \'设置列宽

        rt.Cols(2).Width = 8 \'设置列宽

        rt.Cols(3).Width = 12 \'设置列宽

    Next

End With

Doc.PageSetting.LeftMargin = 26 \'设置左边距

Doc.PageSetting.RightMargin = 10 \'设置右边距

Doc.PageSetting.TopMargin = 60 \'设置上边距

Doc.PageSetting.BottomMargin = 4 \'设置下边距

doc.PageSetting.Width = 210 \'纸张宽度为100毫米

doc.PageSetting.Height = 140 \'纸张高度为120毫米

doc.Body.Children.Add(rt)

 

rx = New prt.RenderText

rx.Style.FontSize = 10

rx.Text = Tables("销售出库").Current("司机")

rx.Style.FontBold = True

rx.x = 40

rx.y = 100

doc.Body.Children.Add(rx)

 

rx = New prt.RenderText

rx.Style.FontSize = 10

rx.Text = Tables("销售出库").Current("装卸")

rx.Style.FontBold = True

rx.x = 90

rx.y = 130

doc.Body.Children.Add(rx)

 

doc.Preview