随便改的,自己调整:
Dim doc As New PrintDoc '定义一个报表 Dim rt As prt.RenderTable Dim rm As prt.RenderEmpty '定一个空对象 For i As Integer = 0 To Tables("表B").rows.Count -1 Step 4 rt = New prt.RenderTable Dim rs As New prt.RenderText() rs.Text = "职工花名册" '设置文本对象的内容 rs.Style.Font = New Font("宋体", 24 , FontStyle.Bold) '设置文本对象的字体 rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本内容水平居中 doc.Body.Children.Add(rs) '将文本对象加入到表格中 With Tables("表B") rt.rows(0).Style.Borders.Top = New prt.LineDef(0,Color.red) rt.rows(0).Style.Borders.Bottom = New prt.LineDef(0,Color.red) rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center rt.Style.TextAlignVert = prt.AlignVertEnum.Center rt.Style.Borders.Bottom = New prt.LineDef(0,Color.red) rt.CellStyle.Spacing.All = 2 rt.Cols.Count = 4 rt.Cells(0,0).Text = "姓名" rt.Cells(0,1).Text = "年龄" rt.Cells(0,2).Text = "部门" '定义列内容 'For r As integer = 0 To .Rows.Count - 1 '遍历关联表每一行 For r As integer = i To math.min(i + 3,.rows.count-1) rt.Cells(r,0).Text = .rows(r)("姓名") rt.Cells(r,1).Text = .rows(r)("年龄") rt.Cells(r,2).Text = .rows(r)("部门") Next End With doc.Body.Children.Add(rt) next Doc.Preview() '预览报表
|