Dim tb As Table=Tables("花名册")
Dim doc As New PrintDoc '定义一个报表
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight '设置排列方式
For i As Integer = 0 To 9
Dim ra As New prt.RenderArea
ra.SplitHorzBehavior = prt.SplitBehaviorEnum.Never '禁止水平分割
ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never '禁止垂直分割
ra.Width = 80 '必须指定宽度
ra.Height = 90 '高度
doc.body.Children.add(ra)
Dim rpar As New prt.RenderParagraph() '定义一个段落对象
Dim f As New Font(rpar.Style.Font, FontStyle.Bold) '定义一个同样但加粗的字体
rpar.Content.AddImage(getimage("logo.jpg"))
rpar.Content.AddText("XXXXXXXXX区")
ra.Children.add(rpar)
Dim rt As New prt.RenderTable() '定义一个表格对象
rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
rt.Width = "auto" '表格宽度为50mm
rt.Height = 70 '设置表格的高度
rt.Style.Spacing.All = 10 '和其他对象之间的间隔为2mm
rt.Style.TextAlignHorz = prt.AlignHorzEnum.center '水平居中排列
rt.style.TextAlignVert = prt.AlignVertEnum.Center
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.Never '禁止水平分割
rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never '避免垂直换页的时候,表格被分割成两部分.
rt.Cols(0).Width = 20
rt.Cols(1).Width = 20
rt.cells(0,0).Text = "姓 名"
rt.Cells(0,1).Text = tb.Rows(i)("姓名")
rt.Cells(1,0).Text = "性 别"
rt.Cells(1,1).Text = tb.Rows(i)("性别")
rt.Cells(2,0).Text= "年 龄"
rt.cells(2,1).Text = tb.Rows(i)("年龄")
rt.Cells(3,0).Text = "项目1"
rt.Cells(3,1).Text = tb.Rows(i)("项目1)
rt.Cells(4,0).Text= "项目2"
rt.cells(4,1).Text = tb.Rows(i)("项目2")
ra.Children.Add(rt) '将表格对象加入到报表中
Next
Doc.Preview() '预览报表