Dim doc As New PrintDoc '定义一个报表
doc.PageSetting.Width =76 '纸张宽度
doc.PageSetting.Height =130 '纸张高度
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight '设置排列方式
For i As Integer = 1 To 5
Dim rt As New prt.RenderTable() '定义一个表格对象
Doc.PageSetting.LeftMargin = 0 '设置左边距
Doc.PageSetting.RightMargin = 0 '设置右边距
Doc.PageSetting.TopMargin = 0 '设置上边距
Doc.PageSetting.BottomMargin = 0 '设置下边距
rt.Width = "Parent.Width" '对象宽度等于页面宽度
rt.Height = "Parent.Height" '对象高度等于页面高度
'指定行数?列数?列宽?行高
rt.Rows.Count = 10 '设置总行数
rt.Cols.Count = 4 '设置总列数
rt.Rows(0).Height = 10 '
rt.Rows(1).Height = 5 '
rt.Rows(2).Height = 12 '
rt.Rows(3).Height = 18 '
rt.Rows(4).Height = 10 '
rt.Rows(5).Height = 7 '
rt.Rows(6).Height = 13 '
rt.Rows(7).Height = 6 '
rt.Rows(8).Height = 6 '
rt.Rows(9).Height = 28 '
rt.Rows(10).Height = 14 '
'设置列宽度
rt.Cols(0).Width = 8.5 '设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列)
rt.Cols(1).Width = 29.5
rt.Cols(2).Width = 23
rt.Cols(3).Width = 15
'设置合并单元格
rt.Cells(0,0).SpanCols =2 '
rt.Cells(1,0).SpanCols = 2 '
rt.Cells(1,2).SpanCols = 2 '
rt.Cells(2,0).SpanCols = 4 '
rt.Cells(3,0).SpanCols = 4 '
rt.Cells(4,0).SpanCols = 2 '
rt.Cells(5,1).SpanCols = 2 '
rt.Cells(5,0).SpanRows = 2 '
rt.Cells(6,1).SpanCols = 2 '
rt.Cells(7,0).SpanRows = 2 '
rt.Cells(7,1).SpanCols = 2 '
rt.Cells(8,1).SpanCols = 2 '
rt.Cells(9,0).SpanCols = 4 '
rt.Cells(10,0).SpanCols = 2 '
rt.Cells(10,2).SpanCols = 2 '
rt.Cells(5,3).SpanRows = 4 '
'设置表格样式
rt.CellStyle.Spacing.All = 1 '单元格内容缩进1毫米
rt.Style.GridLines.All = New prt.Linedef '设置网格线
rt.Style.GridLines.All = new Prt.LineDef(Color.Gainsboro) '设置网格颜色
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '内容垂直居中
rt.Rows(9).Style.TextAlignVert = prt.AlignVertEnum.Top '唯独第7行是备注,内容靠上对齐
'''下面很简单,指定每一个单元格的内容
rt.Cells(0,0).Text= "zto"
rt.Cells(0,0).Style.Font = New Font("微软雅黑", 16, FontStyle.Bold) '设置字体
........
rbc.ShowText = False
rt.Cells(5,3).RenderObject = rbc '将单元格内容设置为图片对象rm
doc.Body.Children.Add(rt) '将表格对象加入到报表中
Next
Doc.Preview() '预览报表