Dim doc As New PrintDoc '定义一个报表
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight '设置排列方式
For i As Integer = 1 To 3
Dim rt As New prt.RenderTable() '定义一个表格对象
rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
rt.Width = 100 '表格宽度为50mm
rt.Style.Spacing.All = 2 '和其他对象之间的间隔为2mm
rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never '避免垂直换页的时候,表格被分割成两部分.
rt.Cols(0).Width = 20
rt.cells(0,0).Text = "姓名"
rt.Cells(0,1).Text = "职务"
rt.Cells(0,2).Text = "数量"
rt.Cells(0,3).Text = "箱数"
rt.cells(1,0).Text = "张三"
rt.Cells(2,0).SpanCols = 4
rt.cells(2,0).Text = " "
rt.cells(3,0).Text = "姓名"
rt.Cells(3,1).Text = "职务"
rt.Cells(3,2).Text = "数量"
rt.Cells(3,3).Text = "垫圈"
Dim cnt As Integer = Rand.Next(5)
For j As Integer = 1 To cnt
rt.cells(3+j,0).Text = "姓名" & j
rt.Cells(3+j,1).Text = "职务" & j
rt.Cells(3+j,2).Text = "数量" & j
rt.Cells(3+j,3).Text = "第" & j & "箱/共" & cnt & "箱"
Next
doc.Body.Children.Add(rt) '将表格对5象加入到报表中
Next
Doc.Preview() '预览报表