Foxtable(狐表)用户栏目专家坐堂 → [求助]专业报表


  共有2051人关注过本帖平板打印复制链接

主题:[求助]专业报表

帅哥哟,离线,有人找我吗?
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106242 积分:540333 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/16 16:45:00 [只看该作者]

Dim Doc As New PrintDoc
Dim CurRow As Row = Tables("员工表").Current
Dim tb As Table = Tables("员工表")
Dim ColNames As String() = New String(){"工号", "姓名", "性别","民族","籍贯","身份证号","出生日期","年龄","户籍地","现住址","联系电话","政治面貌","婚姻状况","学历","资格职称"}

'页面设置
Doc.PageSetting.PaperKind = 8
Doc.PageSetting.Landscape = True
Doc.PageSetting.LeftMargin = 14
Doc.PageSetting.RightMargin = 12
Doc.PageSetting.TopMargin = 24
Doc.PageSetting.BottomMargin = 12

Dim cnt As Integer = tb.Rows.Count

Dim prs As Integer = 20 '每页20行
For p As Integer = 0 To math.Ceiling(cnt / prs) - 1
    Dim rt As New prt.RenderTable()
    
    '设置主标题
    rt.Cells(0,0).text = "员工基本信息一览表"
    rt.Cells(0,0).SpanCols = 15
    rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Cells(0,0).Style.Font = New Font("宋体", 20, FontStyle.Bold)
    rt.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white)
    rt.Rows(0).Height = 12
    
    rt.Cells(1,0).text = "  单位:" + CurRow("单位名称")
    rt.Cells(1,0).SpanCols = 15
    rt.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
    rt.Rows(1).Style.Borders.All = New prt.LineDef("0mm", Color.white)
    rt.Rows(1).Style.Borders.Bottom = New prt.Linedef
    rt.Rows(1).Height = 5
    
    '设置列标题
    rt.Cells(2,0).SpanRows = 2 '第1行第1个单元格向下合并2行(显示工号)
    rt.Cells(2,1).SpanCols = 10  '第1行第2列向右合并10个单元格
    rt.Cells(2,11).SpanRows = 2 '第1行第12个单元格向下合并2行(显示政治面貌)
    rt.Cells(2,12).SpanRows = 2 '第1行第13个单元格向下合并2行(显示婚姻状况)
    rt.Cells(2,13).SpanRows = 2 '第1行第14个单元格向下合并2行(显示学历)
    rt.Cells(2,14).SpanRows = 2 '第1行第15个单元格向下合并2行(显示资格职称)
    rt.Cells(2,1).Text = "基本信息"  '第一行第一个单元格的内容
    rt.Cells(2,0).Text= "工号"
    rt.Cells(3,1).Text = "姓名"
    rt.Cells(3,2).Text = "性别"
    rt.Cells(3,3).Text= "民族"
    rt.Cells(3,4).Text = "籍贯"
    rt.Cells(3,5).Text = "身份证号"
    rt.Cells(3,6).Text= "出生日期"
    rt.Cells(3,7).Text = "年龄"
    rt.Cells(3,8).Text = "户籍地"
    rt.Cells(3,9).Text= "现住址"
    rt.Cells(3,10).Text = "联系电话"
    rt.Cells(2,11).Text = "政治面貌"
    rt.Cells(2,12).Text = "婚姻状况"
    rt.Cells(2,13).Text = "学历"
    rt.Cells(2,14).Text = "资格职称"
    
    '设置每页显示表头
    rt.RowGroups(2,2).Style.BackColor = Color.LightGray '第1-2行的颜色设为灰色
    rt.RowGroups(2,2).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第3-4行的文本水平居中
    rt.RowGroups(2,2).Style.TextAlignVert = prt.AlignVertEnum.Center '第3-4行的文本垂直居中
    rt.RowGroups(0,4).Header = prt.TableHeaderEnum.All  '前4行作为表头
    
    '设置列宽/页宽
    rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
    rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded '表格宽度超出页宽时,可以水平换页
    
    '设置表格字体
    rt.Style.Font = tb.Font '字体为表格字体
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    
    '填入内容
    For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
        'rt.Cells(0,c).Text = ColNames(c) '列名作为标题
        'rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
        rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth '列宽等于实际列宽
        If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then '如果是数值或日期列
            rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平靠右
        End If
        For r As Integer = p * prs To math.min(cnt - 1,( p + 1) * prs - 1) '开始填入该列内容,从第一行到最后一行
            rt.Cells(r + 4, c).Text = tb.Rows(r)(ColNames(c)) '从多层表头以下开始填充第一行(多层表头共4行)
        Next
    Next
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
    rt.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
    If p < math.Ceiling(cnt / prs) - 1
        rt.BreakAfter = prt.BreakEnum.Page
    End If
    doc.Body.Children.Add(rt)
Next

doc.Preview()


 回到顶部
总数 18 1 2 下一页