-- 作者:yangming
-- 发布时间:2011/12/19 13:47:00
--
专业版吗?我有一个现成的,呵呵,这是前年做的,你修改一下
\'筛选后全部选定区域 With Tables("工资_Table1") .Select(0,0, .Rows.Count - 1, .Cols.Count - 1) End With Dim doc As New PrintDoc \'定义一个报表 Dim tbl As Table = Tables("工资_Table1") Dim ColNames As New List(Of String) Dim rs As New prt.RenderText() doc.PageSetting.Landscape = True \'横向打印 For i As Integer = tbl.TopRow To tbl.BottomRow Dim rw As Row = tbl.Rows(i) Dim rt As New prt.RenderTable() \'定义一个表格对象 Dim ra As New prt.RenderArea \'定义一个容器 Dim rx As New prt.RenderTable rt.Style.Spacing.Top = 3 \'表格和前面对象的垂直间隔为4毫米 rt.Style.Spacing.Bottom = 1 \'表和后续对象的垂直间隔为1毫米 \'rx.Cells(0,0).Text = rw("日期") \'设置文本对象的内容 rx.Cells(0,1).Text = Tables("主表")(0,0) & Format(Date.Today,"yyyy年MM月") & "工资条"
rx.Cells(0,2).Text = "第[PageNo]页, 共[PageCount]页 " rx.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left rx.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center rx.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right rx.CellStyle.Spacing.Bottom = 0 \'底端内容缩进毫米 rx.Cells(0,1).Style.FontSize = 16 \'字体大小为16磅 rx.Cells(0,1).Style.FontBold = True \'字体加粗 rx.Cols(1).Width = 120 \'rx.Cols(2).Width = 26 \' rx.Cols(4).Width = 18
Doc.PageHeader = rx \'作为页眉使用 \'指定行数?列数?列宽?行高 Doc.PageSetting.LeftMargin = 10 \'设置左边距 Doc.PageSetting.RightMargin = 10 \'设置右边距 Doc.PageSetting.TopMargin = 8 \'设置上边距 Doc.PageSetting.BottomMargin = 5 \'设置下边距 rt.Rows.Count = 2 \'设置总行数 rt.Cols.Count = 11 \'设置总列数 rt.Height = 15 \'设置表格的高度 \'rt.Cols(0).Width = 22 \'rt.Cols(2).Width = 26 \'rt.Cols(4).Width = 18 \'rt.Cols(5).Width = 18 \'rt.Cols(8).Width = 18 \'rt.Cols(9).Width = 22 \'设置表格样式 rt.CellStyle.Spacing.All = 0 \'单元格内容缩进1毫米 rt.Style.Spacing.Bottom = 1 \'和下一个工资条的距离是3毫米 rt.Style.GridLines.All = New prt.Linedef \'设置网格线 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'所有文本内容居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 \'下面很简单,指定每一个单元格的内容 rt.Cells(0,0).Text= "日期" rt.Cells(1,0).Text = rw("日期") rt.Cells(0,1).Text= "工号" rt.Cells(1,1).Text = rw("工号")
[此贴子已经被作者于2011-12-19 13:53:16编辑过]
|