课堂笔记:
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