这是专业报表截图:
此主题相关图片如下:未命名5.jpg
这是代码:
If Tables("员工").Current IsNot Nothing
Dim dr As DataRow = Tables("员工").Current.DataRow
Dim doc As New PrintDoc() '定义一个报表
doc.AutoRotate = False '禁止自动旋转打印内容
doc.PageSetting.Height = "175mm" ' 纸张高度为93毫米
doc.PageSetting.Width = "120mm" ' '纸张宽度为248毫米
doc.PageSetting.Landscape = True '横向打印
Doc.PageSetting.LeftMargin = 15'设置左边距
Doc.PageSetting.RightMargin = 15 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距
'-----------------------------------------------------------------
Dim rt As New prt.RenderTable() '定义一个表格对象
rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文字默认水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '文字默认垂直居中
rt.Style.Spacing.Top = 4 '表格和前面对象的垂直间隔为4毫米
rt.Style.Spacing.Bottom = 3 '表和和后续对象的垂直间隔为3毫米
rt.Style.Spacing.All = 1
rt.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
rt.Style.GridLines.All = New Prt.LineDef(0.6,Color.Gray)
rt.Width =150
'-----------------------------------------------------------------
rt.Rows.Count = 1 '设置行数
rt.Cols.Count = 11 '设置列数
rt.Cols(0).Width = "35mm"
rt.Cols(1).Width = "50mm"
rt.Cols(2).Width = "35mm"
rt.Cols(3).Width = "55mm"
rt.Cols(4).Width = "20mm"
rt.Cols(5).Width = "20mm"
rt.Cols(6).Width = "20mm"
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,0).Text = "员工资料卡"
rt.Cells(rt.Rows.Count-1,0).SpanCols = 7 '向右合并列
rt.Rows(rt.Rows.Count-1).Height = "8mm"
rt.Rows(rt.Rows.Count-1).Style.GridLines.All = new Prt.LineDef(0,Color.Black)
rt.rows(rt.Rows.Count-1).Style.Font = New Font("宋体", 16,FontStyle.Bold) '设置字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count,4).Text = "编号:"
rt.Cells(rt.Rows.Count-1,4).SpanCols = 2
rt.Rows(rt.Rows.Count-1).Height = "6mm"
rt.cells(rt.Rows.Count-1,4).Style.TextAlignHorz = prt.AlignHorzEnum.right '水平靠右
rt.rows(rt.Rows.Count-1).Style.GridLines.All = new Prt.LineDef(0,Color.Black)
rt.Cells(rt.Rows.Count-1,4).Style.Font = New Font("宋体", 11,FontStyle.Regular) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,6).Text = right("000" & dr("编号"),3)
rt.cells(rt.Rows.Count-1,6).Style.TextAlignHorz = prt.AlignHorzEnum.left '水平靠右
rt.Cells(rt.Rows.Count-1,6).Style.Font = New Font("宋体", 11,FontStyle.Regular) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count,0).Text = "姓名"
rt.Rows(rt.Rows.Count-1).Height = "8mm"
rt.rows(rt.Rows.Count-1).Style.GridLines.top = new Prt.LineDef(0.6,Color.Black)
rt.rows(rt.Rows.Count-1).Style.GridLines.left = new Prt.LineDef(0.6,Color.Black)
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 11,FontStyle.Regular) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,1).Text = dr("姓名")
rt.Cells(rt.Rows.Count-1,1).Style.Font = New Font("宋体", 11,FontStyle.bold) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,2).Text = "出生日期"
rt.Cells(rt.Rows.Count-1,2).Style.Font = New Font("宋体", 11,FontStyle.Regular) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,3).Text = format(dr("出生日期"),"yyyy年mm月dd日")
rt.Cells(rt.Rows.Count-1,3).Style.Font = New Font("宋体", 11,FontStyle.bold) '设置文本对象的字体
'-----------------------------------------------------------------
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count,0).Text = "部门"
rt.Rows(rt.Rows.Count-1).Height = "8mm"
rt.rows(rt.Rows.Count-1).Style.GridLines.left = new Prt.LineDef(0.6,Color.Black)
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 11,FontStyle.Regular) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,1).Text = dr("部门")
rt.Cells(rt.Rows.Count-1,1).Style.Font = New Font("宋体", 11,FontStyle.bold) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,2).Text = "雇佣日期"
rt.Cells(rt.Rows.Count-1,2).Style.Font = New Font("宋体", 11,FontStyle.Regular) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,3).Text = format(dr("雇佣日期"),"yyyy年mm月dd日")
rt.Cells(rt.Rows.Count-1,3).Style.Font = New Font("宋体", 11,FontStyle.bold) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count,0).Text = "性别"
rt.Rows(rt.Rows.Count-1).Height = "8mm"
rt.rows(rt.Rows.Count-1).Style.GridLines.left = new Prt.LineDef(0.6,Color.Black)
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 11,FontStyle.Regular) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,1).Text = dr("性别")
rt.Cells(rt.Rows.Count-1,1).Style.Font = New Font("宋体", 11,FontStyle.bold) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,2).Text = "职务"
rt.Cells(rt.Rows.Count-1,2).Style.Font = New Font("宋体", 11,FontStyle.Regular) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,3).Text = dr("职务")
rt.Cells(rt.Rows.Count-1,3).Style.Font = New Font("宋体", 11,FontStyle.bold) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count,0).Text = "地址"
rt.Rows(rt.Rows.Count-1).Height = "8mm"
rt.rows(rt.Rows.Count-1).Style.GridLines.left = new Prt.LineDef(0.6,Color.Black)
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 11,FontStyle.Regular) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,1).Text = dr("地址")
rt.Cells(rt.Rows.Count-1,1).SpanCols = 3
rt.cells(rt.Rows.Count-1,1).Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Cells(rt.Rows.Count-1,1).Style.Font = New Font("宋体", 11,FontStyle.bold) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count,0).Text = "家庭电话"
rt.Rows(rt.Rows.Count-1).Height = "8mm"
rt.rows(rt.Rows.Count-1).Style.GridLines.left = new Prt.LineDef(0.6,Color.Black)
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体", 11,FontStyle.Regular) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,1).Text = dr("家庭电话")
rt.Cells(rt.Rows.Count-1,1).Style.Font = New Font("宋体", 11,FontStyle.bold) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,2).Text = "办公电话"
rt.Cells(rt.Rows.Count-1,2).Style.Font = New Font("宋体", 11,FontStyle.Regular) '设置文本对象的字体
'-----------------------------------------------------------------
rt.cells(rt.Rows.Count-1,3).Text = dr("办公电话")
rt.Cells(rt.Rows.Count-1,3).Style.Font = New Font("宋体", 11,FontStyle.bold) '设置文本对象的字体
'-----------------------------------------------------------------
rt.Rows(rt.Rows.Count).Height = "30mm"
rt.Cells(rt.Rows.Count-1,0).SpanCols = 7
rt.cells(rt.Rows.Count-1,4).Style.TextAlignHorz = prt.AlignHorzEnum.left '水平靠右
rt.rows(rt.Rows.Count-1).Style.GridLines.left = new Prt.LineDef(0.6,Color.Black)
rt.rows(rt.Rows.Count-1).Style.GridLines.Bottom = new Prt.LineDef(0.6,Color.Black)
rt.rows(rt.Rows.Count-1).Style.GridLines.right = new Prt.LineDef(0.6,Color.Black)
'-----------------------------------------------------------------
rt.Cells(rt.Rows.Count-6,4).SpanCols = 3
rt.Cells(rt.Rows.Count-6,4).Spanrows = 5
rt.Cells(rt.Rows.Count-6,4).CellStyle.Spacing.All = 0 '单元格内距设为0.5毫米
rt.Cells(rt.Rows.Count-6,4).Style.GridLines.right = new Prt.LineDef(0.6,Color.Black)
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dim ra As prt.RenderArea
Dim rm As New prt.RenderImage
ra = rt.Cells(rt.Rows.Count-6,4).Area
rm = New prt.RenderImage
rm.Image = GetImage(dr("照片"))
rm.Height = 43
ra.Children.Add(rm)
doc.Body.Children.Add(rt) '将表格对象加入到报表中
Doc.Preview() '预览报表
End If
说明:之所以在最后给多留了2列,用代码来合并,目的是突出合并示例!
[此贴子已经被作者于2013-4-23 21:09:36编辑过]